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

Andrew Haley aph at redhat.com
Fri Sep 5 14:02:12 EDT 2014

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.

Thanks all,

More information about the Concurrency-interest mailing list