This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]