[cpp-threads] memory model

Doug Lea dl at cs.oswego.edu
Sat Apr 30 17:45:32 BST 2005


Peter Dimov wrote:
> Peter Dimov wrote:
> 
>>Doug Lea wrote:
>>
>>>>Compilers convert between control and data dependence all the
>>>>time, by converting conditionals to predicated instructions.
>>>
>>>Further, in case anyone cares, if you explicitly tie semantics
>>>to control or data dependencies, it is very unlikely that you'll ever
>>>be able to coherently formalize the model. The POPL paper on the JMM
>>>discusses this a bit. (Search "manson pugh adve java memory model"
>>>at http://scholar.google.com/ to find a copy.)
>>
>>http://rsim.cs.uiuc.edu/Pubs/popl05.pdf
> 
> 
> I've read section 4.1 and I don't see the problem, but I may be missing 
> something. The semantics of the example in figure 5 are undefined due to 
> data races. If I "define" it by making the loads (and the store in thread 2) 
> atomic, the compiler is no longer allowed to optimize out a load or skip the 
> r1 == r2 test. 
> 
> 

I'll prod Bill to answer. But in the mean time you might
try the same reasoning with the collection of examples at
http://www.cs.umd.edu/~pugh/java/memoryModel/CausalityTestCases.html
It's conceivable that none of them apply in C++, but  I sorta doubt it.


-Doug




More information about the cpp-threads mailing list