posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
pthread.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) The Zephyr Project Contributors
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
19#ifndef ZEPHYR_INCLUDE_POSIX_PTHREAD_H_
20#define ZEPHYR_INCLUDE_POSIX_PTHREAD_H_
21
22#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
23
24#include <time.h>
25#include <sched.h>
26
27#include <zephyr/posix/sys/_pthreadtypes.h>
28#if defined(_GNU_SOURCE) || defined(__DOXYGEN__)
30#endif
31#include <zephyr/toolchain.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
39#define PTHREAD_BARRIER_SERIAL_THREAD 1
41#define PTHREAD_CANCEL_ASYNCHRONOUS 1
43#define PTHREAD_CANCEL_ENABLE 0
45#define PTHREAD_CANCEL_DEFERRED 0
47#define PTHREAD_CANCEL_DISABLE 1
49#define PTHREAD_CANCELED ((void *)-1)
51#define PTHREAD_CREATE_DETACHED 1
53#define PTHREAD_CREATE_JOINABLE 0
54#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
56#define PTHREAD_EXPLICIT_SCHED 1
58#define PTHREAD_INHERIT_SCHED 0
59#endif
61#define PTHREAD_MUTEX_DEFAULT 3
63#define PTHREAD_MUTEX_ERRORCHECK 2
65#define PTHREAD_MUTEX_NORMAL 0
67#define PTHREAD_MUTEX_RECURSIVE 1
69#define PTHREAD_MUTEX_ROBUST 4
71#define PTHREAD_MUTEX_STALLED 1
73#define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INITIALIZER
74#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(__DOXYGEN__)
76#define PTHREAD_PRIO_INHERIT 1
77#endif
78#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
79 defined(__DOXYGEN__)
81#define PTHREAD_PRIO_NONE 0
82#endif
83#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
85#define PTHREAD_PRIO_PROTECT 2
86#endif
88#define PTHREAD_PROCESS_SHARED 1
90#define PTHREAD_PROCESS_PRIVATE 0
91#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
93#define PTHREAD_SCOPE_PROCESS 1
95#define PTHREAD_SCOPE_SYSTEM 0
96#endif
97
99#define PTHREAD_COND_INITIALIZER _PTHREAD_COND_INITIALIZER
101#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_MUTEX_INITIALIZER
103#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_RWLOCK_INITIALIZER
104
105/* pthread_attr_t, pthread_barrier_t, pthread_barrierattr_t, pthread_cond_t, pthread_condattr_t,
106 * pthread_key_t, pthread_mutex_t, pthread_mutexattr_t, pthread_once_t, pthread_rwlock_t,
107 * pthread_rwlockattr_t, pthread_spinlock_t, and pthread_t
108 * types defined in <zephyr/posix/sys/_pthreadtypes.h>
109 */
110
121int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
122
131
140int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
141
150int pthread_attr_getguardsize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT guardsize);
151
152#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
162 int *ZRESTRICT inheritsched);
163#endif
164
174 struct sched_param *ZRESTRICT param);
175
176#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
185int pthread_attr_getschedpolicy(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT policy);
186
195int pthread_attr_getscope(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT contentionscope);
196#endif
197
198#if (defined(_POSIX_THREAD_ATTR_STACKADDR) && defined(_POSIX_THREAD_ATTR_STACKSIZE)) || \
199 defined(__DOXYGEN__)
209int pthread_attr_getstack(const pthread_attr_t *ZRESTRICT attr, void **ZRESTRICT stackaddr,
210 size_t *ZRESTRICT stacksize);
211#endif
212
213#if defined(_POSIX_THREAD_ATTR_STACKSIZE) || defined(__DOXYGEN__)
222int pthread_attr_getstacksize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT stacksize);
223#endif
224
233
242int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
243
252int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
253
254#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
263int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
264#endif
265
275 const struct sched_param *ZRESTRICT param);
276
277#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
287
296int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
297#endif
298
299#if (defined(_POSIX_THREAD_ATTR_STACKADDR) && defined(_POSIX_THREAD_ATTR_STACKSIZE)) || \
300 defined(__DOXYGEN__)
310int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
311#endif
312
313#if defined(_POSIX_THREAD_ATTR_STACKSIZE) || defined(__DOXYGEN__)
322int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
323#endif
324
325
326
334int pthread_barrier_destroy(pthread_barrier_t *barrier);
335
345int pthread_barrier_init(pthread_barrier_t *ZRESTRICT barrier,
346 const pthread_barrierattr_t *ZRESTRICT attr, unsigned int count);
347
360int pthread_barrier_wait(pthread_barrier_t *barrier);
361
369int pthread_barrierattr_destroy(pthread_barrierattr_t *attr);
370
371#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
380int pthread_barrierattr_getpshared(const pthread_barrierattr_t *ZRESTRICT attr,
381 int *ZRESTRICT pshared);
382#endif
383
391int pthread_barrierattr_init(pthread_barrierattr_t *attr);
392
393#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
402int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared);
403#endif
404
405
406
414int pthread_cancel(pthread_t thread);
415
416
417
425int pthread_cond_broadcast(pthread_cond_t *cond);
426
427#if (_POSIX_C_SOURCE >= 202405L) || defined(__DOXYGEN__)
438int pthread_cond_clockwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex,
439 clockid_t clock_id, const struct timespec *ZRESTRICT abstime);
440#endif
441
449int pthread_cond_destroy(pthread_cond_t *cond);
450
459int pthread_cond_init(pthread_cond_t *ZRESTRICT cond, const pthread_condattr_t *ZRESTRICT attr);
460
468int pthread_cond_signal(pthread_cond_t *cond);
469
470#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
480int pthread_cond_timedwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex,
481 const struct timespec *ZRESTRICT abstime);
482#endif
483
492int pthread_cond_wait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex);
493
501int pthread_condattr_destroy(pthread_condattr_t *attr);
502
511int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT attr,
512 clockid_t *ZRESTRICT clock_id);
513
514#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
523int pthread_condattr_getpshared(const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
524#endif
525
533int pthread_condattr_init(pthread_condattr_t *attr);
534
543int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
544
545#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
554int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
555#endif
556
557
558
569int pthread_create(pthread_t *ZRESTRICT thread, const pthread_attr_t *ZRESTRICT attr,
570 void *(*start_routine)(void *), void *ZRESTRICT arg);
571
579int pthread_detach(pthread_t thread);
580
589int pthread_equal(pthread_t t1, pthread_t t2);
590
597void pthread_exit(void *value_ptr);
598
599#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
607#endif
608
609#if defined(_POSIX_THREAD_CPUTIME) || defined(__DOXYGEN__)
618int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id);
619#endif
620
621#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
631int pthread_getschedparam(pthread_t thread, int *ZRESTRICT policy,
632 struct sched_param *ZRESTRICT param);
633#endif
634
642void *pthread_getspecific(pthread_key_t key);
643
652int pthread_join(pthread_t thread, void **value_ptr);
653
662int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
663
671int pthread_key_delete(pthread_key_t key);
672
673
674
682int pthread_mutex_consistent(pthread_mutex_t *mutex);
683
691int pthread_mutex_destroy(pthread_mutex_t *mutex);
692
693#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
702int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex,
703 int *ZRESTRICT prioceiling);
704#endif
705
714int pthread_mutex_init(pthread_mutex_t *ZRESTRICT mutex, const pthread_mutexattr_t *ZRESTRICT attr);
715
723int pthread_mutex_lock(pthread_mutex_t *mutex);
724
725#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
735int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling,
736 int *ZRESTRICT old_ceiling);
737#endif
738
739#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
748int pthread_mutex_timedlock(pthread_mutex_t *ZRESTRICT mutex,
749 const struct timespec *ZRESTRICT abstime);
750#endif
751
759int pthread_mutex_trylock(pthread_mutex_t *mutex);
760
768int pthread_mutex_unlock(pthread_mutex_t *mutex);
769
777int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
778
779#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
788int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr,
789 int *ZRESTRICT prioceiling);
790#endif
791
792#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
793 defined(__DOXYGEN__)
803int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *ZRESTRICT attr,
804 int *ZRESTRICT protocol);
805#endif
806
807#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
816int pthread_mutexattr_getpshared(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
817#endif
818
827int pthread_mutexattr_getrobust(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust);
828
838int pthread_mutexattr_gettype(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type);
839
847int pthread_mutexattr_init(pthread_mutexattr_t *attr);
848
849#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
858int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling);
859#endif
860
861#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
862 defined(__DOXYGEN__)
871int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol);
872#endif
873
874#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
883int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
884#endif
885
894int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust);
895
905int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
906
907
908
917int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
918
919
920
928int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
929
938int pthread_rwlock_init(pthread_rwlock_t *ZRESTRICT rwlock,
939 const pthread_rwlockattr_t *ZRESTRICT attr);
940
948int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
949
950#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
959int pthread_rwlock_timedrdlock(pthread_rwlock_t *ZRESTRICT rwlock,
960 const struct timespec *ZRESTRICT abstime);
961#endif
962
963#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
972int pthread_rwlock_timedwrlock(pthread_rwlock_t *ZRESTRICT rwlock,
973 const struct timespec *ZRESTRICT abstime);
974#endif
975
983int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
984
992int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
993
1001int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
1002
1010int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
1011
1019int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
1020
1021#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1030int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *ZRESTRICT attr,
1031 int *ZRESTRICT pshared);
1032#endif
1033
1041int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
1042
1043#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1052int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
1053#endif
1054
1055
1056
1063pthread_t pthread_self(void);
1064
1073int pthread_setcancelstate(int state, int *oldstate);
1074
1083int pthread_setcanceltype(int type, int *oldtype);
1084
1085#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
1093int pthread_setconcurrency(int new_level);
1094#endif
1095
1096#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
1106int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param);
1107
1116int pthread_setschedprio(pthread_t thread, int prio);
1117#endif
1118
1127int pthread_setspecific(pthread_key_t key, const void *value);
1128
1129
1130
1138int pthread_spin_destroy(pthread_spinlock_t *lock);
1139
1148int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
1149
1157int pthread_spin_lock(pthread_spinlock_t *lock);
1158
1166int pthread_spin_trylock(pthread_spinlock_t *lock);
1167
1175int pthread_spin_unlock(pthread_spinlock_t *lock);
1176
1177
1178
1187
1198#define pthread_cleanup_push(_rtn, _arg) \
1199 do /* enforce '{'-like behaviour */ { \
1200 void *_z_pthread_cleanup[3]; \
1201 k_thread_cleanup_push(_z_pthread_cleanup, _rtn, _arg)
1202
1212#define pthread_cleanup_pop(_ex) \
1213 k_thread_cleanup_pop(_ex); \
1214 } /* enforce '}'-like behaviour */ \
1215 while (0)
1216
1217
1218
1219#if defined(_GNU_SOURCE) || defined(__DOXYGEN__)
1220
1230int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset);
1231
1241int pthread_getname_np(pthread_t thread, char *name, size_t len);
1242
1260int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset);
1261
1270int pthread_setname_np(pthread_t thread, const char *name);
1271
1281int pthread_timedjoin_np(pthread_t thread, void **status, const struct timespec *abstime);
1282
1292int pthread_tryjoin_np(pthread_t thread, void **status);
1293
1294#endif /* _GNU_SOURCE || __DOXYGEN__ */
1295
1296
1297#ifdef __cplusplus
1298}
1299#endif
1300
1301#endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */
1302
1303#endif /* ZEPHYR_INCLUDE_POSIX_PTHREAD_H_ */
CPU sets for thread affinity (GNU extension, <sched.h>)
int pthread_barrier_init(pthread_barrier_t *ZRESTRICT barrier, const pthread_barrierattr_t *ZRESTRICT attr, unsigned int count)
Initialise a barrier object.
int pthread_barrierattr_getpshared(const pthread_barrierattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a barrier attributes object.
int pthread_barrier_wait(pthread_barrier_t *barrier)
Synchronise participating threads at a barrier.
int pthread_barrierattr_init(pthread_barrierattr_t *attr)
Initialise a barrier attributes object with default values.
int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared)
Set the process-shared attribute of a barrier attributes object.
int pthread_barrierattr_destroy(pthread_barrierattr_t *attr)
Destroy a barrier attributes object.
int pthread_barrier_destroy(pthread_barrier_t *barrier)
Destroy a barrier object.
int pthread_cond_clockwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex, clockid_t clock_id, const struct timespec *ZRESTRICT abstime)
Wait on a condition variable with a specific clock.
int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT attr, clockid_t *ZRESTRICT clock_id)
Get the clock attribute of a condition variable attributes object.
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)
Set the clock attribute of a condition variable attributes object.
int pthread_atfork(void(*prepare)(void), void(*parent)(void), void(*child)(void))
Register fork handlers to be called around fork().
int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset)
Set the CPUs a thread may run on (GNU extension).
int pthread_tryjoin_np(pthread_t thread, void **status)
Try to join a thread without blocking (GNU extension).
int pthread_timedjoin_np(pthread_t thread, void **status, const struct timespec *abstime)
Wait for a thread to terminate with an absolute timeout (GNU extension).
int pthread_getname_np(pthread_t thread, char *name, size_t len)
Get the name of a thread (GNU extension).
int pthread_setname_np(pthread_t thread, const char *name)
Set the name of a thread (GNU extension).
int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset)
Get the set of CPUs a thread may run on (GNU extension).
int pthread_mutexattr_gettype(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type)
Get the type attribute of a mutex attributes object.
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
Set the guard size attribute of a thread attributes object.
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the type attribute of a mutex attributes object.
int pthread_attr_getguardsize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT guardsize)
Get the guard size attribute of a thread attributes object.
int pthread_mutex_consistent(pthread_mutex_t *mutex)
Mark a robust mutex as consistent after recovering from owner death.
int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)
Set the robustness attribute of a mutex attributes object.
int pthread_mutexattr_getrobust(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust)
Get the robustness attribute of a mutex attributes object.
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
Try to acquire a write lock without blocking.
int pthread_rwlock_timedwrlock(pthread_rwlock_t *ZRESTRICT rwlock, const struct timespec *ZRESTRICT abstime)
Acquire a write lock with an absolute timeout.
int pthread_rwlock_timedrdlock(pthread_rwlock_t *ZRESTRICT rwlock, const struct timespec *ZRESTRICT abstime)
Acquire a read lock with an absolute timeout.
int pthread_rwlock_init(pthread_rwlock_t *ZRESTRICT rwlock, const pthread_rwlockattr_t *ZRESTRICT attr)
Initialise a reader-writer lock.
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a reader-writer lock attributes object.
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
Acquire a write lock, blocking until available.
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
Destroy a reader-writer lock attributes object.
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
Destroy a reader-writer lock.
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
Release a reader-writer lock.
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
Initialise a reader-writer lock attributes object with default values.
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
Try to acquire a read lock without blocking.
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
Acquire a read lock, blocking until available.
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared)
Set the process-shared attribute of a reader-writer lock attributes object.
int pthread_spin_unlock(pthread_spinlock_t *lock)
Release a spin lock.
int pthread_spin_lock(pthread_spinlock_t *lock)
Acquire a spin lock, busy-waiting until available.
int pthread_spin_destroy(pthread_spinlock_t *lock)
Destroy a spin lock.
int pthread_spin_init(pthread_spinlock_t *lock, int pshared)
Initialise a spin lock.
int pthread_spin_trylock(pthread_spinlock_t *lock)
Try to acquire a spin lock without busy-waiting.
int pthread_mutex_init(pthread_mutex_t *ZRESTRICT mutex, const pthread_mutexattr_t *ZRESTRICT attr)
Initialise a mutex.
int pthread_condattr_destroy(pthread_condattr_t *attr)
Destroy a condition variable attributes object.
void pthread_exit(void *value_ptr)
Terminate the calling thread.
int pthread_attr_init(pthread_attr_t *attr)
Initialise a thread attributes object with default values.
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex, blocking until it is available.
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
Ensure a one-time initialisation routine is called exactly once.
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition variable, waking at least one waiting thread.
int pthread_setspecific(pthread_key_t key, const void *value)
Set the thread-specific value associated with a key.
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy a mutex attributes object.
int pthread_mutex_trylock(pthread_mutex_t *mutex)
Try to lock a mutex without blocking.
int pthread_cond_timedwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex, const struct timespec *ZRESTRICT abstime)
Wait on a condition variable with an absolute timeout (CLOCK_REALTIME).
int pthread_condattr_init(pthread_condattr_t *attr)
Initialise a condition variable attributes object with default values.
int pthread_setcancelstate(int state, int *oldstate)
Set the cancellability state of the calling thread.
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get the detach state attribute of a thread attributes object.
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy a mutex.
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy a thread attributes object.
pthread_t pthread_self(void)
Return the thread ID of the calling thread.
int pthread_create(pthread_t *ZRESTRICT thread, const pthread_attr_t *ZRESTRICT attr, void *(*start_routine)(void *), void *ZRESTRICT arg)
Create a new thread.
int pthread_mutex_timedlock(pthread_mutex_t *ZRESTRICT mutex, const struct timespec *ZRESTRICT abstime)
Lock a mutex with an absolute timeout.
int pthread_detach(pthread_t thread)
Detach a thread, releasing its resources automatically on termination.
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
int pthread_equal(pthread_t t1, pthread_t t2)
Compare two thread IDs.
int pthread_cancel(pthread_t thread)
Send a cancellation request to a thread.
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy a condition variable.
int pthread_join(pthread_t thread, void **value_ptr)
Wait for a thread to terminate and retrieve its exit status.
int pthread_setcanceltype(int type, int *oldtype)
Set the cancellability type of the calling thread.
int pthread_attr_getschedparam(const pthread_attr_t *ZRESTRICT attr, struct sched_param *ZRESTRICT param)
Get the scheduling parameter attribute of a thread attributes object.
void * pthread_getspecific(pthread_key_t key)
Get the thread-specific value associated with a key.
int pthread_attr_setschedparam(pthread_attr_t *ZRESTRICT attr, const struct sched_param *ZRESTRICT param)
Set the scheduling parameter attribute of a thread attributes object.
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set the detach state attribute of a thread attributes object.
int pthread_key_delete(pthread_key_t key)
Delete a thread-specific data key.
void pthread_testcancel(void)
Create a cancellation point in the calling thread.
int pthread_key_create(pthread_key_t *key, void(*destructor)(void *))
Create a thread-specific data key.
int pthread_cond_wait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex)
Wait on a condition variable.
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialise a mutex attributes object with default values.
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition variable, waking all waiting threads.
int pthread_cond_init(pthread_cond_t *ZRESTRICT cond, const pthread_condattr_t *ZRESTRICT attr)
Initialise a condition variable.
int pthread_setconcurrency(int new_level)
Set the concurrency level (advisory, has no effect on scheduling).
int pthread_getconcurrency(void)
Get the concurrency level (advisory, has no effect on scheduling).
int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize)
Set the stack address and size attributes of a thread attributes object.
int pthread_attr_getstack(const pthread_attr_t *ZRESTRICT attr, void **ZRESTRICT stackaddr, size_t *ZRESTRICT stacksize)
Get the stack address and size attributes of a thread attributes object.
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set the stack size attribute of a thread attributes object.
int pthread_attr_getstacksize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT stacksize)
Get the stack size attribute of a thread attributes object.
int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id)
Get the CPU-time clock of a thread.
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT protocol)
Get the protocol attribute of a mutex attributes object.
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol)
Set the protocol attribute of a mutex attributes object.
int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex, int *ZRESTRICT prioceiling)
Get the priority ceiling of a mutex.
int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling, int *ZRESTRICT old_ceiling)
Set the priority ceiling of a mutex.
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling)
Set the priority ceiling attribute of a mutex attributes object.
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT prioceiling)
Get the priority ceiling attribute of a mutex attributes object.
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Set the scheduling policy and parameters of a thread.
int pthread_attr_getinheritsched(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT inheritsched)
Get the inherit-scheduler attribute of a thread attributes object.
int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope)
Set the contention scope attribute of a thread attributes object.
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
Set the scheduling policy attribute of a thread attributes object.
int pthread_setschedprio(pthread_t thread, int prio)
Set the scheduling priority of a thread.
int pthread_attr_getscope(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT contentionscope)
Get the contention scope attribute of a thread attributes object.
int pthread_attr_getschedpolicy(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT policy)
Get the scheduling policy attribute of a thread attributes object.
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched)
Set the inherit-scheduler attribute of a thread attributes object.
int pthread_getschedparam(pthread_t thread, int *ZRESTRICT policy, struct sched_param *ZRESTRICT param)
Get the scheduling policy and parameters of a thread.
int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
Set the process-shared attribute of a condition variable attributes object.
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a mutex attributes object.
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
Set the process-shared attribute of a mutex attributes object.
int pthread_condattr_getpshared(const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a condition variable attributes object.
unsigned long clockid_t
Identifies a clock (e.g.
Definition posix_time.h:40
POSIX process and thread scheduling API (<sched.h>)
Set of CPUs for pthread_getaffinity_np() and pthread_setaffinity_np() (GNU extension).
Definition cpuset.h:32
Time value with nanosecond resolution.
Definition aio.h:65
POSIX time-of-day types and functions (<sys/time.h>)