Picture a busy bakery. You walk in, pull a paper ticket from a dispenser, and wait. When the clerk calls your number, you step up â and nobody else cuts in front. The line is fair, orderly, and managed without a bouncer at the door.
In 1974, Leslie Lamport used exactly this metaphor to solve one of the oldest puzzles in computer science: how can multiple threads share a single resource â a file, a counter, a device â without ever colliding, using nothing but plain memory reads and writes?
The puzzle is called the mutual exclusion problem. It was first stated formally by Edsger Dijkstra in 1965, and it has three requirements:
- Mutual exclusion: at most one thread is inside the critical section at any moment.
- Progress: if no thread is in the critical section, one of the waiting threads eventually gets in.
- Bounded waiting: no thread waits forever â every request is eventually served.
Hardware designers solved the problem quickly with special atomic instructions like test-and-set or compare-and-swap, but Lamport asked a deeper question: can you guarantee mutual exclusion using only ordinary reads and writes, even on a machine that might reorder or overlap them? The bakery algorithm proved you can â and the proof is elegant enough to teach to undergraduates fifty years later.
Comments
Loading comments...