JavaMemoryModel: Question about volatiles

From: Carr, Wayne (wayne.carr@intel.com)
Date: Tue Mar 23 2004 - 12:52:08 EST


Sorry if I'm covering old ground. I'm passing this question on for
someone else.

Is it the case that "two volatiles writes by two different threads to
two different variables must be seen in the same order by all other
threads" or that justifications must "require a total ordering of
volatile reads because the synchronization order must be total"?

Are the following allowed by the new model?

Use case 1
X and y are both volatile and initialized to 0.

Thread 1
x = 1
r1 = x
r2 = y

Thread 2
y = 1
r3 = y
r4 = x

Behavior in question: r1 = 1, r3 = 1, r2 = 0, r4 = 0

Use case 2:
v1 and v2 are volatile variables initialized to 0:

Thread 1
v1=1

Thread 2
v2=1

Thread 3
r1=v1
r2=v2

Thread 4
r3=v2
r4=v1

Behavior in question: r1 = r3 = 1; r2 = r4 = 0

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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