Re: JavaMemoryModel: Dropping coherence is more complicated thanwe thought

From: Adalberto Castelo (
Date: Tue Nov 09 1999 - 22:15:44 EST

Doug Lea wrote:
> Back to:
> int v;
> int getValue() {
> if (v == 0)
> v = computeValue();
> return v;
> }
> Is getValue allowed by LC to return zero even in some purely single threaded
> context? The possibility of mirrored memory worlds ...

In LC, if the if block is not going to be executed (the case of v!=0),
and in a single threaded context, both reads have to return the same
value. If v was initialized with zero, then, under LC, getValue would
have to return the result of computeValue(). For programs with no data
races, LC == SC.

w0: int v = something;
r0: if (v==0)
w1: v = computeValue;
r1: return v;

if computeValue is called, then V(r1)={w1};
else, V(r1)={w0}.

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:22 EDT