Main index | Section 3 | Options |
#include <threads.h>
In this implementation, the threading interface is therefore implemented as a light-weight layer on top of existing interfaces. The functions to which these routines are mapped, are listed in the following table. Please refer to the documentation of the POSIX equivalent functions for more information.
Function | POSIX equivalent |
call_once() | pthread_once(3) |
cnd_broadcast() | pthread_cond_broadcast(3) |
cnd_destroy() | pthread_cond_destroy(3) |
cnd_init() | pthread_cond_init(3) |
cnd_signal() | pthread_cond_signal(3) |
cnd_timedwait() | pthread_cond_timedwait(3) |
cnd_wait() | pthread_cond_wait(3) |
mtx_destroy() | pthread_mutex_destroy(3) |
mtx_init() | pthread_mutex_init(3) |
mtx_lock() | pthread_mutex_lock(3) |
mtx_timedlock() | pthread_mutex_timedlock(3) |
mtx_trylock() | pthread_mutex_trylock(3) |
mtx_unlock() | pthread_mutex_unlock(3) |
thrd_create() | pthread_create(3) |
thrd_current() | pthread_self(3) |
thrd_detach() | pthread_detach(3) |
thrd_equal() | pthread_equal(3) |
thrd_exit() | pthread_exit(3) |
thrd_join() | pthread_join(3) |
thrd_sleep() | nanosleep(2) |
thrd_yield() | pthread_yield(3) |
tss_create() | pthread_key_create(3) |
tss_delete() | pthread_key_delete(3) |
tss_get() | pthread_getspecific(3) |
tss_set() | pthread_setspecific(3) |
The mutex created by mtx_init() can be of type mtx_plain or mtx_timed to distinguish between a mutex that supports mtx_timedlock(). This type can be or'd with mtx_recursive to create a mutex that allows recursive acquisition. These properties are normally set using pthread_mutex_init()'s attr parameter.
The thrd_current() function returns the thread ID of the calling thread.
The tss_get() function returns the thread-specific data value associated with the given key. If no thread-specific data value is associated with key, then the value NULL is returned.
thrd_nomem | The system has insufficient memory. |
The cnd_timedwait() and mtx_timedlock() functions will fail if:
thrd_timedout | |
The system time has reached or exceeded the time specified in ts before the operation could be completed. | |
The mtx_trylock() function will fail if:
thrd_busy | The mutex is already locked. |
In all other cases, these functions may fail by returning general error code thrd_error.
THRD_CREATE (3) | December 26, 2011 |
Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | I define UNIX as “30 definitions of regular expressions living under one roof.” | ” |
— Donald Knuth |