• 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: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues


  • Subject: Re: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues
  • From: Matt Watson <email@hidden>
  • Date: Thu, 12 May 2005 10:07:40 -0700


On May 12, 2005, at 8:40 AM, Stéphane Letz wrote:

I am porting code that needs the PTHREAD_MUTEX_ERRORCHECK type of pthread_mutex. But it seems that PTHREAD_MUTEX_ERRORCHECK is not supported on Darwin. I get an EINVAL error when trying to use pthread_mutexattr_settype.

Is there a workaround for that?


This works fine for me on Tiger:

#include <assert.h>
#include <pthread.h>

int main (void) {
pthread_mutexattr_t a;
assert(!pthread_mutexattr_init(&a));
assert(!pthread_mutexattr_settype(&a, PTHREAD_MUTEX_ERRORCHECK));
return 0;
}


A second problem on the behaviour of pthread_cancel that is not correct. Is the use of explicit pthread_testcancel the way to go or can the following termination code be used safely?

mach_port_t machThread = pthread_mach_thread_np(fThread);
thread_terminate(machThread);

No, it can't. In previous versions of Mac OS X, pthread_testcancel() was the only cancellation point. Some code depended on this, so we had to preserve this behavior by default. If you define _APPLE_C_SOURCE when building your pthreads code on Tiger, you should get the new (proper) cancellation behavior.


matt. _______________________________________________
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


  • Follow-Ups:
    • Re: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues
      • From: Stéphane Letz <email@hidden>
References: 
 >mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues (From: Stéphane Letz <email@hidden>)

  • Prev by Date: Re: Problems building automount
  • Next by Date: Re: Patch to mount_nfs to make NFSMNT_RESVPORT default
  • Previous by thread: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues
  • Next by thread: Re: mutex PTHREAD_MUTEX_ERRORCHECK and pthread_cancel issues
  • Index(es):
    • Date
    • Thread