Subject: usleep() and system clock resolution
To: NetBSD help list <netbsd-help@netbsd.org>
From: Ruibiao Qiu <ruibiao@arl.wustl.edu>
List: netbsd-help
Date: 05/18/2000 14:13:22
Hi all

I am trying to write a program that sends packets every 5 ms.  I
use usleep in my program.  But, it seems that I can only get 10 ms
intervals.  I wrote a test program that only does usleep() in a
loop, and record the time between each usleep(), as follows:

for ( ... ) {
	gettimeofday( &tv, NULL );
	usleep( 5000 );
}

The result still shows 10 ms.  Taking gettimeofday() out, I did
65535 usleep() in a loop and record the start and finish time,
The resulting average is 10 ms.

So, I wonder if usleep() can get to less than 10 ms.  Does it has
anything to do with system clock resolution?  How can I find out
the current value of it?  How can I configure it?   Do I need 
to use nanosleep()?  (BTW, when I run the tests on a linux box, I
got 20 ms :)

Thanks.

          Regards

            Ruibiao