##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# 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.

### [edit] Threads

Defined in header `<threads.h>`
`thrd_t` | a type identifying a thread [edit]
thrd_create (C11) | creates a thread (function) [edit]
thrd_equal (C11) | checks if two identifiers refer to the same thread (function) [edit]
thrd_current (C11) | obtains the current thread identifier (function) [edit]
thrd_sleep (C11) | suspends execution of the calling thread for the given period of time (function) [edit]
thrd_yield (C11) | yields the current time slice (function) [edit]
thrd_exit (C11) | terminates the calling thread (function) [edit]
thrd_detach (C11) | detaches a thread (function) [edit]
thrd_join (C11) | blocks until a thread terminates (function) [edit]
thrd_success thrd_timedout thrd_busy thrd_nomem thrd_error (C11) | indicates a thread error status (constant) [edit]
thrd_start_t (C11) | function pointer type passed to thrd_create (typedef) [edit]

### [edit] Mutual exclusion

Defined in header `<threads.h>`
`mtx_t` | mutex identifier [edit]
mtx_init (C11) | creates a mutex (function) [edit]
mtx_lock (C11) | blocks until locks a mutex (function) [edit]
mtx_timedlock (C11) | blocks until locks a mutex or times out (function) [edit]
mtx_trylock (C11) | locks a mutex or returns without blocking if already locked (function) [edit]
mtx_unlock (C11) | unlocks a mutex (function) [edit]
mtx_destroy (C11) | destroys a mutex (function) [edit]
mtx_plain mtx_recursive mtx_timed (C11)(C11)(C11) | defines the type of a mutex (enum) [edit]
##### Call once
`once_flag` | the type of the flag used by call_once [edit]
ONCE_FLAG_INIT (C11) | initializes a once_flag (macro constant) [edit]
call_once (C11) | calls a function exactly once (function) [edit]

### [edit] Condition variables

Defined in header `<threads.h>`
`cnd_t` | condition variable identifier
cnd_init (C11) | creates a condition variable (function) [edit]
cnd_signal (C11) | unblocks one thread blocked on a condition variable (function) [edit]
cnd_broadcast (C11) | unblocks all threads blocked on a condition variable (function) [edit]
cnd_wait (C11) | blocks on a condition variable (function) [edit]
cnd_timedwait (C11) | blocks on a condition variable, with a timeout (function) [edit]
cnd_destroy (C11) | destroys a condition variable (function) [edit]

### [edit] Thread-local storage

Defined in header `<threads.h>`
thread_local (C11) | thread local type macro (macro constant) [edit]
`tss_t` | thread-specific storage pointer [edit]
TSS_DTOR_ITERATIONS (C11) | maximum number of times destructors are called (macro constant) [edit]
`tss_dtor_t` | function pointer type used for TSS destructor [edit]
tss_create (C11) | creates thread-specific storage pointer with a given destructor (function) [edit]
tss_get (C11) | reads from thread-specific storage (function) [edit]
tss_set (C11) | write to thread-specific storage (function) [edit]
tss_delete (C11) | releases the resources held by a given thread-specific pointer (function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/thread&oldid=56883"