pthread_mutex_init(3) — Subroutines
Digital
NAME
pthread_mutex_init − Creates a mutex.
SYNOPSIS
#include <pthread.h>
int thread_mutex_init(
pthread_mutex_t ∗mutex ,
pthread_mutexattr_t attr );
PARAMETERS
mutexMutex created.
attrMutex attributes object that defines the characteristics of the created mutex. If you specify pthread_mutexattr_default, default attributes are used.
DESCRIPTION
This routine creates a mutex and initializes it to the unlocked state.
The created mutex is not automatically deallocated because it is considered shared among multiple threads if the thread that called this routine terminates.
RETURN VALUES
If an error condition occurs, this routine returns −1, the mutex is not initialized, and the contents of mutex are undefined. This routine sets errno to the corresponding error value. Possible return values are as follows:
| Return | Error | Description |
| 0 | Successful completion. | |
| −1 | [EAGAIN] | The system lacks the necessary resources to initialize another mutex. |
| The system-imposed limit on the total number of mutexes under execution by a single user is exceeded. | ||
| −1 | [ENOMEM] | Insufficient memory exists to initialize the mutex. |
RELATED INFORMATION
pthread_mutexattr_create(3), pthread_mutexattr_getkind_np(3), pthread_mutexattr_setkind_np(3), pthread_mutex_lock(3), pthread_mutex_trylock(3), pthread_mutex_unlock(3)