This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with usleep's precision.
- From: qrw at bell dot qrwsoftware dot com
- To: gcc-help at gcc dot gnu dot org, uprakash at npd dot hcltech dot com
- Date: Tue, 15 Apr 2003 12:56:34 -0600 (MDT)
- Subject: Re: Problem with usleep's precision.
Ulrich Prakash Wrote:
Hi All,
I want to sleep my program for around 20 milliseconds period.
But usleep doesn't work correctly...
man page tells that usleep wud sleep for the microseconds time,but
when i gave usleep(1),it actually sleeps for 12000-14000
microseconds..
When i gave usleep(20000),it sleeps for 27000-29000microseconds
instead of 20,000...
I also tried using nanosleep,but nanosleep for 1 nanoseconds also
sleep for 12000-14000 microseconds.
I'm not sure, but I don't think there is a way to get precise times with
sleep because it just depends upon when the scheduler next runs and setsrunning again.
-Scott