[concurrency-interest] StampedLock

Boehm, Hans hans.boehm at hp.com
Mon Oct 15 23:21:19 EDT 2012


> From: Doug Lea
> 
> On 10/15/12 05:38, Romain Colle wrote:
> > Out of curiosity, do you mean that a call to Unsafe.getXXVolatile()
> does also
> > issue a LoadLoad barrier before its read?
> > Are there any reasons why this is the case, in addition to the post-
> read fence
> > of a regular volatile read?
> >
> 
> First, I'll echo Aleksey's plea for others to please not use this.
> The effects rely on an undocumented property of an internal JVM
> method that cannot even be formally spec'ed under the current JMM.
> We hope to have a better solution by JDK8 release.
> But for the curious: Because Unsafe.getXXVolatile does not know if
> its argument is even declared as a volatile, in the absence
> of magically powerful global analyses, it must conservatively
> prevent reorderings in either direction.
Doug -

I still don't understand the reasoning here.  Do you have an example where it matters whether the argument is declared as volatile?  I'm assuming the writing side must still use a corresponding (or volatile) access?

Thanks.

Hans

> And at least in
> OpenJDK hotspot, the implementation is aware of this fact and
> acts accordingly.
> 
> -Doug
> 
> 
> 
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest



More information about the Concurrency-interest mailing list