The Sleeping Barber Problem is one of the classical IPC problems. The barber shop has one barber, one barber chair, and n chairs for waiting customers, if any, to sit on. If there are no customers present, the barber sits down in the barber chair and falls asleep. When a customer arrives, he has to wake up the sleeping barber. If additional customers arrive while the barber is cutting a customer's hair, they either sit down (if there are empty chairs) or leave the shop (if all chairs are full).
I would like you to write a program (C or C++) to synchronize the barber and the customers without getting into race conditions. You MUST use semaphores and your problem must be Object Oriented.