PTHREAD_MUTEXATTR_GETROBUST(3C) Standard C Library Functions

NAME


pthread_mutexattr_getrobust, pthrad_mutexattr_setrobust - get and set the
mutex robust attribute

SYNOPSIS


#include <pthread.h>

int
pthread_mutexattr_getrobust(const pthread_mutexattr_t *attr, int *robust);

int
pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust);

DESCRIPTION


The pthread_mutexattr_getrobust() and pthread_mtuexattr_setrobust()
functions obtain and set a mutex's robust attribute, putting it in, or
obtaining it from robust. The valid values for robust include:

PTHREAD_MUTEX_STALLED
The mutex referred to by attr is a traditional mutex. When a
thread holding an intra-process lock or a process holding an
inter-process lock crashes or terminates without unlocking
the mutex, then the lock will be stalled. For another thread
or process to obtain the lock, something else must unlock it.

PTHREAD_MUTEX_ROBUST
The mutex referred to by attr is considered a robust mutex.
When a process holding an inter-process lock crashes or
terminates without unlocking the mutex, the attempt to lock
it will return EOWNERDEAD. This allows the new owner the
chance to fix the internal state and call
pthread_mutex_consistent(3C) prior to unlocking the lock,
allowing normal operation to proceed. Any crashes while in
this state cause the next owner to obtain EOWNERDEAD.

RETURN VALUES


Upon successful completion, the pthread_mutexattr_getrobust() function will
return 0 and update robust with the current value of the robust attribute.
Upon successful completion, the pthread_mutexattr_setrobust() function will
return 0 and update the robust property of the attributes pointed to by
attr to robust. If either function fails, an error code will be returned
to indicate the error. Valid errors are defined below.

ERRORS


The pthread_mutexattr_getrobust() function will fail if:

EINVAL attr is invalid or a null pointer, robust is a null
pointer.

The pthread_mutexattr_setrobust() function will fail if:

EINVAL attr is invalid or a null pointer, robust is not one of
PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST.

INTERFACE STABILITY


Committed

MT-LEVEL
MT-Safe

SEE ALSO


pthread_mutex_consistent(3C), pthread(3HEAD), libpthread(3LIB),
attributes(5), mutex(5)

illumos December 22, 2014 illumos