14.2.11 Locking Constraints
Keywords: perfbook_html

##
14.2.11 Locking Constraints

As noted earlier, locking primitives contain implicit memory barriers. These implicit memory barriers provide the following guarantees:

1. 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.
2. 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.
3. LOCK vs LOCK guarantee:
   - All LOCK operations issued before another LOCK operation will be completed before that LOCK operation.
4. 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.
5. 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.