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


Chiaki Ishikawa wrote:
> 
> X-PMC-CI-e-mail-id: 11535
> 
> >Exactly; SUS says
> >
> >     The suspension
> >     time may be longer than requested due to the scheduling of other
> >     activity by the system.
> >
> >I've seen a few programs using sleep(0) as a replacement for the
> >not-quite-so-well-known sched_yield() function, this would `break'.
> 
> I concur with the last statement.
> I have used sleep(0) for exactly yiedling the time slice in not so
> many programs.
> Maybe I am guilty of using not clearly written functionality, but
reading the
> man pages of sleep made me think the use was a quite a valid one.
> 
> Oh come to think of it, the sleep(0) idiom was the only one
> I could think of to yield time slice without doing much, i.e., like
> calling system calls that does something meaningful. sleep(0) was a
> system call without doing much and thus fitted my need.

[Since my mail account is not accepted by the glibc mailing list I'm
ussing a different account.]

I have a problem with this approach. If you only have one thread and
call sleep(0) very often (as we did) your program will become very slow.
We observed that the processor was mostly idle but the program was very slow.
Perhaps then it is a problem in the kernel?! The problem came up with
the new glibc where nanosleep was used to implement sleep which behaves
quite differently to the old sleep call in the kernel.
And I want to say once again that I used very many OSes with the
problematic code using sleep(0) and did never see such a problem.

I changed our code. So the problem is no problem for us any more. But
other people might encounter this same problem.

Thank you.

-- 
 
connection reset by
      Peer

_______________________________________________________________________
Dr. Peer Griebel                                  Tel. +49 7581 4831 23
Geschäftsführer                                   Fax. +49 7581 4831 11
Knoll Informationssysteme GmbH                   http://www.knoll-is.de
Dreiköniggasse 17                               mailto:peer@knoll-is.de
88348 Saulgau                        privat: mailto:peer.griebel@gmx.de


Sent through Global Message Exchange - http://www.gmx.net


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