Overview
Synchronization Primitives are software abstractions built on top of hardware atomic instructions (or interrupt disabling) that allow concurrent threads to safely access shared resources, enforce mutual exclusion, and coordinate execution timing.
Core Primitives
| Primitive Link | Description | Primary Mechanism / API | Primary Use Case |
|---|---|---|---|
| Locks | Enforces strict mutual exclusion across critical sections. Evolves from hardware spinlocks to guarded sleep locks. | acquire(), release(), test_and_set() | Mutual Exclusion (Single Thread in Critical Section) |
| Semaphores | Dijkstra’s non-negative integer variable. Retains event history to manage resource pools and timing sequences. | wait() (), signal() (), Counter + Wait Queue | Mutual Exclusion () AND Event Sequencing () |
| Condition Variables | Memoryless synchronization queues allowing threads to sleep inside critical sections by atomically releasing locks. | wait(), signal(), broadcast() (Mesa Semantics) | Waiting for complex shared state conditions |
| Monitors | Language-level constructs encapsulating shared data and routines with compiler-enforced implicit mutual exclusion and internal CVs. | Encapsulated Procedures + Implicit Locks + Internal CVs | Structured, language-supported thread synchronization |