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

Re: gettimeofday() and clock



On Tue, Sep 03, 2002 at 12:46:29AM +0200, Gregor M?ckl wrote:

> Please type
> 
> man nanosleep
> 
> and read carefully. At least my version of the manpage describes the 
> behaviour you experience (it's the first paragraph in the BUGS section). 
> Presumably sleep and usleep are no more than wrappers around nanosleep() 
> as there is no other similar syscall available.

To quote the man page:

  Therefore, nanosleep pauses always for at least the specified
  time, however it can take up to 10 ms longer than specified
  until the process becomes runnable again.

<snip>

> However, the second call to schedule() 
> seems to give the next time slice away to another process and the next 
> schedule() activates the task that has called nanosleep(). Thus it adds 
> up to a litle bit less than 20ms, which is the time your program measures.

That would be the problem there.  The man page says to expect up to 10 ms
when in fact we are getting over 10 ms and up to 20 ms.

-- 
Christopher John Purnell  | I thought I'd found a reason to live
http://www.lost.org.uk/   | Just like before when I was a child
--------------------------| Only to find that dreams made of sand
What gods do you pray to? | Would just fall apart and slip through my hands