2010-05-16 16:23:32 +04:00
|
|
|
.\" $NetBSD: pthread.3,v 1.14 2010/05/16 12:23:32 jruoho Exp $
|
2003-07-24 11:50:24 +04:00
|
|
|
.\"
|
2009-04-16 22:37:29 +04:00
|
|
|
.\" Copyright (c) 2003, 2007, 2009 The NetBSD Foundation, Inc.
|
2003-07-24 11:50:24 +04:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
2008-05-09 12:31:13 +04:00
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Hubert Feyrer <hubertf@NetBSD.org> and Thomas Klausner <wiz@NetBSD.org>.
|
|
|
|
.\"
|
2003-07-24 11:50:24 +04:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
2008-05-09 12:31:13 +04:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
2003-07-24 11:50:24 +04:00
|
|
|
.\"
|
2010-05-16 16:20:00 +04:00
|
|
|
.Dd May 16, 2010
|
2003-07-24 11:50:24 +04:00
|
|
|
.Dt PTHREAD 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pthread
|
|
|
|
.Nd POSIX Threads Library
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libpthread
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In pthread.h
|
|
|
|
.Pp
|
|
|
|
.Nm cc
|
|
|
|
.Op Ar flags
|
|
|
|
.Ar files
|
|
|
|
.Fl lpthread
|
|
|
|
.Op Ar libraries
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
2007-03-06 02:53:53 +03:00
|
|
|
library provides an implementation of the standard
|
2003-07-24 11:50:24 +04:00
|
|
|
.Tn POSIX
|
2009-10-06 03:35:42 +04:00
|
|
|
threads library.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nx
|
|
|
|
implementation is based on 1:1 thread model, therefore each
|
|
|
|
.Nm
|
|
|
|
has a kernel thread, called a light-weight process (LWP).
|
2007-11-19 18:53:20 +03:00
|
|
|
.Pp
|
|
|
|
Note that the system private thread interfaces upon which the
|
|
|
|
.Nm
|
|
|
|
library is built are subject to change without notice.
|
|
|
|
In order to remain compatible with future
|
|
|
|
.Nx
|
|
|
|
releases, programs must be linked against the dynamic version of the
|
|
|
|
thread library.
|
|
|
|
Statically linked programs using the
|
|
|
|
.Tn POSIX
|
|
|
|
threads framework may not work when run on a future version of the system.
|
2010-05-16 16:20:00 +04:00
|
|
|
.Sh FUNCTIONS
|
|
|
|
The following functions comprise the core of the
|
|
|
|
.Nm
|
|
|
|
library:
|
|
|
|
.Bl -column -offset indent "pthread_barrier_destroy(3)" "XXX"
|
|
|
|
.It Sy Function Ta Sy Description
|
|
|
|
.It Xr pthread_attr 3 Ta thread attribute operations
|
|
|
|
.It Xr pthread_barrier_destroy 3 Ta destroy a barrier
|
|
|
|
.It Xr pthread_barrier_init 3 Ta create a barrier
|
|
|
|
.It Xr pthread_barrier_wait 3 Ta wait for a barrier
|
|
|
|
.It Xr pthread_barrierattr 3 Ta barrier attribute operations
|
|
|
|
.It Xr pthread_cancel 3 Ta cancel the execution of a thread
|
|
|
|
.It Xr pthread_cleanup_push 3 Ta add or remove cleanup functions
|
|
|
|
.It Xr pthread_cond_broadcast 3 Ta unblock one or more threads
|
|
|
|
.It Xr pthread_cond_destroy 3 Ta destroy a condition variable
|
|
|
|
.It Xr pthread_cond_init 3 Ta create a condition variable
|
|
|
|
.It Xr pthread_cond_wait 3 Ta wait for a condition variable
|
|
|
|
.It Xr pthread_condattr 3 Ta condition attribute operations
|
|
|
|
.It Xr pthread_create 3 Ta create a new thread
|
|
|
|
.It Xr pthread_detach 3 Ta detach a thread
|
|
|
|
.It Xr pthread_equal 3 Ta compare thread identifiers
|
|
|
|
.It Xr pthread_exit 3 Ta terminate the calling thread
|
|
|
|
.It Xr pthread_getspecific 3 Ta get a thread-specific data value
|
|
|
|
.It Xr pthread_join 3 Ta wait for thread termination
|
|
|
|
.It Xr pthread_key_create 3 Ta thread-specific data key creation
|
|
|
|
.It Xr pthread_key_delete 3 Ta delete a thread-specific data key
|
|
|
|
.It Xr pthread_kill 3 Ta send a signal to a specific thread
|
|
|
|
.It Xr pthread_mutex_destroy 3 Ta free a mutex
|
|
|
|
.It Xr pthread_mutex_init 3 Ta create a mutex
|
|
|
|
.It Xr pthread_mutex_lock 3 Ta acquire a lock on a mutex
|
|
|
|
.It Xr pthread_mutex_unlock 3 Ta unlock a mutex
|
|
|
|
.It Xr pthread_mutexattr 3 Ta mutex attribute operations
|
|
|
|
.It Xr pthread_once 3 Ta dynamic package initialization
|
|
|
|
.It Xr pthread_rwlock_destroy 3 Ta destroy a read/write lock
|
|
|
|
.It Xr pthread_rwlock_init 3 Ta initialize a read/write lock
|
|
|
|
.It Xr pthread_rwlock_rdlock 3 Ta acquire a read/write lock for reading
|
|
|
|
.It Xr pthread_rwlock_unlock 3 Ta release a read/write lock
|
|
|
|
.It Xr pthread_rwlock_wrlock 3 Ta acquire a read/write lock for writing
|
|
|
|
.It Xr pthread_rwlockattr 3 Ta read/write lock attribute operations
|
|
|
|
.It Xr pthread_schedparam 3 Ta thread scheduling manipulation
|
|
|
|
.It Xr pthread_self 3 Ta get the ID of the calling thread
|
|
|
|
.It Xr pthread_setspecific 3 Ta get a thread-specific data value
|
|
|
|
.It Xr pthread_sigmask 3 Ta manipulate a thread's signal mask
|
|
|
|
.It Xr pthread_spin_destroy 3 Ta destroy a spin lock
|
|
|
|
.It Xr pthread_spin_init 3 Ta initialize a spin lock
|
|
|
|
.It Xr pthread_spin_lock 3 Ta acquire a spin lock
|
|
|
|
.It Xr pthread_spin_unlock 3 Ta release a spin lock
|
|
|
|
.It Xr pthread_testcancel 3 Ta set cancelability state
|
|
|
|
.El
|
2003-07-24 11:50:24 +04:00
|
|
|
.Sh ENVIRONMENT
|
2010-05-16 16:20:00 +04:00
|
|
|
The following environment variables affect the behavior of the library:
|
|
|
|
.Bl -tag -width "XXX"
|
2003-07-24 11:50:24 +04:00
|
|
|
.It Ev PTHREAD_DIAGASSERT
|
|
|
|
Possible values are any combinations of:
|
2008-10-08 14:11:11 +04:00
|
|
|
.Pp
|
2010-05-16 16:20:00 +04:00
|
|
|
.Bl -tag -width "X " -offset 1n -compact
|
|
|
|
.It Em A
|
2008-10-08 14:11:11 +04:00
|
|
|
Report errors to application by error return, but do not abort.
|
2010-05-16 16:20:00 +04:00
|
|
|
.It Em a
|
2003-07-24 11:50:24 +04:00
|
|
|
Abort on errors, creating a core dump for further debugging.
|
2010-05-16 16:20:00 +04:00
|
|
|
.It Em E
|
2003-07-24 11:50:24 +04:00
|
|
|
Do not log errors to stdout.
|
2010-05-16 16:20:00 +04:00
|
|
|
.It Em e
|
2003-07-24 11:50:24 +04:00
|
|
|
Log errors to stdout.
|
2010-05-16 16:20:00 +04:00
|
|
|
.It Em L
|
2003-07-24 11:50:24 +04:00
|
|
|
Do not log errors via
|
|
|
|
.Xr syslogd 8 .
|
2010-05-16 16:20:00 +04:00
|
|
|
.It Em l
|
2003-07-24 11:50:24 +04:00
|
|
|
Log errors via
|
|
|
|
.Xr syslogd 8 .
|
|
|
|
.El
|
2008-10-08 14:11:11 +04:00
|
|
|
.Pp
|
|
|
|
If not set in the environment, the
|
|
|
|
.Nm
|
2009-04-11 20:51:28 +04:00
|
|
|
library behaves as if
|
2010-05-16 16:20:00 +04:00
|
|
|
.Em AEL
|
2008-10-08 14:11:11 +04:00
|
|
|
has been specified.
|
2003-11-27 19:30:54 +03:00
|
|
|
.It Ev PTHREAD_STACKSIZE
|
|
|
|
Integer value giving the stack size in kilobytes.
|
|
|
|
This allows to set a smaller stack size than the default stack size.
|
|
|
|
The default stack size is the current limit on the stack size as
|
|
|
|
set with the shell's command to change limits
|
|
|
|
.Ic ( limit
|
|
|
|
for
|
|
|
|
.Xr csh 1 ,
|
|
|
|
or
|
|
|
|
.Ic ulimit
|
|
|
|
for
|
|
|
|
.Xr sh 1 ) .
|
2003-07-24 11:50:24 +04:00
|
|
|
.El
|
2010-05-16 16:23:32 +04:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Rs
|
|
|
|
.%A David R. Butenhof
|
|
|
|
.%T Programming with POSIX(R) Threads
|
|
|
|
.%D 1997
|
|
|
|
.%I Addison-Wesley
|
|
|
|
.Re
|
2003-07-24 11:50:24 +04:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
library conforms to
|
|
|
|
.St -p1003.1-2001 .
|
2009-04-16 22:37:29 +04:00
|
|
|
.Sh CAVEATS
|
|
|
|
Due to limitations in the current pthread implementation,
|
|
|
|
.Xr makecontext 3
|
|
|
|
and
|
|
|
|
.Xr sigaltstack 2
|
|
|
|
should not be used in programs which link against the
|
|
|
|
.Nm
|
|
|
|
library (whether threads are used or not).
|