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 >= 202412L) || 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
476int pthread_cond_timedwait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex,
477 const struct timespec *ZRESTRICT abstime);
478
487int pthread_cond_wait(pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex);
488
496int pthread_condattr_destroy(pthread_condattr_t *attr);
497
506int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT attr,
507 clockid_t *ZRESTRICT clock_id);
508
509#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
518int pthread_condattr_getpshared(const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
519#endif
520
528int pthread_condattr_init(pthread_condattr_t *attr);
529
538int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
539
540#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
549int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
550#endif
551
552
553
564int pthread_create(pthread_t *ZRESTRICT thread, const pthread_attr_t *ZRESTRICT attr,
565 void *(*start_routine)(void *), void *ZRESTRICT arg);
566
574int pthread_detach(pthread_t thread);
575
584int pthread_equal(pthread_t t1, pthread_t t2);
585
592void pthread_exit(void *value_ptr);
593
594#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
602#endif
603
604#if defined(_POSIX_THREAD_CPUTIME) || defined(__DOXYGEN__)
613int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id);
614#endif
615
616#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
626int pthread_getschedparam(pthread_t thread, int *ZRESTRICT policy,
627 struct sched_param *ZRESTRICT param);
628#endif
629
637void *pthread_getspecific(pthread_key_t key);
638
647int pthread_join(pthread_t thread, void **value_ptr);
648
657int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
658
666int pthread_key_delete(pthread_key_t key);
667
668
669
677int pthread_mutex_consistent(pthread_mutex_t *mutex);
678
686int pthread_mutex_destroy(pthread_mutex_t *mutex);
687
688#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
697int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex,
698 int *ZRESTRICT prioceiling);
699#endif
700
709int pthread_mutex_init(pthread_mutex_t *ZRESTRICT mutex, const pthread_mutexattr_t *ZRESTRICT attr);
710
718int pthread_mutex_lock(pthread_mutex_t *mutex);
719
720#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
730int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling,
731 int *ZRESTRICT old_ceiling);
732#endif
733
742int pthread_mutex_timedlock(pthread_mutex_t *ZRESTRICT mutex,
743 const struct timespec *ZRESTRICT abstime);
744
752int pthread_mutex_trylock(pthread_mutex_t *mutex);
753
761int pthread_mutex_unlock(pthread_mutex_t *mutex);
762
770int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
771
772#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
781int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr,
782 int *ZRESTRICT prioceiling);
783#endif
784
785#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
786 defined(__DOXYGEN__)
796int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *ZRESTRICT attr,
797 int *ZRESTRICT protocol);
798#endif
799
800#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
809int pthread_mutexattr_getpshared(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT pshared);
810#endif
811
820int pthread_mutexattr_getrobust(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust);
821
831int pthread_mutexattr_gettype(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type);
832
840int pthread_mutexattr_init(pthread_mutexattr_t *attr);
841
842#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined(__DOXYGEN__)
851int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling);
852#endif
853
854#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) || \
855 defined(__DOXYGEN__)
864int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol);
865#endif
866
867#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
876int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
877#endif
878
887int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust);
888
898int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
899
900
901
910int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
911
912
913
921int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
922
931int pthread_rwlock_init(pthread_rwlock_t *ZRESTRICT rwlock,
932 const pthread_rwlockattr_t *ZRESTRICT attr);
933
941int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
942
951int pthread_rwlock_timedrdlock(pthread_rwlock_t *ZRESTRICT rwlock,
952 const struct timespec *ZRESTRICT abstime);
953
962int pthread_rwlock_timedwrlock(pthread_rwlock_t *ZRESTRICT rwlock,
963 const struct timespec *ZRESTRICT abstime);
964
972int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
973
981int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
982
990int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
991
999int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
1000
1008int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
1009
1010#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1019int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *ZRESTRICT attr,
1020 int *ZRESTRICT pshared);
1021#endif
1022
1030int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
1031
1032#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(__DOXYGEN__)
1041int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
1042#endif
1043
1044
1045
1052pthread_t pthread_self(void);
1053
1062int pthread_setcancelstate(int state, int *oldstate);
1063
1072int pthread_setcanceltype(int type, int *oldtype);
1073
1074#if (_XOPEN_SOURCE < 800) || defined(__DOXYGEN__)
1082int pthread_setconcurrency(int new_level);
1083#endif
1084
1085#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || defined(__DOXYGEN__)
1095int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param);
1096
1105int pthread_setschedprio(pthread_t thread, int prio);
1106#endif
1107
1116int pthread_setspecific(pthread_key_t key, const void *value);
1117
1118
1119
1127int pthread_spin_destroy(pthread_spinlock_t *lock);
1128
1137int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
1138
1146int pthread_spin_lock(pthread_spinlock_t *lock);
1147
1155int pthread_spin_trylock(pthread_spinlock_t *lock);
1156
1164int pthread_spin_unlock(pthread_spinlock_t *lock);
1165
1166
1167
1176
1187#define pthread_cleanup_push(_rtn, _arg) \
1188 do /* enforce '{'-like behaviour */ { \
1189 void *_z_pthread_cleanup[3]; \
1190 k_thread_cleanup_push(_z_pthread_cleanup, _rtn, _arg)
1191
1201#define pthread_cleanup_pop(_ex) \
1202 k_thread_cleanup_pop(_ex); \
1203 } /* enforce '}'-like behaviour */ \
1204 while (0)
1205
1206
1207
1208#if defined(_GNU_SOURCE) || defined(__DOXYGEN__)
1209
1219int pthread_getname_np(pthread_t thread, char *name, size_t len);
1220
1229int pthread_setname_np(pthread_t thread, const char *name);
1230
1240int pthread_timedjoin_np(pthread_t thread, void **status, const struct timespec *abstime);
1241
1251int pthread_tryjoin_np(pthread_t thread, void **status);
1252
1253#endif /* _GNU_SOURCE || __DOXYGEN__ */
1254
1255
1256#ifdef __cplusplus
1257}
1258#endif
1259
1260#endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */
1261
1262#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_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_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_mutexattr_gettype(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type)
Get the type attribute of a mutex attributes object.
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_condattr_setpshared(pthread_condattr_t *attr, int pshared)
Set the process-shared attribute of a condition variable attributes object.
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_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_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_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
Set the guard size attribute of a thread attributes object.
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_mutexattr_getpshared(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a mutex attributes object.
int pthread_mutex_consistent(pthread_mutex_t *mutex)
Mark a robust mutex as consistent after recovering from owner death.
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
Set the process-shared attribute of a mutex attributes object.
int pthread_mutex_timedlock(pthread_mutex_t *ZRESTRICT mutex, const struct timespec *ZRESTRICT abstime)
Lock a mutex with an absolute timeout.
int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)
Set the robustness attribute of a mutex attributes object.
int pthread_detach(pthread_t thread)
Detach a thread, releasing its resources automatically on termination.
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the type attribute of a mutex attributes object.
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_condattr_getpshared(const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
Get the process-shared attribute of a condition variable attributes object.
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.
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_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)
Set the clock attribute of a condition variable 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_mutexattr_getrobust(const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust)
Get the robustness attribute of a mutex 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.
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:62
POSIX time-of-day types and functions (<sys/time.h>)