[concurrency-interest] Racy lazy initialization: blush test
hans.boehm at hp.com
Wed Feb 20 18:28:54 EST 2013
I'm not sure what reordering you mean. It doesn't prevent the unexpected Dekker's result.
x = 1; r1 = y;
turns into memory_barrier; x = 1; r1 = y; memory_barrier;
which still allows the store and the load to be reordered.
From: Vitaly Davidovich [mailto:vitalyd at gmail.com]
Sent: Wednesday, February 20, 2013 3:07 PM
To: Dmitry Zaslavsky
Cc: concurrency-interest at cs.oswego.edu; Boehm, Hans; Timothy Chen
Subject: Re: [concurrency-interest] Racy lazy initialization: blush test
.net docs are clearly wrong. Thread.VolatileRead() invokes Thread.MemoryBarrier() after the read, thus preventing the reordering. In turn, Thread.VolatileWrite() issues MemoryBarrier() before the write, preventing reordering in the other direction. For some reason, they don't mention this important bit.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest