Previous | Next --- Slide 26 of 52
Back to Lecture Thumbnails
ask

This can be viewed as a one-way barrier. Acquire semantics only allows instructions from above to move below the barrier, while release semantics allows only instructions from below to move above.

eosofsky

The reason that taking a lock must have acquire semantics but not release semantics is that the operations following taking the lock (but before releasing it) are part of a critical section. Reordering an operation to be above the locking would likely introduce a race condition because that operation is no longer in the defined critical section (but needs to be in order to ensure correctness). However, operations above the locking can be reordered to follow the locking because that would simply be adding logic to the critical section and would not affect program correctness.

A similar explanation exists for why releasing a lock must have release semantics but not acquire semantics; operations that follow the release in program order can be reordered to be above the release since this is again adding logic to the critical section (does not affect correctness), but reordering operations to be below the release would be taking logic out of the critical section and thus introducing the possibility of a race condition.