[concurrency-interest] AtomicXXX.lazySet and happens-before reasoning

Ruslan Cheremin cheremin at gmail.com
Fri Oct 7 09:24:20 EDT 2011


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.

Or the difference is what volatile store must have both LoadStore and
StoreStore barrier before?


2011/9/30 Doug Lea <dl at cs.oswego.edu>:
> On 09/30/11 11:18, Ruslan Cheremin wrote:
>>
>> I still do not catch it. As far as I see we have 2 question about the
>> code:
>
> These are still good questions, because they have no direct answers in JLS.
> But because they don't, you need to use other existing information to
> decode.
> One more try:
>
>>
>> 1) Will lazySet write actually happens in some finite time?
>
> The most you can say from the spec is that it will be written
> no later than at the point that the process must write anything
> else in the Synchronization Order, if such a point exists.
> However, independently of the spec, we know that so long as
> any process makes progress,  only a finite number of writes
> can be delayed. So, yes.
>
>> 2) If it happens (== we see spin-wait loop finished) -- does it mean,
>>     what all writes preceeding lazySet are also done, commited, _and
>> visible_
>> to thread 2,
>>     which finished spin-wait loop?
>
> Yes, although technically, you cannot show this by reference
> to the Synchronization Order in the current JLS. A fully
> integrated account would be along the lines of that for
> the (non-existent) order{Writes,Accesses} Fences in
> http://gee.cs.oswego.edu/dl/jsr166/dist/docs/java/util/concurrent/atomic/Fences.html
>
> -Doug
>
>



More information about the Concurrency-interest mailing list