[Previous] [Contents] [Next]

pthread_mutex_init()

Initialize mutex

Synopsis:

#include <pthread.h>

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

int pthread_mutex_init(
            pthread_mutex_t* mutex,
            const pthread_mutexattr_t* attr );

Library:

libc

Description:

The pthread_mutex_init() function initializes the mutex mutex using the attributes specified by the mutex attributes object attr. If attr is NULL then the mutex is initialized with the default attributes (see pthread_mutexattr_init()). After initialization the mutex is in an unlocked state.

A statically allocated mutex may be initialized with the default attributes by assigning it the macro PTHREAD_MUTEX_INITIALIZER or PTHREAD_RMUTEX_INITIALIZER (for recursive mutexes).

Returns:

EOK
Success.
EAGAIN
All kernel synchronization objects are in use.
EBUSY
Previously initialized but undestroyed mutex mutex.
EFAULT
A fault occurred when the kernel tried to access mutex or attr.
EINVAL
The value specified by attr is invalid.

Classification:

POSIX 1003.1 (Threads)

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pthread_mutexattr_init(), pthread_mutex_destroy(), SyncTypeCreate()


[Previous] [Contents] [Next]