volatile and consistency

Started by
11 comments, last by Prune 13 years, 4 months ago
Prune, do you intend to write your own synchronization primitives from ground up or why are you worrying about all this stuff?
Advertisement
Quote:Original post by Prune
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.
You'd have to check the assembly language ;)
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.
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)

This topic is closed to new replies.

Advertisement