14.2.11 Locking Constraints
As noted earlier, locking primitives contain implicit memory barriers.
These implicit memory barriers provide the following guarantees:
- LOCK operation guarantee:
- Memory operations issued after the LOCK will be completed
after the LOCK operation has completed.
- Memory operations issued before the LOCK may be completed
after the LOCK operation has completed.
- UNLOCK operation guarantee:
- Memory operations issued before the UNLOCK will be
completed before the UNLOCK operation has completed.
- Memory operations issued after the UNLOCK may be completed
before the UNLOCK operation has completed.
- LOCK vs LOCK guarantee:
- All LOCK operations issued before another LOCK operation
will be completed before that LOCK operation.
- LOCK vs UNLOCK guarantee:
- All LOCK operations issued before an UNLOCK operation
will be completed before the UNLOCK operation.
- All UNLOCK operations issued before a LOCK operation
will be completed before the LOCK operation.
- Failed conditional LOCK guarantee:
- Certain variants of the LOCK operation may fail, either
due to being unable to get the lock immediately, or due
to receiving an unblocked signal or exception
whilst asleep waiting
for the lock to become available. Failed locks do not
imply any sort of barrier.
Paul E. McKenney
2011-12-16