• 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: Elapsed time vs sleep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Elapsed time vs sleep


  • Subject: Re: Elapsed time vs sleep
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 26 Jul 2010 09:36:27 -0700

On Mon, Jul 26, 2010 at 9:27 AM, Charlie Dickman <email@hidden> wrote:
> As long as the NSTimer firing interval is sufficiently small the NSTimer can be used. If the run loop is stalled for any "significant: time _all_ timers will be inaccurate to some degree.

This is untrue. mach_absolute_time is the kernel's timekeeping
mechanism. It is not susceptible to runloop stalling or any stalling
for that matter, short of a hardware failure or a bug in the kernel.

NSTimer can't fire at a rate beyond a certain threshold. On the main
runloop, I believe this will wind up being somewhere around one thread
quantum because the main runloop is responsible for fetching events
from Quartz, which would most likely involve taking a lock and thus
waiting for WindowServer to get scheduled on the CPU. And then of
course there's all manner of clock drift on a multicore machine like
any Mac sold in the past few years; sometimes threads might execute on
different cores, sometimes on the same core, and the ordering thereof
affects how frequently the runloop can wake. All of this assumes that
the stall doesn't happen for more than one timer duration, and to make
matters worse, doesn't solve the OP's problem at all, since NSTimer
isn't going to fire during machine sleep!

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Elapsed time vs sleep
      • From: Jeffrey Oleander <email@hidden>
References: 
 >Elapsed time vs sleep (From: Matt Gough <email@hidden>)
 >Re: Elapsed time vs sleep (From: Charlie Dickman <email@hidden>)
 >Re: Elapsed time vs sleep (From: Kyle Sluder <email@hidden>)
 >Re: Elapsed time vs sleep (From: Charlie Dickman <email@hidden>)

  • Prev by Date: Re: Elapsed time vs sleep
  • Next by Date: Re: Elapsed time vs sleep
  • Previous by thread: Re: Elapsed time vs sleep
  • Next by thread: Re: Elapsed time vs sleep
  • Index(es):
    • Date
    • Thread