liveBook · Manning

Sequential consistency

As explained in Modern C

Sequential consistency is a memory-consistency model in which all operations on atomic objects appear in one global order consistent with each thread's program order.

Sequential consistency is a memory-consistency model in which every atomic operation participates in one global order, while preserving each thread’s program order. Unlike acquire-release consistency, it extends causal ordering into a total ordering across atomic objects. section 19.3

This model makes concurrent behavior easier to reason about, but its stronger constraints can restrict parallel execution and impose implementation costs. It is the default consistency model for atomic operations, not for ordinary C library functions. section 19.3 section 19.5

Two threads synchronizing through an atomic

Imagine two threads communicating through an atomic object x while their observable state changes over time. Sequential consistency requires every atomic operation on x—and on any other atomic object—to fit into one timeline that agrees with each thread’s own execution order, even when processors or memory banks differ. section 19.3

The C atomic interfaces that use their ordinary, non-explicit forms provide sequential consistency, including:

  • The _explicit variants accept a memory_order argument; memory_order_seq_cst requests sequential consistency and matches the ordinary forms. section 19.4

How Modern C covers it

How deep it goes
Explains global linearization, acquire-release implications, C interfaces, and performance costs without developing every implementation detail.
Examples
Uses a two-thread atomic-synchronization figure and declarations for ordinary and explicit C atomic interfaces.
What it assumes
Assumes atomic objects, synchronization, program order, and the happened-before relation while situating them within concurrent C execution.
What you can do after
Operate/configure C atomic operations using default sequential consistency or memory_order_seq_cst through _explicit interfaces.
How it connects
Connects atomic objects, modification order, program order, acquire-release consistency, synchronization, and memory_order.

Also explained in

Compare how 2 books explain sequential consistency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.