From: David F. <fa...@kd...> - 2012-08-26 09:04:53
|
On Sunday 26 August 2012 01:30:43 David Faure wrote: > On Saturday 25 August 2012 22:43:58 Julian Seward wrote: > > Or maybe Qt really is racey > > Bingo :) OK, maybe not. Turns out the code runs as intended by the Qt developers. Marc Mutz said " The standard says it's racy, but the implementation of std::atomic::load(memory_order_acquire) won't look different. Simple reads and writes on x86 are already sequentially consistent. Think MESI cache coherency. Before a CPU writes to a memory location it needs to acquire exclusive ownership (E) of the cache line, the well-known "hardware mutex" on a cache line that produces False Sharing, too. This seems to hold for all architectures, cf. threads re: "Brief example ..." at http://www.decadent.org.uk/pipermail/cpp-threads/2008-December/thread.html " I attached a pure C++ testcase of the issue. Compile it with g++ testcase_atomic_ops_helgrind.cpp -o testcase_atomic_ops_helgrind -lpthread Thiago expects that helgrind can't autodetect this case and that helgrind- macros markup is needed in Qt, I'm fine with adding that if you guys agree -- after you show me how by modifying the attached example :-) Thanks. -- David Faure, fa...@kd..., http://www.davidfaure.fr Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5 |