Re: high accuracy timing options?
Re: high accuracy timing options?
- Subject: Re: high accuracy timing options?
- From: Andrew Gallatin <email@hidden>
- Date: Fri, 28 Mar 2008 08:24:32 -0400 (EDT)
Jonas Maebe writes:
>
> On 27 Mar 2008, at 22:25, Andrew Gallatin wrote:
> > One thing to keep in mind about MacOSX is that the sleep
> > is *really* accurate compared to Linux, BSD and Solaris.
> >
> > See http://www.dragonflybsd.org/docs/nanosleep/index.shtml
>
> And also that this is mainly because for very small delays, Darwin
Please read the referenced web page. This has nothing to do with
small delays. What this test is doing is setting a wakeup time once
per second, and seeing how close the OS gets to waking up at
exactly the requested time.
Most *nix OSes stink at this kind of thing, as they'll wake processes
up once per clock tick, or every 10ms or so. Worse, if your desired
wakeup time straddles a clock tick, you might be off by as much as
2 clock ticks (reference the 19ms in the article). The nice thing
about Darwin is that it tries to wake you up at exactly the time
you requested.
> lets the "waiting" thread simply burn cpu cycles until the delay is
> over (at least when I looked into this a couple of years ago). The
> result is that very small delays are (were) quite inefficient from a
> multi-processing perspective on Darwin (with the mentioned upshot that
> they're pretty accurate).
FWIW, the referenced program is mostly idle:
% /usr/bin/time ~/tmp/wakeup_latency.intel_mac
21.000000
21.000000
21.000000
20.000000
20.000000
^CCommand terminated abnormally.
4.62 real 0.00 user 0.00 sys
We actually had a daemon that needed an accurate sleep period between
1 and 60 seconds. On other OSes, we had to wake it up a few 100ms
early and busywait. On Darwin, we were able to ifdef out that code
and sleep for the desired amount of time.
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden