pthread_mutexattr_getrobust()
Get the robust attribute from a mutex attribute object
Synopsis:
#include <pthread.h>
int pthread_mutexattr_getrobust( const pthread_mutexattr_t *attr,
int *robust );
Arguments:
- attr
- A pointer to the pthread_mutexattr_t object that you want to get the attribute from.
- robust
- A pointer to a location where the function can store the robust attribute.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The pthread_mutexattr_getrobust() function gets the robust attribute from the mutex attribute object attr and stores it in robust. You can use pthread_mutexattr_setrobust() to set this attribute.
The valid values for the robust attribute are:
- PTHREAD_MUTEX_STALLED
- No special actions are taken if the owner of the mutex is terminated while holding the mutex lock. This can lead to deadlocks if no other thread can unlock the mutex. This is the default value.
- PTHREAD_MUTEX_ROBUST
- If the process containing the owning thread of a robust mutex terminates while holding the mutex
lock, the next thread that acquires the mutex is notified about the termination by the return value
EOWNERDEAD from the locking function.
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 subsequent and in-progress attempts to lock the mutex will either fail with the error ENOTRECOVERABLE or will be left mutex-blocked. The only permissible operation on such a mutex is pthread_mutex_destroy().
Returns:
- EOK
- Success.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |