Which one of the instruction(s) given below is/are a full memory barrier instruction in x86...
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Which one of the instruction(s) given below is/are a full memory barrier instruction in x86 processor?
I) SFENCE
II) MFENCE
III) LFENCE
Show answer & explanation
MFENCE is the only full memory barrier instruction in x86. SFENCE (Store Fence) orders only store operations, while LFENCE (Load Fence) orders only load operations. A full memory barrier must order both loads and stores with respect to all memory operations, which only MFENCE does in x86.
Step-by-step Derivation:
In x86 memory barrier semantics:
SFENCE (Store Fence):
- Serializes all store (write) operations
- Does NOT order loads
- Partial barrier, not full
MFENCE (Memory Fence):
- Serializes ALL memory operations (both loads and stores)
- Acts as a full memory barrier
- Creates a complete ordering point
LFENCE (Load Fence):
- Serializes all load (read) operations
- Does NOT order stores
- Partial barrier, not full
A full memory barrier must prevent both load-store and store-load reordering. Only MFENCE provides this complete serialization in x86 architecture. Therefore, the answer is C) Only (II).