Definition
Condition Synchronisation
Condition synchronisation is a concurrency control mechanism that ensures a specific execution order between processes or threads. A process delays execution until a logical condition or event (triggered by another process) is satisfied.
Unlike mutual exclusion, which prevents simultaneous access to maintain data consistency, condition synchronisation concerns coordination of action sequences to enforce required ordering.
Orthogonality to Mutual Exclusion
| Goal | Mutual Exclusion | Condition Synchronisation |
|---|---|---|
| Primary Purpose | Data consistency | Execution ordering |
| Logic | ”Only one at a time" | "Wait until event X” |
| Constraint | No overlapping access | Defined action sequence |
Combined Use
These mechanisms are orthogonal. A solution may require mutual exclusion to protect shared data and condition synchronisation to enforce correct ordering of operations on that data.
Mechanism
To enforce that action in completes before in begins:
Semaphore S = 0
Void P1()
C1()
S.signal() // signal completion
Void P2()
S.wait() // wait for C1
C2()
Implementation
Common Primitives
- Counting Semaphores: Values represent available units or signals
- Condition Variables: Used within monitors to wait for state changes
- Message Passing: Blocking
receiveuntil a message (the condition) arrives