atomic_read & set will act as memory barrier?

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?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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?).

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.

All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
http://www.1024cores.net

Leave a Comment

Please sign in to add a comment. Not a member? Join today