Subj : Re: Shared Mutex Ownership To : comp.programming.threads From : Sebastien Decugis Date : Wed Jan 05 2005 04:41 am zeddicus76 wrote: >I have an app that uses shared memory alongside other apps. I create >mutexes with the pthread_mutexattr_setpshared(, &attr, >PTHREAD_PROCESS_SHARED) attribute. > >If the owner of the mutex dies (seg fault in this instance), my other >app can not lock that mutex. Is there anyway to force ownership once >an app that owns the mutex dies? > >What recovery options are available? How do other people handle this >case? >Would there be a better method with the 2.6 kernel? > > Hi! The feature you need is called "robust mutex". When a thread or process dies while holding a mutex, one of the waiter for that mutex is woken up and the call for pthread_mutex_lock returns an error code which tells that an owner died. This feature is not (yet?) implemented in the standard glibc for GNU/Linux systems, but a project exists which implements this behavior on top of the NTPL. It indeeds imply deep changes in the libc and in the kernel (there are 2 different patchs to apply). This project is located at http://developer.osdl.org/dev/robustmutexes/ and is very active. I hope this helps... ------------------------------- Sebastien DECUGIS NPTL Test & Trace Project http://nptl.bullopensouce.org/ .