• 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: pthread_cond_signal and priority inversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pthread_cond_signal and priority inversion


  • Subject: Re: pthread_cond_signal and priority inversion
  • From: Paul Davis <email@hidden>
  • Date: Mon, 23 May 2016 11:37:56 -0400

Unless you know the author of an email works inside Apple in a highly technical role, I would advise against staking too much faith in a comment like "or better yet dispatch semaphores". And someone who doesn't know what POSIX semaphores are is doubly unlikely to be the right person to take advice from on this matter.

On Fri, May 20, 2016 at 7:15 AM, Michael Tyson <email@hidden> wrote:
Many thanks, Kyle, that’s most helpful!

Some further digging: it looks like not only are condition variables and mach semaphores acceptable, but dispatch semaphores are too, and are apparently even preferable (http://lists.apple.com/archives/darwin-dev/2012/Oct/msg00004.html). 

So, all great news!
 
-- 
Michael Tyson | atastypixel.com

Loopy: Record, loop, layer. Like a pro.
http://loopyapp.com

On 20 May 2016, at 08:41, Kyle Neideck <email@hidden> wrote:

You might find this thread useful if you haven't seen it already: https://lists.apple.com/archives/coreaudio-api/2010/Oct/msg00245.html (continues at https://lists.apple.com/archives/coreaudio-api/2010/Oct/msg00252.html).

I also found this post where Jeff Moore says that pthread_cond_signal is OK: https://lists.apple.com/archives/coreaudio-api/2009/Nov/msg00174.html. In this 2006 post he says that there "is a spin lock in the pthread implementation" (though I'm not completely sure that includes pthread_cond_signal) but that it very rarely causes problems: https://lists.apple.com/archives/coreaudio-api/2006/Jan/msg00044.html. I've been using Mach semaphores, which are also fine according to that post.

Kyle


On 19 May 2016 at 19:55, Michael Tyson <email@hidden> wrote:
Hi folks,

I noticed recently that the AUAudioFilePlayer audio unit is using pthread_cond_signal from its render function, via CAGuard::Notify (http://goo.gl/VErpxz), itself a piece of code made available to the public as part of the Core Audio Utility Classes (https://goo.gl/RFMxcL).

I always thought pthread_cond_signal was a no-no for use on the audio thread due to the risk of priority inversion; this post from way back in 2002 reports that pthread_cond_signal can block http://goo.gl/DwFYUq, although I’ve not followed up on the findings. 

Consequently, I’ve always used polling, rather than a condition variable or semaphore, but this can cause a bit of lag, or an awkward amount of CPU consumption.

Is the presence of pthread_cond_signal in CAGuard and AUAudioFilePlayer an indication that this is now safe?

Many thanks,
Michael

-- 
Michael Tyson | atastypixel.com

Loopy: Record, loop, layer. Like a pro.
http://loopyapp.com


 _______________________________________________
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

 _______________________________________________
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

  • Follow-Ups:
    • Re: pthread_cond_signal and priority inversion
      • From: Ross Bencina <email@hidden>
References: 
 >Re: pthread_cond_signal and priority inversion (From: Kyle Neideck <email@hidden>)

  • Prev by Date: Re: pthread_cond_signal and priority inversion
  • Next by Date: Re: pthread_cond_signal and priority inversion
  • Previous by thread: Re: pthread_cond_signal and priority inversion
  • Next by thread: Re: pthread_cond_signal and priority inversion
  • Index(es):
    • Date
    • Thread