Microsoft Interview Question

Implement semaphore using lock.