Re: high accuracy timing options?
Re: high accuracy timing options?
- Subject: Re: high accuracy timing options?
- From: Andrew Gallatin <email@hidden>
- Date: Wed, 26 Mar 2008 08:34:08 -0400 (EDT)
Rather than re-inventing the wheel, have you tried to measure the
accuracy of gettimeofday() on darwin? It will be much better
than you expect.
MacOSX/Darwin uses a really clever method to move most of the heavy
lifting out of the kernel and into userspace for gettimeofday().
The kernel sets up a "commpage" with an appropriate gettimeofday()
function for the hardware you're on. It then shares timestamp
information with this gettimeofday() implementation. This commpage is
then mapped into your process, so when you call gettimeoday(), you use
this clever version.
At least in the ppc implementation, the library calls mftb, so the
timing info on ppc should be both cheap and very accurate. I don't
understand x86 asm nearly as well, so I can't say exactly what the x86
implementation does.
Anyway, check out the kernel sources to see what I mean:
xnu-$VERSION/osfmk/ppc/commpage/gettimeofday.s
xnu-$VERSION/osfmk/i386/commpage/commpage_gettimeofday.s
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