On Mar 22, 2004, at 8:59 AM, Vijay Saraswat wrote:
> Folks --
>
> I was working through some theorems on volatiles and noticed the 
> following issue.
>
> Is the following program properly synchronized (i.e. has no race 
> conditions under SC executions)?
>
> -----------------------------------------
> Initially: x=0, x volatile
>
> Thread 1
>  x=1
>
> Thread 2
>  x=2
>  r1=x
>  r2=x
>  r3=x
> Observatiom: r1=1,r2=2,r3=1
> ----------------------------------------
>
> Weak semantics: Yes.
> Strong semantics: Agrees with weak
I don't know why you believe this is allowed by the semantics.
At a minimum, all interpretations agree on the following:
        * for each volatile, there is a total order over all accesses to that 
volatile
        * for each thread, the program order for accesses to a volatile are in 
agreement
                with the total order over accesses to that volatile
        * each volatile read sees the most recent write to that volatile in 
the total
                order on that volatile.
So r1 = 1, r2 = 2 and r3 = 1 is impossible.
Bill
-------------------------------
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