Global Payments interview question

How to implement semaphore, semaphore vs mutex,