内存模型


硬件内存模型
顺序一致性: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.
// This kind of question about execution results for a sample program is called a litmus test.
// 为了更快,现代硬件有可能会偏离内存一致性

x86 Total Store Order (x86-TSO) // 先写本地
// 内存屏障:确保已经写入共享内存
ARM/POWER Relaxed Memory Model
The conceptual model for ARM and POWER systems is that each processor reads from and writes to its own complete copy of memory, and each write propagates to the other processors independently, with reordering allowed as the writes propagate.

Data-Race-Free Sequential Consistency // 修改会同步