OS Concepts · Chapter 6

Race Condition

Two processes increment and decrement a shared counter with no synchronization at all — watch an update get lost.

What's happening

Both processes read the counter into a private register, modify it, then write it back. If their reads/writes interleave badly, one update silently disappears.

Shared state

Race Condition

0 / 0
Speed
5
counter

Event log