◄ Wiki / OS
critical section
A stretch of code that must be run by only one thread at a time to avoid corruption.
When multiple threads touch the same shared data, letting them into the same code region simultaneously can interleave their operations and corrupt state. That region is a critical section, and locks are used to admit just one thread at a time. Discovering two CPUs inside the same critical section means the lock protecting it failed.
See also
- compare-and-swap (CAS)An atomic operation that updates a value only if it still equals what you expected, all in one indivisible step.
- coreOne independent execution unit inside a CPU that can run a thread on its own.
- context switchThe kernel saving one thread's full state and loading another's, so a single CPU can juggle many tasks.
Referenced by
clone · CMPXCHG · compare-and-swap (CAS) · context switch · core · CPU exception / trap