#include <pthread.h> int pthread_mutexatttr_settype(pthread_mutexattr_t *attr, int type);Service Program Name: QP0WPTHR
The pthread_mutexattr_settype() function sets the type attribute in the mutex attributes object specified by attr. The mutex type attribute is used to create mutexes with different behaviors.
The type will be one of PTHREAD_MUTEX_DEFAULT, PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or PTHREAD_MUTEX_OWNERTERM_NP or the EINVAL error will be returned.
The default mutex type (or PTHREAD_MUTEX_DEFAULT) is PTHREAD_MUTEX_NORMAL.
A normal mutex cannot be locked repeatedly by the owner. Attempts by a thread to relock an already held mutex, or to lock a mutex that was held by another thread when that thread terminated result in a deadlock condition.
A recursive mutex can be locked repeatedly by the owner. The mutex does not become unlocked until the owner has called pthread_mutex_unlock() for each successful lock request that it has outstanding on the mutex.
An errorcheck mutex checks for deadlock conditions that occur when a thread re-locks an already held mutex. If a thread attempts to relock a mutex that it already holds, the lock request fails with the EDEADLK error.
An ownerterm mutex is an i5/OS extension to the errorcheck mutex type. An ownerterm mutex checks for deadlock conditions that occur when a thread re-locks an already held mutex. If a thread attempts to relock a mutex that it already holds, the lock request fails with the EDEADLK error. An ownerterm mutex also checks for deadlock conditions that occur when a thread attempts to lock a mutex that was held by another thread when that thread terminated (an orphaned mutex). If a thread attempts to lock an orphaned mutex, the lock request fails with the EOWNERTERM error.
None.
If pthread_mutexatttr_settype() was not successful, the error condition returned usually indicates one of the following errors. Under some conditions, the value returned could indicate an error other than those listed here.
The value specified for the argument is not correct.
See Code disclaimer information for information pertaining to code examples.
See pthread_mutexattr_gettype() for an example.
Top | Pthread APIs | APIs by category |