After all only JVM implementers must understand all of JLSv3 and JVMSv2.
So this article only teaches you the necessary parts of JMM that are needed for a programmer to make safe multi-threaded code. Here is the URL:
JAVA MEMORY MODEL FROM A PROGRAMER’S POINT-OF-VIEW
However I do have a question regarding the "Causality Loop" mentioned in the article and JMM: what microprocesses are supporting it?
I actually sent an email request to professor Sarita V. Adve because his paper "Memory Models: A Case for Rethinking Parallel Languages and Hardware" mentioned the same thing in Figure 4's case (a).
Here is my question:
My understanding is when core 1 speculatively executes "Y = 1", it puts the new value in a temporary store (core 2 will not see it) until it detects the predicate in the "if" statement becomes true; I have similar argument for core 2. So neither core 1 nor core 2 will make its speculative write operation visible to the other core.
Today I got a response from Profession Adve regarding the "Causality Loop". Here is the email:
ReplyDeleteDear Yong,
There are no processors today that do this (otherwise, we would have trouble with the C++ and Java memory models prohibiting this). The goal here is to ensure (1) future processors never allow this outcome, and (2) to make it part of the formal semantics so programmers can rely on it. The data-race-free model clearly prohibits this outcome.
Sarita