Boost logo

Boost :

From: Cory Nelson (phrosty_at_[hidden])
Date: 2008-08-21 21:42:33


On Thu, Aug 21, 2008 at 5:23 PM, Simon Thornington
<simon.thornington_at_[hidden]> wrote:
> Hi folks,
>
> Quick question about the use of _ReadWriteBarrier (Win32 MSVC):
>
> According to http://msdn.microsoft.com/en-us/library/ms684208(VS.85).aspx ,
> this compiler intrinsic doesn't generate any memory fencing instructions at
> all, it's strictly a compiler optimization barrier. I was wondering if
> someone had any documentation to contradict this, or if boost is relying on
> the new volatile semantics in VC2005 to ensure the fence?
>
> It sure looks like it's being used as if it were a real memory fence, but I
> am not sure that's the case. I'm not an expert though.

Correct, it only prevents the compiler from reordering - it doesn't
emit any fence instruction itself. You must use
_mm_lfence/_mm_sfence/_mm_mfence if you want that. It just happens
that for many things, fence instructions aren't needed on current x86
hardware.

-- 
Cory Nelson

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk