Microsoft Interview Question

I was asked to code semaphores and implement locks and race conditions. Shared reader-writer model. There is a shared data structure, and multiple processes access it. If there is a reader, another process can read it, but no process can write to it. If there is a writer, no process can read. A reader count needs to be maintained, and only if all the readers are done reading, can any process write to the shared data structure.

Interview Answer

Anonymous

Feb 9, 2014

I was able to get close to the solution, but I was told that the code I've written still has race conditions. Wrote reader, writer code and read lock, write lock code. The interviewer did not give out any hints otherwise to get me closer to the solution. Finally, I ran out of time, and a couple weeks after that got a reject.