Jeremy,
Returning to my original question, I was not clear but I am more
interested in the use of volatiles (such as are used in the proposed
java.util.concurrent.ConcurrentHashMap) to ensure visibility
of preceding writes:
Consider:
Object o
o.n is non-volatile (primitive or Object)
Object p
p.v is volatile (not long or double, maybe an Object or <= 32 bit
primitive)
Thread 1 Thread 2
o.n = a;
p.v = b;
c = p.v;
d = o.n;
For which 1.4 JVMs can we be certain that a == d?
Does anyone have an existing test cases for the general issue above,
which is that of the "visibility" aspect of volatile access?
> -----Original Message-----
> From: owner-javamemorymodel@cs.umd.edu
> [mailto:owner-javamemorymodel@cs.umd.edu]On Behalf Of Jeremy Manson
> Sent: Wednesday, 11 February 2004 9:45 a.m.
> To: Juergen Kreileder
> Cc: Doug Lea; Evan Ireland; javamemorymodel@cs.umd.edu
> Subject: Re: JavaMemoryModel: On which JDK 1.4 VMs is "volatile access"
> already compliant with the proposed JDK 1.5 JMM?
>
>
> From the "better late than never" files:
>
>
> > > I don't think there is a list anwhere (feel free to post one :-),
> > > but when in doubt, you can run the "volatile spec compiance tests"
> > > that Bill has at http://www.cs.umd.edu/~pugh/java/memoryModel/
> > > Direct link:
> > > http://www.cs.umd.edu/~pugh/java/memoryModel/Volatiles.tar
> >
> > You might want to change the AtomicLong test a bit. HotSpot 1.4.2
> > passes the test with the original code but with this change
> >
> > --- AtomicLong.java.orig 2004-01-06 20:05:14.000000000 +0100
> > +++ AtomicLong.java 2004-01-06 20:05:01.000000000 +0100
> > @@ -33,6 +33,9 @@
> > public class AtomicLong extends Thread {
> > static int w;
> > static volatile long v;
> > +
> > + static Object o;
> > +
> > static int count = 10000000;
> >
> > long key;
> >
> > I see some violations (at least on x86 and AMD64).
> >
>
> This seems to occur because the long isn't aligned to a 64-bit boundary.
> We don't have a foolproof way of reproducing this, but we changed
> the test
> so it works on 2 long volatiles, with a 32 bit int declared
> between them.
> You can look at the new one at the address quoted above.
>
> Worth checking into, for any VM writers out there.
>
> Jeremy
> -------------------------------
> JavaMemoryModel mailing list -
> http://www.cs.umd.edu/~pugh/java/memoryModel
>
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:57 EDT