Multicore & Synchronization
Which statement is correct about memory operations with acquire and release semantics?
- ABoth acquire and release are the heaviest barriers, completely stopping all reads and writes
- BAcquire allocates memory and release frees it
- CReads and writes after an acquire cannot move before it, and reads and writes before a release cannot move after it
Show answer and explanation
Answer: C. Reads and writes after an acquire cannot move before it, and reads and writes before a release cannot move after it
Taking a lock has acquire semantics and releasing it has release semantics. Operations after the acquire do not leak to before the lock is taken, and operations before the release do not leak to after it is released, so accesses in the protected region stay inside it. With fewer restrictions than a full barrier, which blocks both directions, hardware can keep the remaining reorderings for performance.
- A. They restrict only one direction, so they are lighter than a full barrier.
- B. This is unrelated to memory allocation.
- C. Correct. It is a lighter, one-directional ordering guarantee.