gettimeofday() & the commpage
I noticed that in Darwin 7.x you've optimized gettimeofday() by mapping some timecounter variables out into every process via the commpage. Very, very cool. I was concerned that it might yield results that were not accurate. Specifically, I was concerned that the kernel would not know to update the mapped-out timecounter variables more than once-per-clock tick as it would were gettimeofday() was always a syscall. So I wrote a tiny program which calls gettimeofday() in a tight loop, counting how many times it sees tv_usecs incremented. I was pleasantly surprised to see that its still very accurate (saw 998811 usec increments in a second). With 1 call to gettimeofday() according to ktrace. So.. how the heck do you do it? Is the actual clock hardware mapped out to userspace? Or is there a trick I'm missing. Impressed, Drew _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Andrew Gallatin