Re: Time tracking through machine sleep
Re: Time tracking through machine sleep
- Subject: Re: Time tracking through machine sleep
- From: Brian Mastenbrook <email@hidden>
- Date: Wed, 15 Oct 2008 15:25:13 -0500
On Oct 15, 2008, at 3:07 PM, Dave Zarzycki wrote:
Mark,
gettimeofday() is what you want. There are also timeradd() and
timersub() macros for computing deltas.
davez
Mark is looking for a monotonic timer. gettimeofday() is susceptible
to time shifts caused by NTP synchronization or user setting of the
system time. In this case it sounds like he needs to know when a
certain amount of real time has passed, independent of the setting of
the system clock.
In this case I would register to receive system sleep events and use
gettimeofday() to track the amount of time the system has been asleep,
but use mach_absolute_time() for monotonic time while the machine is
awake. See the following tech note for information on how to receive
sleep and wake events:
http://developer.apple.com/qa/qa2004/qa1340.html
Brian
--
Brian Mastenbrook
email@hidden
http://brian.mastenbrook.net/
_______________________________________________
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