This is the mail archive of the cygwin mailing list for the Cygwin 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: does usleep() sleep more than it's supposed to?


On Mon, Feb 26, 2007 at 03:57:10PM +0800, Carlo Florendo wrote:
> Good Day,
> 
> I'm writing an application that requires time precisions up to the
> microsecond level.  However, I put a hard-coded adjustment of
> 9000 microseconds since usleep() seems to sleep on the average of
> 9000 microseconds more than it's supposed to, at least on my
> system.  I could work with up to 2000 microseconds for
> function overhead but 9000 microseconds seems to be too long.

Without using POSIX Realtime extensions, you will *never* attain
consistent granularity at the microsecond level with any sleep()
function.

Think about it - on a preemptive multiprocess OS - the minimum
intervals the OS uses for handing out timeslices to all processes
contained within the current environment (and also the associated
forced sleeping of processes who have used too many of their
timeslices within a given interval) will always limit your
granularity.

-cl

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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