翻译
Sequential Consistency (SC) 的形式化定义 和你提到的 “两个核心约束” 在理论上是等价的.
但表述方式不同,适用于不同语境
形式化定义 适用于 抽象
两个核心约束适用于 具体实现
Parallel Computer Architecture - A Hardware Software Approach(DRAFT).pdf P275
Implementing SC requires that the system (software and hardware) preserve the intuitive constraints defined above.
SC 是一个抽象模型,为了在实际系统中“实现”它,就要让系统的行为符合它的定义要求,也就是让程序执行的效果“看起来像是”所有处理器的操作按某种顺序一个接一个地完成。
There are really two constraints.
SC 的定义包含两个本质要求:程序顺序(program order)和原子可见性(atomic visibility). 这两个本质需求和形式化定义完全等价
The first is the program order requirement discussed above, which means that it must appear as if the memory operations of a process become visible—to itself and others—in program order.
一个 执行流中的 Load/Store 等操作必须对所有执行流(包括自身)看起来是按代码写的顺序发生的。
但不要求被同时看到
The second requirement, needed to guarantee that the total order or interleaving is consistent for all processes, is that the operations appear atomic; that is, it appear that one is completed with respect to all processes before the next one in the total order is issued.
所有进程看到的“整体顺序”或交错顺序是一致的
第一个约束解读
第一个约束 描述了
一个 执行流中的 Load/Store 等操作必须对所有执行流(包括自身)看起来是按代码写的顺序发生的。
但不要求被同时看到
第二个约束 描述了
store 必须被 所有(包括自身)执行流 同时看到
第二个约束解读
The second requirement, needed to guarantee that the total order or interleaving is consistent for all processes, is that the operations appear atomic; that is, it appear that one is completed with respect to all processes before the next one in the total order is issued. 完全等价于 Write atomicity
The tricky part of this second requirement is making writes appear atomic, especially in a system with multiple copies of a block that need to be informed on a write.
Write atomicity, included in the definition of SC above, implies that the position in the total order at which a write appears to perform should be the same with respect to all processors.
It ensures that nothing a processor does after it has seen the new value produced by a write becomes visible to other processes before they too have seen the new value for that write.
In effect, while coherence (write serialization) says that writes to the same location should appear to all processors to have occurred in the same order, sequential consistency says that all writes (to any location) should appear to all processors to have occurred in the same order.
这里提及了 write serialization 是 Write atomicity 的 必要非充分条件
约束解读
项目 | 第一约束(程序顺序) | 第二约束(Write atomicity) |
---|---|---|
关注点 | 单个执行流的顺序 | 所有处理器的全局一致(完全等价于Write atomicity) |
作用对象 | 一个执行流的内存操作(Load/Store)被其他执行流看到的顺序 | Store操作 一旦可见,必须全部可见 |
是否要求操作同步可见 | ❌ 否,仅顺序对外一致 | ✅ 是,写操作必须“同时”可见 |
示例 | 程序中写了 A 再写 B,任何人都不能先看到 B 再看到 A | 某个 CPU 看到写 A 的值 N,那就说明所有 CPU 都应该看到值 N |