volatile and consistency
Prune, do you intend to write your own synchronization primitives from ground up or why are you worrying about all this stuff?
Quote:Original post by PruneYou'd have to check the assembly language ;)
One interesting thing I noticed is that at least for x86 and x86-64, while MSVC has separate _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier, GCC has for all three macros that in the end expand to the same thing, __asm__ __volatile__("" ::: "memory"), and Intel's compiler for both Windows and Linux uses __memory_barrier. Why are they the same for these compilers? I know that older Intel x86 chips did not do write reordering, but I thought x86-64 does.
IIRC, x86 only has one instruction (or instruction modifier) to cause a memory barrier, and it acts as a full fence (ReadWrite). x64 might be the same in only having a full-fence instruction.
Other architectures do have different fence instructions though, which is why MSVC gives you the 3 different macros.
Quote:Original post by Red Ant
Prune, do you intend to write your own synchronization primitives from ground up or why are you worrying about all this stuff?
Because I am using it. When possible, I use alternatives to locks, such as lock-free, message passing, double buffering of shared data, etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement