• 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: Threading/timer issues on Mach-O vs. OS 9
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading/timer issues on Mach-O vs. OS 9


  • Subject: Re: Threading/timer issues on Mach-O vs. OS 9
  • From: Kurt Revis <email@hidden>
  • Date: Sun, 23 Apr 2006 22:24:51 -0700

On Apr 23, 2006, at 8:37 PM, Stephen Kay wrote:

There is a mechanism to set a "lockoutFlag" around "critical
sections" of
code that you don't want interrupted for any reason. The lockout flag
prevents interrupts while it is set to true.

What is your "lockoutFlag" exactly? Just a variable in memory that you set to true during your critical section? Or is there some function you have to call to change it?

The lockout flag is a global variable. When the TimerProc is called, every 1
ms, if the flag is "true" (locked), you exit and don't process any Scheduled
Tasks.

OK, so I'm confused about how this thing gets "stuck". If it's just a global variable that's completely under the control of your own code, you should be able to figure out what's going on, yes? Nothing else in the system is going to touch it.


Is this value a simple integer (long or int or whatever) or is it some larger structure? Is it part of some other structure that happens to have some weird alignment? Normally writes to an int should be atomic -- if one processor is writing it, the other processor will see either the old or new value but not some mixture of both. If your value is larger than an integer or if it isn't 4- byte aligned then that might not be the case.

All I know is I've got my incredibly ancient 1ms clock running perfectly
fine in Mach-O. Timing sounds very solid (haven't quantitatively analyzed it
yet). Just this problem with the flag getting stuck. Or maybe more problems
that I don't know about yet. ;-)


But maybe there's a better way to do it. I've been pointed to the concept of
creating a POSIX thread with "real time priority scheduling", but I haven't
figured out how to integrate that yet. I just want some function to call me
every 1 ms.

Hard to tell anything from just listening to the results -- I bet you're getting called back frequently, but the jitter is probably pretty high compared to your 1 ms period. Only measuring it will tell you for sure. Last time I looked (2002 or so) the high level CF/ NSTimers wouldn't get you anywhere near 1 ms. I don't know how Carbon simulates the Time Manager stuff, but it could well be doing a better job.


Also -- and I know this is beyond the bounds of what you want to do right now -- I really recommend that you think about a redesign in the future. There's a considerable amount of overhead in making your thread wake up 1000 times a second, and it's especially pointless if you do nothing 99.9% of the time. It's entirely possible to get rid of all this overhead, and wake up your timer thread only when it has actual work to do.

--
Kurt Revis
email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Threading/timer issues on Mach-O vs. OS 9
      • From: philippe wicker <email@hidden>
    • Re: Threading/timer issues on Mach-O vs. OS 9
      • From: Stephen Kay <email@hidden>
References: 
 >Re: Threading/timer issues on Mach-O vs. OS 9 (From: Stephen Kay <email@hidden>)

  • Prev by Date: Re: Capturing audio from a running program
  • Next by Date: Re: Threading/timer issues on Mach-O vs. OS 9
  • Previous by thread: Re: Threading/timer issues on Mach-O vs. OS 9
  • Next by thread: Re: Threading/timer issues on Mach-O vs. OS 9
  • Index(es):
    • Date
    • Thread