In computer science, the sleeping barber problem is a synchronization problem. The problem revolves around a barber shop that has one barber, one barber chair, and several waiting chairs. When there are no customers, the barber sits in his chair and sleeps. As soon as a customer arrives, he either awakens the barber or if the barber is cutting someone's hair, he sits down on one of the waiting chairs (or he leaves if the waiting chairs are all occupied). The problem consists of engaging in the activity without any race conditions. The solution involves using semaphores and mutexes to guard the critical region.

See also