Microsoft interview question

Implement semaphore using lock.