|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Valdis.Kletnieks
vt.edu
Date: Thu Jul 02 2009 - 21:04:26 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 03 Jul 2009 11:01:34 +1000, silky said:
> Basically, you just need to check if you should still be computing,
> and, at the end of computation, if your data is still "wanted".
All that does is push the race condition around. You *still* need to
do some sort of locking around the tail end. This is still racy:
if (update_still_wanted) {
stash_my_update();
update_still_wanted = false;
}
(Admittedly, not *as* racy, especially if you move the assignment first. But
that's still racy enough to actually *trip* on occasion - this sort of bug
is actually found at least once a month in the Linux kernel in some device
driver or other...)
And to be honest - the "best" way of fixing this is *really* going to depend on
the relative weight of locking (which can be *very* different if you have 2
threads on 2 CPUs, or 4096 threads on a 4096-core monster, or are split across
systems possibly in different countries connected by a high or maybe low speed
network), and how much effort goes into the computation, and how much
correctness matters - for some cases, you *really* want "first to finish"
(possibly due to side effects of the computation), others "any complete answer"
is good enough, etc..
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Exmh version 2.5 07/13/2001
iD8DBQFKTWcqcC3lWbTT17ARAhFFAJ9WiTY9zc/A1eDsI6Ij35XjFei0NACdFoQ9
2Ez8nzdUP23u7GgPqXP4xEU=
=Qbda
-----END PGP SIGNATURE-----
_______________________________________________
Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]