On 8 March 2014 18:34, Niall Douglas wrote:
On 8 Mar 2014 at 18:29, Jonathan Wakely wrote:
The new version is present in both Clang and GCC, and if you use those compilers' built-in atomic operations (either the older __sync_xxxx or newer __atomic_xxx intrinsics) then tsan should understand them and need no instrumentation.
Can tsan understand when an atomic is being used for serialisation? I can see a CAS lock being heuristically determined, but some of the fancier semaphore based techniques surely need some explicit markup.
I believe it can, because it knows that an atomic store with memory_order_release in one thread and a load with memory_order_acquire in another thread implies an ordering, and so can tell there is no race. I don't think tsan v2 even supports any explicit markup, so you couldn't use it if you wanted to.