Initialize a mutex attribute object
#include <pthread.h> int pthread_mutexattr_init( pthread_mutexattr_t* attr );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The pthread_mutexattr_init() function initializes the attributes in the mutex attribute object attr to their default values. After calling this function, you can use the pthread_mutexattr_* family of functions to make any changes to the attributes:
Attribute | Default | Get | Set |
---|---|---|---|
Priority ceiling | None | pthread_mutexattr_getprioceiling() | pthread_mutexattr_setprioceiling() |
Protocol | PTHREAD_PRIO_INHERIT | pthread_mutexattr_getprotocol() | pthread_mutexattr_setprotocol() |
Process-shared | PTHREAD_PROCESS_PRIVATE | pthread_mutexattr_getpshared() | pthread_mutexattr_setpshared() |
Recursiveness | PTHREAD_RECURSIVE_DISABLE | pthread_mutexattr_getrecursive() | pthread_mutexattr_setrecursive() |
Type | PTHREAD_MUTEX_DEFAULT | pthread_mutexattr_gettype() | pthread_mutexattr_settype() |
Wake-up | PTHREAD_WAKEUP_DISABLE | pthread_mutexattr_getwakeup_np() | pthread_mutexattr_setwakeup_np() |
The default values include:
After initializing a mutex attribute object, you can use it to initialize one or more mutexes by calling pthread_mutex_init().
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pthread_mutex_init(), pthread_mutexattr_destroy(), pthread_mutexattr_getprioceiling(), pthread_mutexattr_getprotocol(), pthread_mutexattr_getpshared(), pthread_mutexattr_getrecursive(), pthread_mutexattr_gettype(), pthread_mutexattr_getwakeup_np(), pthread_mutexattr_setprioceiling(), pthread_mutexattr_setprotocol(), pthread_mutexattr_setpshared(), pthread_mutexattr_setrecursive(), pthread_mutexattr_settype(), pthread_mutexattr_setwakeup_np()
“Mutexes: mutual exclusion locks” in the QNX Neutrino Microkernel chapter of the System Architecture guide