|
From: David F. <fa...@kd...> - 2012-12-05 21:48:56
|
On Wednesday 05 December 2012 16:39:47 Leif Walsh wrote: > The important synchronization point isn't the rdunlock, it's the wrlock. Well, you need two locks, for a happens-before relationship to be established. If you remove the rdlock/rdunlock completely (since it could basically be a no-op for a write operation anyway, as others pointed out earlier), then this will be more clear: this write might never become visible to the other thread. > I have a hard time believing that you can take a pthread write lock and then > look at a value some other processor wrote before you took the lock and not > get that value. You say "before", but this assumes a global ordering, which you don't get, when not using atomics or the proper locks. Each CPU can have a different notion of "before", without the correct synchronization primitives. I recommend reading "C++ Concurrency in action" by Anthony Williams, it taught me a lot on all this all works... definitely not a simple topic. -- David Faure, fa...@kd..., http://www.davidfaure.fr Working on KDE, in particular KDE Frameworks 5 |