Multicore & Synchronization
What is the role of a memory barrier (fence) instruction?
- AIt guarantees that memory operations before the barrier become visible to other cores before those after it
- BIt physically partitions memory and forbids access
- CIt stops the program until every thread arrives
Show answer and explanation
Answer: A. It guarantees that memory operations before the barrier become visible to other cores before those after it
CPUs can reorder memory operations, so passing data to other cores in a fixed order requires an instruction that prevents it. A memory barrier makes all earlier reads and writes complete (become visible to other cores) before later ones are performed. Lock acquisition and release include this barrier effect, which is why variables protected by a lock are passed correctly.
- A. Correct. It stops memory operations from being reordered across it.
- B. Forbidding access is done by page protection and similar.
- C. That is barrier synchronization among threads.