Re: render callback + pthread_cond_signal
Re: render callback + pthread_cond_signal
- Subject: Re: render callback + pthread_cond_signal
- From: "Ross Bencina" <email@hidden>
- Date: Sat, 30 Oct 2010 18:54:24 +1100
Brian Willoughby wrote:
It may not block, but from your description it sounds like it causes an
immediate context
switch.
You wouldn't _expect_ it to switch contexts if the other thread has a lower
priority...
However, as to blocking... I was interested in this and googled "mach
realtime thread pthread_cond_signal" and the first hit was a thread from
this list way back in 2002 entitled "Can pthread_cond_signal() block?":
http://lists.apple.com/archives/coreaudio-api/2002/Nov/msg00004.html
Interesting reading. At least back then, someone was getting
blocking/priority inversion with pthread_cond_wait and trawled the pthread
source code and found a lock that appeared to be occasionally causing
priority inversion.
the most relevant post seems to be this one which suggests better results
using Mach semaphores ( semaphore_signal() api ) instead of
pthread_cond_signal:
http://lists.apple.com/archives/coreaudio-api/2002/Nov/msg00035.html
Of course the lock in the pthread_cond implementation may have been removed
by now... and last time I checked Supercollider was signalling it's disk io
thread from a render proc using pthread_cond_signal so you'd be in good
company if you used pthread_cond_signal
Ross.
To: Paul Sanders
Cc: CoreAudio API
Sent: Saturday, October 30, 2010 3:26 PM
Subject: Re: render callback + pthread_cond_signal
On Oct 29, 2010, at 15:31, Paul Sanders wrote:
On 28 Oct 2010, at 18:30, Scott Burgess <email@hidden>
wrote:
Is calling pthread_cond_signal() from an AU render callback cool?
If not, what is the safe alternative to signal a UI or other thread?
I do it and it works fine for me. pthread_cond_signal is never going to
block - it just releases one of however many threads are waiting on the
condition variable (which, I imagine, is what you are trying to accomplish).
It may not block, but from your description it sounds like it causes an
immediate context switch. A context switch is usually not nearly as bad as
a block, but still ...
Brian Willoughby
Sound Consulting
_______________________________________________
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
_______________________________________________
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