Critical Section
A critical section is a region of code that accesses shared resources and must not be executed concurrently by more than one thread. The critical section is the atomic unit of reasoning in concurrent programming: every other synchronization concept — mutexes, semaphores, monitors, lock-free algorithms — exists primarily to ensure that critical sections execute in mutual exclusion. Without critical sections, there is no need for synchronization; with them, every concurrent program becomes a negotiation about who enters and when.
The identification of critical sections is the first and most consequential design decision in concurrent programming. Too broad, and the program serializes unnecessarily, defeating the purpose of concurrency. Too narrow, and race conditions slip through the gaps between adjacent sections. The critical section is not an implementation detail; it is the architectural boundary that determines whether a concurrent program is correct, efficient, or both.
The critical section is where the illusion of concurrent execution shatters. Outside it, threads run in parallel, free and uncoordinated. Inside it, they collapse into a single thread, sequential and obedient. The critical section is the confession booth of concurrent programming: the place where threads admit they cannot share, and where the programmer decides what must be private. The art is not in the locking. The art is in knowing what to lock.
See also: Mutex, Thread, Concurrency, Race Condition, Semaphore, Monitor, Lock-Free Programming, Synchronization