Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: high accuracy timing options?



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

References: 
 >high accuracy timing options? (From: "Aaron Turner" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.