C ++ 0x: memory ordering

The current C ++ 0x draft talks about sections 29.3.9 and 29.3.10 on pages 1111-1112, which in the following example

// Thread 1
r1 = y.load(memory_order_relaxed);
x.store(1, memory_order_relaxed);

// Thread 2
r2 = x.load(memory_order_relaxed);
y.store(1, memory_order_relaxed);

The result r1 = r2 = 1is possible because the operations of each thread are weakened and are not interconnected. Now my question is about the possible results of the following (similar) example:

// Thread 1
r1 = y.load(memory_order_acquire);
x.store(1, memory_order_release);

// Thread 2
r2 = x.load(memory_order_acquire);
y.store(1, memory_order_release);

I think that in this case the result is r1 = r2 = 1impossible. If this were possible, loading y would synchronize with (thus, happening earlier) with storage up to y. Like x, the load x will be - to the store to x. But the load y is ordered to (thus, occurs earlier) storage to x. This creates a cyclical event-up relationship, which, I think, is not allowed.

+5
1

( , ), , , , ,

  • ,
  • ,

,

acquire
// other stuff
release

/ , ( /).

, , r1 = r2 = 1. / , , , r1 = r2 = 1 .

+4

All Articles