Set the robust attribute in a mutex attribute object
#include <pthread.h> int pthread_mutexattr_setrobust( pthread_mutexattr_t *attr, int robust );
For more information, see below.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The pthread_mutexattr_setrobust() function sets the robust attribute in the mutex attribute object attr:
The notified thread can then attempt to mark the state protected by the mutex as consistent again by a call to pthread_mutex_consistent(). After a subsequent successful call to pthread_mutex_unlock(), the mutex lock is released and can be used normally by other threads.
If the mutex is unlocked without a call to pthread_mutex_consistent(), it remains in a permanently unusable state and all attempts to lock the mutex fail with the error ENOTRECOVERABLE. The only permissible operation on such a mutex is pthread_mutex_destroy().
You can use pthread_mutexattr_getrobust() to get the value of this attribute. The behavior of a mutex also depends on its type; see pthread_mutexattr_settype().
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |