On May 30, 2004, at 8:01 PM, Eliot Moss wrote:
>>>>>> "Sylvia" == Sylvia Else <syljmm32@cryogenic.net> writes:
>
> Sylvia> At 09:36 PM 30/05/2004 +1000, David Holmes wrote:
>>> Master thread fills in a buffer with work items and then starts a
>>> new worker
>>> thread to process the buffer. Worker threads executes:
>>>
>>> while (!buf.empty()) process(buf.take());
>>> workerFinished = true;
>>>
>>> where workerFinished is a volatile. Not quite as dramatic as firing
>>> the
>>> missiles, but same basic problem.
>
> Sylvia> All the actions performed by the loop happen-before the
> setting of
> Sylvia> workerFinished to true. Any thread that reads true from
> workerFinished must
> Sylvia> see the effects of all the actions that happen-before it,
> which includes
> Sylvia> the processing of the work in the buffer.
>
> Sylvia> I don't see the problem.
>
> I would agree. The interesting case in this context is where the loop
> does
> only thread-private work, perhaps only on local variables all of which
> have
> been allocated to registers .... EM
> -------------------------------
The standard rule has always been: If you can't be caught, it isn't
illegal.
In other words, the spec only describes what behaviors are allowed, not
the allowable ways in which to execute a program. If moving a write
ahead of
a non-terminating loop causes behavior that can't be explained any
other way,
it is illegal. But if the move doesn't cause behavior that is
prohibited, it is allowed.
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:08 EDT