[concurrency-interest] AtomicXXX.lazySet and happens-before reasoning
dl at cs.oswego.edu
Fri Sep 30 13:03:41 EDT 2011
On 09/30/11 11:45, Nathan Reynolds wrote:
> ... lazySet() ...
> won't be reordered with respect to preceding stores.
The important part of the spec is to prohibit reordering
wrt previous writes. Sorry again for the terrible method name.
For those familiar with new C++ spec, it is the same as
store(memory_order_release). Because all of these modes were
spec'ed at the same time, the C++ specs have a much better
integration with the data-race-free parts of the memory model,
so it is in some ways a better guide, modulo all the ways
Java and C++ memory models differ wrt thin-air reads.
> weakCompareAndSet() appear to simply defer to compareAndSet() in the JDK code.
In the base implementations on x86 and sparc, it is the same.
But others can specialize it, and at least Azul does so.
In particular, a weakCompareAndset can be mapped to LL/SC
on ARM and POWER or other machines that have it but not CAS.
We don't use weakCompareAndSet much inside j.u.c. because we
normally need the fully-fenced version anyway.
More information about the Concurrency-interest