Re: Sound Manager & MIDI callbacks, interrupts and threads
Re: Sound Manager & MIDI callbacks, interrupts and threads
- Subject: Re: Sound Manager & MIDI callbacks, interrupts and threads
- From: Herbie Robinson <email@hidden>
- Date: Mon, 18 Feb 2002 19:37:21 -0500
Thanks again for more replies.
What I now plan to do is this. I'm going to ignore the instruction not
to put a lock in a callback since some people tell me that in fact a
lock is ok, and no-one has proposed any other way of protecting critical
sections. If anyone is going to tell me again not to do this, then
please tell me what I _should_ do instead. In fact, is the instruction
not to put a lock in a callback a hangover from Classic Mac when the
callback would be running in "interrupt time" rather than a true thread
of its own?
I thought about this some more and locks will be fine as long as you
aren't trying to keep the callback thread wired when the other thread
is not wired. You can still make that work, but it's necessary to
transfer into a wired environment before locking from the non-wired
thread (otherwise, a page fault on the non-wired thread can end up
blocking the wired thread). I haven't seen any utilities to do this
in OS X; so, you might be on your own writing some assembly language
code. Of course, you could just wire the other thread, too. This
is essentially part of solving the priority inversion problem one has
with locks (the OS should be dealing with the other facets of the
priority inversion problem without you having to do anything).
If you have a fixed number of buffers you are dealing with (fairly
likely), you might be able to structure the queue as a circular
buffer. If you can do that, you don't have to lock. Just remember
to use "volatile" on the buffer indexes so the compiler doesn't
optimize things too much. The less locking you do, the better; so,
if you can use a circular buffer, it's a win.
--
-*****************************************
**
http://www.curbside-recording.com/ **
******************************************
_______________________________________________
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.