• 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: Accuracy of timers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accuracy of timers?


  • Subject: Re: Accuracy of timers?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Thu, 23 Apr 2009 10:27:36 -0400

Thanks for all the great feedback.
Eric

On Thu, Apr 23, 2009 at 9:12 AM, Michael Ash <email@hidden> wrote:

> On Thu, Apr 23, 2009 at 2:06 AM, Wade Tregaskis <email@hidden>
> wrote:
> > P.S. For completeness I should mention of course nanosleep, but I don't
> know
> > of its precision and in any case it can be interrupted by signals, which
> > makes it more difficult to use than you'd expect.
>
> Its precision is, of course, nanoseconds. The question is its
> accuracy. I think the answer there is that it's as accurate as the
> scheduler can make it, which will depend on system load.
>
> Signal interruption is not very difficult at all. Essentially all you
> have to do is stick the call in a loop. Unsafe code already has the
> necessary calculations (pseudocode):
>
> remainingTime = targetTime - now;
> nanosleep(remainingTime);
>
> So all you have to do is wrap it in a loop that keeps retrying:
>
> while(1) {
>    remainingTime = targetTime - now;
>    if(remainingTime <= 0) break;
>    nanosleep(remainingTime);
> }
> _______________________________________________
>
> 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
>



--
http://ericd.net
Interactive design and development
_______________________________________________

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

References: 
 >Accuracy of timers? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Accuracy of timers? (From: Wade Tregaskis <email@hidden>)
 >Re: Accuracy of timers? (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
  • Next by Date: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
  • Previous by thread: Re: Accuracy of timers?
  • Next by thread: image transition while dragging
  • Index(es):
    • Date
    • Thread