• 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: Sound Manager & MIDI callbacks, interrupts and threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sound Manager & MIDI callbacks, interrupts and threads


  • Subject: Re: Sound Manager & MIDI callbacks, interrupts and threads
  • From: Doug Wyatt <email@hidden>
  • Date: Sun, 17 Feb 2002 21:24:52 -0500

\On Saturday, February 16, 2002, at 05:30 , Andy Robinson wrote:
Both these callbacks communicate with the main app code via queues, so
there are brief moments of queue-manipulation when it would be fatal for
one to interrupt the other and access the queue.

On classic Mac (AFAI understand it) these callbacks were called at
"interrupt time" so there was never any danger of the main app
interrupting the callback. To prevent the callback interrupting the main
app I would briefly disable interrupts using InterruptDisableLib.c as
provided by Apple. This uses assembly code which doesn't work on Mach-O.

Well, you can certainly compile assembler in Mach-O with gcc's assembler, but then I suspect you'd bomb out trying to execute a privileged instruction in user space.

I'm not at all clear what the situation is now. Is the callback running
in some pre-emptive thread?

Yes, *everything* is running in preemptive threads, and *nothing* is running at interrupt level (except for extremely minimal pieces of code in drivers).

Do I need to worry about the main app
interrupting the callback?

Yes (despite its relative unlikeliness compared to the opposite scenario).


And how can I prevent (for brief moments) the
callback interrupting the main app?

You can't. You have to use a mutex.

There's a Mutex C++ class in /Developer/Examples/CoreAudio/MIDI/SampleUSBDriver/Shared/MIDIDriverUtils.
[cpp,h]

Doug
--
Doug Wyatt
work: email@hidden (CoreAudio)
personal: email@hidden http://www.sonosphere.com

"Premature optimization is the root of all evil."
-- Knuth
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >Sound Manager & MIDI callbacks, interrupts and threads (From: Andy Robinson <email@hidden>)

  • Prev by Date: Re: MIDI source unique IDs (was Names for MIDI sources)
  • Next by Date: Re: MIDI source unique IDs (was Names for MIDI sources)
  • Previous by thread: Re: Sound Manager & MIDI callbacks, interrupts and threads
  • Next by thread: Re: Sound Manager & MIDI callbacks, interrupts and threads
  • Index(es):
    • Date
    • Thread