Thread support library

From cppreference.com
< c

If the macro constant __STDC_NO_THREADS__(C11) is defined by the compiler, the header <threads.h> and all of the names listed here are not provided.

Threads

Defined in header <threads.h>
thrd_t implementation-defined complete object type identifying a thread
creates a thread
(function)
checks if two identifiers refer to the same thread
(function)
obtains the current thread identifier
(function)
suspends execution of the calling thread for the given period of time
(function)
yields the current time slice
(function)
terminates the calling thread
(function)
detaches a thread
(function)
blocks until a thread terminates
(function)
indicates a thread error status
(constant)
thrd_start_t
(C11)
a typedef of the function pointer type int(*)(void*), used by thrd_create
(typedef)

Mutual exclusion

Defined in header <threads.h>
mtx_t mutex identifier
creates a mutex
(function)
blocks until locks a mutex
(function)
blocks until locks a mutex or times out
(function)
locks a mutex or returns without blocking if already locked
(function)
unlocks a mutex
(function)
destroys a mutex
(function)
defines the type of a mutex
(enum)
Call once
calls a function exactly once
(function)

Condition variables

Defined in header <threads.h>
cnd_t condition variable identifier
creates a condition variable
(function)
unblocks one thread blocked on a condition variable
(function)
unblocks all threads blocked on a condition variable
(function)
blocks on a condition variable
(function)
blocks on a condition variable, with a timeout
(function)
destroys a condition variable
(function)

Thread-local storage

Defined in header <threads.h>
thread local type macro
(keyword macro)
tss_t thread-specific storage pointer
maximum number of times destructors are called
(macro constant)
tss_dtor_t function pointer type void(*)(void*), used for TSS destructor
creates thread-specific storage pointer with a given destructor
(function)
reads from thread-specific storage
(function)
write to thread-specific storage
(function)
releases the resources held by a given thread-specific pointer
(function)

Reserved identifiers

Function names, type names, and enumeration constants that begin with either cnd_, mtx_, thrd_, or tss_, and a lowercase letter may be added to the declarations in the <threads.h> header in future revisions of the C standard, and portable programs should not use those identifiers.

References

  • C11 standard (ISO/IEC 9899:2011):
  • 7.26 Threads <threads.h> (p: 376-387)
  • 7.31.15 Threads <threads.h> (p: 456)

See also