Leslie Lamport 1979 年的论文 How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs 定义:

The customary approach to designing and proving the correctness of multiprocess algorithms for such a computer assumes that the following condition is satisfied: the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program. A multiprocessor satisfying this condition will be called sequentially consistent.

为这种计算机设计和证明多处理算法正确性的通常方法假定满足下列条件:任何执行的结果都是相同的,就好像所有处理器的操作都是按某种顺序执行的,每个处理器的操作都是按程序指定的顺序出现的。满足这一条件的多处理器系统将被称为顺序一致的。

顺序一致性允许程序员假设程序按照它们在源码中组织相同的顺序执行,并且单个线程的执行只是以某种顺序交替(interleaving),而不是以其他方式排列。

看一下下面这个 litmus test

Litmus Test: Message Passing
Can this program see r1 = 1, r2 = 0?
// Thread 1           // Thread 2
x = 1                 r1 = y
y = 1                 r2 = x

如果 litmus test 的执行顺序一致,则有六种可能的交替:

所以这个 litmus test 的答案是 no

不幸得时,实践中现在硬件都会偏离顺序一致性来放弃严格的顺序一致性可以让硬件更快的执行程序。