What is Sequential consistency?
The most intuitive memory consistency model: all cores' operations appear in one order in which each core's operations keep their program order.
Japanese name: 逐次一貫性
The most intuitive memory consistency model: all cores' operations appear in one order in which each core's operations keep their program order.
Japanese name: 逐次一貫性
Sequential consistency, defined by Leslie Lamport, requires that the result of any execution be the same as if all cores' memory operations were interleaved into one global sequence, with each core's operations appearing in that sequence in program order. Like shuffling several decks of cards together without reordering any single deck, the interleaving may be anything, but every core sees the same one. Programmers can reason about concurrent code by imagining the threads taking turns, which is why it is considered the most intuitive memory consistency model.
Strictly preserving program order across all memory accesses forbids many hardware optimizations. A store buffer lets a core continue executing after a write without waiting for it to reach the cache, and out-of-order execution lets later loads complete before earlier stores. Both break sequential consistency. Most processors therefore implement weaker models: x86 uses total store order (TSO), which allows a later load to pass an earlier store to a different address, and Arm and RISC-V use still weaker models that permit more reordering unless the program inserts fences.
Suppose core 0 executes x = 1 then r1 = y, while core 1 executes y = 1 then r2 = x, with x and y initially 0. Under sequential consistency one of the writes must come first in the global order, so at least one read sees 1, and r1 = r2 = 0 is impossible. On x86, each write can sit in its core's store buffer while the following read fetches the old value from cache, so both reads can return 0. Placing a full memory barrier between the write and the read on each core restores the sequentially consistent outcome.
Cache coherence concerns a single memory location: all cores agree on the order of writes to that address and eventually see the latest value. A memory consistency model such as sequential consistency concerns the ordering of accesses to different addresses, which coherence alone does not constrain. Languages bridge the gap: C11 and C++11 atomics default to memory_order_seq_cst, and programs free of data races behave as if sequentially consistent. Weaker orders such as acquire/release or relaxed let the compiler emit fewer barriers when full ordering is unnecessary.
Answer: B. All cores' operations appear in some single order in which each core's operations occur in program order
Under sequential consistency, the operations of all cores appear interleaved into one sequence, like shuffling cards, with each core's operations keeping their program order within it. It is the easiest model for programmers, but it severely limits hardware optimizations such as reordering through store buffers, so most real CPUs adopt looser models.
No. x86 implements total store order (TSO), which lets a load complete before an earlier store to a different address becomes visible to other cores, so the store-buffer litmus outcome r1 = r2 = 0 can occur. A fence such as MFENCE or a locked instruction prevents it.
Coherence guarantees a single agreed order of writes for each individual address. Sequential consistency is stronger and covers the relative order of operations on all addresses, as one global interleaving that respects every core's program order.
It is the default ordering for std::atomic operations and makes all seq_cst operations appear in one total order consistent with each thread's program order. It is the easiest to reason about but may require the most expensive barrier instructions.
Sequential consistency appears in 3 practice questions across 1 topic, including Multicore & Synchronization.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.