Skip to content

Mutual Exclusion and Critical Sections

A critical section is code that accesses shared resources and must not be executed by more than one thread simultaneously. Mutual exclusion ensures only one thread enters the critical section at a time, trading parallelism for safety.

Tension Addressed

Safety vs. Liveness, Simplicity vs. Scalability

Recognizable As

Locks/mutexes, synchronized blocks, any "acquire before access, release after" pattern. The smaller the critical section, the better the parallelism; but too fine-grained leads to complexity and potential for missed synchronization.

Canonical Sources

Dijkstra, "Solution of a Problem in Concurrent Programming Control" (1965); Lamport, "A New Solution of Dijkstra's Concurrent Programming Problem" (1974)

Transfers To

Database transactions, distributed locking, any exclusive resource access pattern