The most intuitive model
Sequential consistency (SC), defined by Lamport, says the result of any execution is as if all operations ran in some single total order, and each thread's operations appear in that order in their program order. It is the model most programmers imagine by default.
Why it is expensive
SC forbids many reorderings that hardware and compilers love. A processor that has buffered a store cannot let a later load bypass it without breaking SC. Enforcing it everywhere would require frequent memory barriers, hurting performance, so most real CPUs offer weaker models by default.
- SC gives a clean interleaving abstraction.
- Real hardware allows store buffering and reordering that violate SC.
- Languages recover SC only for properly synchronized programs.
SC for data race free programs
The key compromise in both Java and C plus plus is the SC for DRF theorem: if a program has no data races, it behaves as if sequentially consistent. So you reason with the simple model as long as you synchronize all conflicting accesses correctly.
Key idea
Sequential consistency means one total order respecting each thread's program order, and Java and C plus plus deliver it only for data race free programs.