Sleeping Barber: The Waiting Room Problem
The Sleeping Barber Problem The Sleeping Barber is a classic synchronization problem proposed by Edsger Dijkstra in 1965. It elegantly demonstrates resource management, waiting, and signaling in concurrent systems. The Scenario A barbershop has: 1 barber 1 barber chair N waiting room chairs The rules: If no customers, the barber sleeps When a customer arrives: If barber is sleeping → wake him up If barber is busy → sit in waiting room (if space available) If waiting room is full → leave When barber finishes a customer → check waiting room Real-World Applications This pattern appears in many systems: ...