Objective-C in a Time Constraint Thread
Objective-C in a Time Constraint Thread
- Subject: Objective-C in a Time Constraint Thread
- From: Chandrasekhar Ramakrishnan <email@hidden>
- Date: Sun, 26 Feb 2006 14:19:07 +0100
I'm trying to get a better understanding of issues that may arise
when using Objective-C inside of a CoreAudio IOProc.
The CoreAudio Hardware Abstraction Layer calls clients to produce
audio on a time-constraint thread. Thus, audio generating functions
are discouraged from invoking functions that may block the thread or
take "a long time" to return (e.g., locking mutexes, allocating
memory, reading from disk) [1].
On the CoreAudio list, it was pointed out that "... ObjC message
sends are treated as an opportunity for the ObjC runtime to re-
evaluate its world, and thus can not only involve locks, but also
memory allocations" [2].
I looked at the source for objc_msgSend <http://
darwinsource.opendarwin.org/10.3/objc4-235/runtime/Messengers.subproj/
objc-msg-ppc.s> and, sure enough, there is a comment before the macro
LockCache:
; The collecting cache mechanism precludes the need for a cache lock
; in objc_msgSend. The cost of the collecting cache is small: a few
; K of memory for uncollected caches, and less than 1 ms per
collection.
; A large app will only run collection a few times.
I'm assuming this is what was being referred to in the ca-api list post.
Is this comment still accurate? If so, calling objc_msgSend in an
IOProc is certainly risking audio glitches. Are there ways to
decrease the probability of having the cache collected or is there
any way to avoid it altogether? For example, will caching the IMP and
invoking that directly help?
Thanks.
- sekhar
[1] http://lists.apple.com/archives/coreaudio-api/2001/May/msg00017.html
[2] http://lists.apple.com/archives/coreaudio-api/2006/Jan/msg00275.html
--
C. Ramakrishnan email@hidden
Illposed Software http://www.illposed.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden