
Printf(" Attempting to lock the robust mutex.\n") * "original_owner_thread" should have exited by now. Pthread_create(&thr, NULL, original_owner_thread, NULL) Pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST) Mutex is now consistent unlockingĭo while (0) pthread_mutex_lock() returned EOWNERDEAD The following shell session shows what we see when running this Successfully and gets the error EOWNERDEAD, after which it makes The main thread subsequently acquires the mutex Thread holding the mutex dies prematurely without unlocking the The program below demonstrates the use of the robustnessĪttribute of a mutex attributes object. Glibc 2.34 these APIs are marked as deprecated. Nowadays obsolete and should not be used in new programs since These GNU-specific APIs, which first appeared in glibc 2.4, are PTHREAD_MUTEX_ROBUST_NP were also defined. Int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t * attr, int * robustness ) int pthread_mutexattr_setrobust_np(const pthread_mutexattr_t * attr, int robustness ) Ĭorrespondingly, the constants PTHREAD_MUTEX_STALLED_NP and Pthread_mutexattr_setrobust() to POSIX, glibc defined theįollowing equivalent nonstandard functions if _GNU_SOURCE was POSIX.1 does not specify thisĭetail, but the same behavior also occurs in at least some otherīefore the addition of pthread_mutexattr_getrobust() and Notification if the owner of a robust mutex performs an execve(2) Mutexes, a waiting thread also receives the EOWNERDEAD In the Linux implementation, when using process-shared robust VERSIONS top pthread_mutexattr_getrobust() and pthread_mutexattr_setrobust() In the glibc implementation, pthread_mutexattr_getrobust() alwaysĮRRORS top EINVAL A value other than PTHREAD_MUTEX_STALLED or Object that was initialized by pthread_mutexattr_init(3), Pthread_mutexattr_setrobust() should refer to a mutex attributes Note that the attr argument of pthread_mutexattr_getrobust() and

Operations on this mutex will still return EOWNERDEAD. Pthread_mutex_consistent(3), further pthread_mutex_lock(3) If the next owner terminates before calling Operation on such a mutex is pthread_mutex_destroy(3). Mutex will be permanently unusable and any subsequentĪttempts to lock it using pthread_mutex_lock(3) will fail Pthread_mutex_unlock(3) before making it consistent, the If the next owner unlocks the mutex using The acquired mutex to make it consistent again before The next owner should call pthread_mutex_consistent(3) on The original owner no longer exists and the mutex is in an

Mutex will succeed and return EOWNERDEAD to indicate that If a mutex is initialized with the PTHREAD_MUTEX_ROBUSTĪttribute and its owner dies without unlocking it, anyįuture attempts to call pthread_mutex_lock(3) on this Mutex remains locked afterwards and any future attempts toĬall pthread_mutex_lock(3) on the mutex will block If a mutex is initialized with the PTHREAD_MUTEX_STALLEDĪttribute and its owner dies without unlocking it, the

This is the default value for a mutex attributes object. Theįollowing values are valid for robustness: The owning thread dies without unlocking the mutex.

The robustness attribute specifies the behavior of the mutex when The pthread_mutexattr_setrobust()įunction sets the value of the robustness attribute of the mutexĪttributes object referred to by attr to the value specified in The robustness attribute of the mutex attributes object referred The pthread_mutexattr_getrobust() function places the value of Pthread_mutexattr_getrobust(), pthread_mutexattr_setrobust(): SYNOPSIS top #include int pthread_mutexattr_getrobust(const pthread_mutexattr_t * attr, int * robustness ) int pthread_mutexattr_setrobust(pthread_mutexattr_t * attr, int robustness ) įeature Test Macro Requirements for glibc (see Pthread_mutexattr_getrobust, pthread_mutexattr_setrobust - getĪnd set the robustness attribute of a mutex attributes object PTHREAD_MUTEXATTR_SETROBUST(3)Programmer'sPManual_MUTEXATTR_SETROBUST(3) NAME top
