.\" 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.
.\"
.\"	%Id: pthread.3,v 1.7 1998/09/12 13:53:58 alex Exp %
.\"
.\" jpman %Id$
.\"
.Dd September 10, 1998
.Dt PTHREAD 3
.Os BSD 4
.Sh ̾��
.Nm pthread
.Nd POSIX ����åɴؿ�
.Sh ����
POSIX ����åɤϡ��ץ������������ʣ���Υե���
(����å�) ���׵᤹�륢�ץꥱ�������򥵥ݡ��Ȥ���ؿ��Ǥ���
�ޥ������åɤϡ�
�ץ������Υѥե����ޥ󥹤�������뤿��˻��Ѥ���ޤ���
���Υ��������Ǥϡ�
POSIX ����åɴؿ��γ��פˤĤ��ưʲ��Υ��롼�פ�ʬ�����������ޤ���
.Bl -bullet -offset indent
.It
����åɥ롼����
.It
°�����֥������ȥ롼����
.It
Mutex �롼����
.It
����ѿ��롼����
.It
�ɤ߽񤭥��å��롼����
.It
����åɸ�ͭ����ƥ����ȥ롼����
.It
���꡼�󥢥åץ롼����
.El
.Sh ����åɥ롼����
.Bl -tag -width Er
.It int Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg"
�¹Ԥο���������åɤ�������ޤ���
.It int Fn pthread_detach "pthread_t thread"
����åɤ˺���ޡ������դ��ޤ���
.It int Fn pthread_equal "pthread_t t1" "pthread_t t2"
2 �ĤΥ���å� ID ����Ӥ��ޤ���
.It void Fn pthread_exit "void *value_ptr"
�ƤӽФ�����åɤ�λ���ޤ���
.It int Fn pthread_join "pthread_t thread" "void **value_ptr"
�ƤӽФ�����åɤ������ꤷ������åɤν�λ���ԤĤ褦�ˤʤꤹ��
.It int Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)"
������롼����� 1 ��ƤӽФ��ޤ���
.It pthread_t Fn pthread_self void
�ƤӽФ�����åɤΥ���å� ID ���ᤷ�ޤ���
.El
.Sh °�����֥������ȥ롼����
.Bl -tag -width Er
.It int Fn pthread_attr_destroy "pthread_attr_t *attr"
����åɤ�°�����֥������Ȥ��˲����ޤ���
.It int Fn pthread_attr_getinheritsched "pthread_attr_t *attr" "int *inheritsched"
����åɤ�°�����֥������Ȥ���Ѿ��������塼���°�������ꤷ�ޤ���
.It int Fn pthread_attr_getschedparam "pthread_attr_t *attr" "struct sched_param *param"
����åɤ�°�����֥������Ȥ��饹�����塼��󥰥ѥ�᡼��°�������ꤷ�ޤ���
.It int Fn pthread_attr_getschedpolicy "pthread_attr_t *attr" "int *policy"
����åɤ�°�����֥������Ȥ��饹�����塼�������°�������ꤷ�ޤ���
.It int Fn pthread_attr_getscope "pthread_attr_t *attr" "int *contentionscope"
����åɤ�°�����֥������Ȥ��饳��ƥ󥷥���ϰ�°�������ꤷ�ޤ���
.It int Fn pthread_attr_getstacksize "pthread_attr_t *attr" "size_t *stacksize"
����åɤ�°�����֥������Ȥ��饹���å�������°�������ꤷ�ޤ���
.It int Fn pthread_attr_getstackaddr "pthread_attr_t *attr" "void **stackaddr"
����åɤ�°�����֥������Ȥ��饹���å����ɥ쥹°�������ꤷ�ޤ���
.It int Fn pthread_attr_getdetachstate "pthread_attr_t *attr" "int *detachstate"
����åɤ�°�����֥������Ȥ����ڤ�Υ������°�������ꤷ�ޤ���
.It int Fn pthread_attr_init "pthread_attr_t *attr"
����åɤ�°�����֥������Ȥ�ǥե�����ͤǽ�������ޤ���
.It int Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched"
����åɤ�°�����֥������ȤǷѾ��������塼���°�������ꤷ�ޤ���
.It int Fn pthread_attr_setschedparam "pthread_attr_t *attr" "struct sched_param *param"
����åɤ�°�����֥������Ȥǥ������塼��󥰥ѥ�᡼��°�������ꤷ�ޤ���
.It int Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy"
����åɤ�°�����֥������Ȥǥ������塼�������°�������ꤷ�ޤ���
.It int Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope"
����åɤ�°�����֥������Ȥǥ���ƥ󥷥���ϰ�°�������ꤷ�ޤ���
.It int Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize"
����åɤ�°�����֥������Ȥǥ����å�������°�������ꤷ�ޤ���
.It int Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr"
����åɤ�°�����֥������Ȥǥ����å����ɥ쥹°�������ꤷ�ޤ���
.It int Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
����åɤ�°�����֥������Ȥ��ڤ�Υ�����֤����ꤷ�ޤ���
.El
.Sh MUTEX �롼����
.Bl -tag -width Er
.It int Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr"
MUTEX °�����֥������Ȥ��˲����ޤ���
.It int Fn pthread_mutexattr_init "pthread_mutexattr_t *attr"
MUTEX °�����֥������Ȥ�ǥե�����ͤǽ�������ޤ���
.It int Fn pthread_mutex_destroy "pthread_mutex_t *mutex"
MUTEX ���˲����ޤ���
.It int Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr"
���ꤵ�줿°���� MUTEX ���������ޤ���
.It int Fn pthread_mutex_lock "pthread_mutex_t *mutex"
MUTEX ����å�����MUTEX �����ѤǤ���褦�ˤʤ�ޤǥ֥��å����ޤ���
.It int Fn pthread_mutex_trylock "pthread_mutex_t *mutex"
MUTEX ����å����褦�Ȥ��ޤ�����
���ԥ���åɤ�ޤ᤿�̤Υ���åɤ�
MUTEX �����å�����Ƥ�����ϥ֥��å����ޤ���
.It int Fn pthread_mutex_unlock "pthread_mutex_t *mutex"
MUTEX �Υ��å��������ޤ���
.El
.Sh ����ѿ��롼����
.Bl -tag -width Er
.It int Fn pthread_condattr_init "pthread_condattr_t *attr"
����ѿ�°�����֥������Ȥ�ǥե�����ͤǽ�������ޤ���
.It int Fn pthread_condattr_destroy "pthread_condattr_t *attr"
����ѿ�°�����֥������Ȥ��˲����ޤ���
.It int Fn pthread_cond_broadcast "pthread_cond_t *cond"
���ꤵ�줿����ѿ��Ǹ��ߥ֥��å�����Ƥ��롢
���٤ƤΥ���åɤΥ֥��å��������ޤ���
.It int Fn pthread_cond_destroy "pthread_cond_t *cond"
����ѿ����˲����ޤ���
.It int Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr"
���ꤵ�줿°���Ǿ���ѿ����������ޤ���
.It int Fn pthread_cond_signal "pthread_cond_t *cond"
���ꤵ�줿����ѿ��ǥ֥��å�����Ƥ��륹��åɤΡ�
���� 1 �ĤΥ֥��å��������ޤ���
.It int Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime"
���ꤵ�줿���ְ���Ǿ����Ե�����
���ꤵ�줿 MUTEX ����å����ޤ���
.It int Fn pthread_cond_wait "pthread_cond_t *" "pthread_mutex_t *mutex"
�����Ե��������ꤵ�줿 MUTEX ����å����ޤ���
.El
.Sh �ɤ߽񤭥��å��롼����
.Bl -tag -width Er
.It int Fn pthread_rwlock_destroy "pthread_rwlock_t *lock"
�ɤ߽񤭥��å����֥������Ȥ��˲����ޤ���
.It int Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockat-tr_t *attr"
�ɤ߽񤭥��å����֥������Ȥ��������ޤ���
.It int Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock"
�ɤ߽񤭥��å����ɹ����Ѥ˥��å�����
���å�������Ǥ���ޤǥ֥��å����ޤ���
.It int Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock"
�ɤ߽񤭥��å����ɹ����Ѥ˥��å����褦�Ȥ��ޤ�����
���å�����ѤǤ��ʤ����ϥ֥��å����ޤ���
.It int Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock"
�ɤ߽񤭥��å��������Ѥ˥��å����褦�Ȥ��ޤ�����
���å�����ѤǤ��ʤ����ϥ֥��å����ޤ���
.It int Fn pthread_rwlock_unlock "pthread_rwlock_t *lock"
�ɤ߽񤭥��å��������ޤ���
.It int Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock"
�ɤ߽񤭥��å��������Ѥ˥��å�����
���å�������Ǥ���ޤǥ֥��å����ޤ���
.It int Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr"
�ɤ߽񤭥��å�°�����֥������Ȥ��˲����ޤ���
.It int Fn pthread_rwlockattr_getpshared "pthread_rwlockattr_t *attr" "int *pshared"
�ץ������Ƕ�ͭ���Ƥ��롢
�ɤ߽񤭥��å�°�����֥������Ȥ��������Ф��ޤ���
.It int Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr"
�ɤ߽񤭥��å�°�����֥������Ȥ��������ޤ���
.It int Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int *pshared"
�ץ������Ƕ�ͭ���Ƥ��롢
�ɤ߽񤭥��å�°�����֥������Ȥ���������ꤷ�ޤ���
.El
.Sh ����åɸ�ͭ����ƥ����ȥ롼����
.Bl -tag -width Er
.It int Fn pthread_key_create "pthread_key_t *key" "void (*routine)(void *)"
����åɤ˸�ͭ�ʥǡ���������������ޤ���
.It int Fn pthread_key_delete "pthread_key_t key"
����åɤ˸�ͭ�ʥǡ��������������ޤ���
.It void * Fn pthread_getspecific "pthread_key_t key" "void **value_ptr"
���ꤵ�줿�����Υ���åɤ˸�ͭ���ͤ����ꤷ�ޤ���
.It int Fn pthread_setspecific "pthread_key_t key" "const void *value_ptr"
���ꤵ�줿�����Υ���åɤ˸�ͭ���ͤ����ꤷ�ޤ���
.El
.Sh ���꡼�󥢥åץ롼����
.Bl -tag -width Er
.It void Fn pthread_cleanup_pop "int execute"
�ƤӽФ�����åɤΥ���󥻥륯�꡼�󥢥åץ����å���
�Ǿ�̤ǥ롼��������������ץ����ǵ�ư���ޤ���
.It void Fn pthread_cleanup_push "void (*routine)(void *)" "void *routine_arg"
���ꤵ�줿����󥻥륯�꡼�󥢥åץϥ�ɥ��ƤӽФ�
����åɤΥ���󥻥륹���å��˥ץå��夷�ޤ���
.El
.Sh ���󥹥ȥ졼�����
���ߤ� FreeBSD POSIX ����åɥ����ƥ�ϡ�
����åɥ����դ� libc �ؿ��ȥ���åɴؿ���ޤ�饤�֥��
.Fa libc_r
�ǹ��ۤ���Ƥ��ޤ������Υ饤�֥��ϡ�����åɥ��ץꥱ��������
.Fa libc
���֤������ޤ���
.Pp
�ǥե���ȤǤϡ�
.Fa libc_r
�� 'make world' �ΰ����Ȥ��ƹ��ۤ���ޤ���
.Fa libc_r
�ι��ۤ�̵���ˤ���ˤϡ�'-DNOLIBC_R' ���ץ�����
.Xr make 1
�˻��ꤹ��ɬ�פ�����ޤ���
.Pp
gcc �ˤ� FreeBSD �˸�ͭ�ʥ��ץ�����ɲä���Ƥ��ꡢ
����åɥץ������Υ�󥯤���ñ�ˤʤäƤ��ޤ���
.Fa gcc -pthread
��¹Ԥ���ȡ�
.Fa libc
�ǤϤʤ�
.Fa libc_r
�˥���åɥץ���������󥯤���ޤ���
.Sh ����
��Ƭ��
.Fa pthread_
���դ���������
.Fa _np
����Ƭ��
.Fa pthread_rwlock
���դ��Ƥ��ʤ�
.Fa libc_r
�δؿ��ϡ�IEEE
.Pq Dq Tn POSIX
Std 1003.1 Second Eition 1996-07-12 �˽�򤷤Ƥ��ޤ���
.Pp
��Ƭ��
.Fa pthread_
��������
.Fa _np
���դ��Ƥ��� libc_r �δؿ��ϡ�
POSIX ����åɤΰܿ��Բ�ǽ�ʥ������ƥ󥷥��Ǥ���
.Pp
��Ƭ��
.Fa pthread_rwlock
���դ��Ƥ��� libc_r �δؿ��ϡ�
Single UNIX Specification, Version 2 ��
The Open Group �����������������ƥ󥷥��Ǥ���