LWN.net Logo

Short sleeps suffering from slack

Short sleeps suffering from slack

Posted Feb 23, 2012 13:55 UTC (Thu) by Ben_P (subscriber, #74247)
Parent article: Short sleeps suffering from slack

What types of applications break when sleep(0) just returns? sleep(0) seems like it would be used to "fix" concurrency issues in an even more naive way than sched_yield()?

I've seen so many poorly written programs "fix" concurrency problems with yields that I'm quite cynically whenever I see them in code. Unless it's in some very primitive concurrency or IO; yields only seem to delay incorrect code from breaking.


(Log in to post comments)

Short sleeps suffering from slack

Posted Feb 24, 2012 23:02 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

What types of applications break when sleep(0) just returns? ...
I've seen so many poorly written programs "fix" concurrency problems with yields ...

It seems like you've answered your own question.

I have no trouble believing that these programs you've seen worked better after sleep(0) was added than before. Maybe it's just within a narrow field of application, but that may be the only field that matters. You might say these programs don't deserve to keep working, even in that narrow application, but you can't deny that making sleep() a no-op would do damage there.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds