• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Time tracking through machine sleep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Time tracking through machine sleep (From: Mark Hanks <email@hidden>)
 >Re: Time tracking through machine sleep (From: Dave Zarzycki <email@hidden>)

  • Prev by Date: Re: Time tracking through machine sleep
  • Next by Date: Re: DarwinBuild for Leopard
  • Previous by thread: Re: Time tracking through machine sleep
  • Next by thread: My first? question
  • Index(es):
    • Date
    • Thread