I had a thought about the Java Memory Model on a cluster. Suppose one
thread accesses a variable. Then it will have that variable in its local
memory. Then, suppose another thread on the *same node* wants to access
that same variable. It would be nice if it could use the same copy as the
first thread, because it has access to the same local memory (being on the
same node).
However, you can't let this happen. Suppose A1 and A2 are two threads on
one node, and B is a thread on another node. You could get a trace like
this:
A1 A2 B
a(x)1 u(x)1 u(x)0
a(y)1 u(y)0 u(y)1
(where "a" is "assign" and "u" is "use").
This is illegal with the JMM because the main memory is (I think) supposed
to serialize all writes, and there is no sequence that could produce these
values.
The full (erroneous) trace from the cluster would look like this:
A1 A2 B
a(x)1
u(x)1 <--- This is the problem
u(y)0
a(y)1
s(y)1
w(y)1
r(x)0
l(x)0
u(x)0
r(y)1
l(y)1
u(y)1
Notice that A2 got the value of x from A1 before it had been written to
main memory, thanks to the fact that it has access to A1's local memory.
Is this something that has been discussed before? Is there an efficient
way to implement the proper semantics on a cluster?
-- Patrick Doyle doylep@ecf.toronto.edu------------------------------- JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:25 EDT