Even std::atomic shouldn't be using volatile. You really need hardware memory barriers for atomic operations, except in cases where the basic load and store instructions provide sufficient synchronization guarantees. You also need compiler hooks to ensure that the more lax operations are respected, including ubiquitous acquire-release semantics.
Regarding volatile, IMHO unless you're writing a device driver, the only place you should use volatile is inside the implementation of std::atomic (or similar reinvented wheel).
Inter-thread communication
True - but for some reason MS decided that the Interlocked intrinsics (which act as runtime and compile-time memory fences) can only be passed volatile integers... :/Even std::atomic shouldn't be using volatile. You really need hardware memory barriers for atomic operations, except in cases where the basic load and store instructions provide sufficient synchronization guarantees. You also need compiler hooks to ensure that the more lax operations are respected, including ubiquitous acquire-release semantics.Regarding volatile, IMHO unless you're writing a device driver, the only place you should use volatile is inside the implementation of std::atomic (or similar reinvented wheel).
So you'll definitely see the keyword used on a Windows/MSVC implementation ;-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement