Mutex synchronization APIs

Thread synchronization is required whenever two threads share a resource or need to be aware of what the other threads in a process are doing. Mutexes are the most simple and primitive object used for the co-operative mutual exclusion required to share and protect resources. One thread owns a mutex by locking it successfully, when another thread tries to lock the mutex, that thread will not be allowed to successfully lock the mutex until the owner unlocks it. The mutex support provides different types and behaviors for mutexes that can be tuned to your application requirements.

The table below lists important mutex attributes, their default values, and all supported values.

Attribute Default value Supported values
pshared PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED
kind (non portable) PTHREAD_MUTEX_NONRECURSIVE_NP PTHREAD_MUTEX_NONRECURSIVE_NP or PTHREAD_MUTEX_RECURSIVE_NP
name (non portable) PTHREAD_DEFAULT_MUTEX_NAME_NP "QP0WMTX UNNAMED" Any name that is 15 characters or less. If not terminated by a null character, name is truncated to 15 characters.
type PTHREAD_MUTEX_DEFAULT
(PTHREAD_MUTEX_NORMAL)
PTHREAD_MUTEX_DEFAULT or PTHREAD_MUTEX_NORMAL or PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_OWNERTERM_NP

The PTHREAD_MUTEX_OWNERTERM_NP attribute value is non portable.

For information about the examples included with the APIs, see the information on the API examples.

The Mutex synchronization APIs are:


Top | Pthread APIs | APIs by category