OK, we should discuss the issue of how the memory model
interacts with the environment and non-determinism.
Consider the following:
initially, x = y = 0
Thread 1:
r1 = readDevice()
x = r1
r2 = y
x = r2
Thread 2:
r3 = x
y = r3
writeToDevice(r3)
Behavior in question: r1 == 0, r2 == r3 == 1
OK, if readDevice is a quantum random number generate that returns
either 0 or 1, I don't think we want to allow this behavior.
In other words, no bait-and-switch with non-deterministic input.
However, if readDevice returns 1 unless 1 has been written to
the device, perhaps we do want to allow it, because then
it is semantically equivalent to:
initially, x = y = z = 0
Thread 1:
r1 = 1-z
x = r1
r2 = y
x = r2
Thread 2:
r3 = x
y = r3
z = r3
Of course, to get this behavior, we'd probably have to allow the JVM to
reason about things outside of the world of Java bytecode.
For example, you have a Java program that is reading from a file
or socket. Could a system that analyzed how that data was generated
use the information that all the bytes being read were
guaranteed to be in the range 0-9?
We've got a couple of ideas on how to handle this. But the first
thing to figure out is whether or not we do need to allow JVMs
to reason about things occurring outside of the bytecode universe.
Things would be simpler if we did not (and we wouldn't have to allow
r1 == 0, r2 == r3 == 1 in the example where readDevice returns 1
unless 1 has been written to the device).
What do people think?
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:03 EDT