Skip to main content
PRISM

Concurrency, enumerated

A concurrent program does not have a behaviour. It has a set of them, one per valid interleaving of its threads — and the bug is almost never in the ordering you imagined. Every concept here enumerates that set and marks the members that are wrong.

28 concepts · every one runnable · start with the lost update · or break one yourself

Races and atomicity

What an increment actually is, why a question can go stale between asking and acting, and the outcome space that appears the moment two threads touch one variable.

Mutual exclusion

Locks, and what they do to the set of possible orderings. Granularity, deadlock and its cycle, livelock, starvation, and the reentrancy that stops a lock deadlocking against itself.

Coordination

Making threads wait for each other on purpose. Bounded buffers, condition variables and the while loop that is not optional, semaphores, barriers and reader-writer locks.

Async and event loops

One thread, many tasks, and a queue discipline with exactly one valid schedule. Why a promise beats a zero-delay timer, what a blocking call costs everyone else, and what await actually suspends.

Memory and hardware

Where the interleaving model runs out. Store buffers producing outcomes no ordering explains, the barriers that forbid them, false sharing, and the ceiling Amdahl puts on all of it.

Patterns in practice

Thread pools and the deadlock they invite, work stealing against a shared queue, actors that share nothing, and immutability as a way to make the whole problem not apply.