[concurrency-interest] Synchronization question

Brian Goetz brian at quiotix.com
Wed Jun 28 11:52:32 EDT 2006


> I agree w/ the spirit of Holger's questions 100% because it deals w/
> what is happening on the ground now, not what is theoritically
> supposed to happen.  Since I use Sun JVMs almost exclusively I would
> love to hear back from Sun engineers about what is going on under the
> covers today in regards to this discussion.

To some degree, Holger's question is analogous to when your kid says 
"but I ran with the scissors every day last week and I didn't put my eye 
out!"  Just because one can engage in risky behavior "a lot of times" 
and not suffer negative consequences doesn't mean that you are not 
asking for trouble.

Most popular CPUs (Intel, Sparc) offer a stronger memory model than 
required by the JMM.  That means that _some_ of the bad things that can 
happen in broken code won't actually happen on these CPUs.  Similarly, 
_some_ of the bad things that can happen don't on single-CPU systems.

I've taken the position of deliberately not enumerating or explaining 
them, because I know that at some point, someone will incorrectly say 
(probably just leaving off the "In X and Y cases" qualification) in an 
embarassingly public forum "Brian says its OK to do Z" based on that. 
Besides, any advice along those lines would be dangerously CPU- and 
JVM-specific.

As to the duration of the visibility race -- I've seen evidence that it 
can be at least minutes on real systems.  (That's basically forever, 
isn't it?)  But the JMM does allow it to be forever, and Joe's example 
of a compiler optimization shows one when it will be forever because the 
compiler has hoisted the fetch out of the loop.  (This one really 
happens too.)



More information about the Concurrency-interest mailing list