OS Concepts · Chapter 6
Seven standalone pages covering the chapter's synchronization primitives and classic problems. Each page animates a deterministic, textbook-accurate trace frame by frame — press Play to watch processes race, wait, block and wake up.
An unsynchronized counter++ / counter-- loses an update. Toggle between the unsafe interleaving and the safe, serialized version.
Motivation Software solutionTwo flags and a turn variable give mutual exclusion and bounded waiting with no hardware support at all.
flag[] · turn Hardware solutionAn atomic TestAndSet instruction builds a spinlock — simple, but costs CPU cycles while busy-waiting.
TestAndSet AbstractionA counting semaphore with wait()/signal() and a real waiting list — no busy-waiting, processes block and get woken.
wait · signal Classic problemProducer and Consumer share a circular buffer, synchronized with mutex, full and empty semaphores.
Producer–Consumer Classic problemAny number of readers may read concurrently; a writer needs the data set all to itself.
readcount · wrt Classic problemFive philosophers, five chopsticks — watch the naive solution deadlock, then see the asymmetric fix avoid it.
Circular wait