On Apr 15, 2004, at 1:54 PM, Sylvia Else wrote:
> At 01:04 PM 15/04/2004 -0400, Bill Pugh wrote:
>> OK, here is a better, more concrete example.
>> Initially, x = 0
>> Thread 1:
>> r1 = readSocket1()
>> x = 1
>> Thread 2:
>> r2 = x
>> Note: readSocket1() will always return 0, unless
>> there is an earlier write of 1 to socket 2. Because these
>> are different sockets, their implementation might not
>> synchronize on any object in common.
>> Behavior in question: r1 == r2 == 1
> Does this really differ in essence from
> y not volatile, initially zero.
> Thread 1:
> r1 = (y == 1) ? 1 : 0;
> x = 1
> Thread 2
> r2 = x
> y = r2
> Behavior in question: r1 == r2 == 1
> A prescient write of x gives the behaviour in question. The external
> world behaves like non-volatile memory for the purposes of the memory
> model, and the example contains a data-race.
That is, essentially, the question.
If one external operation influences another, should the compiler
be required to conservatively treat that as a happens-before edge?
We don't know whether or not that causality chain in the real world
is correctly synchronized or not. In practice, some of them will be and
might not. Do we require the compiler to treat them conservatively, or
do we allow the compiler to assume that none of them are.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:04 EDT