This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [comp.os.linux.development.system] Bug in glibc-2.1.1: sleep(0) sleeps 10ms


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/>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]