>Initially x == y == v == v2 == 0, x and y non-volatile, v and v2 volatile
>Then r1==r3==1 becomes possible with the strong and weak interpretations.
How? v=0 has a release fence, and r2=v has an acquire fence, ending up
as a full fence. Same for v2=0; r4=v2;
Certainly you cannot perform r2=v until v=0 has been performed.
>> I also believe volatile variables preventing compile time
>> code motion is
>> a good idea, for the same reason.
>Again, it is a myth that volatile variables prevent compile time code
>motion. They prevent it some of the time but not all of the time. To figure
>out when they do or do not prevent it, we have to reason about the
Hmm, so you say we can re-order the volatiles, if we know they do not
v = new Integer(0); // v is volatile Integer
String x = v2; // v2 is volatile String; v and v2 do not alias
// can loading v2 happen prior to storing to v?
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:00 EDT