Re: high accuracy timing options?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Andrew Gallatin