A barbershop has one barber, one chair, and a few waiting seats. How do you avoid chaos?

A barbershop has a single barber, one barber chair, and a small waiting room with a few chairs. If no customers are around, the barber sleeps in his chair. When a customer arrives, they either wake the sleeping barber, take a waiting seat if the barber is busy, or leave if every seat is full. How do you design the rules for arriving customers and the barber so that two customers are never seated in the chair at once, and no customer is left waiting forever without knowing what's happening?

Reveal the answer

The puzzle is solved with the same tools that prevent chaos in computer systems: coordination locks that let a customer safely check whether a chair is free and reserve it in one atomic step, so no two customers can grab the barber's attention at the same time. Computer scientist Edsger Dijkstra devised the sleeping barber problem in 1965 as an accessible way to illustrate the challenge of coordinating processes that compete for a shared, limited resource.

— Edsger W. Dijkstra, Cooperating Sequential Processes — 1965 (technical report, Technische Hogeschool Eindhoven)

One credited idea per card. No filler. Swipe the rest in Savvy.

Keep swiping — it's free Works right in your browser. No app store needed.

More Puzzles

All Puzzles cards →
More from Edsger W. Dijkstra →

Five ideas worth knowing, every week

The week's best cards and a puzzle, credited as always. Free, unsubscribe any time.