Re: JavaMemoryModel: Semantics musings

From: Bill Pugh (pugh@cs.umd.edu)
Date: Tue Sep 25 2001 - 11:51:36 EDT


At 8:43 AM -0700 9/25/01, Cliff Click wrote:
>Bill Pugh wrote:
>
>>For example, consider:
>>
>>Initially, x = y = 0
>>
>>Thread 1:
>> if x != 0
>> y = 1
>>
>>Thread 2:
>> if y != 0
>> x = 1
>>
>>You must be careful to not allow this program to result in x = 1 and y = 1.
>>
>> Bill
>>-------------------------------
>>JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
>
>
>Why not? No, I'm not arguing that this should be allowed.
>I just want to hear your reasons why This Is Bad.
>
>Cliff

This program is correctly synchronized and therefore must execute
according to sequentially consistent semantics.

The basic definition of "correctly synchronized" is, for all
sequentially consistent executions of the program, an ordering
consistent exists between any two conflicting accesses to a variable.

There is only one sequentially consistent execution of this program,
in which each thread reads one variable and doesn't write any. So
there are no conflicting accesses, and the only execution allowed is
the sequentially consistent one.

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



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