Adelsbach Enhanced Threading Library

Manual Pages (DD-00013-001)

Enhanced Threading Library > mtx_init (3)
HTML TXT PDF PS
mtx_init(3) Library Functions Manual mtx_init(3)

mtx_initinitialize a mutex

library “threads”
#include <threads.h>

int
mtx_init(mtx_t *mtx, int type);

The function () initializes a mutex mtx of the given type.

The type argument can be either of

a simple mutex, can be shared across child processes.
a simple mutex, can be shared across child processes, allows timed locking.
|
a simple mutex, can be shared across child processes, the same thread can acquire the lock multiple times recursively. It must be unlocked by an equal amount of times by the thread.
|
a simple mutex, can be shared across child processes, allows timed locking, the same thread can acquire the lock multiple times recursively. It must be unlocked by an equal amount of times by the thread.

Upon success mtx_init() returns thrd_success, if there is insufficient memory it will return thrd_nomem in case of any other error thrd_error will be returned.

mtx_destroy(3) mtx_lock(3) mtx_timedlock(3) mtx_trylock(3) mtx_unlock(3)

The mtx_init() function first appeared in the C11 standard ISO/IEC 9899:2011.

Jan Adelsbach <jan@jadelsbach.de>

May 9, 2020 Debian