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#include <zephyr/toolchain.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
36#define PTHREAD_BARRIER_SERIAL_THREAD 1
38#define PTHREAD_CANCEL_ASYNCHRONOUS 1
40#define PTHREAD_CANCEL_ENABLE 0
42#define PTHREAD_CANCEL_DEFERRED 0
44#define PTHREAD_CANCEL_DISABLE 1
46#define PTHREAD_CANCELED ((void *)-1)
48#define PTHREAD_CREATE_DETACHED 1
50#define PTHREAD_CREATE_JOINABLE 0
51#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
53#define PTHREAD_EXPLICIT_SCHED 1
55#define PTHREAD_INHERIT_SCHED 0
56#endif
58#define PTHREAD_MUTEX_DEFAULT 3
60#define PTHREAD_MUTEX_ERRORCHECK 2
62#define PTHREAD_MUTEX_NORMAL 0
64#define PTHREAD_MUTEX_RECURSIVE 1
66#define PTHREAD_MUTEX_ROBUST 4
68#define PTHREAD_MUTEX_STALLED 1
70#define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INITIALIZER
71#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(__DOXYGEN__)
73#define PTHREAD_PRIO_INHERIT 1
74#endif
75#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
76 defined(__DOXYGEN__)
78#define PTHREAD_PRIO_NONE 0
79#endif
80#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
82#define PTHREAD_PRIO_PROTECT 2
83#endif
85#define PTHREAD_PROCESS_SHARED 1
87#define PTHREAD_PROCESS_PRIVATE 0
88#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
90#define PTHREAD_SCOPE_PROCESS 1
92#define PTHREAD_SCOPE_SYSTEM 0
93#endif
94
96#define PTHREAD_COND_INITIALIZER _PTHREAD_COND_INITIALIZER
98#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_MUTEX_INITIALIZER
100#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_RWLOCK_INITIALIZER
101
102/* pthread_attr_t, pthread_barrier_t, pthread_barrierattr_t, pthread_cond_t, pthread_condattr_t,
103 * pthread_key_t, pthread_mutex_t, pthread_mutexattr_t, pthread_once_t, pthread_rwlock_t,
104 * pthread_rwlockattr_t, pthread_spinlock_t, and pthread_t
105 * types defined in <zephyr/posix/sys/_pthreadtypes.h>
106 */
107
118int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
119
128
137int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
138
147int pthread_attr_getguardsize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT guardsize);
148
149#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
159 int *ZRESTRICT inheritsched);
160#endif
161
171 struct sched_param *ZRESTRICT param);
172
173#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
182int pthread_attr_getschedpolicy(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT policy);
183
192int pthread_attr_getscope(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT contentionscope);
193#endif
194
195#if (defined(_POSIX_THREAD_ATTR_STACKADDR) && defined(_POSIX_THREAD_ATTR_STACKSIZE)) || \
196 defined(__DOXYGEN__)
206int pthread_attr_getstack(const pthread_attr_t *ZRESTRICT attr, void **ZRESTRICT stackaddr,
207 size_t *ZRESTRICT stacksize);
208#endif
209
210#if defined(_POSIX_THREAD_ATTR_STACKSIZE) || defined(__DOXYGEN__)
219int pthread_attr_getstacksize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT stacksize);
220#endif
221
230
239int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
240
249int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
250
251#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
260int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
261#endif
262
272 const struct sched_param *ZRESTRICT param);
273
274#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
284
293int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
294#endif
295
296#if (defined(_POSIX_THREAD_ATTR_STACKADDR) && defined(_POSIX_THREAD_ATTR_STACKSIZE)) || \
297 defined(__DOXYGEN__)
307int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
308#endif
309
310#if defined(_POSIX_THREAD_ATTR_STACKSIZE) || defined(__DOXYGEN__)
319int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
320#endif
321
322
323
331int pthread_barrier_destroy(pthread_barrier_t *barrier);
332
342int pthread_barrier_init(pthread_barrier_t *ZRESTRICT barrier,
343 const pthread_barrierattr_t *ZRESTRICT attr, unsigned int count);
344
357int pthread_barrier_wait(pthread_barrier_t *barrier);
358
366int pthread_barrierattr_destroy(pthread_barrierattr_t *attr);
367
368#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
377int pthread_barrierattr_getpshared(const pthread_barrierattr_t *ZRESTRICT attr,
378 int *ZRESTRICT pshared);
379#endif
380
388int pthread_barrierattr_init(pthread_barrierattr_t *attr);
389
390#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
399int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared);
400#endif
401
402
403
411int pthread_cancel(pthread_t thread);
412
413
414
422int pthread_cond_broadcast(pthread_cond_t *cond);
423
424#if (_POSIX_C_SOURCE >= 202405L) || defined(__DOXYGEN__)
435int pthread_cond_clockwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex,
436 clockid_t clock_id, const struct timespec *ZRESTRICT abstime);
437#endif
438
446int pthread_cond_destroy(pthread_cond_t *cond);
447
456int pthread_cond_init(pthread_cond_t *ZRESTRICT cond, const pthread_condattr_t *ZRESTRICT attr);
457
465int pthread_cond_signal(pthread_cond_t *cond);
466
467#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
477int pthread_cond_timedwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex,
478 const struct timespec *ZRESTRICT abstime);
479#endif
480
489int pthread_cond_wait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex);
490
498int pthread_condattr_destroy(pthread_condattr_t *attr);
499
508int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT attr,
509 clockid_t *ZRESTRICT clock_id);
510
511#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
520int pthread_condattr_getpshared(const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
521#endif
522
530int pthread_condattr_init(pthread_condattr_t *attr);
531
540int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
541
542#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
551int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
552#endif
553
554
555
566int pthread_create(pthread_t *ZRESTRICT thread, const pthread_attr_t *ZRESTRICT attr,
567 void *(*start_routine)(void *), void *ZRESTRICT arg);
568
576int pthread_detach(pthread_t thread);
577
586int pthread_equal(pthread_t t1, pthread_t t2);
587
594void pthread_exit(void *value_ptr);
595
596#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
604#endif
605
606#if defined(_POSIX_THREAD_CPUTIME) || defined(__DOXYGEN__)
615int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id);
616#endif
617
618#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
628int pthread_getschedparam(pthread_t thread, int *ZRESTRICT policy,
629 struct sched_param *ZRESTRICT param);
630#endif
631
639void *pthread_getspecific(pthread_key_t key);
640
649int pthread_join(pthread_t thread, void **value_ptr);
650
659int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
660
668int pthread_key_delete(pthread_key_t key);
669
670
671
679int pthread_mutex_consistent(pthread_mutex_t *mutex);
680
688int pthread_mutex_destroy(pthread_mutex_t *mutex);
689
690#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
699int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex,
700 int *ZRESTRICT prioceiling);
701#endif
702
711int pthread_mutex_init(pthread_mutex_t *ZRESTRICT mutex, const pthread_mutexattr_t *ZRESTRICT attr);
712
720int pthread_mutex_lock(pthread_mutex_t *mutex);
721
722#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
732int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling,
733 int *ZRESTRICT old_ceiling);
734#endif
735
736#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
745int pthread_mutex_timedlock(pthread_mutex_t *ZRESTRICT mutex,
746 const struct timespec *ZRESTRICT abstime);
747#endif
748
756int pthread_mutex_trylock(pthread_mutex_t *mutex);
757
765int pthread_mutex_unlock(pthread_mutex_t *mutex);
766
774int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
775
776#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
785int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr,
786 int *ZRESTRICT prioceiling);
787#endif
788
789#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
790 defined(__DOXYGEN__)
800int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *ZRESTRICT attr,
801 int *ZRESTRICT protocol);
802#endif
803
804#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
813int pthread_mutexattr_getpshared(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
814#endif
815
824int pthread_mutexattr_getrobust(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust);
825
835int pthread_mutexattr_gettype(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type);
836
844int pthread_mutexattr_init(pthread_mutexattr_t *attr);
845
846#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
855int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling);
856#endif
857
858#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
859 defined(__DOXYGEN__)
868int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol);
869#endif
870
871#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
880int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
881#endif
882
891int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust);
892
902int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
903
904
905
914int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
915
916
917
925int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
926
935int pthread_rwlock_init(pthread_rwlock_t *ZRESTRICT rwlock,
936 const pthread_rwlockattr_t *ZRESTRICT attr);
937
945int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
946
947#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
956int pthread_rwlock_timedrdlock(pthread_rwlock_t *ZRESTRICT rwlock,
957 const struct timespec *ZRESTRICT abstime);
958#endif
959
960#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
969int pthread_rwlock_timedwrlock(pthread_rwlock_t *ZRESTRICT rwlock,
970 const struct timespec *ZRESTRICT abstime);
971#endif
972
980int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
981
989int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
990
998int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
999
1007int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
1008
1016int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
1017
1018#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1027int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *ZRESTRICT attr,
1028 int *ZRESTRICT pshared);
1029#endif
1030
1038int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
1039
1040#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1049int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
1050#endif
1051
1052
1053
1060pthread_t pthread_self(void);
1061
1070int pthread_setcancelstate(int state, int *oldstate);
1071
1080int pthread_setcanceltype(int type, int *oldtype);
1081
1082#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
1090int pthread_setconcurrency(int new_level);
1091#endif
1092
1093#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
1103int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param);
1104
1113int pthread_setschedprio(pthread_t thread, int prio);
1114#endif
1115
1124int pthread_setspecific(pthread_key_t key, const void *value);
1125
1126
1127
1135int pthread_spin_destroy(pthread_spinlock_t *lock);
1136
1145int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
1146
1154int pthread_spin_lock(pthread_spinlock_t *lock);
1155
1163int pthread_spin_trylock(pthread_spinlock_t *lock);
1164
1172int pthread_spin_unlock(pthread_spinlock_t *lock);
1173
1174
1175
1184
1195#define pthread_cleanup_push(_rtn, _arg) \
1196 do /* enforce '{'-like behaviour */ { \
1197 void *_z_pthread_cleanup[3]; \
1198 k_thread_cleanup_push(_z_pthread_cleanup, _rtn, _arg)
1199
1209#define pthread_cleanup_pop(_ex) \
1210 k_thread_cleanup_pop(_ex); \
1211 } /* enforce '}'-like behaviour */ \
1212 while (0)
1213
1214
1215
1216#if defined(_GNU_SOURCE) || defined(__DOXYGEN__)
1217
1227int pthread_getname_np(pthread_t thread, char *name, size_t len);
1228
1237int pthread_setname_np(pthread_t thread, const char *name);
1238
1248int pthread_timedjoin_np(pthread_t thread, void **status, const struct timespec *abstime);
1249
1259int pthread_tryjoin_np(pthread_t thread, void **status);
1260
1261#endif /* _GNU_SOURCE || __DOXYGEN__ */
1262
1263
1264#ifdef __cplusplus
1265}
1266#endif
1267
1268#endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */
1269
1270#endif /* ZEPHYR_INCLUDE_POSIX_PTHREAD_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_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_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>)
Time value with nanosecond resolution.
Definition aio.h:65
POSIX time-of-day types and functions (<sys/time.h>)