Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (n - p) pthread_mutex_init(2)
NAME
pthread_mutex_init - Initializes a mutex
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_mutex_init(
pthread_mutex_t *mutex,
const pthread_mutexattr_t *
attr);
PARAMETERS
mutex specifies the mutex to be initialized.
attr specifies the mutex attributes object that defines the characteristics of the mutex
to be initialized.
DESCRIPTION
This function initializes a mutex with the attributes of the mutex attributes object specified by the
attr parameter. A mutex is a synchronization object that allows multiple threads to serialize their
access to shared data.
A mutex is a resource of the process, not part of any particular thread. A mutex is neither des-
troyed nor unlocked automatically when any thread exits. If a mutex is allocated on a stack,
static initializers cannot be used on the mutex.
The mutex is initialized and set to the unlocked state. If attr is NULL, the default mutex attri-
butes are used.
NOTES
Use the PTHREAD_MUTEX_INITIALIZER macro to statically initialize a mutex without
calling this function. Use this macro as follows:
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
Only normal mutexes can be statically initialized.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error, the
mutex is not initialized, and the contents of mutex are undefined. Possible return values are:
0 Successful completion.
[EAGAIN] The system lacks the necessary resources to initialize the mutex.
[EBUSY] The system detected an attempt to reinitialize a mutex (an attempt to initialize a
previously initialized but not yet destroyed mutex).
[EINVAL] The value specified by the attr parameter is invalid.
[ENOMEM] Insufficient memory exists to initialize the mutex.
[EPERM] The caller does not have the required privileges to perform the operation.
527186-003 Hewlett-Packard Company 5−77