Morgan Stanley Interview Question






Comment hidden because of low score. Click to expand.
0
of 0 vote

For primitives` description search wiki. And about mutex: in Windows if thread dies/terminates OS releases mutex by itself and WaitForSigleObject(multiply) function returns WAIT_ABANDONED which means that mutex has been released in unnormal way.

- Anonymous November 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

"OS releases mutex by itself" - if possible can you provide a reference.
And "WaitForSigleObject" looks like a windows based function, we prefer something that works for unix/linux, (windows hides a lot of details).
Thanks

- blueskin.neo November 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes, right, it is WinAPI`s function.

From msdn: "If a thread terminates without releasing its ownership of a mutex object, the mutex object is considered to be abandoned. A waiting thread can acquire ownership of an abandoned mutex object, but the wait function will return WAIT_ABANDONED to indicate that the mutex object is abandoned."

Can`t tell how it`s gonna be for linux

- Anonymous November 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think interviewer expect to know about java Atomic primitives. like AtomitInteger. those classes provide fine grained, thread safe way to set new value.
see - Java Atomic primitives, compare and set algorithm

- Mohd Adnan August 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A robust mutex can be used to handle the case where the owner of the mutex is terminated while holding the mutex lock, so that a deadlock does not occur. These have more overhead than a regular mutex, and require that all clients locking the mutex be prepared to handle the error code EOWNERDEAD. This indicates that the former owner has died and that the client receiving this error code is the new owner and is responsible for cleaning up any inconsistent state.

A robust mutex is a mutex with the robust attribute set. On Linux this can be set using pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP), or using the POSIX standard function pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST) if you have glibc 2.12 or later (this function was standardized in POSIX.1-2008).

- Nit January 26, 2014 | 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