This is the simplest and performs no interrupt disabling but includes full memory barriers. 这是一个最简单的变量,它不会执行中断禁用,但是包含全部的内存壁垒(memorybarrier)。
Mutexes will insert a " memory barrier," which ensures that the writes to main memory occur in the order the threads lock the mutex. 互斥对象将插入一道“内存关卡”,由它来确保对主存的写入按照线程锁定互斥对象的顺序进行。
Changing the semantics to require releasing a lock to be a full memory barrier would have performance penalties. 即使编译器不会重序,在一个多核处理或内存系统中也会进行重序。
The memory barrier is a signal that tells the CPU that it must coordinate with all the other CPUs in order to fetch the most up to date value. 存储关卡像一个信号,它通知CPU此时必须和其他所有的CPU进行协调,以此获得最新的数值。
Inter-core coordination, that is, memory barrier semantics, clearly has its overhead as evidenced by the performance of the benchmark when running on my system with one of the cores turned off. 不同核之间的协调,比如存储关卡语义,通过关掉一个核运行的测试结果看,很明显会带来系统开销。