[cpp-threads] Memory model question

Boehm, Hans hans.boehm at hp.com
Fri Aug 26 19:41:56 BST 2005


I agree with Alexander.

Presumably you are asking the question, because the pthread standard
uses the word "modify", and it's not clear that x is being modified
here?

I have no idea whether that was intentional or not.  Dave - Do you know?

After thinking about it for a bit, I think that not calling this a data
race would disable some compiler optimizations, but perhaps not major
ones.
("Speculative" code hoisting, which hoists an assignment out of a switch
statement, even though a different assignment to the same variable
occurs
in one of the branches, seems to be one example.)
It does seem to make compiler correctness arguments much harder.
I can't convince myself that it matters much to the programmer, one way
or the other.

Hans
> -----Original Message-----
> From: 
> Cpp-threads_decadentplace.org.uk-bounces at decadentplace.org.uk 
> [mailto:Cpp-threads_decadentplace.org.uk-bounces at decadentplace
> .org.uk] On Behalf Of Alexander Terekhov
> Sent: Friday, August 26, 2005 4:43 AM
> To: cpp-threads at decadentplace.org.uk
> Subject: Re: [cpp-threads] Memory model question
> 
> 
> On 8/26/05, Peter Dimov <pdimov at mmltd.net> wrote:
> > In your opinion, does the following example contain a data race?
> > 
> > // initially x == 0
> > 
> > T1:
> > 
> > x = 0;
> > 
> > T2:
> > 
> > r1 = x;
> 
> Yes.
> 
> regards,
> alexander.
> 
> -- 
> cpp-threads mailing list
> cpp-threads at decadentplace.org.uk 
> http://decadentplace.org.uk/mailman/listinfo/cpp-threads_decad
entplace.org.uk




More information about the cpp-threads mailing list