[concurrency-interest] Ordering Question

Michael Barker mikeb01 at gmail.com
Wed Jul 20 02:42:01 EDT 2016


Hi Justin,

Good spot, I did mean A = 0, B= 0.

Mike.

On 20 July 2016 at 17:19, Justin Sampson <jsampson at guidewire.com> wrote:

> Hi Michael,
>
>
>
> I'm confused by the question. If T2 runs completely after T1, you get A=1
> and B=0 without any reordering whatsoever. The only outcome that is
> impossible without reordering is A=0 and B=0. Is that the case you're
> asking about?
>
>
>
> Cheers,
>
> Justin
>
>
>
>
>
> *From:* Concurrency-interest [mailto:
> concurrency-interest-bounces at cs.oswego.edu] *On Behalf Of *Michael Barker
> *Sent:* Tuesday, July 19, 2016 7:11 PM
> *To:* concurrency-interest
> *Subject:* [concurrency-interest] Ordering Question
>
>
>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160720/30b3c316/attachment.html>


More information about the Concurrency-interest mailing list