[concurrency-interest] AtomicXXX.lazySet and happens-before reasoning
dl at cs.oswego.edu
Fri Oct 7 09:45:49 EDT 2011
On 10/07/11 09:24, Ruslan Cheremin wrote:
> After some thinking and reading I still do not understand some issues...
> As far, as I can see from description of lazySet, it is just ordinary
> store with StoreStore barrier just before it. But if it is so, what is
> the difference between it and ordinary volatile write? In JSR-133
> implementation cookbook http://gee.cs.oswego.edu/dl/jmm/cookbook.html
> you've shown volatile store implementation as store having exactly
> StoreStore barrier before it.
Plus, for a volatile, a StoreLoad fence between the write and any read.
Almost always, the only good choice for where to place it is
immediately after the write. In addition to disabling
more optimizations, StoreLoad fences translate to
instructions that are not cheap on any platform, although they are
currently a lot cheaper than they were about 5 years ago on most
platforms. But in any case, if you have a situation that is
guaranteed not to need one to preserve correctness, it is always
faster not to require one.
More information about the Concurrency-interest