Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (n - p) pthread_mutexattr_gettype(2)
NAME
pthread_mutexattr_gettype - Gets 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_gettype(
const 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 obtained.
type Specifies the mutex type based on the type value retrieved from the attr parame-
ter value.
DESCRIPTION
The pthread_mutexattr_gettype() function gets the mutex type attribute of the mutex attribute
object specified by the attr parameter.
The following are the valid values for the type parameter 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 provides 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.
527186-023 Hewlett-Packard Company 5−143