[concurrency-interest] Happens Before guarantee in case of unsafe.putOrderedObject and corresponding nomal read of a variable

Paul Sandoz paul.sandoz at oracle.com
Mon Sep 8 04:48:19 EDT 2014


On Sep 5, 2014, at 8:02 PM, Andrew Haley <aph at redhat.com> wrote:

> On 09/05/2014 06:49 PM, Vitaly Davidovich wrote:
>> lazySet orders preceding writes with the write being done as part of
>> lazySet, but does not guarantee that this write is globally visible before
>> next instruction is executed by the writing CPU.  In practical terms, on
>> x86/64, this compiles into a plain mov instruction with a compiler barrier
>> prevent prior stores from moving past the lazy one.  If this store were
>> done via volatile write or AtomicXXX.set(), then a cpu serializing
>> instruction would be added after the store (e.g. lock add $0, %rsp).
>> 
>> I'm guessing on non-TSO platforms lazySet implies a weaker release fence
>> instruction is emitted, but I don't know the details.
> 
> Okay, so it's simply a store release without a following barrier.  I
> guess all of this will be clarified as part of the JMM work.
> 

Yes. The different names also threw me off the scent for a while (need to look at the code).

Also, it does not help that we got the docs wrong on Unsafe.storeFence :-)

  https://bugs.openjdk.java.net/browse/JDK-8038978

Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140908/3ab8af57/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140908/3ab8af57/attachment.bin>


More information about the Concurrency-interest mailing list