Software → Operating Systems
Critical Section
A region of code that must not be executed by multiple concurrent actors at the same time.
Motivation
Critical section identifies code that must not be executed by multiple concurrent flows at the same time.
Where it fits
Critical Section belongs to synchronization and concurrent programming.
Mental model
It is the protected region where shared state or resources are accessed.
Common mistakes
- Making critical sections larger than necessary.
- Protecting only writes while reads can also observe inconsistent state.
Related concepts
Critical Section connects to mutex, semaphore, race condition, and synchronization.