pthread_mutexattr_init()
QNX SDP8.0C Library ReferenceAPIDeveloper
Initialize a mutex attribute object
Synopsis:
#include <pthread.h>
int pthread_mutexattr_init( pthread_mutexattr_t* attr );
Arguments:
- attr
 - A pointer to the pthread_mutexattr_t object that you want to initialize.
 
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
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() | 
| Robustness | PTHREAD_MUTEX_STALLED | pthread_mutexattr_getrobust() | pthread_mutexattr_setrobust() | 
| 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:
- PTHREAD_PRIO_INHERIT
 - When a thread is blocking higher-priority threads by locking one or more mutexes with this attribute, the thread's priority is raised to that of the highest priority thread waiting on the PTHREAD_PRIO_INHERIT mutex.
 - PTHREAD_RECURSIVE_DISABLE
 - Threads can't recursively lock a mutex; any thread that tries to lock an already locked mutex becomes blocked.
 
Note: 
Robust mutexes and mutexes with priority ceilings use more system resources than other mutexes.
After initializing a mutex attribute object, you can use it to initialize one or more mutexes by calling pthread_mutex_init().
Returns:
- EOK
 - Success.
 - ENOMEM
 - Insufficient memory to initialize mutex attribute object attr.
 
Classification:
| Safety: | |
|---|---|
| Cancellation point | No | 
| Signal handler | Yes | 
| Thread | Yes | 
Page updated: 
