Explain like I'm five · Systems

What is Process Synchronization?

Semaphores, mutexes, and monitors, told as a story about the rule for handing out the lift key.

Both mechanics see "it's free" and lift a car at the same momentonly one lift, but neither knows the other is reaching for it

Two mechanics reach for the same lift at the same time.Neither knows the other is reaching for it.

checked "it's free" — then turned awayme too, "it's free" — both climb onthe gap between "check" and "use" is where the crash happens (race condition)

The crash happens in the gap between checking and using.A crash in that gap is called a race condition.

no key — so I waitsynchronization = only whoever holds the key may use the liftthe next person waits until the key comes back

Synchronization = only the key-holder may use the lift.The next person waits until the key comes back.

Mutexexactly one key exists
SemaphoreN keys — up to N at once
Monitora room with a built-in waiting lounge
Critical Sectionthe stretch of work done while holding the key
SYNC TOOLSMutex: exactly one keySemaphore: N keys at onceMonitor: a room with a waiting loungeCritical section: work done holding the keyeach tool differs in how many get in at oncea mutex resembles a semaphore with N=1, but only its locker can unlock it

Each tool differs in how many get in at once.A mutex resembles a semaphore with N=1, but only its locker can unlock it.

return it in time, and thenext car goes right upforget it, and the nextmechanic waits foreverholding one key while waiting for another can lead to deadlock

If the key isn't returned, the next mechanic freezes in place.Holding one key while waiting for another can lead to deadlock.

In one breath

Process synchronization = the rule that lets several tasks touch a shared resource like the lift only one at a time (up to N with a semaphore).

When several processes or threads touch the same resource (a variable, file, or memory region) at once, a race condition results. A mutex enforces mutual exclusion so only one enters the critical section at a time; a semaphore uses a counter to allow up to N; a monitor bundles a lock with condition variables at the language level to handle waiting and signaling safely.

When grown-ups say it

Race Condition
A crash in the gap between checking and using. Scramble the order, and the result changes each time.
Mutex
A lock with exactly one key. Only one task gets in at a time.
Semaphore
A lock with N keys. Up to N can be inside at once.
Monitor
A room with a built-in waiting lounge. Bundles a lock with condition variables.
Deadlock
Frozen forever, each waiting on the other's key. Holding a key while waiting on each other's leads straight here. → the garage frozen waiting on each other's keys
Process/Thread
Several hands working the same car. Synchronization matters most for threads, which share "the same car." → one car, many hands
CPU Scheduling
The car order written on the job board. "Who goes first" is scheduling — synchronization is "don't touch at once." → who gets the lift first
Cache Memory
A small toolbox holding only the frequently used tools. Similar coordination is needed when several cores share a cache line. → the toolbox kept right beside you
Next story
The Toolbox Kept Right Beside You →
Want another term as a picture book? Request →