[cpp-threads] Relaxed reload example

Herb Sutter hsutter at microsoft.com
Wed Aug 1 22:53:22 BST 2007


The following question came up in the context of IA64, but I thought it was worth repeating here to see what the C++MM answer is supposed to be. (I'm not sure the latest syntax for a relaxed load in thread 2, so I made up something hopefully close.)

Initially:
  atomic<int*> s = 0;

Thread 1:
  r1 = new int;
  *r1 = 55;
  s = r1; // release

Thread 2:
  r2 = s.load( memory_order_relaxed ); // not acquire
  r3 = *r2; // not acquire

Is it possible that (r2 != 0 && r3 != 55)? I'm not sure if the reload that would permit that to happen is allowed. Is it?

Herb


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.decadentplace.org.uk/pipermail/cpp-threads/attachments/20070801/fa1cbfaf/attachment.htm 


More information about the cpp-threads mailing list