.\" 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 % .\" %FreeBSD: src/share/man/man3/pthread.3,v 1.12.2.5 2001/12/17 11:30:11 ru Exp % .\" .\" $FreeBSD$ .Dd September 10, 1998 .Dt PTHREAD 3 .Os .Sh ̾�� .Nm pthread .Nd POSIX ����åɴؿ� .Sh �� .In pthread.h .Sh ���� POSIX ����åɤϡ��ץ�������ǥ���å� (thread) �ȸƤФ�� �����ʣ���Υե������᤹�륢�ץꥱ�������ݡ��Ȥ���ؿ����Ǥ��� �ޥ������åɤϡ��ץ������Υѥե����ޥ�������뤿��˻��Ѥ���ޤ��� .Pp ���Υ��������Ǥϡ� POSIX ����åɴؿ��γ��פˤĤ��ưʲ��Υ��롼�פ�ʬ�����������ޤ��� .Bl -bullet -offset indent .It ����åɥ롼���� .It °�����֥������ȥ롼���� .It mutex �롼���� .It ����ѿ��롼���� .It �ɼ�� / ����ߥ��å��롼���� .It ����åɸ�ͭ����ƥ����ȥ롼���� .It ����åץ롼���� .El .Sh ����åɥ롼���� .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" .Xc �������¹Ԥ��륹��åɤ�������ޤ��� .It Xo .Ft int .Fn pthread_detach "pthread_t thread" .Xc ����åɤ˺���Τ���ΰ����դ��ޤ��� .It Xo .Ft int .Fn pthread_equal "pthread_t t1" "pthread_t t2" .Xc 2 �ĤΥ���åɤ� ID ����Ӥ��ޤ��� .It Xo .Ft void .Fn pthread_exit "void *value_ptr" .Xc �ƤӽФ��Ƥ��륹��åɤ�λ���ޤ��� .It Xo .Ft int .Fn pthread_join "pthread_t thread" "void **value_ptr" .Xc �ƤӽФ��Ƥ��륹��åɤ������ꤷ������åɤν�λ���ԤĤ褦�ˤ��ޤ��� .It Xo .Ft int .Fn pthread_cancel "pthread_t thread" .Xc ����åɤμ¹Ԥ���ä��ޤ��� .It Xo .Ft int .Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)" .Xc ������롼�������٤����ƤӽФ��ޤ��� .It Xo .Ft pthread_t .Fn pthread_self void .Xc �ƤӽФ��Ƥ��륹��åɤ� ID ���֤��ޤ��� .El .Sh °�����֥������ȥ롼���� .Bl -tag -width Er .It Xo .Ft int .Fn pthread_attr_destroy "pthread_attr_t *attr" .Xc ����åɤ�°�����֥������Ȥ��˲����ޤ��� .It Xo .Ft int .Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched" .Xc ����åɤ�°�����֥������Ȥ���Ѿ��������塼���°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param" .Xc ����åɤ�°�����֥������Ȥ��饹�����塼��ѥ���°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" .Xc ����åɤ�°�����֥������Ȥ��饹�����塼�������°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" .Xc ����åɤ�°�����֥������Ȥ��饳��ƥ���ϰ�°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" .Xc ����åɤ�°�����֥������Ȥ��饹���å�������°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr" .Xc ����åɤ�°�����֥������Ȥ��饹���å����ɥ쥹°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate" .Xc ����åɤ�°�����֥������Ȥ���ǥ��å�����°����������ޤ��� .It Xo .Ft int .Fn pthread_attr_init "pthread_attr_t *attr" .Xc ����å�°�����֥������Ȥ�ǥե�����ͤǽ�������ޤ��� .It Xo .Ft int .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" .Xc ����åɤ�°�����֥������Ȥ˷Ѿ��������塼���°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param" .Xc ����åɤ�°�����֥������Ȥ˥������塼��ѥ���°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" .Xc ����åɤ�°�����֥������Ȥ˥������塼�������°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" .Xc ����åɤ�°�����֥������Ȥ˥���ƥ���ϰ�°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" .Xc ����åɤ�°�����֥������Ȥ˥����å�������°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" .Xc ����åɤ�°�����֥������Ȥ˥����å����ɥ쥹°�������ꤷ�ޤ��� .It Xo .Ft int .Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" .Xc ����åɤ�°�����֥������Ȥ˥ǥ��å�����°�������ꤷ�ޤ��� .El .Sh mutex �롼���� .Bl -tag -width Er .It Xo .Ft int .Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr" .Xc mutex ��°�����֥������Ȥ��˲����ޤ��� .It Xo .Ft int .Fn pthread_mutexattr_init "pthread_mutexattr_t *attr" .Xc mutex ��°�����֥������Ȥ�ǥե�����ͤǽ�������ޤ��� .It Xo .Ft int .Fn pthread_mutex_destroy "pthread_mutex_t *mutex" .Xc mutex ���˲����ޤ��� .It Xo .Ft int .Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" .Xc mutex ����ꤵ�줿°���ǽ�������ޤ��� .It Xo .Ft int .Fn pthread_mutex_lock "pthread_mutex_t *mutex" .Xc mutex ����å����ơ�mutex �����Ѳ�ǽ�ˤʤ�ޤǥ֥��å����ޤ��� .It Xo .Ft int .Fn pthread_mutex_trylock "pthread_mutex_t *mutex" .Xc mutex ����å����褦�Ȥ��ޤ�����mutex �����ߤΥ���åɤ�ޤ �̤Υ���åɤˤ�äƥ��å�����Ƥ�����ˤϡ��֥��å����ޤ��� .It Xo .Ft int .Fn pthread_mutex_unlock "pthread_mutex_t *mutex" .Xc mutex �Υ��å��������ޤ��� .El .Sh ����ѿ��롼���� .Bl -tag -width Er .It Xo .Ft int .Fn pthread_condattr_init "pthread_condattr_t *attr" .Xc ����ѿ���°�����֥������Ȥ�ǥե�����ͤǽ�������ޤ��� .It Xo .Ft int .Fn pthread_condattr_destroy "pthread_condattr_t *attr" .Xc ����ѿ���°�����֥������Ȥ��˲����ޤ��� .It Xo .Ft int .Fn pthread_cond_broadcast "pthread_cond_t *cond" .Xc ���ꤵ�줿����ѿ��Ǹ��ߥ֥��å�����Ƥ��� ���ƤΥ���åɤΥ֥��å��������ޤ��� .It Xo .Ft int .Fn pthread_cond_destroy "pthread_cond_t *cond" .Xc ����ѿ����˲����ޤ��� .It Xo .Ft int .Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" .Xc ����ѿ�����ꤵ�줿°���ǽ�������ޤ��� .It Xo .Ft int .Fn pthread_cond_signal "pthread_cond_t *cond" .Xc ���ꤵ�줿����ѿ��Ǹ��ߥ֥��å�����Ƥ��� ���ʤ��Ȥ� 1 �ĤΥ���åɤΥ֥��å��������ޤ��� .It Xo .Ft int .Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" .Xc ������ꤵ�줿��������Ե��������ꤵ�줿 mutex ����å����ޤ��� .It Xo .Ft int .Fn pthread_cond_wait "pthread_cond_t *" "pthread_mutex_t *mutex" .Xc �����Ե��������ꤵ�줿 mutex ����å����ޤ��� .El .Sh �ɼ�� / ����ߥ��å��롼���� .Bl -tag -width Er .It Xo .Ft int .Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å����֥������Ȥ��˲����ޤ��� .It Xo .Ft int .Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" .Xc �ɼ�� / ����ߥ��å����֥������Ȥ��������ޤ��� .It Xo .Ft int .Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å����ɼ���Ѥ˥��å����� ���å�������Ǥ���褦�ˤʤ�ޤǥ֥��å����ޤ��� .It Xo .Ft int .Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å����ɼ���Ѥ˥��å����褦�Ȥ��ޤ����� ���å��Ǥ��ʤ����ˤϥ֥��å����ޤ��� .It Xo .Ft int .Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å��������Ѥ˥��å����褦�Ȥ��ޤ����� ���å��Ǥ��ʤ����ˤϥ֥��å����ޤ��� .It Xo .Ft int .Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å��Υ��å��������ޤ��� .It Xo .Ft int .Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" .Xc �ɼ�� / ����ߥ��å��������Ѥ˥��å����� ���å�������Ǥ���褦�ˤʤ�ޤǥ֥��å����ޤ��� .It Xo .Ft int .Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" .Xc �ɼ�� / ����ߥ��å���°�����֥������Ȥ��˲����ޤ��� .It Xo .Ft int .Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared" .Xc �ɼ�� / ����ߥ��å���°�����֥������ȤΥץ�������ͭ�����������ޤ��� .It Xo .Ft int .Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" .Xc �ɼ�� / ����ߥ��å���°�����֥������Ȥ��������ޤ��� .It Xo .Ft int .Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared" .Xc �ɼ�� / ����ߥ��å���°�����֥������ȤΥץ�������ͭ��������ꤷ�ޤ��� .El .Sh ����åɸ�ͭ����ƥ����ȥ롼���� .Bl -tag -width Er .It Xo .Ft int .Fn pthread_key_create "pthread_key_t *key" "void (*routine)(void *)" .Xc ����åɸ�ͭ�Υǡ���������������ޤ��� .It Xo .Ft int .Fn pthread_key_delete "pthread_key_t key" .Xc ����åɸ�ͭ�Υǡ��������������ޤ��� .It Xo .Ft "void *" .Fn pthread_getspecific "pthread_key_t key" .Xc ���ꤵ�줿�����Υ���åɸ�ͭ���ͤ�������ޤ��� .It Xo .Ft int .Fn pthread_setspecific "pthread_key_t key" "const void *value_ptr" .Xc ���ꤵ�줿�����Υ���åɸ�ͭ���ͤ����ꤷ�ޤ��� .El .Sh ����åץ롼���� .Bl -tag -width Er .It Xo .Ft void .Fn pthread_cleanup_pop "int execute" .Xc �ƤӽФ��Ƥ��륹��åɤμ��ä�����åץ����å��κǽ�Υ롼����� ����������ץ����Ǥ��Υ롼�����¹Ԥ��ޤ��� .It Xo .Ft void .Fn pthread_cleanup_push "void (*routine)(void *)" "void *routine_arg" .Xc �ƤӽФ��Ƥ��륹��åɤμ��ä������å��˻��ꤵ�줿���ä�����å� �ϥ�ɥ���Ѥߤޤ��� .El .Sh ���ȥ졼����� ���ߤ� .Fx POSIX ����åɤμ����ϡ�����åɥ����դ� libc �ؿ��ȥ���åɴؿ���ޤ� �饤�֥�� .Fa libc_r �ǹ��ۤ���Ƥ��ޤ������Υ饤�֥��ϥ���åɥ��ץꥱ�������� .Fa libc ���֤������ޤ��� .Pp �ǥե���ȤǤϡ� .Fa libc_r �� 'make world' �ΰ����Ȥ��ƹ��ۤ���ޤ������ι��ۤ�̵���ˤ���ˤϡ� .Xr make 1 �� '-DNOLIBC_R' ���ץ�����Ϳ���ʤ���Фʤ�ޤ��� .Pp ����åɲ����줿�ץ��������ñ�˥���뤿��ˡ�gcc �� .Fx ��ͭ�Υ��ץ�����ɲä���Ƥ��ޤ��� .Fa gcc -pthread �ϥ���åɲ����줿�ץ������� .Fa libc ����ä� .Fa libc_r �����ޤ��� .Sh ��Ϣ���� .Xr pthread_create 3 , .Xr pthread_detach 3 , .Xr pthread_equal 3 , .Xr pthread_exit 3 , .Xr pthread_join 3 , .Xr pthread_once 3 , .Xr pthread_self 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_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_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_key_delete 3 , .Xr pthread_getspecific 3 , .Xr pthread_setspecific 3 , .Xr pthread_cleanup_pop 3 , .Xr pthread_cleanup_push 3 .Sh ���� .Fa pthread_ ��Ƭ�줬�դ��� .Fa _np ������ޤ��� .Fa pthread_rwlock ��Ƭ�줬�դ��Ƥ��ʤ� .Fa libc_r �δؿ��ϡ� .St -p1003.1-96 ��Ŭ�礷�Ƥ��ޤ��� .Pp .Fa pthread_ ��Ƭ�줪��� .Fa _np �����줬�դ��� libc_r �δؿ��ϡ�POSIX ����åɤؤ���ݡ����֥��ĥ�Ǥ��� .Pp .Fa pthread_rwlock ��Ƭ�줬�դ��� libc_r �δؿ��ϡ� .St -susv2 �� The Open Group �ˤ�äƺ������줿��ĥ�Ǥ���