Community
cancel
Showing results for 
Search instead for 
Did you mean: 
softarts
Beginner
62 Views

atomic_read & set will act as memory barrier?

I remember someone said on WIN32, read/set volatile variable willimplicitlycarry a memory fence
but how is it on Linux?
no memory fence when read/set volatile variable?
0 Kudos
2 Replies
RafSchietekat
Black Belt
62 Views

Some compilers do that, but it is not and never will be standard behaviour, so don't write nonportable code that will fail with your most likely weapon of choice on Linux (g++). It is a compiler issue rather than an O.S. one, though: if I'm not mistaken, Intel's icc does this on Linux as well as on Windows (configurable?).
Dmitry_Vyukov
Valued Contributor I
62 Views

Quoting softarts
I remember someone said on WIN32, read/set volatile variable willimplicitlycarry a memory fence
but how is it on Linux?
no memory fence when read/set volatile variable?

Yes, gcc does not emit any memory fences for volatile reads/writes.

Reply