Re: Can't sleep less than 20 ms

Marcus Meissner (marcus@jet.franken.de)
Fri, 2 Jul 1999 17:18:26 +0200


In article <19990702073845.A27173@revue.linux-kernel-luna.science-computing.de> you write:
>On Thu, Jul 01, 1999 at 06:12:24PM -0400, Dong Liu wrote:
>> Hi,
>>
>> I know Linux on i386 has a timer resolution of 10 ms, but
>> why I can't sleep for 10 ms, I can only sleep at
>> interval of 20 , 30, 40 ... ms.
>
>this is what the man page says :
>
>(from man 3 usleep)
>...
>DESCRIPTION
> The usleep() function suspends execution of the calling
> process for usec microseconds. The sleep may be length­
> ened slightly by any system activity or by the time spent
> processing the call.
>...

Won't help, usleep(3) uses nanosleep(2) which uses the 1/HZ (10ms) timers
under the normal scheduling type. Check the manpage on nanosleep(2).

If you set the scheduler to SCHED_RR or SCHED_FIFO nanosleep(2) does up
to 2ms busy waits (finegrained sleep) and then switches back to the standard
10ms timer.

Ciao, Marcus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/