Sunday, January 11, 2009

C++0x中Memory Order的解释

来自N2153的非常好的解释:

Each atomic operation defines three sets of memory operations:
A: Memory operations preceding the atomic operation in program order 2 , plus any memory operations from other threads performed with respect to this thread before the atomic operation.
B: Memory operations implied by the atomic operation.
C: Memory operations following the atomic operation in program order, plus any memory operations performed by other threads that have observed the result of a store in C.


  • An atomic operation with acquire semantics ensures that all memory operations in set B are performed before any memory operation in set C.
  • An atomic operation with release semantics ensures that all memory operations in set A are performed before any memory operation in set B.
  • An atomic operation with ordered semantics has both acquire and release semantics. That is, all memory operations in set A are performed before any memory operation in set B, and all memory operations in set B are performed before any memory operation in set C.

0 comments: