• 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_wait() missing broadcast?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pthread_cond_wait() missing broadcast?


  • Subject: Re: pthread_cond_wait() missing broadcast?
  • From: Pierre Baillargeon <email@hidden>
  • Date: Wed, 9 Jan 2008 08:46:16 -0500


On 9-Jan-08, at 7:56 , Jim Magee wrote:

The unlock needs to be atomic with the marking of the thread waiting on the condition. Since that latter part happens in the kernel, so must the unlock.

What you are missing is the logic that converts a mutex being marked busy in user memory, to one being indicated as locked via being assigned a Mach semaphore. That Mach semaphore is then passed into the kernel in the Mach semaphore_{timed}wait_signal() call. That system call atomically marks the thread waiting on the condition's semaphore and pre-posts the mutex's semaphore - effectively unlocking the mutex for future attempts to acquire it (the first of those susequent attempts will have to make a trip to the kernel to acquire it via a semaphore_wait()).


Thanks for explanation.

The biggest thing I was missing is that the core of pthread_cond_wait is implemented in libc, not in the kernel (in bsd/kern/ pthread_sync.c). I was thus missing a big part of the picture, which explains my confusion.

--
Pierre Baillargeon




_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >pthread_cond_wait() missing broadcast? (From: Pierre Baillargeon <email@hidden>)
 >Re: pthread_cond_wait() missing broadcast? (From: Jim Magee <email@hidden>)

  • Prev by Date: Re: A Bug in pthread_cond_destroy?
  • Next by Date: kextload serialization lock busy; sleeping ?
  • Previous by thread: Re: pthread_cond_wait() missing broadcast?
  • Next by thread: RE: fread/fwrite/fflush bug (Norm Green)
  • Index(es):
    • Date
    • Thread