Set a mutex type
pthread_mutexattr_t * attr,
int type );
- A pointer to the pthread_mutexattr_t object that you
want to set the attribute in.
- The new type; one of:
- PTHREAD_MUTEX_NORMAL — no deadlock detection.
A thread that attempts to relock this mutex without first unlocking it
Attempts to unlock a mutex locked by a different thread or attempts to
unlock an unlocked mutex result in undefined behavior.
- PTHREAD_MUTEX_ERRORCHECK — provides error checking.
A thread returns with an error when it attempts to
relock this mutex without first unlocking it, unlock a mutex that another
thread has locked, or unlock an unlocked mutex.
- PTHREAD_MUTEX_RECURSIVE — a thread that attempts
to relock this mutex without first unlocking it succeeds in
locking the mutex. The relocking deadlock that can occur with mutexes of type
PTHREAD_MUTEX_NORMAL can't occur with this mutex type. Multiple locks
of this mutex require the same number of unlocks to release the mutex before
another thread can acquire the mutex. A thread that attempts to unlock a mutex that
another thread has locked, or unlock an unlocked mutex, returns with an error.
- PTHREAD_MUTEX_DEFAULT — the default value of the
In QNX Neutrino, PTHREAD_MUTEX_DEFAULT mutexes are
treated in the same way as PTHREAD_MUTEX_ERRORCHECK ones.
Use the -l c option to
to link against this library.
This library is usually included automatically.
The pthread_mutexattr_settype() function sets the mutex type
in the mutex attribute object attr to the value given by
- The value specified by attr or type is invalid.
POSIX 1003.1 XSI
An application shouldn't use a PTHREAD_MUTEX_RECURSIVE mutex
with condition variables because the implicit unlock performed for a
may not actually release the mutex (if it's been locked multiple times).
If this happens, no other thread can satisfy the condition of the predicate.