Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
pthread_mutexattr_settype(2) OSS System Calls Reference Manual
NAME
pthread_mutexattr_settype - Sets the mutex type attribute of a mutex attribute object
LIBRARY
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yputdll
SYNOPSIS
#include <pthread.h>
int pthread_mutexattr_settype(
pthread_mutexattr_t *attr,
int type);
PARAMETERS
attr Specifies the address of a pthread mutex attribute object whose mutex type attri-
bute is to be updated.
type Specifies the mutex type that is used to update the type attribute for the attr
parameter value.
DESCRIPTION
The pthread_mutexattr_settype() function sets the mutex type attribute of the mutex attribute
object specified by the attr parameter.
The following are the valid type parameter values and their characteristics:
PTHREAD_MUTEX_NORMAL
A normal mutex does not detect deadlock. If a thread attempts to relock a nor-
mal mutex without first unlocking it, the thread deadlocks. If a thread attempts to
unlock a normal mutex locked by a different thread, the result is undefined
behavior. If a thread attempts to unlock an unlocked normal mutex, the result is
undefined behavior.
PTHREAD_MUTEX_ERRORCHECK
An error checking mutex returns error checking. If a thread attempts to relock an
error checking mutex without first unlocking it, the function returns an error. If a
thread attempts to unlock an error checking mutex locked by a different thread,
the function returns an error. If a thread attempts to unlock an unlocked error
checking mutex, the function returns an error.
PTHREAD_MUTEX_RECURSIVE
A recursive mutex can be locked more than once by the same thread without
returning an error. If a thread attempts to relock a recursive mutex without first
unlocking it, the thread succeeds in locking the mutex. The relocking deadlock
that can occur with normal mutexes cannot occur with this type of mutex. Multi-
ple locks of a recursive mutex require the same number of unlocks to release the
mutex before another thread can acquire the mutex. If a thread attempts to
unlock a recursive mutex that another thread has locked, the function returns an
error. If a thread attempts to unlock an unlocked recursive mutex, the function
returns an error.
PTHREAD_MUTEX_DEFAULT
A default mutex can be locked only once. If a thread attempts to relock a default
mutex, the result is undefined behavior. If a thread attempts to unlock a default
mutex locked by a different thread, the result is undefined behavior. If a thread
attempts to unlock an unlocked default mutex, the result is undefined behavior.
An implementation can map this mutex to one of the other mutex types.
5−150 Hewlett-Packard Company 527186-023