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

Justin Sampson jsampson at guidewire.com
Mon Sep 8 15:55:34 EDT 2014


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.

Is there a simple translation of those implementation details into
happens-before semantics (perhaps like I tried to describe), or is it
best to always think in terms of reordering?

Thanks,
Justin




More information about the Concurrency-interest mailing list