OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

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

Choose one option.
Show answer & explanation
Answer: C. Only (II)

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:

  1. SFENCE (Store Fence):

    • Serializes all store (write) operations
    • Does NOT order loads
    • Partial barrier, not full
  2. MFENCE (Memory Fence):

    • Serializes ALL memory operations (both loads and stores)
    • Acts as a full memory barrier
    • Creates a complete ordering point
  3. 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).