Re: Bug in 2.4 nanosleep()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 25, 2001 at 11:40:04PM -0500, Michael Arras wrote:

> Greetings,
> 
> I seems to me that at least 2.4.8 & 2.4.14 have miscalculation
> bugs beneath the sys_nanosleep() call.  Calls to nanosleep() on
> my Mandrake 8.1 based Dell 450 MHz PII produce poor results
> even when called with a resolution of 1/10 of a second.
> 
> Is this a) a 2.4 kernel bug, b) a glibc 2.2.4 bug, c) due to
> a 450MHz PII being "underpowered", or d) the nature of scheduling
> under Linux?  I tried to investigate a), but between all the
> jiffies and x86 assembly I got lost.
> 
> Look at these results.  Each value should be 1.000 second.
> The included program loops N times with a 1/N second sleep,
> using three different methods.  Using select(), nanosleep(),
> and usleep().
> 
> Sleeping 1000 times for one millisecond should take 1 second
> of wall clock, yet it takes 20 seconds!  Try the program and
> see for yourself.

I think that this is because when it enters via a syscall, it checks to see if
anything needs scheduling, on the return. If it doed, then it will wait till
that syscalls, or the sleep is over, or the timer interrupt interrupts. The
thing with sleep is that it gaurentees a sleep of /at least/ x, rather than
/exactly/ x. (be that milliseconds, nanoseconds, seconds, ...).

-- 

Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
mark@zealos.org
mark@itsolve.co.uk

UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
!E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
!R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

(www.geekcode.com)
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux