Sequential Consistency and Interleavings

Analyze a two-thread outcome by asking whether there is a global ordering that preserves each thread’s order.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. An interleaving must respect both local sequences
  2. A system can promise fewer cross-location constraints

An interleaving must respect both local sequences

In a simple sequentially consistent model, all operations appear in one total order consistent with each processor’s program order. With \(x=y=0\), one thread writes \(x=1\) then reads \(y\), and another writes \(y=1\) then reads \(x\). If both reads return zero, each must precede the other thread’s write. Combined with local orders, these relations form a cycle, so no such total order exists.

A system can promise fewer cross-location constraints

A coherence guarantee about each location does not alone forbid that pair of observations. Some memory models and operation orders admit behavior that a sequentially consistent interleaving excludes. Use the precise model and actual operations before treating an interleaving argument as a proof. Cache coherence explains the per-location guarantee. Acquire and release introduce selected cross-thread constraints rather than a total order of all events.[1][2]

References

  1. Vijay Nagarajan et al., A Primer on Memory Consistency and Cache Coherence ↩
  2. ISO C++ Working Draft, Order and Consistency ↩