Re: sleep() API behaves differently in Linux 2.4 and Linux 2.6
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Wed, 28 Feb 2007 20:55:02 -0000
On 2007-02-28, bizhan.gholikhamseh@xxxxxxxxx <bizhan.gholikhamseh@xxxxxxxxx> wrote:
I have a simple program utilizing "sleep()" api to sleep 3
msec periodically.
No, you don't. You have a program that uses select() api to
sleep at least 3ms periodically.
I measured the time difference before calling the api and
after it returns back.
The same application behaves differently running on Linux 2.4
and 2.6 In Linux 2.6.11, it takes about 3 msec, and running on
Linux 2.4.20 it takes about 10 msec.
The default system timer tick on 2.4 kernels was 10ms. With a
10ms tick, 10ms is the minimum amount of time you can sleep.
On 2.6, most systems use a 1ms or 4ms timer tick. The system
on which you tested must have been configured for 1ms. Some
2.6 systems might still be configured for 10ms.
Unfortunately, the man page for select() is incorrect. timeout
is not an upper bound on the the amount of time elapsed before
select() returns (as is stated on the man page).
timeout is actually a lower bound on the maximimum time slept
in the case where the selected events do not occur and the
system call is not interrupted. In that case the amount of
time slept will be a multiple of the system tick time that is
greater than or equal to the specified timeout. On a busy
system it could be many ticks larger than the specified
timeout.
Expecting it to be precisely 3ms is futile.
--
Grant Edwards grante Yow! PUNK ROCK!! DISCO
at DUCK!! BIRTH CONTROL!!
visi.com
.
- References:
- sleep() API behaves differently in Linux 2.4 and Linux 2.6
- From: bizhan.gholikhamseh@xxxxxxxxx
- sleep() API behaves differently in Linux 2.4 and Linux 2.6
- Prev by Date: Re: sleep() API behaves differently in Linux 2.4 and Linux 2.6
- Previous by thread: Re: sleep() API behaves differently in Linux 2.4 and Linux 2.6
- Index(es):
Relevant Pages
|
|