[cpp-threads] C++ memory model

Boehm, Hans hans.boehm at hp.com
Tue Sep 22 23:41:47 BST 2009


> From: Lawrence Crowl [mailto:crowl at google.com] 
> Sent: Tuesday, September 22, 2009 2:51 PM
> 
> On 9/22/09, Boehm, Hans <hans.boehm at hp.com> wrote:
> > I still have a general problem with all forms of this sentence, in 
> > that it doesn't seem to be a constraint on observable program 
> > behavior.  The program can't tell whether it was moved out 
> of the loop 
> > or just held in a local store buffer indefinitely.
> 
> Agreed.
> 
> > It seems to me that the most we can really properly state 
> is precisely 
> > what's already said in the preceding sentence.
> 
> Are you saying you would like to change the preceding sentence?
No.  I like the first sentence in 29.3p9:

"Implementations should make atomic stores visible to atomic loads within a reasonable amount of time"

It's a bit vague, arguably doesn't formally constrain implementations, but I think it gets the essential idea across.  Certainly if you move an an atomic store to after an infinite loop, this sentence makes it clear that you're doing something we don't recommend.  If you hoist an atomic store of a constant value to before such an infinite loop, you have similar issues if the atomic variable may be modified by another thread.  On the other hand, hoisting an atomic store of a constant to before the loop, when there can be no simultaneous assignments to that variable seems fine, and this senetence doesn't appear to prohibit it.

I'd like to just delete the second senetnce:

"Implementations shall not move an atomic operation out of an unbounded loop."

Hans

> 
> > I think this sentence should just disappear.
> >
> > Does Clark have an opinion?
> 
> --
> Lawrence Crowl
> 


More information about the cpp-threads mailing list