Key Concurrency Terms

CRITICAL SECTION, RACE CONDITION, INDETERMINATE, MUTUAL EXCLUSION
These four terms are so central to concurrent code that we thought it worth while to call them out explicitly.

CRITICAL SECTION

A critical section is a piece of code that accesses a shared resource, usually a variable or data structure.

RACE CONDITION

A race condition arises if multiple threads of execution enter the critical section at roughly the same time; both attempt to update the shared data structure, leading to a surprising (and perhaps un- desirable) outcome.

INDETERMINATE

An indeterminate program consists of one or more race conditions; the output of the program varies from run to run, depending on which threads ran when. The outcome is thus not deterministic, something we usually expect from computer systems.

MUTUAL EXCLUSION

To avoid these problems, threads should use some kind of mutual exclusion primitives; doing so guarantees that only a single thread ever enters a critical section, thus avoiding races, and resulting in deterministic program outputs.