I am pretty conservative in selecting the tools I use for my projects, thus sticking with good old C++. To be really productive on C++ - using of some sort of smart pointers is a must. And to make things a bit more complicated there are multi-core machines, that run different OS'es and the project has to build correctly for 32 and 64 bits. Here we got things to protect...Using atomic barriers in GCC (supported since v.4.1.0 or so) may allow significant performance gain in comparison to pthread' mutexes. Though I've not done any benchmarks of this matter on Linux (yet), the gain on Windows while migrating from critical sections to interlocked exchange was pretty significant.The GCC built-in functions for atomic memory access work wonders:
Defining the compiler's option:
solved the issue (i486 worked here Ok too).