[phobos] std.parallelism: Request for review/comment
Sean Kelly
sean at invisibleduck.org
Tue Aug 31 16:38:40 PDT 2010
On Aug 31, 2010, at 4:24 PM, Brad Roberts wrote:
> On Tue, 31 Aug 2010, Sean Kelly wrote:
>>
>> Theoretical mumbo-jumbo, mostly. Here's the wiki entry: http://en.wikipedia.org/wiki/Spurious_wakeup For the most part, it's just good programming practice to double-check the invariant on wakeup.
>
> Very much not theoretical. I've seen it happen more than a little. A lot
> of it can be blamed on using notify all rather than notify one type
> behavior. The other ways it can happen is signals for things like gc
> pause/resume, or pipe, or ... breaking in-progress sleeps.
Oops, for some reason I thought pthread_cont_wait would return EINTR for most of those cases, but that's semaphore_wait. You're right, a signal, etc, could cause the condition wait call to return and we can't detect this inside the Condition object. I've seen the signals used for gc cycles cause all sorts of blocking calls to return in D, so that's a very real issue regardless how good one might consider the rest of the logic in their code. For conditions, using a loop is so automatic that I've never seen the issue there. Interesting that the quotes from D. Butenhof would be so off-base. I guess he was simply talking about the wait algorithm itself rather than the interaction of conditions with other stuff.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100831/831ebf79/attachment.html>
More information about the phobos
mailing list