There are valid transformations to result into (0,1)/(1, 0)  The 2nd test obviously should be 1,1 always as x.f is practically ignored for the final outcome .<br>Recently there was discussion about that stuff.<br><br>Stanimir<br>
<br><div class="gmail_quote">On Sat, Feb 16, 2013 at 12:42 PM, Aleksey Shipilev <span dir="ltr"><<a href="mailto:aleksey.shipilev@oracle.com" target="_blank">aleksey.shipilev@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi there,<br>
<br>
I think it's time to have another argument about racy stuff! :)<br>
<br>
I want to assign the grading for some of the new<br>
java-concurrency-torture tests, and wanted to cross-check the reasoning.<br>
Given this test [1], what are the plausible outcomes?<br>
<br>
In pseudo-code:<br>
<br>
   class X {<br>
       int f;<br>
   }<br>
<br>
   X x = new X();<br>
<br>
          T1      |     T2<br>
   ---------------+---------------<br>
   if (x.f == 0)  | if (x.f == 0)<br>
       x.f = 1    |     x.f = 1<br>
   r1 = x.f       | r2 = x.f<br>
<br>
Is there a valid execution which yields (r1, r2) as (1, 0) or (0, 1)?<br>
(It appears there are valid executions under JMM, mostly because there<br>
is the data race on x.f; Jeremy had a post [2] about the similar issue<br>
before, and reaching to the same conclusion.)<br>
<br>
In that spirit,<br>
<br>
          T1        |      T2<br>
   -----------------+---------------<br>
   rX1 = x.f        | rX2 = x.f<br>
   if (rX1 == 0) {  | if (rX2 == 0) {<br>
       rX1 = 1      |     rX2 = 1<br>
       x.f = rX1    |     x.f = rX2<br>
   }                | }<br>
   r1 = rX1         | r2 = rX2<br>
<br>
...should always yield (r1, r2) = (1, 1).<br>
<br>
Thanks,<br>
Aleksey.<br>
<br>
[1]<br>
<a href="https://github.com/shipilev/java-concurrency-torture/blob/master/src/main/java/org/openjdk/concurrent/torture/tests/causality/lazyinit/plain/IntLazyTest.java" target="_blank">https://github.com/shipilev/java-concurrency-torture/blob/master/src/main/java/org/openjdk/concurrent/torture/tests/causality/lazyinit/plain/IntLazyTest.java</a><br>

[2] <a href="http://jeremymanson.blogspot.ru/2008/12/benign-data-races-in-java.html" target="_blank">http://jeremymanson.blogspot.ru/2008/12/benign-data-races-in-java.html</a><br>
_______________________________________________<br>
Concurrency-interest mailing list<br>
<a href="mailto:Concurrency-interest@cs.oswego.edu">Concurrency-interest@cs.oswego.edu</a><br>
<a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>
</blockquote></div><br>