mtx_init, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, mtx_destroy - C11 mutex functions
#include <threads.h>
int mtx_init(mtx_t *mtx, int type);
int mtx_lock(mtx_t *mtx);
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts);
int mtx_trylock(mtx_t *mtx);
int mtx_unlock(mtx_t *mtx);
void mtx_destroy(mtx_t *mtx);
The mtx_init(), mtx_lock(), mtx_timedlock(), mtx_trylock(), mtx_unlock(), and mtx_destroy() functions are part of the threads interfaces as specified in the C11 standard. They are simple wrappers over the more general pthreads functions. See INCITS/ISO/IEC 9899:2011.
|
Upon successful completion, each of the mtx_init(), mtx_lock(), mtx_timedlock(), mtx_trylock(), and mtx_unlock() functions return thrd_success. If the requested resource is not acquired in the time specified by ts, the mtx_timedlock() function returns thrd_timedout. If the resource requested by mtx_trylock() is already in use, mtx_trylock() returns thrd_busy. If the request could not otherwise be honored by any of these functions, thrd_error is returned.
No value is returned by the mtx_destroy() function.
See attributes(7) for descriptions of the following attributes:
|
pthread_mutex_destroy(3C), pthread_mutex_init(3C), pthread_mutex_lock(3C), pthread_mutex_timedlock(3C), pthread_mutex_trylock(3C), pthread_mutex_unlock(3C), threads.h(3HEAD), attributes(7)