In this problem you are to synchronize the actions of a barber and some number of customers. The barber can only cut one customer's hair at a time. A barber shop has one barber, one barber chair for the customer currently getting their hair cut, and N chairs for waiting customers.
If there are no customers the barber sits in the barber chair and falls asleep.
When a customer arrives and the barber is sleeping, the customer has to wake up the sleeping barber to get his/her hair cut.
If a customers arrives while the barber is cutting hair, then if there is a free chair the customer sits down and waits, otherwise the customer leaves and does not get a hair cut.
Program the barber and the customers using semaphores to synchronize their actions. Your solution should be live, safe, and deadlock free. A couple suggestions: (1) think about who can wake up whom (this will help you determine how many semaphores you need for your solution); (2) think about if you need to keep any state to determine actions.