From ge at linuxbox.org Fri Jul 3 00:25:23 2009 From: ge at linuxbox.org (Gadi Evron) Date: Fri, 03 Jul 2009 03:25:23 +0300 Subject: [Code-Crunchers] a simple race condition and how you'd solve it Message-ID: <4A4D4FF3.8070101@linuxbox.org> A friend recently demonstrated on his blog a simple race condition he encountered. He also challenged folks to solve the problem. http://www.algorithm.co.il/blogs/index.php/programming/a-simple-race-condition/ There's an interesting discussion in the comments which is worth a quick read. Also, maybe someone here will come up with a cuter idea? Gadi. -- Gadi Evron, ge at linuxbox.org. Blog: http://gevron.livejournal.com/ From michaelslists at gmail.com Fri Jul 3 01:01:34 2009 From: michaelslists at gmail.com (silky) Date: Fri, 3 Jul 2009 11:01:34 +1000 Subject: [Code-Crunchers] a simple race condition and how you'd solve it In-Reply-To: <4A4D4FF3.8070101@linuxbox.org> References: <4A4D4FF3.8070101@linuxbox.org> Message-ID: <5e01c29a0907021801i2c38a62cxf07bb3190d825d94@mail.gmail.com> On Fri, Jul 3, 2009 at 10:25 AM, Gadi Evron wrote: > A friend recently demonstrated on his blog a simple race condition he > encountered. He also challenged folks to solve the problem. > > http://www.algorithm.co.il/blogs/index.php/programming/a-simple-race-condition/ > > There's an interesting discussion in the comments which is worth a quick > read. > > Also, maybe someone here will come up with a cuter idea? Posted my proposed solution in the comments, but will probably take a while to be moderated. Basically, you just need to check if you should still be computing, and, at the end of computation, if your data is still "wanted". > ? ? ? ?Gadi. > -- > Gadi Evron, > ge at linuxbox.org. > > Blog: http://gevron.livejournal.com/ -- noon silky http://lets.coozi.com.au/