顺序一致性是否蕴含缓存一致性?
Hey folks, let's unpack how sequential consistency relates to cache consistency, and why the former implies the latter:
Cache Consistency Basics
Cache consistency is all about ensuring shared memory behaves predictably across multiple processors, with three core guarantees:
- Any read operation must return the most recently written value for that memory location.
- Every write you perform will eventually be visible to subsequent reads (no writes vanish into the ether).
- All processors will observe writes to the same memory location in the exact same order.
Sequential Consistency: A Stricter Model
Sequential consistency raises the bar with even tighter rules for memory operations:
- There’s a single global total order that applies to all memory operations (reads and writes) across every processor in the system.
- Each operation is atomic—from the perspective of other processors, it looks like it completed instantly.
- This global order has to respect the program order of each individual processor: if your code does operation A then operation B on one CPU, the global order will never have B come before A.
Why Sequential Consistency Covers Cache Consistency
If a system follows sequential consistency, it automatically checks all the boxes for cache consistency:
- Latest write on reads: Since there’s a global order, any read will always see the last write that precedes it in this order—so it’s guaranteed to be the most recent value.
- Writes are eventually visible: Every write is part of that global sequence, so eventually any read that comes after it in the order will pick it up.
- Uniform write order: The global total order ensures every processor sees writes to a location in the same sequence, which directly satisfies the third cache consistency rule.
In short: sequential consistency is a stricter memory model than cache consistency. Any system that’s sequentially consistent is automatically cache-consistent, but a cache-consistent system might not meet the more rigid global order and program order requirements of sequential consistency.
内容的提问来源于stack exchange,提问作者Owe u.

