[concurrency-interest] Fwd: Synchronization blocks, locks and reorderings

David Holmes dcholmes at optusnet.com.au
Wed Jan 23 18:36:16 EST 2008

> the somewhat more interesting scenario is this:
> time writer()        reader()
> ---- --------        --------
> t1                   lock l
> t2                   read y
> t3   write to x
> t4                   read x
> t5                   unlock l
> t6   lock l
> t7   write to y
> t8   unlock l
> Now what value of x will the reader read? According to the happens-before
stuff, value 0 will be > read from x despite that x has actually value 1

No, the absence of a happens-before ordering between the read of x at t4 and
write of x at t3 means that the read can return either 1 or 0

David Holmes

More information about the Concurrency-interest mailing list