Wednesday, August 31, 2016

C Library Header – threads

The <threads.h> header defines functions for managing multiple Threads as well as mutexes and condition variables.

The <threads.h> header shall define the following macro constants:
indicates a thread error status (C11)
thread_localthread local type macro (C11)
TSS_DTOR_ITERATIONSmaximum number of times destructors are called (C11)

The <threads.h> header shall define the following functions:
thrd_createcreates a thread (C11)
thrd_equalchecks if two identifiers refer to the same thread (C11)
thrd_currentobtains the current thread identifier (C11)
thrd_sleepsuspends execution of the calling thread for the given period of time (C11)
thrd_yieldyields the current time slice (C11)
thrd_exitterminates the calling thread (C11)
thrd_detachdetaches a thread (C11)
thrd_joinblocks until a thread terminates (C11)
mtx_init creates a mutex (C11)
mtx_lock blocks until locks a mutex (C11)
mtx_timedlock blocks until locks a mutex or times out (C11)
mtx_trylock locks a mutex or returns without blocking if already locked (C11)
mtx_unlock unlocks a mutex (C11)
mtx_destroy destroys a mutex (C11)
cnd_init creates a condition variable (C11)
cnd_signal unblocks one thread blocked on a condition variable (C11)
cnd_broadcast unblocks all threads blocked on a condition variable (C11)
cnd_wait blocks on a condition variable (C11)
cnd_timedwait blocks on a condition variable, with a timeout (C11)
cnd_destroy destroys a condition variable (C11)
tss_create creates thread-specific storage pointer with a given destructor (C11)
tss_get reads from thread-specific storage (C11)
tss_set write to thread-specific storage (C11)
tss_delete releases the resources held by a given thread-specific pointer (C11)

The <threads.h> header shall define the following type:
thrd_t implementation-defined complete object type identifying a thread
thrd_start_t a typedef of the function pointer type int(*)(void*), used by thrd_create (C11)
mtx_t mutex identifier
defines the type of a mutex (enum)(C11)
cnd_t condition variable identifier
tss_t thread-specific storage pointer
tss_dtor_t function pointer type void(*)(void*), used for TSS destructor

Related topics:
<tgmath.h>   |   <time.h>   |   <uchar.h>   |   <wchar.h>   |   <wctype.h>   |   Standard Library in C

List of topics: C Programming

No comments:

Post a Comment