Re: Thread issue - sure can use some help
Re: Thread issue - sure can use some help
- Subject: Re: Thread issue - sure can use some help
- From: Jeff Moore <email@hidden>
- Date: Fri, 7 Apr 2006 17:33:50 -0700
On Apr 7, 2006, at 5:10 PM, John Draper wrote:
Jeff Moore wrote:
The crash looks to me like your thread is trying to message a bad
ObjC object. That implies some kind of data coherency issue in
your code. My guess is that you have one thread that is disposing
of an object while another thread is trying to use it.
yes - That is what I suspect, but I'm clueless as to how to deal
with it. Especially since I'm using
a thread from some outside non-mac code I'm using (JRTPLIB).
Although it uses the POSIX
pthreads, somehow I have to get it to "know about" the
MTCoreAudio. If you've seen my
earlier postings, I asked the group about using the @synchronize
directive, but don't know
how to use it, or how much latency it's going to introduce in the
program.
I'm not an ObjC expert, but I think the @synchronize directive works
more or less like synchronized methods in Java do.
The hang is a deadlock of some flavor. This means that one thread
is blocking while holding onto a lock that is blocking the other
thread while it tries to acquire the lock.
yes - I suspect this to be the case, but I'm clueless as to how to
deal with it, and this is why I'm
willing to share the code and have others (who have the time) to
review it, but privately (off the list)
of course. And if others are interested, I'll be happy to post
the fix if I ever find it.
It's easy to pick out the blocked threads using the output of the
sample tool. From there, it's generally pretty easy to identify what
locks and code paths are involved in the dead lock.
Both problems are pretty basic parallel programming problems that
unfortunately, have no set answers.
yes - and I'm not a systems kernal programmer and not familiar with
multi-threading concepts...
That's cool. If you are looking for books on the topic, I'd start
with David Butenhof's "Programming with POSIX Threads". Not only is
it a great reference to the pthread API, but it is chock full of
advice on using the API as well as general knowledge about parallel
programming.
I have also been reading Gregory Andrews' "Concurrent Programming:
Principles and Practice" again lately. This book is much more into
the theoretical side of things. It spends a good deal of text
teaching the concepts through logic proofs as opposed to using more
practical examples in C. Still, I've been able to apply it's lessons
to my everyday work. I particularly like the sections that detail the
history of the development of the various techniques. For instance, I
didn't know why the two semaphore operations were always notated with
P and V before reading this book.
The solution is going to be totally driven by the context. You
need to look very closely at how the various threads interact
with your data and design a locking solution that ensures that
things like this don't happen while at the same time allowing the
code to still be able to satisfy the real time demands of the
audio system (ie. make the deadlines and don't block the IO
thread, ever).
Yes - I've been working on that, but cannot do that because I don't
have the source of Cocoa tools,
and I still haven't been able to get any response from the
MTCoreAudio framework author.
You can still get an idea of what threads are doing what using the
tools on the system. The sample tool I mentioned is one good tool for
the job, but Shark is also eminently helpful, especially when using
the System Trace profile.
But let me ask this.... lets say there IS object contention in
MTCoreAudio, and I assume such,
is there a way I can still keep this from happening. I was
referred to the @synchronize directive,
but not even ONE single example of how to use it....
the source for MTCoreAudio is on the net.
Sure you can. You are totally in control here since you are the one
that is writing the code that glues the SIP library to the
MTCoreAudio library. You can always use your own locks to manage the
synchronization. The first step for you will be to identify the
causes of the hangs and crashes using the tools. From there you can
formulate a plan to deal with it.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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