Something went wrong. Try again.
Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443.\" Portions Copyright (c) 2001 Apple Computer, Inc. All Rights Reserved..\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>..\" All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by John Birrell..\" 4. Neither the name of the author nor the names of any co-contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" $FreeBSD: src/share/man/man3/pthread.3,v 1.12.2.4 2001/08/17 13:08:36 ru Exp $.\".Dd November 5, 2001.Dt PTHREAD 3.Os Darwin.Sh NAME.Nm pthread.Nd POSIX thread functions.Sh SYNOPSIS.Fd #include <pthread.h>.Sh DESCRIPTIONPOSIX threads are a set of functions that support applications withrequirements for multiple flows of control, called.Fa threads ,within a process.Multithreading is used to improve the performance of aprogram..PpThe POSIX thread functions are summarized in this section in the followinggroups:.Bl -bullet -offset indent.ItThread Routines.ItAttribute Object Routines.ItMutex Routines.ItCondition Variable Routines.ItRead/Write Lock Routines.ItPer-Thread Context Routines.ItCleanup Routines.El.Sh THREAD ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg".XcCreates a new thread of execution..It Xo.Ft int.Fn pthread_detach "pthread_t thread".XcMarks a thread for deletion..It Xo.Ft int.Fn pthread_equal "pthread_t t1" "pthread_t t2".XcCompares two thread IDs..It Xo.Ft void.Fn pthread_exit "void *value_ptr".XcTerminates the calling thread..It Xo.Ft int.Fn pthread_join "pthread_t thread" "void **value_ptr".XcCauses the calling thread to wait for the termination of the specified thread..It Xo.Ft int.Fn pthread_cancel "pthread_t thread".XcCancels execution of a thread..It Xo.Ft int.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)".XcCalls an initialization routine once..It Xo.Ft pthread_t.Fn pthread_self void.XcReturns the thread ID of the calling thread..It Xo.Ft int .Fn pthread_atfork "void (*prepare)(void)" "void (*parent)(void)" "void (*child)(void)".XcRegisters handlers to be called before and after.Fn fork.El.Sh ATTRIBUTE OBJECT ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_attr_destroy "pthread_attr_t *attr".XcDestroy a thread attributes object..It Xo.Ft int.Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched".XcGet the inherit scheduling attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param".XcGet the scheduling parameter attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy".XcGet the scheduling policy attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope".XcGet the contention scope attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize".XcGet the stack size attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr".XcGet the stack address attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate".XcGet the detach state attribute from a thread attributes object..It Xo.Ft int.Fn pthread_attr_init "pthread_attr_t *attr".XcInitialize a thread attributes object with default values..It Xo.Ft int.Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched".XcSet the inherit scheduling attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param".XcSet the scheduling parameter attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy".XcSet the scheduling policy attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope".XcSet the contention scope attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize".XcSet the stack size attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr".XcSet the stack address attribute in a thread attributes object..It Xo.Ft int.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate".XcSet the detach state in a thread attributes object..El.Sh MUTEX ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr".XcDestroy a mutex attributes object..It Xo.Ft int.Fn pthread_mutexattr_init "pthread_mutexattr_t *attr".XcInitialize a mutex attributes object with default values..It Xo.Ft int.Fn pthread_mutex_destroy "pthread_mutex_t *mutex".XcDestroy a mutex..It Xo.Ft int.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr".XcInitialize a mutex with specified attributes..It Xo.Ft int.Fn pthread_mutex_lock "pthread_mutex_t *mutex".XcLock a mutex and block until it becomes available..It Xo.Ft int.Fn pthread_mutex_trylock "pthread_mutex_t *mutex".XcTry to lock a mutex, but don't block if the mutex is locked by another thread,including the current thread..It Xo.Ft int.Fn pthread_mutex_unlock "pthread_mutex_t *mutex".XcUnlock a mutex..El.Sh CONDITION VARIABLE ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_condattr_init "pthread_condattr_t *attr".XcInitialize a condition variable attributes object with default values..It Xo.Ft int.Fn pthread_condattr_destroy "pthread_condattr_t *attr".XcDestroy a condition variable attributes object..It Xo.Ft int.Fn pthread_cond_broadcast "pthread_cond_t *cond".XcUnblock all threads currently blocked on the specified condition variable..It Xo.Ft int.Fn pthread_cond_destroy "pthread_cond_t *cond".XcDestroy a condition variable..It Xo.Ft int.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr".XcInitialize a condition variable with specified attributes..It Xo.Ft int.Fn pthread_cond_signal "pthread_cond_t *cond".XcUnblock at least one of the threads blocked on the specified condition variable..It Xo.Ft int.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime".XcWait no longer than the specified time for a condition and lock the specified mutex..It Xo.Ft int.Fn pthread_cond_wait "pthread_cond_t *" "pthread_mutex_t *mutex".XcWait for a condition and lock the specified mutex..El.Sh READ/WRITE LOCK ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock".XcDestroy a read/write lock object..It Xo.Ft int.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr".XcInitialize a read/write lock object..It Xo.Ft int.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock".XcLock a read/write lock for reading, blocking until the lock can beacquired..It Xo.Ft int.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock".XcAttempt to lock a read/write lock for reading, without blocking if thelock is unavailable..It Xo.Ft int.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock".XcAttempt to lock a read/write lock for writing, without blocking if thelock is unavailable..It Xo.Ft int.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock".XcUnlock a read/write lock..It Xo.Ft int.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock".XcLock a read/write lock for writing, blocking until the lock can beacquired..It Xo.Ft int.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr".XcDestroy a read/write lock attribute object..It Xo.Ft int.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared".XcRetrieve the process shared setting for the read/write lock attributeobject..It Xo.Ft int.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr".XcInitialize a read/write lock attribute object..It Xo.Ft int.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared".XcSet the process shared setting for the read/write lock attribute object..El.Sh PER-THREAD CONTEXT ROUTINES.Bl -tag -width Er.It Xo.Ft int.Fn pthread_key_create "pthread_key_t *key" "void (*routine)(void *)".XcCreate a thread-specific data key..It Xo.Ft int.Fn pthread_key_delete "pthread_key_t key".XcDelete a thread-specific data key..It Xo.Ft "void *".Fn pthread_getspecific "pthread_key_t key".XcGet the thread-specific value for the specified key..It Xo.Ft int.Fn pthread_setspecific "pthread_key_t key" "const void *value_ptr".XcSet the thread-specific value for the specified key..El.Sh CLEANUP ROUTINES.Bl -tag -width Er.It Xo.Ft void.Fn pthread_cleanup_pop "int execute".XcRemove the routine at the top of the calling thread's cancellation cleanupstack and optionally invoke it..It Xo.Ft void.Fn pthread_cleanup_push "void (*routine)(void *)" "void *routine_arg".XcPush the specified cancellation cleanup handler onto the calling thread'scancellation stack..El.Sh INSTALLATIONThe default system libraries include.Nm pthreadfunctions.No additional libraries or CFLAGS are necessary to use this API..Sh SEE ALSO.Xr pthread_cleanup_pop 3 ,.Xr pthread_cleanup_push 3 ,.Xr pthread_cond_broadcast 3 ,.Xr pthread_cond_destroy 3 ,.Xr pthread_cond_init 3 ,.Xr pthread_cond_signal 3 ,.Xr pthread_cond_timedwait 3 ,.Xr pthread_cond_wait 3 ,.Xr pthread_create 3 ,.Xr pthread_detach 3 ,.Xr pthread_equal 3 ,.Xr pthread_exit 3 ,.Xr pthread_getspecific 3 ,.Xr pthread_join 3 ,.Xr pthread_key_delete 3 ,.Xr pthread_mutex_destroy 3 ,.Xr pthread_mutex_init 3 ,.Xr pthread_mutex_lock 3 ,.Xr pthread_mutex_trylock 3 ,.Xr pthread_mutex_unlock 3 ,.Xr pthread_once 3 ,.Xr pthread_rwlock_destroy 3 ,.Xr pthread_rwlock_init 3 ,.Xr pthread_rwlock_rdlock 3 ,.Xr pthread_rwlock_unlock 3 ,.Xr pthread_rwlock_wrlock 3 ,.Xr pthread_rwlockattr_destroy 3 ,.Xr pthread_rwlockattr_getpshared 3 ,.Xr pthread_rwlockattr_init 3 ,.Xr pthread_rwlockattr_setpshared 3 ,.Xr pthread_self 3 ,.Xr pthread_setspecific 3.Sh STANDARDSThe functions in.Fa libcwith the.Fa pthread_prefix and not.Fa _npsuffix or.Fa pthread_rwlockprefix conform to.St -p1003.1-96 ..PpThe functions in libc with the.Fa pthread_prefix and.Fa _npsuffix are non-portable extensions to POSIX threads..PpThe functions in libc with the.Fa pthread_rwlockprefix are extensions created by The Open Group as part of the.St -susv2 .