
19 Apr
2011
19 Apr
'11
4:07 a.m.
On Mon, 18 Apr 2011 18:42:22 +0600, Peter Dimov <pdimov@pdimov.com> wrote:
Artyom wrote:
Mutex acquisition and release is full memory barrier.
No, they are only guaranteed to have acquire and release semantics, respectively.
IIRC, acquire and full due to existence of try_lock.
Double-checked locking is broken even if they're full barriers though. That said, MSVC from some version onwards, I forget which,
From 8.0 (2005).
guarantees that volatile reads have acquire semantics and that volatile writes have release semantics, and under this assumption, the code is correct.