[cpp-threads] Relaxed reload example

Paul E. McKenney paulmck at linux.vnet.ibm.com
Wed Aug 1 23:09:33 BST 2007


On Wed, Aug 01, 2007 at 02:53:22PM -0700, Herb Sutter wrote:
> 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?

DEC Alpha would in fact permit this outcome.  But don't take my word
for it, see:

	http://www.openvms.compaq.com/wizard/wiz_2637.html

which now maps to:

	http://h71000.www7.hp.com/wizard/wiz_2637.html

I am not aware of any other CPU that permits this outcome.

							Thanx, Paul



More information about the cpp-threads mailing list