nanosleep
thanx - how much of a difference should i expect - i know the syscall is asking for at least the required ammount but that the task switcher might not give me control back for a while after the requested delay but i was expecting to be a little closer to what i had asked for - this isnt critical of corse but i would like to know what to expect.
----- Original Message -----
From: "H. Peter Anvin" <[email protected]>
Date: Tue, 09 Apr 2002 21:17:03 -0700
To: mark manning <[email protected]>
Subject: Re: nanosleep
Quoted 12 lines
Quoted 2 lines · mark manning
doh - i think something is still wrong, i ask for 1000 ms and i get a second but if i do a 500 itteration loop asking for 1 ms i get 5 seconds. i am also starting to distrust my elapsed time display which is using the gettimeofday syscall
It doesn't work that way. Each call to
nanosleep()gives you a *MINIMUM* time to delay. The kernel may decide to schedule you away and pick your process up when it suits it.-hpa
Signature · 4 lines
_______________________________________________ Get your free email from http://www.fastermail.com Powered by Outblaze
Quoted 5 lines · mark manning
thanx - how much of a difference should i expect - i know the syscall is asking for at least the required ammount but that the task switcher might not give me control back for a while after the requested delay but i was expecting to be a little closer to what i had asked for - this isnt critical of corse but i would like to know what to expect.
The minimum granularity of the timer is 1/HZ, which on a i386 is only 10ms.
If you want high-resolution timers, check out the high-res-timers project at http://high-res-timers.sf.net/ - they implement POSIX timers (which include a nanosleep call) with very high resolution (1/cpu clock).
Robert Love