[concurrency-interest] LoadStore and StoreStore , are both are required before lazySet and volatile write

Vitaly Davidovich vitalyd at gmail.com
Mon Sep 22 16:50:48 EDT 2014


As for Aleksey's point, I don't quite follow why initializing a final field
off some racy field *requires* a LoadStore.  Eliminating StoreStore may
happen, I guess, if something like escape analysis removes the allocation
of an object with final field and scalar replaces it.  But again, unsure
why another racy memory location requires LoadStore (unless this is talking
about same thing as Hans in different terms).

Sent from my phone
On Sep 22, 2014 3:46 PM, "vikas" <vikas.vksingh at gmail.com> wrote:

>
> I was reading a article from Hans and he argues that LoadStore is also
> needed before lazySet or a final variable write (i assume then also before
> volatile write).
>
> He demonstrated a particular race condition which i couldn't understand
> (link below).
>
> http://www.hboehm.info/c++mm/no_write_fences.html see *Recipient writes to
> object*.
>
> Its very counter intuitive how  * store of x.a = 43* can be done past the
> StoreStore barrier in thread 1.
> *
> x.a = 0; x.a++;
> x_init.store_write_release(true);
>
> and the code that uses x in thread 2 updates it, with e.g.
>
> if (x_init.load_acquire())
>     x.a = 42;*
>
>
> Similar argument here http://shipilev.net/blog/2014/all-fields-are-final/
>
> Copying Shiplev here :
>
> /JSR 133 Cookbook only requires StoreStore, but might also require
> LoadStore
> barriers. This covers for a corner case when the final field is getting
> initialized off some other field which experiences a racy update. *This
> corner case can be enabled by runtime optimization which figures out the
> final store is not needed, puts the value in the local variable, and hence
> breaks out of ordering guarantees of StoreStore alone*/
>
> How runtime can figure out that final Store is not needed, also if load is
> getting passed/reorder the StoreStore Barrier then Store to local Variable
> also is getting passed/reorder with the storeStore barrier, *This is the
> part i don't quite understand , why store to local variable can reorder
> with
> StoreStore Barrier. *
>
> It would be very help full if anybody can explain in more details what is
> the race condition they both are mentioning by some simple example.
>
>
>
>
> --
> View this message in context:
> http://jsr166-concurrency.10961.n7.nabble.com/LoadStore-and-StoreStore-are-both-are-required-before-lazySet-and-volatile-write-tp11291.html
> Sent from the JSR166 Concurrency mailing list archive at Nabble.com.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140922/80a24b4e/attachment.html>


More information about the Concurrency-interest mailing list