
18 Apr
2011
18 Apr
'11
12:42 p.m.
Artyom wrote:
Mutex acquisition and release is full memory barrier.
No, they are only guaranteed to have acquire and release semantics, respectively. Double-checked locking is broken even if they're full barriers though. That said, MSVC from some version onwards, I forget which, guarantees that volatile reads have acquire semantics and that volatile writes have release semantics, and under this assumption, the code is correct.