PTHREAD(3) | Library Functions Manual | PTHREAD(3) |
pthread
— POSIX
thread functions
#include
<pthread.h>
POSIX threads are a set of functions that support applications with requirements for multiple flows of control, called threads, within a process. Multithreading is used to improve the performance of a program.
The POSIX thread functions are summarized in this section in the following groups:
pthread_create
(pthread_t
*thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void
*arg);pthread_cancel
(pthread_t
thread)pthread_detach
(pthread_t
thread)pthread_equal
(pthread_t
t1, pthread_t t2)pthread_exit
(void
*value_ptr)pthread_join
(pthread_t
thread, void **value_ptr)pthread_kill
(pthread_t
thread, int sig)pthread_once
(pthread_once_t
*once_control, void (*init_routine)(void))pthread_self
(void)pthread_setcancelstate
(int
state, int *oldstate)pthread_setcanceltype
(int
type, int *oldtype)pthread_testcancel
(void)pthread_attr_destroy
(pthread_attr_t
*attr)pthread_attr_getinheritsched
(const
pthread_attr_t *attr, int *inheritsched);pthread_attr_getschedparam
(const
pthread_attr_t *attr, struct sched_param
*param);pthread_attr_getschedpolicy
(const
pthread_attr_t *attr, int *policy)pthread_attr_getscope
(const
pthread_attr_t *attr, int *contentionscope)pthread_attr_getstacksize
(const
pthread_attr_t *attr, size_t *stacksize)pthread_attr_getstackaddr
(const
pthread_attr_t *attr, void **stackaddr)pthread_attr_getdetachstate
(const
pthread_attr_t *attr, int *detachstate)pthread_attr_init
(pthread_attr_t
*attr)pthread_attr_setinheritsched
(pthread_attr_t
*attr, int inheritsched)pthread_attr_setschedparam
(pthread_attr_t
*attr, const struct sched_param *param);pthread_attr_setschedpolicy
(pthread_attr_t
*attr, int policy)pthread_attr_setscope
(pthread_attr_t
*attr, int contentionscope)pthread_attr_setstacksize
(pthread_attr_t
*attr, size_t stacksize)pthread_attr_setstackaddr
(pthread_attr_t
*attr, void *stackaddr)pthread_attr_setdetachstate
(pthread_attr_t
*attr, int detachstate)pthread_mutexattr_destroy
(pthread_mutexattr_t
*attr)pthread_mutexattr_getprioceiling
(pthread_mutexattr_t
*attr, int *ceiling)pthread_mutexattr_getprotocol
(pthread_mutexattr_t
*attr, int *protocol)pthread_mutexattr_gettype
(pthread_mutexattr_t
*attr, int *type)pthread_mutexattr_init
(pthread_mutexattr_t
*attr)pthread_mutexattr_setprioceiling
(pthread_mutexattr_t
*attr, int ceiling)pthread_mutexattr_setprotocol
(pthread_mutexattr_t
*attr, int protocol)pthread_mutexattr_settype
(pthread_mutexattr_t
*attr, int type)pthread_mutex_destroy
(pthread_mutex_t
*mutex)pthread_mutex_init
(pthread_mutex_t
*mutex, const pthread_mutexattr_t *attr);pthread_mutex_lock
(pthread_mutex_t
*mutex)pthread_mutex_trylock
(pthread_mutex_t
*mutex)pthread_mutex_unlock
(pthread_mutex_t
*mutex)pthread_condattr_destroy
(pthread_condattr_t
*attr)pthread_condattr_init
(pthread_condattr_t
*attr)pthread_cond_broadcast
(pthread_cond_t
*cond)pthread_cond_destroy
(pthread_cond_t
*cond)pthread_cond_init
(pthread_cond_t
*cond, const pthread_condattr_t *attr)pthread_cond_signal
(pthread_cond_t
*cond)pthread_cond_timedwait
(pthread_cond_t
*cond, pthread_mutex_t *mutex,
const struct timespec *abstime);pthread_cond_wait
(pthread_cond_t
*, pthread_mutex_t *mutex)pthread_rwlock_destroy
(pthread_rwlock_t
*lock)pthread_rwlock_init
(pthread_rwlock_t
*lock, const pthread_rwlockattr_t *attr);pthread_rwlock_rdlock
(pthread_rwlock_t
*lock)pthread_rwlock_tryrdlock
(pthread_rwlock_t
*lock)pthread_rwlock_trywrlock
(pthread_rwlock_t
*lock)pthread_rwlock_unlock
(pthread_rwlock_t
*lock)pthread_rwlock_wrlock
(pthread_rwlock_t
*lock)pthread_rwlockattr_destroy
(pthread_rwlockattr_t
*attr)pthread_rwlockattr_init
(pthread_rwlockattr_t
*attr)pthread_key_create
(pthread_key_t
*key, void (*routine)(void *))pthread_key_delete
(pthread_key_t
key)pthread_getspecific
(pthread_key_t
key)pthread_setspecific
(pthread_key_t
key, const void *value_ptr)pthread_atfork
(void
(*prepare)(void), void (*parent)(void),
void (*child)(void));pthread_cleanup_pop
(int
execute)pthread_cleanup_push
(void
(*routine)(void *), void *routine_arg)The default system libraries include
pthread
functions. No additional libraries or CFLAGS
are necessary to use these interfaces.
pthread_atfork(3), pthread_attr(3), pthread_cancel(3), pthread_cleanup_pop(3), pthread_cleanup_push(3), pthread_cond_broadcast(3), pthread_cond_destroy(3), pthread_cond_init(3), pthread_cond_signal(3), pthread_cond_timedwait(3), pthread_cond_wait(3), pthread_condattr(3), pthread_condattr_destroy(3), pthread_condattr_init(3), pthread_create(3), pthread_detach(3), pthread_equal(3), pthread_exit(3), pthread_getschedparam(3), pthread_getspecific(3), pthread_join(3), pthread_key_create(3), pthread_key_delete(3), pthread_kill(3), pthread_mutex_destroy(3), pthread_mutex_init(3), pthread_mutex_lock(3), pthread_mutex_trylock(3), pthread_mutex_unlock(3), pthread_mutexattr(3), pthread_mutexattr_destroy(3), pthread_mutexattr_getprioceiling(3), pthread_mutexattr_getprotocol(3), pthread_mutexattr_gettype(3), pthread_mutexattr_init(3), pthread_mutexattr_setprioceiling(3), pthread_mutexattr_setprotocol(3), pthread_mutexattr_settype(3), pthread_once(3), pthread_rwlock_destroy(3), pthread_rwlock_init(3), pthread_rwlock_rdlock(3), pthread_rwlock_tryrdlock(3), pthread_rwlock_trywrlock(3), pthread_rwlock_unlock(3), pthread_rwlock_wrlock(3), pthread_rwlockattr_destroy(3), pthread_rwlockattr_getpshared(3), pthread_rwlockattr_init(3), pthread_rwlockattr_setpshared(3), pthread_self(3), pthread_setcancelstate(3), pthread_setcanceltype(3), pthread_setspecific(3), pthread_testcancel(3)
The functions with the pthread_
prefix and
not _np
suffix or
pthread_rwlock
prefix conform to
ISO/IEC 9945-1:1996 (“POSIX.1”).
The functions with the pthread_
prefix and
_np
suffix are non-portable extensions to POSIX
threads.
The functions with the pthread_rwlock
prefix are extensions created by The Open Group as part of the
Version 2 of the Single UNIX Specification
(“SUSv2”).
August 12, 2014 | Darwin |