Peraso interview question

How to use lock to implement a semaphore?