posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
POSIX_THREADS_BASE

POSIX Threads Base option group. More...

Files

file  limits.h
 <limits.h>: POSIX symbolic constants for limits
 
file  types.h
 POSIX fundamental types (<sys/types.h>)
 

Macros

#define PTHREAD_CANCEL_ASYNCHRONOUS   1
 Thread cancellation is performed immediately.
 
#define PTHREAD_CANCEL_ENABLE   0
 Cancellation is enabled (default).
 
#define PTHREAD_CANCEL_DEFERRED   0
 Cancellation is deferred until a cancellation point (default).
 
#define PTHREAD_CANCEL_DISABLE   1
 Cancellation delivery is disabled.
 
#define PTHREAD_CANCELED   ((void *)-1)
 Value returned by pthread_join() for a cancelled thread.
 
#define PTHREAD_CREATE_DETACHED   1
 Thread is created in the detached state.
 
#define PTHREAD_CREATE_JOINABLE   0
 Thread is created in the joinable state (default).
 
#define PTHREAD_MUTEX_DEFAULT   3
 Default mutex type; behaviour on deadlock/unlock-by-non-owner is undefined.
 
#define PTHREAD_MUTEX_ERRORCHECK   2
 Mutex that returns an error on deadlock or unlock by a non-owner.
 
#define PTHREAD_MUTEX_NORMAL   0
 Non-recursive mutex with no error checks (fastest).
 
#define PTHREAD_MUTEX_RECURSIVE   1
 Recursive mutex; the owning thread may lock it multiple times.
 
#define PTHREAD_MUTEX_ROBUST   4
 Robust mutex; the state is recoverable if the owner dies.
 
#define PTHREAD_MUTEX_STALLED   1
 Mutex is not recovered on owner death (default, for non-robust mutexes).
 
#define PTHREAD_ONCE_INIT   _PTHREAD_ONCE_INITIALIZER
 Static initialiser for pthread_once_t objects.
 
#define PTHREAD_PRIO_NONE   0
 Mutex protocol: no priority inheritance or ceiling.
 
#define PTHREAD_PROCESS_SHARED   1
 Mutex or barrier attribute: object is shared between processes.
 
#define PTHREAD_PROCESS_PRIVATE   0
 Mutex or barrier attribute: object is private to the process (default).
 
#define PTHREAD_COND_INITIALIZER   _PTHREAD_COND_INITIALIZER
 Static initialiser for pthread_cond_t objects.
 
#define PTHREAD_MUTEX_INITIALIZER   _PTHREAD_MUTEX_INITIALIZER
 Static initialiser for pthread_mutex_t objects.
 
#define pthread_cleanup_push(_rtn, _arg)
 Push a cleanup handler onto the calling thread's cleanup stack.
 
#define pthread_cleanup_pop(_ex)
 Pop a cleanup handler from the calling thread's cleanup stack.
 

Functions

int pthread_kill (pthread_t thread, int sig)
 Send a signal to a specific thread.
 
int pthread_sigmask (int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset)
 Examine and change blocked signals for the calling thread.
 
int pthread_attr_destroy (pthread_attr_t *attr)
 Destroy a thread attributes object.
 
int pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
 Get the detach state 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_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_init (pthread_attr_t *attr)
 Initialise a thread attributes object with default values.
 
int pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
 Set the detach state attribute of a thread 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_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_cancel (pthread_t thread)
 Send a cancellation request to a thread.
 
int pthread_cond_broadcast (pthread_cond_t *cond)
 Broadcast a condition variable, waking all waiting threads.
 
int pthread_cond_destroy (pthread_cond_t *cond)
 Destroy a condition variable.
 
int pthread_cond_init (pthread_cond_t *ZRESTRICT cond, const pthread_condattr_t *ZRESTRICT attr)
 Initialise a condition variable.
 
int pthread_cond_signal (pthread_cond_t *cond)
 Signal a condition variable, waking at least one waiting thread.
 
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_cond_wait (pthread_cond_t *ZRESTRICT cond, pthread_mutex_t *ZRESTRICT mutex)
 Wait on a condition variable.
 
int pthread_condattr_destroy (pthread_condattr_t *attr)
 Destroy a condition variable 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_condattr_getpshared (const pthread_condattr_t *ZRESTRICT attr, int *ZRESTRICT pshared)
 Get the process-shared attribute of a condition variable attributes object.
 
int pthread_condattr_init (pthread_condattr_t *attr)
 Initialise a condition variable attributes object with default values.
 
int pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock_id)
 Set the clock attribute of a condition variable attributes object.
 
int pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
 Set the process-shared attribute of a condition variable 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_detach (pthread_t thread)
 Detach a thread, releasing its resources automatically on termination.
 
int pthread_equal (pthread_t t1, pthread_t t2)
 Compare two thread IDs.
 
void pthread_exit (void *value_ptr)
 Terminate the calling thread.
 
void * pthread_getspecific (pthread_key_t key)
 Get the thread-specific value associated with a key.
 
int pthread_join (pthread_t thread, void **value_ptr)
 Wait for a thread to terminate and retrieve its exit status.
 
int pthread_key_create (pthread_key_t *key, void(*destructor)(void *))
 Create a thread-specific data key.
 
int pthread_key_delete (pthread_key_t key)
 Delete a thread-specific data key.
 
int pthread_mutex_consistent (pthread_mutex_t *mutex)
 Mark a robust mutex as consistent after recovering from owner death.
 
int pthread_mutex_destroy (pthread_mutex_t *mutex)
 Destroy a mutex.
 
int pthread_mutex_init (pthread_mutex_t *ZRESTRICT mutex, const pthread_mutexattr_t *ZRESTRICT attr)
 Initialise a mutex.
 
int pthread_mutex_lock (pthread_mutex_t *mutex)
 Lock a mutex, blocking until it is available.
 
int pthread_mutex_timedlock (pthread_mutex_t *ZRESTRICT mutex, const struct timespec *ZRESTRICT abstime)
 Lock a mutex with an absolute timeout.
 
int pthread_mutex_trylock (pthread_mutex_t *mutex)
 Try to lock a mutex without blocking.
 
int pthread_mutex_unlock (pthread_mutex_t *mutex)
 Unlock a mutex.
 
int pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
 Destroy a mutex 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_getrobust (const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT robust)
 Get the robustness attribute of a mutex attributes object.
 
int pthread_mutexattr_gettype (const pthread_mutexattr_t *ZRESTRICT attr, int *ZRESTRICT type)
 Get the type attribute of a mutex attributes object.
 
int pthread_mutexattr_init (pthread_mutexattr_t *attr)
 Initialise a mutex attributes object with default values.
 
int pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
 Set the process-shared attribute of a mutex attributes object.
 
int pthread_mutexattr_setrobust (pthread_mutexattr_t *attr, int robust)
 Set the robustness attribute of a mutex attributes object.
 
int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type)
 Set the type attribute of a mutex attributes object.
 
int pthread_once (pthread_once_t *once_control, void(*init_routine)(void))
 Ensure a one-time initialisation routine is called exactly once.
 
pthread_t pthread_self (void)
 Return the thread ID of the calling thread.
 
int pthread_setcancelstate (int state, int *oldstate)
 Set the cancellability state of the calling thread.
 
int pthread_setcanceltype (int type, int *oldtype)
 Set the cancellability type of the calling thread.
 
int pthread_setspecific (pthread_key_t key, const void *value)
 Set the thread-specific value associated with a key.
 
void pthread_testcancel (void)
 Create a cancellation point in the calling thread.
 
int sched_yield (void)
 Yield the processor to another thread of equal or higher priority.
 

Detailed Description

POSIX Threads Base option group.

Macro Definition Documentation

◆ PTHREAD_CANCEL_ASYNCHRONOUS

#define PTHREAD_CANCEL_ASYNCHRONOUS   1

Thread cancellation is performed immediately.

Definition at line 38 of file pthread.h.

◆ PTHREAD_CANCEL_DEFERRED

#define PTHREAD_CANCEL_DEFERRED   0

Cancellation is deferred until a cancellation point (default).

Definition at line 42 of file pthread.h.

◆ PTHREAD_CANCEL_DISABLE

#define PTHREAD_CANCEL_DISABLE   1

Cancellation delivery is disabled.

Definition at line 44 of file pthread.h.

◆ PTHREAD_CANCEL_ENABLE

#define PTHREAD_CANCEL_ENABLE   0

Cancellation is enabled (default).

Definition at line 40 of file pthread.h.

◆ PTHREAD_CANCELED

#define PTHREAD_CANCELED   ((void *)-1)

Value returned by pthread_join() for a cancelled thread.

Definition at line 46 of file pthread.h.

◆ pthread_cleanup_pop

#define pthread_cleanup_pop (   _ex)
Value:
k_thread_cleanup_pop(_ex); \
} /* enforce '}'-like behaviour */ \
while (0)

Pop a cleanup handler from the calling thread's cleanup stack.

Parameters
_exIf non-zero, the handler is executed before being removed.
Note
This macro must be paired with pthread_cleanup_push() in the same lexical scope.

Definition at line 1201 of file pthread.h.

◆ pthread_cleanup_push

#define pthread_cleanup_push (   _rtn,
  _arg 
)
Value:
do /* enforce '{'-like behaviour */ { \
void *_z_pthread_cleanup[3]; \
k_thread_cleanup_push(_z_pthread_cleanup, _rtn, _arg)

Push a cleanup handler onto the calling thread's cleanup stack.

The handler _rtn is called with _arg when the thread exits or calls pthread_cleanup_pop() with a non-zero argument.

Note
This macro must be paired with pthread_cleanup_pop() in the same lexical scope.

Definition at line 1187 of file pthread.h.

◆ PTHREAD_COND_INITIALIZER

#define PTHREAD_COND_INITIALIZER   _PTHREAD_COND_INITIALIZER

Static initialiser for pthread_cond_t objects.

Definition at line 96 of file pthread.h.

◆ PTHREAD_CREATE_DETACHED

#define PTHREAD_CREATE_DETACHED   1

Thread is created in the detached state.

Definition at line 48 of file pthread.h.

◆ PTHREAD_CREATE_JOINABLE

#define PTHREAD_CREATE_JOINABLE   0

Thread is created in the joinable state (default).

Definition at line 50 of file pthread.h.

◆ PTHREAD_MUTEX_DEFAULT

#define PTHREAD_MUTEX_DEFAULT   3

Default mutex type; behaviour on deadlock/unlock-by-non-owner is undefined.

Definition at line 58 of file pthread.h.

◆ PTHREAD_MUTEX_ERRORCHECK

#define PTHREAD_MUTEX_ERRORCHECK   2

Mutex that returns an error on deadlock or unlock by a non-owner.

Definition at line 60 of file pthread.h.

◆ PTHREAD_MUTEX_INITIALIZER

#define PTHREAD_MUTEX_INITIALIZER   _PTHREAD_MUTEX_INITIALIZER

Static initialiser for pthread_mutex_t objects.

Definition at line 98 of file pthread.h.

◆ PTHREAD_MUTEX_NORMAL

#define PTHREAD_MUTEX_NORMAL   0

Non-recursive mutex with no error checks (fastest).

Definition at line 62 of file pthread.h.

◆ PTHREAD_MUTEX_RECURSIVE

#define PTHREAD_MUTEX_RECURSIVE   1

Recursive mutex; the owning thread may lock it multiple times.

Definition at line 64 of file pthread.h.

◆ PTHREAD_MUTEX_ROBUST

#define PTHREAD_MUTEX_ROBUST   4

Robust mutex; the state is recoverable if the owner dies.

Definition at line 66 of file pthread.h.

◆ PTHREAD_MUTEX_STALLED

#define PTHREAD_MUTEX_STALLED   1

Mutex is not recovered on owner death (default, for non-robust mutexes).

Definition at line 68 of file pthread.h.

◆ PTHREAD_ONCE_INIT

#define PTHREAD_ONCE_INIT   _PTHREAD_ONCE_INITIALIZER

Static initialiser for pthread_once_t objects.

Definition at line 70 of file pthread.h.

◆ PTHREAD_PRIO_NONE

#define PTHREAD_PRIO_NONE   0

Mutex protocol: no priority inheritance or ceiling.

Definition at line 78 of file pthread.h.

◆ PTHREAD_PROCESS_PRIVATE

#define PTHREAD_PROCESS_PRIVATE   0

Mutex or barrier attribute: object is private to the process (default).

Definition at line 87 of file pthread.h.

◆ PTHREAD_PROCESS_SHARED

#define PTHREAD_PROCESS_SHARED   1

Mutex or barrier attribute: object is shared between processes.

Definition at line 85 of file pthread.h.

Function Documentation

◆ pthread_attr_destroy()

int pthread_attr_destroy ( pthread_attr_t attr)

Destroy a thread attributes object.

Parameters
attrThread attributes object to destroy.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_destroy.html

◆ pthread_attr_getdetachstate()

int pthread_attr_getdetachstate ( const pthread_attr_t attr,
int *  detachstate 
)

Get the detach state attribute of a thread attributes object.

Parameters
attrThread attributes object.
detachstateOutput: PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getdetachstate.html

◆ pthread_attr_getguardsize()

int pthread_attr_getguardsize ( const pthread_attr_t *ZRESTRICT  attr,
size_t *ZRESTRICT  guardsize 
)

Get the guard size attribute of a thread attributes object.

Parameters
attrThread attributes object.
guardsizeOutput: guard size in bytes.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getguardsize.html

◆ pthread_attr_getschedparam()

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.

Parameters
attrThread attributes object.
paramOutput: scheduling parameters.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedparam.html

◆ pthread_attr_init()

int pthread_attr_init ( pthread_attr_t attr)

Initialise a thread attributes object with default values.

Parameters
attrThread attributes object to initialise.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html

◆ pthread_attr_setdetachstate()

int pthread_attr_setdetachstate ( pthread_attr_t attr,
int  detachstate 
)

Set the detach state attribute of a thread attributes object.

Parameters
attrThread attributes object.
detachstatePTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setdetachstate.html

◆ pthread_attr_setguardsize()

int pthread_attr_setguardsize ( pthread_attr_t attr,
size_t  guardsize 
)

Set the guard size attribute of a thread attributes object.

Parameters
attrThread attributes object.
guardsizeGuard size in bytes.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setguardsize.html

◆ pthread_attr_setschedparam()

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.

Parameters
attrThread attributes object.
paramScheduling parameters to apply.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedparam.html

◆ pthread_cancel()

int pthread_cancel ( pthread_t  thread)

Send a cancellation request to a thread.

Parameters
threadThread to cancel.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cancel.html

◆ pthread_cond_broadcast()

int pthread_cond_broadcast ( pthread_cond_t *  cond)

Broadcast a condition variable, waking all waiting threads.

Parameters
condCondition variable to broadcast.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_broadcast.html

◆ pthread_cond_destroy()

int pthread_cond_destroy ( pthread_cond_t *  cond)

Destroy a condition variable.

Parameters
condCondition variable to destroy.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_destroy.html

◆ pthread_cond_init()

int pthread_cond_init ( pthread_cond_t *ZRESTRICT  cond,
const pthread_condattr_t *ZRESTRICT  attr 
)

Initialise a condition variable.

Parameters
condCondition variable to initialise.
attrCondition variable attributes, or NULL for defaults.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_init.html

◆ pthread_cond_signal()

int pthread_cond_signal ( pthread_cond_t *  cond)

Signal a condition variable, waking at least one waiting thread.

Parameters
condCondition variable to signal.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html

◆ pthread_cond_timedwait()

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

Parameters
condCondition variable.
mutexAssociated mutex (must be locked by the caller).
abstimeAbsolute timeout (CLOCK_REALTIME).
Returns
0 on success, ETIMEDOUT on timeout, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html

◆ pthread_cond_wait()

int pthread_cond_wait ( pthread_cond_t *ZRESTRICT  cond,
pthread_mutex_t *ZRESTRICT  mutex 
)

Wait on a condition variable.

Parameters
condCondition variable.
mutexAssociated mutex (must be locked by the caller).
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_wait.html

◆ pthread_condattr_destroy()

int pthread_condattr_destroy ( pthread_condattr_t *  attr)

Destroy a condition variable attributes object.

Parameters
attrCondition variable attributes object to destroy.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_destroy.html

◆ pthread_condattr_getclock()

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.

Parameters
attrCondition variable attributes object.
clock_idOutput: clock ID.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_getclock.html

◆ pthread_condattr_getpshared()

int pthread_condattr_getpshared ( const pthread_condattr_t *ZRESTRICT  attr,
int *ZRESTRICT  pshared 
)

Get the process-shared attribute of a condition variable attributes object.

Parameters
attrCondition variable attributes object.
psharedOutput: PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_getpshared.html

◆ pthread_condattr_init()

int pthread_condattr_init ( pthread_condattr_t *  attr)

Initialise a condition variable attributes object with default values.

Parameters
attrCondition variable attributes object to initialise.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_init.html

◆ pthread_condattr_setclock()

int pthread_condattr_setclock ( pthread_condattr_t *  attr,
clockid_t  clock_id 
)

Set the clock attribute of a condition variable attributes object.

Parameters
attrCondition variable attributes object.
clock_idClock ID (e.g. CLOCK_MONOTONIC or CLOCK_REALTIME).
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_setclock.html

◆ pthread_condattr_setpshared()

int pthread_condattr_setpshared ( pthread_condattr_t *  attr,
int  pshared 
)

Set the process-shared attribute of a condition variable attributes object.

Parameters
attrCondition variable attributes object.
psharedPTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_setpshared.html

◆ pthread_create()

int pthread_create ( pthread_t *ZRESTRICT  thread,
const pthread_attr_t *ZRESTRICT  attr,
void *(*)(void *)  start_routine,
void *ZRESTRICT  arg 
)

Create a new thread.

Parameters
threadOutput: thread ID of the new thread.
attrThread attributes, or NULL for defaults.
start_routineThread entry point function.
argArgument passed to start_routine.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html

◆ pthread_detach()

int pthread_detach ( pthread_t  thread)

Detach a thread, releasing its resources automatically on termination.

Parameters
threadThread to detach.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_detach.html

◆ pthread_equal()

int pthread_equal ( pthread_t  t1,
pthread_t  t2 
)

Compare two thread IDs.

Parameters
t1First thread ID.
t2Second thread ID.
Returns
Non-zero if t1 and t2 refer to the same thread, 0 otherwise.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_equal.html

◆ pthread_exit()

void pthread_exit ( void *  value_ptr)

Terminate the calling thread.

Parameters
value_ptrValue made available to pthread_join().
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html

◆ pthread_getspecific()

void * pthread_getspecific ( pthread_key_t  key)

Get the thread-specific value associated with a key.

Parameters
keyThread-specific data key.
Returns
Value associated with key for the calling thread, or NULL if none.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getspecific.html

◆ pthread_join()

int pthread_join ( pthread_t  thread,
void **  value_ptr 
)

Wait for a thread to terminate and retrieve its exit status.

Parameters
threadThread to wait for.
value_ptrOutput: exit value or PTHREAD_CANCELED.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

◆ pthread_key_create()

int pthread_key_create ( pthread_key_t *  key,
void(*)(void *)  destructor 
)

Create a thread-specific data key.

Parameters
keyOutput: new key.
destructorDestructor called with the thread's value when the thread exits, or NULL.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_key_create.html

◆ pthread_key_delete()

int pthread_key_delete ( pthread_key_t  key)

Delete a thread-specific data key.

Parameters
keyKey to delete.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_key_delete.html

◆ pthread_kill()

int pthread_kill ( pthread_t  thread,
int  sig 
)

Send a signal to a specific thread.

Parameters
threadTarget thread.
sigSignal number, or 0 to check thread existence.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html

◆ pthread_mutex_consistent()

int pthread_mutex_consistent ( pthread_mutex_t *  mutex)

Mark a robust mutex as consistent after recovering from owner death.

Parameters
mutexRobust mutex to mark consistent.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_consistent.html

◆ pthread_mutex_destroy()

int pthread_mutex_destroy ( pthread_mutex_t *  mutex)

Destroy a mutex.

Parameters
mutexMutex to destroy.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_destroy.html

◆ pthread_mutex_init()

int pthread_mutex_init ( pthread_mutex_t *ZRESTRICT  mutex,
const pthread_mutexattr_t *ZRESTRICT  attr 
)

Initialise a mutex.

Parameters
mutexMutex to initialise.
attrMutex attributes, or NULL for defaults.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html

◆ pthread_mutex_lock()

int pthread_mutex_lock ( pthread_mutex_t *  mutex)

Lock a mutex, blocking until it is available.

Parameters
mutexMutex to lock.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html

◆ pthread_mutex_timedlock()

int pthread_mutex_timedlock ( pthread_mutex_t *ZRESTRICT  mutex,
const struct timespec *ZRESTRICT  abstime 
)

Lock a mutex with an absolute timeout.

Parameters
mutexMutex to lock.
abstimeAbsolute timeout (CLOCK_REALTIME).
Returns
0 on success, ETIMEDOUT on timeout, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html

◆ pthread_mutex_trylock()

int pthread_mutex_trylock ( pthread_mutex_t *  mutex)

Try to lock a mutex without blocking.

Parameters
mutexMutex to try to lock.
Returns
0 if the lock was acquired, EBUSY if already locked, or a positive error number.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_trylock.html

◆ pthread_mutex_unlock()

int pthread_mutex_unlock ( pthread_mutex_t *  mutex)

Unlock a mutex.

Parameters
mutexMutex to unlock.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_unlock.html

◆ pthread_mutexattr_destroy()

int pthread_mutexattr_destroy ( pthread_mutexattr_t *  attr)

Destroy a mutex attributes object.

Parameters
attrMutex attributes object to destroy.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_destroy.html

◆ pthread_mutexattr_getpshared()

int pthread_mutexattr_getpshared ( const pthread_mutexattr_t *ZRESTRICT  attr,
int *ZRESTRICT  pshared 
)

Get the process-shared attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
psharedOutput: PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_getpshared.html

◆ pthread_mutexattr_getrobust()

int pthread_mutexattr_getrobust ( const pthread_mutexattr_t *ZRESTRICT  attr,
int *ZRESTRICT  robust 
)

Get the robustness attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
robustOutput: PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_getrobust.html

◆ pthread_mutexattr_gettype()

int pthread_mutexattr_gettype ( const pthread_mutexattr_t *ZRESTRICT  attr,
int *ZRESTRICT  type 
)

Get the type attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
typeOutput: PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE, or PTHREAD_MUTEX_DEFAULT.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_gettype.html

◆ pthread_mutexattr_init()

int pthread_mutexattr_init ( pthread_mutexattr_t *  attr)

Initialise a mutex attributes object with default values.

Parameters
attrMutex attributes object to initialise.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_init.html

◆ pthread_mutexattr_setpshared()

int pthread_mutexattr_setpshared ( pthread_mutexattr_t *  attr,
int  pshared 
)

Set the process-shared attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
psharedPTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_setpshared.html

◆ pthread_mutexattr_setrobust()

int pthread_mutexattr_setrobust ( pthread_mutexattr_t *  attr,
int  robust 
)

Set the robustness attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
robustPTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_setrobust.html

◆ pthread_mutexattr_settype()

int pthread_mutexattr_settype ( pthread_mutexattr_t *  attr,
int  type 
)

Set the type attribute of a mutex attributes object.

Parameters
attrMutex attributes object.
typePTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE, or PTHREAD_MUTEX_DEFAULT.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_settype.html

◆ pthread_once()

int pthread_once ( pthread_once_t *  once_control,
void(*)(void)  init_routine 
)

Ensure a one-time initialisation routine is called exactly once.

Parameters
once_controlPointer to a pthread_once_t initialised with PTHREAD_ONCE_INIT.
init_routineInitialisation function to call at most once.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_once.html

◆ pthread_self()

pthread_t pthread_self ( void  )

Return the thread ID of the calling thread.

Returns
Thread ID of the calling thread.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_self.html

◆ pthread_setcancelstate()

int pthread_setcancelstate ( int  state,
int *  oldstate 
)

Set the cancellability state of the calling thread.

Parameters
statePTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.
oldstateOutput: previous state, or NULL.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setcancelstate.html

◆ pthread_setcanceltype()

int pthread_setcanceltype ( int  type,
int *  oldtype 
)

Set the cancellability type of the calling thread.

Parameters
typePTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS.
oldtypeOutput: previous type, or NULL.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setcanceltype.html

◆ pthread_setspecific()

int pthread_setspecific ( pthread_key_t  key,
const void *  value 
)

Set the thread-specific value associated with a key.

Parameters
keyThread-specific data key.
valueValue to associate with key for the calling thread.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setspecific.html

◆ pthread_sigmask()

int pthread_sigmask ( int  how,
const sigset_t *ZRESTRICT  set,
sigset_t *ZRESTRICT  oset 
)

Examine and change blocked signals for the calling thread.

Parameters
howSIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK.
setSignal set to apply, or NULL.
osetOutput: previous signal mask, or NULL.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html

◆ pthread_testcancel()

void pthread_testcancel ( void  )

Create a cancellation point in the calling thread.

If cancellation is pending and enabled, this function does not return.

See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_testcancel.html

◆ sched_yield()

int sched_yield ( void  )

Yield the processor to another thread of equal or higher priority.

Returns
0 on success, or -1 with errno set on failure.
See also
IEEE 1003.1, sched_yield
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html