mtx_init(3) | Library Functions Manual | mtx_init(3) |
NAME
mtx_init
—
initialize a mutex
SYNOPSIS
library “threads”
#include <threads.h>
int
mtx_init
(mtx_t
*mtx, int
type);
DESCRIPTION
The function
mtx_init
()
initializes a mutex mtx of the given
type.
The type argument can be either of
- mtx_plain
- a simple mutex, can be shared across child processes.
- mtx_timed
- a simple mutex, can be shared across child processes, allows timed locking.
- mtx_plain | mtx_recursive
- 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.
- mtx_timed | mtx_recursive
- 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.
RETURN VALUES
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.
SEE ALSO
mtx_destroy(3) mtx_lock(3) mtx_timedlock(3) mtx_trylock(3) mtx_unlock(3)
HISTORY
The mtx_init
() function first appeared in
the C11 standard ISO/IEC 9899:2011.
AUTHORS
Jan Adelsbach <jan@jadelsbach.de>
May 9, 2020 | Debian |