RE: JavaMemoryModel: Fairness Guarantees in the Memory Model?

From: Bill Pugh (pugh@cs.umd.edu)
Date: Mon Oct 22 2001 - 17:58:32 EDT


>
>In terms of my earlier email on modelling semantics (to which no one
>ever responded), the semantics of thread 2 require repeated memory
>operations (reads) of Volatile1 until a read returns a value not
>equal to 1. The system is free to avoid those reads when it can
>determine that doing so will not violate the semantics of the
>overall program. For example, a compiler that knew it was acting in
>the context of a non-preemptive scheduler would be free to hoist the
>read in Thread 2. But a compiler that is acting without context
>(such as a java to bytecode compiler) is not free to make that
>transformation.

Java should only have one semantics, not two (a preemptively
scheduled semantics and a non-preemptively scheduled semantics).

If we decide that reads of volatiles can be hoisted out of infinite
loops, then we should allow them to be hoisted out of infinite loops
on all platforms, not just Oracle's. And if we allow Oracle's
compiler to do it, then any bytecode transformation that does it
should be legal for all Java platforms.

I understand that the issue is a little bigger than I had spoken of
earlier; putting fairness into Java semantics will prohibit any pure
non-preemptive JVM (e.g., a VM in which "while (true);" halts the
entire VM).

I am willing to go either way on this. Allowing "while (true);" to
halt the entire VM is rather unpleasant, but it may be too difficult
to force all VM implementors to use some form of preemption.

        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