[concurrency-interest] Ordering Question

Vitaly Davidovich vitalyd at gmail.com
Tue Jul 19 22:30:59 EDT 2016


Yes to both of your questions.  As you suspect, you need a storeLoad
between 1) and 2), and that's what a volatile write would give you.

On Tuesday, July 19, 2016, Michael Barker <mikeb01 at gmail.com> wrote:

> Hi,
>
> I have a question around ordering of events.
>
> Given, threads (T1, T2), and variables (A, B, X, Y) where X and Y are
> shared on the heap and visible to T1 and T2.
>
> Initially:
>
> X = 0
> Y = 0;
>
> T1:
> 1) X = 1 (lazySet/putOrdered)
> 2) B = Y (volatile read)
>
> T2
> 3) Y = 1 (compare and set)
> 4) A = X (volatile read)
>
> Is it possible to get a final state of A = 1 and B = 0?
>
> My current suspicion is that it is, due to 1) and 2) being reordered.  If
> so, can the final state of A=1, B=0 be prevented by strengthening 1) to be
> a volatile store?
>
> Regards,
> Michael Barker.
>


-- 
Sent from my phone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160719/9a3437ca/attachment.html>


More information about the Concurrency-interest mailing list