This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: [comp.os.linux.development.system] Bug in glibc-2.1.1: sleep(0) sleeps 10ms
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: Re: [comp.os.linux.development.system] Bug in glibc-2.1.1: sleep(0) sleeps 10ms
- From: Markus Kuhn <Markus dot Kuhn at cl dot cam dot ac dot uk>
- Date: Fri, 15 Oct 1999 11:43:17 +0100
- Cc: peer at knoll-is dot de
Wolfram Gloger wrote on 1999-10-15 10:20 UTC:
> > Should we add:
> > if (seconds == 0)
> > return 0;
> > to sleep to optimize sleep (0) ?
>
> I have no strong opinion, but I don't think so.
I also don't like the above change. I would intuitively expect sleep(0)
to be functionally somewhat comparable to a sched_yield() call: Send the
process into the ready queue after not sleeping. Another argument is
(probably much more relevant for nanosleep), that some real-time
programmers like to have constant function-call overhead. They expect
that sleep(1) sleeps 1000 ms longer than sleep(0), so a sleep(0) should
really create the same overhead as a sleep(>0). Sleep functions are one
of the functions that you do not want to speed optimize for special
cases. Sleep's slowness is a feature, not a bug :-), and the above check
for zero should better be done in the application in question. If you
don't want a delay, clearly don't call sleep().
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>