Bug in glibc-2.1.1: sleep(0) sleeps 10ms

Bug in glibc-2.1.1: sleep(0) sleeps 10ms

Post by Dr. Peer Grieb » Fri, 15 Oct 1999 04:00:00



Hi,

I hope this is the right forum to inform about in bug in glibc-2.1.1.
Otherwise please tell me where to go. (I don't know the adress of a
glibc mailing list).

We just ported our very large ERP system to linux. All went well but
the programs were very slow.
After 3 days of bug hunting I observed that our debugging package uses
sleep(0) very often. In all OSes we already used this makes no
problem. But glibc-2.1.1 uses nanosleep() to implement sleep(). A call
of nanosleep to sleep for 0 seconds results in a sleep of at least
10ms (as also described in the manual page).

We think this is a bug. sleep() should check for a argument of 0 and
simply return in this case.

glibc-2.0.7 doesn't have this problem, because this version does not
use nanosleep() to imlement sleep().

This bug is currently no problem for us any longer. We simply check
ourselves for a 0 argument to sleep. But it might happen that other
people also run into this same problem.

Peer.

 
 
 

Bug in glibc-2.1.1: sleep(0) sleeps 10ms

Post by David Schwart » Wed, 20 Oct 1999 04:00:00



> We think this is a bug. sleep() should check for a argument of 0 and
> simply return in this case.

        No. It's handly to be able to use 'sleep(0)' to get the minimum
possible sleep. It's a good way to implement something similar to
spinlocks or to yield the processor.

Quote:> This bug is currently no problem for us any longer. We simply check
> ourselves for a 0 argument to sleep. But it might happen that other
> people also run into this same problem.

        When your program calls 'sleep(0)', what is it trying to do? What do
you think 'sleep(1)' should do?

        DS

 
 
 

Bug in glibc-2.1.1: sleep(0) sleeps 10ms

Post by Nix » Wed, 20 Oct 1999 04:00:00




> > We think this is a bug. sleep() should check for a argument of 0 and
> > simply return in this case.

>    No. It's handly to be able to use 'sleep(0)' to get the minimum
> possible sleep. It's a good way to implement something similar to
> spinlocks or to yield the processor.

This is what sched_yield() is for.

--
`I'm glad you want me to be happy. I'd like you to be happy too.'
            --- Nat Lanza, while flaming Larry McVoy on linux-kernel

 
 
 

Bug in glibc-2.1.1: sleep(0) sleeps 10ms

Post by David Schwart » Mon, 25 Oct 1999 04:00:00



> This is what sched_yield() is for.

        No, that is not what sched_yield is for. Read the pthreads standard.

        DS

 
 
 

1. Upgrading glibc-2.1.1 to glibc-2.1.2

Recently I have download the Java 1.2.2 for Linux. However, it only support
glibc-2.1.2. so I want to upgrade it too. I am using RH6.0, so is it just
download the glibc-2.1.2 and glibc-devel-2.1.2 rpm and upgrade them?? I am
afraid my system would crash, if I just type "rpm -Uvh xxxx".

Eric Lo

2. Starting xdm without switching vt

3. glibc-2.0.7 to glibc-2.1.1

4. 16MB on Compaq Proliant 2500 with 256MB?

5. how to sleep < 10ms

6. Gimp won't print, deletes my queue from printrc

7. Bug in glibc-2.1.1 (initgroups)

8. an ansi terminal program

9. Sleep in ksh script ignored until the sleep time expires

10. Process sleeping < sleep time

11. sleep() sleeps the thread or the proc?

12. I can not compile anything after glibc-2.1.1 installed