Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

mtx_unlock(3C)

Name

mtx_init, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, mtx_destroy - C11 mutex functions

Synopsis

#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);

Description

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.

C11 Threads
POSIX Threads
mtx_init()
pthread_mutex_init()
mtx_lock()
pthread_mutex_lock()
mtx_timedlock()
pthread_mutex_timedlock()
mtx_trylock()
pthread_mutex_trylockl()
mtx_unlock()
pthread_mutex_unlock()
mtx_destroy()
pthread_mutex_destroy()

Return Values

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.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe

See Also

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)