Goldman Sachs Interview Question for Software Engineer / Developers


Team: Trading System
Country: United States




Comment hidden because of low score. Click to expand.
1
of 3 vote

1> As the application has stopped means that deadlock situation had occurred. Somehow your thread lock fails to lock the shared resources or the context switching happened in such a way that Func could not reserve the resource necessary for its normal execution.

2> Func is using certain resources with is currently owned by other thread.

3> Handle that exception by releasing all the acquired resources than call sync call to Func to deliver the service.. other way to fix is to handle inside the function itself for resource constraints .

- hprem991 October 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Apart from those mentioned above, the fun() may have infinite loop.

- madan October 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I'm not sure if this is particular to any language, but I see this in the C++ section, so I'll answer accordingly.

1. A number of things may have happened in func(). I would check out the call stack and make sure that the function was the last thing that called. Once I have confirmed that, I would investigate and make sure func() does not throw any exceptions or get caught in an infinite loop (or any other basic errors like referencing nulls). There is a possibility of a deadlock (but only in the case if there is a static or member mutex).

2. Again, we do not know for sure what has happened in func() with what is given, but due to the nature of this question, the interviewer is probably implying that func() has thrown an exception.

3. In C++, the correct way to handle this is through the use of RAII. A number of solutions will work including scoped locks, mutex with functors, or narrowing the scope of that lock to known parts of code where you KNOW exceptions will not be thrown. A try/catch will not help you in C++. However, in Java, simply use a try/finally block to ensure forward movement in the code.

- elau89 October 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

IMHO first question to be asked is - what does it mean that application 'stops working'. Does it mean it crashed, locked or exit?

- EmilFlater January 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It stopped responding as soon as the function acquired the lock. This suggests a deadlock situation.
The most likely situation is that Func() needed a resource and didn't get it, so it couldn't proceed further. On the other hand, other threads might be waiting for Func() to end so that it can release its locks.

- sbhatla@ncsu.edu October 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Or, a thread acquired the lock and never released it, perhaps because Func() threw an exception. Adding a try/finally around Func with a release in the finally would resolve that. That's not a deadlock, but is a different plausible explanation.

- Dan October 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

problem could be
1. if any exception issue in fun()
2. dead lock situation due to locking order in calledfun and func
3. inifite loops in func

- Anonymous November 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Actually CalledFunc() should be present in a try-catch-finally block. If you are using your own lock objects, they must be explicitly released in the finally block.

- Murali Mohan July 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

make the function synchronize otherwise lock won't work

- Anonymous July 26, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More