On Thursday 09 July 2009 21:01:31 cbswbot wrote: > Hi all, > > can anybody tell me why a usleep(1 usec) takes 20 ms ? > > usleep(1000000) takes 1000.00 ms > usleep(100000) takes 100.00 ms > usleep(10000) takes 20.00 ms > usleep(1000) takes 20.00 ms > usleep(100) takes 20.00 ms > usleep(1) takes 20.00 ms > > Is there any way to get a lower time than 20ms? > > Regards > Rouven
Hi, >From the usleep man page: "The usleep() function suspends execution of the calling process for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers." So thats probably the issue. As for a solution: http://high-res-timers.sourceforge.net/ http://www.google.co.za/search?q=High+resolution+timers+linux -- Regards, Stewart Allen [email protected]
