Definition
Condition Synchronisation
Condition synchronisation is a concurrency control mechanism used to ensure a specific execution order between multiple processes or threads. It allows a process to delay its execution until a specific logical condition or event (triggered by another process) is met.
Unlike mutual exclusion, which focuses on preventing simultaneous access to data to maintain consistency, condition synchronisation focuses on the coordination of action sequences to avoid race conditions.
Comparison with Mutual Exclusion
Mutual exclusion and condition synchronisation are orthogonal concepts that can be used independently or together:
| Goal | Mutual Exclusion | Condition Synchronisation |
|---|---|---|
| Primary Purpose | Data Consistency | Execution Ordering |
| Logic | ”Only one at a time" | "Wait until event X occurs” |
| Constraint | No overlapping access | Defined action sequence |
Mechanism
A common requirement for condition synchronisation is that an action in process must finish before an action in process can begin. This can be implemented using a semaphore initialised to 0:
- Process : Executes , then calls
signal(S). - Process : Calls
wait(S), then executes .
Implementation Tools
Operating systems provide several constructs to facilitate condition synchronisation:
- Counting Semaphores: Using values to represent available units or signals.
- Condition Variables: Used within monitors to explicitly wait for state changes.
- Message Passing: A process blocks on a
receivecall until a message (the condition) arrives.