RE: JavaMemoryModel: Semantics musings

From: Bill Pugh (pugh@cs.umd.edu)
Date: Wed Sep 26 2001 - 07:11:52 EDT


At 11:36 AM +1000 9/26/01, David Holmes wrote:
>
> > A single threaded program is always correctly synchronized.
>>
>> Two threads that run in parallel but touch no data in common are
>> correctly synchronized, no matter what synchronization they contain.
>
>Sure. But here's the example that was being discussed:
>
>>>For example, consider:
>>>
>>>Initially, x = y = 0
>>>
>>>Thread 1:
>>> if x != 0
>>> y = 1
>>>
>>>Thread 2:
>>> if y != 0
>>> x = 1
>
>I see two threads, each accessing data modified by the other. That's a data
>race. ;-)

If executed in a sequentially consistent manner, there is no data
race, because nether thread will see a non-zero value and thus nether
thread performs a write.

If there is no data race when the program is executed in a
sequentially consistent fashion, then there is no data race and the
program behaves as though it was executed with sequentially
consistent semantics.

        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