problem of sleeping barber using the semaphore
Sleeping Barber Problem:
In a barber shop, there is a waiting room with n chairs and a barber chair. If there are no customers waiting in the hall, the barber goes to sleep and does not expect the other barbers to shave. If all the seats in the hall are full and a customer enters, the customer leaves the hall because the hall is full. If the barber is shaving someone at that time, but there is an empty chair, the person who is entering enters one of the empty chairs. If a customer enters the barbershop while sleeping, the client awakens the barber.