JavaMemoryModel: Test case 15

From: Vijay Saraswat (vijay@saraswat.org)
Date: Sun Feb 15 2004 - 05:20:09 EST


Isnt there a data race between the write in Thread 3 and the the read in
Thread 1, so that the program is not correctly synchronized?

Best,
Vijay
------------------------------------------------------------------------------
<H2>Causality test case 15</H2><PRE>Initially, a = b = x = y = 0, x and
y are volatile

Thread 1:
r0 = x
if (r0 == 1)
  r1 = a
else
  r1 = 0
if (r1 == 0)
  y = 1
else
  b = 1

Thread 2:
do {
  r2 = y
  r3 = b
  } while (r2 + r3 == 0);
a = 1;

Thread 3:
x = 1

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

Decision: Disallowed. In all sequentially consistent executions, r1 = 0 and
    the program is correctly synchronized. Since the program is correctly
    synchronized in all SC executions, no non-sc behaviors are allowed.

</PRE>
<HR>

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



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