Microsoft interview question

Code for Reader writer problem.