[cpp-threads] memory model
Peter Dimov
pdimov at mmltd.net
Sat Apr 30 17:20:34 BST 2005
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.
More information about the cpp-threads
mailing list