| Matt,
Absolute time is an abstract notion of "CPU ticks". The value is meaningless without conversion to nanoseconds.
The only use of absolute time is for measuring time deltas, and even for that purpose, we advise that the time deltas be small, given that the absolute clock pauses while the machine is asleep.
davez
On Mar 25, 2008, at 1:34 PM, Matt Burnett wrote: Could you tell me what event the time value is based off of in IOHIKeyboard's keyboardEventAction? It seems similar to the system's uptime, but as you can see from the code below it is not.
Code: void myKeyboardEventAction(OSObject * target, unsigned eventType, unsigned flags, unsigned key, unsigned charCode, unsigned charSet, unsigned origCharCode, unsigned origCharSet, unsigned keyboardType, bool repeat, AbsoluteTime time) { u_int32_t calendarHi,calendarLo,systemHi,systemLo; u_int64_t uptime; ... clock_get_uptime(&uptime); clock_get_calendar_nanotime(&calendarHi,&calendarLo); clock_get_system_nanotime(&systemHi,&systemLo); IOLog("event time %u %u calendar time %u %u systime %u %u uptime %qu\n",time.hi,time.lo,calendarHi,calendarLo,systemHi,systemLo,uptime); }
Output: 3/25/08 3:33:45 PM kernel event time 228 1774164770 calendar time 1206477225 220085000 systime 981 26764241 uptime 981026763195 3/25/08 3:33:45 PM kernel event time 228 1846204876 calendar time 1206477225 292127000 systime 981 98805951 uptime 981098804881 3/25/08 3:33:46 PM kernel event time 228 2606205566 calendar time 1206477226 52123000 systime 981 858791519 uptime 981858790570
On Mar 25, 2008, at 1:26 PM, Dave Zarzycki wrote: Matt and Brian,
Absolute time and calendar time are completely different clocks and cannot be converted. To the best of my knowledge, "absolute time" pauses whenever the machine enters deep energy saving modes.
davez
On Mar 25, 2008, at 3:25 AM, Matt Burnett wrote: Also this doesnt seem to work. This should show me the up time assuming the machine was started on 1970/1/1 00:00:00. It says it has been up for 10 hours when the uptime command says over 1 day. What exactly am i doing wrong? Code: AbsoluteTime keyTimeAbs = UpTime(); Nanoseconds keyTimeNano = AbsoluteToNanoseconds(keyTimeAbs); double seconds = ((double) UnsignedWideToUInt64( keyTimeNano )) * 1e-9; NSDate *keyTimeDate = [NSDate dateWithTimeIntervalSince1970:seconds]; NSLog(@"Key event date: %@",keyTimeDate);
2008-03-25 05:23:47.625 timeTest[5051:10b] Key event date: 1970-01-01 10:17:25 -0600
Uptime: 5:24 up 1 day, 4:57, 3 users, load averages: 0.56 0.55 0.53
On Mar 25, 2008, at 4:49 AM, Brian Bergstrand wrote: AbsoluteTime is CPU specific. You have to use the mach clock_* functions to convert the interval to nano seconds. The epoch for the converted value will be the standard UNIX epoch (1970/1/1 00:00:00).
On Mar 25, 2008, at 11:35 AM, Matt Burnett wrote:
I have a KEXT which hooks in to IOHIKeyboard's _keyboardEventAction. One of the variables it provides me is time of the event in the form of AbsoluteTime. What date or event (power on?) is this value counting up from? Thanks.
Brian Bergstrand <http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2
_______________________________________________ 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
|