Discussions on Java memory model

Miles Sabin msabin@cromwellmedia.co.uk
Tue Jun 13 04:14:00 GMT 2000


Jerry Kramskoy wrote,
> Jeff Sturm wrote,
> > o no existing VM correctly implements the semantics 
> > required by the JLS
>
> which VMs have you *tried* to make this statement? What 
> specific tests do you have to show this?

>From the slides from Doug and Bill's JavaOne session the 
following JVMs have been shown to fail on a range of volatile 
issues: code motion; sequential consistency; atomic 
long+double:

  Sun Solaris Sparc 1.2.2 EVM
  Sun Solaris Sparc 1.3 beta Hotspot client and server
  Sun Windows 1.3 Hotspot client and server
  IBM Windows 1.1.8

In all likelihood many others fail too.

You can find the whole set of slides at,

  http://www.cs.umd.edu/~pugh/java/memoryModel/BOF-6up.pdf

There's a lot more info, including links to the JMM mailing 
list and archive, and a draft of a proposed revised memory 
model at,

  http://www.cs.umd.edu/~pugh/java/memoryModel/

Bill Pugh has put together a set of test cases for the volatile
semantics which you'll find there too.

> Moreover, this is lot more of an issue for compiled bytecodes
> (JIT, whatever ...) than for the interpreter.

I don't see why this should be less of an issue for an
interpreter. It still has to make sure that memory reads and 
writes happen at the right time and in the right order, and
that's not as easy as it might seem given that some 
architectures allow writes to be reordered at the CPU/bus- 
interconnect level.

It's also worth bearing in mind that these aren't just issues
for SMP machines ... some of the problems show up on 
uniprocessors too because you don't necessarily have 
particularly strong guarantees about write ordering.

This is a pretty big deal, because there's a range of 
concurrent programming idioms (double-check, array copy on 
write) that simply can't be guaranteed to work in the way you'd 
expect under the current JMM.

Cheers,


Miles

-- 
Miles Sabin                       Cromwell Media
Internet Systems Architect        5/6 Glenthorne Mews
+44 (0)20 8817 4030               London, W6 0LJ, England
msabin@cromwellmedia.com          http://www.cromwellmedia.com/





More information about the Java mailing list