pthread_mutexattr_settype()

set mutex type attribute of mutex attribute object 

Function


SYNOPSIS

#include <pthread.h>

int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);


DESCRIPTION

The pthread_mutexattr_settype() function sets the mutex type attribute in the specified mutex attribute object. Valid settings for type include:

PTHREAD_MUTEX_NORMAL  

This type of mutex does not detect deadlock. An attempt to relock this mutex without first unlocking it deadlocks. Attempting to unlock a mutex locked by a different thread results in undefined behavior. Attempting to unlock an unlocked mutex results in undefined behavior.

PTHREAD_MUTEX_ERRORCHECK  

This type of mutex provides error checking. An attempt to relock this mutex without first unlocking it returns with an error. An attempt to unlock a mutex that another thread has locked returns with an error. An attempt to unlock an unlocked mutex returns with an error.

PTHREAD_MUTEX_RECURSIVE  

A thread attempting 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 cannot occur with this type of mutex. Multiple locks of this mutex require the same number of unlocks to release the mutex before another thread can acquire the mutex. An attempt to unlock a mutex that another thread has locked returns with an error. An attempt to unlock an unlocked mutex returns with an error.

PTHREAD_MUTEX_DEFAULT  

Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a mutex of this type that was not locked by the calling thread results in undefined behavior. Attempting to unlock a mutex of this type that is not locked results in undefined behavior.


PARAMETERS

attr 
Is a mutex attribute object.
type 
The mutex type attribute value; one of the values specified above.


RETURN VALUES

On success, pthread_mutexattr_settype() returns 0. On error, one of the following values is returned:

EINVAL 

attr is not an initialized mutex attribute object, or type is not a valid mutex type setting.

EFAULT 

attr is an invalid pointer.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_mutex_init(), pthread_mutexattr_gettype(), pthread_mutexattr_init()


PTC MKS Toolkit 10.5 Documentation Build 40.