OSDN Git Service

LDP: Update draft based on the previous commit (pthread)
authorAkihiro Motoki <amotoki@gmail.com>
Mon, 29 Mar 2021 10:11:05 +0000 (19:11 +0900)
committerAkihiro Motoki <amotoki@gmail.com>
Mon, 29 Mar 2021 14:15:42 +0000 (23:15 +0900)
29 files changed:
manual/LDP_man-pages/draft/man3/getcontext.3
manual/LDP_man-pages/draft/man3/makecontext.3
manual/LDP_man-pages/draft/man3/pthread_attr_init.3
manual/LDP_man-pages/draft/man3/pthread_attr_setdetachstate.3
manual/LDP_man-pages/draft/man3/pthread_attr_setguardsize.3
manual/LDP_man-pages/draft/man3/pthread_attr_setinheritsched.3
manual/LDP_man-pages/draft/man3/pthread_attr_setschedparam.3
manual/LDP_man-pages/draft/man3/pthread_attr_setschedpolicy.3
manual/LDP_man-pages/draft/man3/pthread_attr_setscope.3
manual/LDP_man-pages/draft/man3/pthread_attr_setstack.3
manual/LDP_man-pages/draft/man3/pthread_attr_setstacksize.3
manual/LDP_man-pages/draft/man3/pthread_cancel.3
manual/LDP_man-pages/draft/man3/pthread_cleanup_push.3
manual/LDP_man-pages/draft/man3/pthread_create.3 [new file with mode: 0644]
manual/LDP_man-pages/draft/man3/pthread_detach.3
manual/LDP_man-pages/draft/man3/pthread_getattr_default_np.3 [new file with mode: 0644]
manual/LDP_man-pages/draft/man3/pthread_getattr_np.3
manual/LDP_man-pages/draft/man3/pthread_getcpuclockid.3
manual/LDP_man-pages/draft/man3/pthread_join.3
manual/LDP_man-pages/draft/man3/pthread_rwlockattr_setkind_np.3
manual/LDP_man-pages/draft/man3/pthread_setaffinity_np.3
manual/LDP_man-pages/draft/man3/pthread_setcancelstate.3
manual/LDP_man-pages/draft/man3/pthread_setname_np.3
manual/LDP_man-pages/draft/man3/pthread_setschedparam.3
manual/LDP_man-pages/draft/man3/pthread_setschedprio.3
manual/LDP_man-pages/draft/man3/pthread_sigmask.3
manual/LDP_man-pages/draft/man3/pthread_testcancel.3
manual/LDP_man-pages/draft/man3/pthread_tryjoin_np.3
manual/LDP_man-pages/draft/man7/pthreads.7

index 56aa2ae..16a79b1 100644 (file)
@@ -68,8 +68,7 @@ typedef struct ucontext_t {
 を見よ)。 \fIuc_stack\fP はこのコンテキストが用いているスタックである (\fBsignalstack\fP(2)  を見よ)。
 \fIuc_mcontext\fP は保存されているコンテキストの マシン特有の表現形式であり、 ここには呼び出したスレッドのマシンレジスターが格納される。
 .PP
-The function \fBgetcontext\fP()  initializes the structure pointed to by \fIucp\fP
-to the currently active context.
+\fBgetcontext\fP()  関数は、 ポインター \fIucp\fP が指す構造体を、 現在アクティブなコンテキストに初期化する。
 .PP
 The function \fBsetcontext\fP()  restores the user context pointed to by
 \fIucp\fP.  A successful call does not return.  The context should have been
@@ -109,14 +108,11 @@ T}        Thread safety   MT\-Safe race:ucp
 SUSv2, POSIX.1\-2001.  POSIX.1\-2008 では、移植性の問題から \fBgetcontext\fP()  の仕様が削除された。
 代わりに、アプリケーションを POSIX スレッドを使って書き直すことが 推奨されている。
 .SH 注意
-The earliest incarnation of this mechanism was the
-\fBsetjmp\fP(3)/\fBlongjmp\fP(3)  mechanism.  Since that does not define the
-handling of the signal context, the next stage was the
-\fBsigsetjmp\fP(3)/\fBsiglongjmp\fP(3)  pair.  The present mechanism gives much
-more control.  On the other hand, there is no easy way to detect whether a
-return from \fBgetcontext\fP()  is from the first call, or via a
-\fBsetcontext\fP()  call.  The user has to invent their own bookkeeping device,
-and a register variable won't do since registers are restored.
+このメカニズムの最古の実装は、 \fBsetjmp\fP(3)/\fBlongjmp\fP(3)  機構であった。
+これらにはシグナルコンテキストの取り扱いが定義されていなかったので、 次の段階では \fBsigsetjmp\fP(3)/\fBsiglongjmp\fP(3)
+のペアが現われた。 現在の機構ではずっと細かな制御ができる。 一方 \fBgetcontext\fP()  から返ったとき、 これが最初の呼び出しであったか、
+それとも \fBsetcontext\fP()  呼び出しからのものであるかを 区別する容易な方法がなくなってしまった。
+ユーザーは「しおり」機構を自分で作らなければならない。 レジスター変数は (レジスターはリストアされてしまうので) これをやってくれない。
 .PP
 シグナルが発生すると、 現在のユーザーコンテキストは保存され、 シグナルハンドラー用のコンテキストがカーネルによって生成される。 今後はハンドラーに
 \fBlongjmp\fP(3)  を使わせないこと: この関数のコンテキスト下での動作は定義されていない。 代わりに \fBsiglongjmp\fP(3)  か
index 10d7737..92f52c4 100644 (file)
@@ -102,7 +102,7 @@ SUSv2, POSIX.1\-2001.  POSIX.1\-2008 では、移植性の問題から \fBmakeco
 よりも大きいアーキテクチャーでは正しく動作しないことだろう。 それにも関わらず、バージョン 2.8 以降の glibc では、
 \fBmakecontext\fP()  に変更が行われ、(x86\-64 などの) いくつかの 64 ビットアーキテクチャーで
 引き数としてポインターを渡すことができるようになっている。
-.SH EXAMPLES
+.SH 
 以下のサンプルプログラムは、 \fBgetcontext\fP(3), \fBmakecontext\fP(), \fBswapcontext\fP()
 の使用方法の例を示すものである。 このプログラムを実行すると、以下のような出力が得られる:
 .PP
index b72d537..ca9914c 100644 (file)
@@ -71,9 +71,8 @@ pthread_attr_init, pthread_attr_destroy \-
 成功すると、これらの関数は 0 を返す。
 エラーの場合、0 以外のエラー番号を返す。
 .SH エラー
-POSIX.1 documents an \fBENOMEM\fP error for \fBpthread_attr_init\fP(); on Linux
-these functions always succeed (but portable and future\-proof applications
-should nevertheless handle a possible error return).
+POSIX.1 では \fBpthread_attr_init\fP() にはエラー \fBENOMEM\fP が記載されている。 Linux
+では、これらの関数は常に成功する (ただし、移植性や将来も動作することを保証したいアプリケーションでは正のエラーの返り値を処理するようにすべきである)。
 .SH 属性
 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
 .ad l
@@ -94,7 +93,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 \fIpthread_attr_t\fP 型の内部構造は意識すべきではない。
 pthreads 関数経由以外でのオブジェクトへのアクセスは移植性がなく、
 どのような結果が得られるかも分からない。
-.SH EXAMPLES
+.SH 
 下記のプログラムは、\fBpthread_attr_init\fP() と種々の関連関数を使って、
 スレッド属性オブジェクトの初期化を行い、
 そのオブジェクトを使ってスレッドを一つ作成する。
index 10f5ccd..9bb3b2f 100644 (file)
@@ -103,7 +103,7 @@ join 可能状態で作成されたスレッドは、最終的に
 detached 状態で作成されたスレッドのスレッド ID を指定して、
 \fBpthread_detach\fP(3) や \fBpthread_join\fP(3) を後から呼び出すのは
 エラーである。
-.SH EXAMPLES
+.SH 
 \fBpthread_attr_init\fP(3) を参照。
 .SH 関連項目
 \fBpthread_attr_init\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
index 2359ff0..68512ff 100644 (file)
@@ -78,9 +78,11 @@ pthread_attr_setguardsize, pthread_attr_getguardsize \-
 成功すると、これらの関数は 0 を返す。
 エラーの場合、0 以外のエラー番号を返す。
 .SH エラー
-POSIX.1 documents an \fBEINVAL\fP error if \fIattr\fP or \fIguardsize\fP is invalid.
-On Linux these functions always succeed (but portable and future\-proof
-applications should nevertheless handle a possible error return).
+POSIX.1 では、エラー \fBEINVAL\fP が
+ \fIattr\fP か \fIguardsize\fP が無効な場合に対して規定されている。
+Linux では、これらの関数は常に成功する
+(ただし、移植性や将来も動作することを保証したいアプリケーションでは
+正のエラーの返り値を処理するようにすべきである)。
 .SH バージョン
 これらの関数は glibc バージョン 2.1 以降で提供されている。
 .SH 属性
@@ -136,7 +138,7 @@ glibc 2.8 の時点では、 NPTL スレッド実装ではガード領域はス
 廃止予定の LinuxThreads 実装では、
 POSIX.1 で求められている通りの動作で、
 ガード領域がスタックの末尾に追加の領域が割り当てられる。
-.SH EXAMPLES
+.SH 
 \fBpthread_getattr_np\fP(3) を参照。
 .SH 関連項目
 \fBmmap\fP(2), \fBmprotect\fP(2), \fBpthread_attr_init\fP(3),
index 78ba70f..f4ff3b8 100644 (file)
@@ -89,9 +89,9 @@ inherit\-scheduler 属性を \fIinheritsched\fP が指すバッファーに入
 .PP
 .\" .SH VERSIONS
 .\" Available since glibc 2.0.
-POSIX.1 also documents an optional \fBENOTSUP\fP error ("attempt was made to
-set the attribute to an unsupported value") for
-\fBpthread_attr_setinheritsched\fP().
+POSIX.1 では、 \fBpthread_attr_setinheritsched\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値を属性に設定しようとした")
+も追加で規定されている。
 .SH 属性
 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
 .TS
@@ -115,7 +115,7 @@ inherit\-scheduler 属性に \fBPTHREAD_EXPLICIT_SCHED\fP
 が設定されると、このスレッド属性オブジェクトを使って作成されたスレッドでは、スレッドを作成するスレッドのスケジューリング属性が間違って継承されてしまう。
 \fBpthread_create\fP(3) を呼び出す前にスケジューリングポリシー属性かスケジューリング優先度属性のどちらかが明示的に設定された場合には、
 このバグは発生しない。
-.SH EXAMPLES
+.SH 
 \fBpthread_setschedparam\fP(3) を参照。
 .SH 関連項目
 .ad l
index 0435457..120f9e1 100644 (file)
@@ -82,7 +82,7 @@ struct sched_param {
 成功すると、これらの関数は 0 を返す。
 エラーの場合、0 以外のエラー番号を返す。
 .SH エラー
-\fBpthread_attr_setschedparam\fP()  can fail with the following error:
+\fBpthread_attr_setschedparam\fP() は以下のエラーで失敗する場合がある。
 .TP 
 \fBEINVAL\fP
 The priority specified in \fIparam\fP does not make sense for the current
@@ -111,7 +111,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 .SH 注意
 Linux でサポートされているスレッドのスケジューリングポリシーのリストに
 ついては、 \fBpthread_attr_setschedpolicy\fP(3) を参照。
-.SH EXAMPLES
+.SH 
 \fBpthread_setschedparam\fP(3) を参照。
 .SH 関連項目
 .ad l
index cf541ce..af87e78 100644 (file)
@@ -78,9 +78,8 @@ pthread_attr_setschedpolicy, pthread_attr_getschedpolicy \- スレッド属性
 .PP
 .\" .SH VERSIONS
 .\" Available since glibc 2.0.
-POSIX.1 also documents an optional \fBENOTSUP\fP error ("attempt was made to
-set the attribute to an unsupported value") for
-\fBpthread_attr_setschedpolicy\fP().
+POSIX.1 では、 \fBpthread_attr_setschedpolicy\fP() に関してエラー \fBENOTSUP\fP
+("サポートされていない値を属性に設定しようとした") も追加で規定されている。
 .SH 属性
 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
 .TS
@@ -95,7 +94,7 @@ T}    Thread safety   MT\-Safe
 .TE
 .SH 準拠
 POSIX.1\-2001, POSIX.1\-2008.
-.SH EXAMPLES
+.SH 
 \fBpthread_setschedparam\fP(3) を参照。
 .SH 関連項目
 .ad l
index fd4c657..0593cde 100644 (file)
@@ -49,11 +49,9 @@ pthread_attr_setscope, pthread_attr_getscope \-
 \fI\-pthread\fP でコンパイルしてリンクする。
 .fi
 .SH 説明
-The \fBpthread_attr_setscope\fP()  function sets the contention scope attribute
-of the thread attributes object referred to by \fIattr\fP to the value
-specified in \fIscope\fP.  The contention scope attribute defines the set of
-threads against which a thread competes for resources such as the CPU.
-POSIX.1 specifies two possible values for \fIscope\fP:
+\fBpthread_attr_setscope\fP() 関数は、 \fIattr\fP が参照するスレッド属性オブジェクトの contention scope
+属性を \fIscope\fP で指定された値に設定する。 contention scope 属性により、スレッドが CPU
+などのリソースを取り合うスレッド集合が規定される。 POSIX.1 では \fIscope\fP に指定する値として 2 つの値が規定されている。
 .TP 
 \fBPTHREAD_SCOPE_SYSTEM\fP
 スレッドは、同じスケジューリング割り当てドメイン (一つ以上のプロセッサ
@@ -63,17 +61,18 @@ POSIX.1 specifies two possible values for \fIscope\fP:
 優先度に基づき、互いに相対的にスケジューリングされる。
 .TP 
 \fBPTHREAD_SCOPE_PROCESS\fP
-The thread competes for resources with all other threads in the same process
-that were also created with the \fBPTHREAD_SCOPE_PROCESS\fP contention scope.
-\fBPTHREAD_SCOPE_PROCESS\fP threads are scheduled relative to other threads in
-the process according to their scheduling policy and priority.  POSIX.1
-leaves it unspecified how these threads contend with other threads in other
-process on the system or with other threads in the same process that were
-created with the \fBPTHREAD_SCOPE_SYSTEM\fP contention scope.
+スレッドは、contention scope が \fBPTHREAD_SCOPE_PROCESS\fP で作成された
+同じプロセスの自分以外の全てのスレッドとリソースを取り合う。
+\fBPTHREAD_SCOPE_PROCESS\fP のスレッドは、スケジューリングポリシーと優先度
+に基づき、同じプロセスの他のスレッドと相対的にスケジューリングされる。
+POSIX.1 では、これらのスレッドがシステム上の他のプロセスのスレッド
+や同じプロセス内の contention scope が \fBPTHREAD_SCOPE_SYSTEM\fP で作成
+された他のスレッドとどのようにリソースを取り合うかは、
+規定されないままになっている。
 .PP
-POSIX.1 requires that an implementation support at least one of these
-contention scopes.  Linux supports \fBPTHREAD_SCOPE_SYSTEM\fP, but not
-\fBPTHREAD_SCOPE_PROCESS\fP.
+POSIX.1 で求められているのは、スレッド実装がこれらの contention scope のうち少なくとも 1 つをサポートすることだけである。
+Linux は \fBPTHREAD_SCOPE_SYSTEM\fP をサポートしているが、 \fBPTHREAD_SCOPE_PROCESS\fP
+はサポートしていない。
 .PP
 複数の contention scope をサポートしているシステムで、 \fBpthread_create\fP(3) を呼び出した際に
 \fBpthread_attr_setscope\fP() で行ったパラメーター設定を有効にするには、 呼び出し側で
@@ -116,8 +115,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 Linux では、廃止予定の LinuxThreads 実装も新しい NPTL 実装もこれに
 該当し、両方とも 1:1 で結び付けられるスレッド実装となっている。
 .PP
-POSIX.1 specifies that the default contention scope is
-implementation\-defined.
+POSIX.1 では、 contention scope 属性のデフォルト値は実装時で定義されるものと規定されている。
 .SH 関連項目
 .ad l
 .nh
index 75b3927..9dc4bc7 100644 (file)
@@ -88,9 +88,8 @@ _POSIX_C_SOURCE\ >=\ 200112L
 \fIstackaddr\ +\ stacksize\fP のアライメントが適切でない場合にも
 このエラーが発生する。
 .PP
-POSIX.1 also documents an \fBEACCES\fP error if the stack area described by
-\fIstackaddr\fP and \fIstacksize\fP is not both readable and writable by the
-caller.
+POSIX.1 では エラー \fBEACCES\fP も規定されており、このエラーは \fIstackaddr\fP と \fIstacksize\fP
+で規定されるスタック領域に呼び出し側から読み書き両方のアクセスができない状況を表す。
 .SH バージョン
 これらの関数は glibc バージョン 2.2 以降で提供されている。
 .SH 属性
@@ -134,7 +133,7 @@ guard size の値は無視される。
 呼び出し側でスタックアドレス属性を変更しなければならない。
 さもなければ、複数のスレッドがスタックとして同じメモリー領域を
 使おうとするため、訳の分からない状況が発生してしまう。
-.SH EXAMPLES
+.SH 
 \fBpthread_attr_init\fP(3) を参照。
 .SH 関連項目
 .ad l
index 971116a..d8436d3 100644 (file)
@@ -99,11 +99,10 @@ POSIX.1\-2001, POSIX.1\-2008.
 アプリケーションは、スレッドが使用するスタックとして、
 呼び出し側で割り当てたスタックのサイズと場所を指定できる。
 .SH バグ
-As at glibc 2.8, if the specified \fIstacksize\fP is not a multiple of
-\fBSTACK_ALIGN\fP (16 bytes on most architectures), it may be rounded
-\fIdownward\fP, in violation of POSIX.1, which says that the allocated stack
-will be at least \fIstacksize\fP bytes.
-.SH EXAMPLES
+glibc 2.8 の時点では、指定された \fIstacksize\fP が \fBSTACK_ALIGN\fP (ほとんどのアーキテクチャーでは 16 バイト)
+の倍数でない場合、 \fIstacksize\fP は\fI小さくなる方向に\fPに丸められる。これは POSIX.1 に違反している。 POSIX.1
+では、割り当てらたスタックの大きさは少なくとも \fIstacksize\fP バイトになると書かれている。
+.SH 例
 \fBpthread_create\fP(3) を参照。
 .SH 関連項目
 \fBgetrlimit\fP(2), \fBpthread_attr_init\fP(3), \fBpthread_attr_setguardsize\fP(3),
index d41f32f..816dcfb 100644 (file)
@@ -117,7 +117,7 @@ Linux では、キャンセルはシグナルを使って実装されている
 最初のリアルタイムシグナル (つまり、シグナル 32)がこのために使用される。
 LinuxThreads では、リアルタイムシグナルが利用可能な場合は2 番目のリアルタイム
 シグナルが使用され、そうでない場合は \fBSIGUSR2\fP が使用される。
-.SH EXAMPLES
+.SH 
 以下のプログラムは、スレッドを一つ作成してから、そのスレッドをキャンセルする。
 メインスレッドはキャンセルされたスレッドをジョインし、
 キャンセルされたスレッドの終了ステータスが \fBPTHREAD_CANCELED\fP かどうかを
index c2ec847..42c26f5 100644 (file)
@@ -128,7 +128,7 @@ POSIX.1 には、括弧を含む \fBpthread_cleanup_push\fP() と
 \fIreturn\fP, \fIbreak\fP, \fIcontinue\fP, \fIgoto\fP を使った場合の影響は
 不定であると書かれている。
 移植性が必要なアプリケーションではこれを行うのは避けるべきである。
-.SH EXAMPLES
+.SH 
 以下のプログラムは、このページで説明した関数の簡単な使用例を示すもので
 ある。このプログラムは \fBpthread_cleanup_push\fP() と
 \fBpthread_cleanup_pop\fP() で囲まれたループを実行するスレッドを作成する。
diff --git a/manual/LDP_man-pages/draft/man3/pthread_create.3 b/manual/LDP_man-pages/draft/man3/pthread_create.3
new file mode 100644 (file)
index 0000000..4d07eea
--- /dev/null
@@ -0,0 +1,357 @@
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\"     <mtk.manpages@gmail.com>
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 2012  Akihiro MOTOKI
+.\"         all rights reserved.
+.\" Translated 2012-05-04, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH PTHREAD_CREATE 3 2020\-11\-01 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_create \- 新しいスレッドを作成する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+.PP
+\fBint pthread_create(pthread_t *\fP\fIthread\fP\fB, const pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB                   void *(*\fP\fIstart_routine\fP\fB) (void *), void *\fP\fIarg\fP\fB);\fP
+.fi
+.PP
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_create\fP() 関数は、呼び出したプロセス内に新しいスレッドを作成する。
+新しいスレッドの実行は、 \fIstart_routine\fP() を起動することで開始される。
+\fIstart_routine\fP() は引き数を一つだけ取り、
+\fIarg\fP が \fIstart_routine\fP() の引き数として渡される。
+.PP
+新しく作成されたスレッドは、以下のいずれかで終了する。
+.IP * 2
+スレッドが \fBpthread_exit\fP(3) を呼び出す。
+\fBpthread_exit\fP(3) を呼び出す際には終了ステータス値を指定する。
+この値は \fBpthread_join\fP(3) を呼び出した同じプロセス内の
+別のスレッドで参照できる。
+.IP *
+スレッドが \fIstart_routine\fP() から返る。これは、
+\fIreturn\fP 文に渡した値で \fBpthread_exit\fP(3) を呼び出すのと等価である。
+.IP *
+スレッドがキャンセルされる (\fBpthread_cancel\fP(3) 参照)。
+.IP *
+プロセス内のいずれかのスレッドで \fBexit\fP(3) が呼ばれるか、
+メインスレッドで \fImain\fP() 内で return が実行される。
+この場合は、プロセス内の全てのスレッドが終了される。
+.PP
+\fIattr\fP 引き数は \fIpthread_attr_t\fP 構造体へのポインターであり、
+\fIpthread_attr_t\fP 構造体の内容を使用して、スレッド作成時に
+新しいスレッドの属性が決定される。
+この構造体は \fBpthread_attr_init\fP(3) や関連の関数を使って初期化される。
+\fIattr\fP が NULL の場合、新しいスレッドはデフォルトの属性で作成される。
+.PP
+成功した場合は、 \fBpthread_create\fP() は返る前に新しいスレッドの ID を
+\fIthread\fP が指すバッファーに格納する。この ID は、これ以降に他の
+pthreads 関数の呼び出しでスレッドを参照するのに使用される。
+.PP
+新しいスレッドは、スレッドを作成したスレッドのシグナルマスク
+(\fBpthread_sigmask\fP(3) 参照) のコピーを継承する。
+新しいスレッドの処理待ちシグナル (\fBsigpending\fP(2)) の集合は空となる。
+新しいスレッドはスレッドを作成したスレッドの代替シグナルスタック
+(\fBsigaltstack\fP(2)) を継承しない。
+.PP
+新しいスレッドは呼び出したスレッドの浮動小数点環境 (\fBfenv\fP(3))
+を継承する。
+.PP
+.\" CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
+新しいスレッドの CPU 時間時計の初期値は 0 である
+(\fBpthread_getcpuclockid\fP(3) 参照)。
+.SS "Linux 固有の詳細"
+新しいスレッドは、呼び出したスレッドの
+ケーパビリティセット (\fBcapabilities\fP(7) 参照) と
+CPU affinity マスク (\fBsched_setaffinity\fP(2) 参照) の
+コピーをを継承しない。
+.SH 返り値
+成功すると、 \fBpthread_create\fP() は 0 を返す。
+エラーの場合は、エラー番号が返され、 \fI*thread\fP の内容は不定である。
+.SH エラー
+.TP 
+\fBEAGAIN\fP
+別のスレッドを作成するのに十分なリソースがない。
+.TP 
+\fBEAGAIN\fP
+.\" NOTE! The following should match the description in fork(2)
+システムで設定されたスレッド数の上限に達していた。 このエラーの原因となる上限値はいくつかある。 実ユーザー ID
+当たりのプロセス数とスレッド数の上限である、ソフトリソース上限 \fBRLIMIT_NPROC\fP に達していた (\fBsetrlimit\fP(2)
+で設定できる)。 カーネルのシステム全体のプロセスとスレッドの数の上限値である \fI/proc/sys/kernel/threads\-max\fP
+が達していた (\fBproc\fP(5) 参照)。 PID の最大値 \fI/proc/sys/kernel/pid_max\fP に達していた
+(\fBproc\fP(5) 参照)。
+.TP 
+\fBEINVAL\fP
+\fIattr\fP で指定された設定が不正である。
+.TP 
+.\" FIXME . Test the following
+\fBEPERM\fP
+\fIattr\fP に指定されたスケジューリングポリシーとパラメーターを
+設定する許可がない。
+.SH 属性
+この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
+.TS
+allbox;
+lb lb lb
+l l l.
+インターフェース       属性  値
+T{
+\fBpthread_create\fP()
+T}     Thread safety   MT\-Safe
+.TE
+.sp 1
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008.
+.SH 注意
+\fBpthread_create\fP() が \fI*thread\fP で返すスレッド ID についての
+詳しい情報は \fBpthread_self\fP(3) を参照のこと。
+リアルタイムスケジューリングポリシーが使用されない限り、
+\fBpthread_create\fP() の呼び出し後に、
+どのスレッドが\(em呼び出したスレッドか新しいスレッドか\(em
+次に実行されるかは決まっていない。
+.PP
+スレッドは \fIjoin 可能\fPか \fIdetached (切り離された状態)\fP のどちらかに
+することができる。スレッドが join 可能な場合、別のスレッドが
+\fBpthread_join\fP(3) を使って終了したスレッドを待ち、終了ステータスを取得
+することができる。終了した join 可能なスレッドは join された場合にのみ、
+そのスレッドの最後に残ったリソースが解放されシステムに戻される。
+detached 状態のスレッドが終了すると、そのスレッドのリソースは自動的に
+システムに戻される。detached 状態のスレッドを join して、その終了
+ステータスを取得することはできない。スレッドを detached 状態にするのは、
+その終了ステータスをアプリケーションが気にする必要がないある種の
+デーモン (daemon) スレッドでは有用である。
+デフォルトでは、新しいスレッドは join 可能な状態で作成される。
+(\fBpthread_attr_setdetachstate\fP(3) を使って) \fIattr\fP でスレッドが
+detached 状態で作成されるように設定されていない限り、join 可能な状態で
+作成される。
+.PP
+Under the NPTL threading implementation, if the \fBRLIMIT_STACK\fP soft
+resource limit \fIat the time the program started\fP has any value other than
+"unlimited", then it determines the default stack size of new threads.
+Using \fBpthread_attr_setstacksize\fP(3), the stack size attribute can be
+explicitly set in the \fIattr\fP argument used to create a thread, in order to
+obtain a stack size other than the default.  If the \fBRLIMIT_STACK\fP resource
+limit is set to "unlimited", a per\-architecture value is used for the stack
+size.  Here is the value for a few architectures:
+.RS
+.TS
+allbox;
+lb lb
+l r.
+Architecture   Default stack size
+i386   2 MB
+IA\-64 32 MB
+PowerPC        4 MB
+S/390  2 MB
+Sparc\-32      2 MB
+Sparc\-64      4 MB
+x86_64 2 MB
+.TE
+.RE
+.SH バグ
+廃止予定の LinuxThreads 実装では、プロセス内の各スレッドは異なる
+プロセス ID を持つ。これは POSIX スレッドの規格に違反しており、
+他の多くの標準非準拠の点の原因になっている。
+\fBpthreads\fP(7) を参照のこと。
+.SH 例
+以下のプログラムは、 \fBpthread_create\fP() や
+pthreads API の他のいろいろな関数の使用例を示している。
+.PP
+以下の実行例は、 NPTL スレッド実装が提供されているシステムでのもので、
+スタックサイズがデフォルト値の "stack size" リソース上限で指定される値
+になる。
+.PP
+.in +4n
+.EX
+$\fB ulimit \-s\fP
+8192            # The stack size limit is 8 MB (0x800000 bytes)
+$\fB ./a.out hola salut servus\fP
+Thread 1: top of stack near 0xb7dd03b8; argv_string=hola
+Thread 2: top of stack near 0xb75cf3b8; argv_string=salut
+Thread 3: top of stack near 0xb6dce3b8; argv_string=servus
+Joined with thread 1; returned value was HOLA
+Joined with thread 2; returned value was SALUT
+Joined with thread 3; returned value was SERVUS
+.EE
+.in
+.PP
+次の実行例では、プログラム内で、作成されるスレッドに対して (\fBpthread_attr_setstacksize\fP(3) を使って1\ MB
+のスタックサイズを明示的に設定している。
+.PP
+.in +4n
+.EX
+$\fB ./a.out \-s 0x100000 hola salut servus\fP
+Thread 1: top of stack near 0xb7d723b8; argv_string=hola
+Thread 2: top of stack near 0xb7c713b8; argv_string=salut
+Thread 3: top of stack near 0xb7b703b8; argv_string=servus
+Joined with thread 1; returned value was HOLA
+Joined with thread 2; returned value was SALUT
+Joined with thread 3; returned value was SERVUS
+.EE
+.in
+.SS プログラムのソース
+\&
+.EX
+#include <pthread.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+
+#define handle_error_en(en, msg) \e
+        do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+#define handle_error(msg) \e
+        do { perror(msg); exit(EXIT_FAILURE); } while (0)
+
+struct thread_info {    /* Used as argument to thread_start() */
+    pthread_t thread_id;        /* ID returned by pthread_create() */
+    int       thread_num;       /* Application\-defined thread # */
+    char     *argv_string;      /* From command\-line argument */
+};
+
+/* Thread start function: display address near top of our stack,
+   and return upper\-cased copy of argv_string */
+
+static void *
+thread_start(void *arg)
+{
+    struct thread_info *tinfo = arg;
+    char *uargv;
+
+    printf("Thread %d: top of stack near %p; argv_string=%s\en",
+            tinfo\->thread_num, &p, tinfo\->argv_string);
+
+    uargv = strdup(tinfo\->argv_string);
+    if (uargv == NULL)
+        handle_error("strdup");
+
+    for (char *p = uargv; *p != \(aq\e0\(aq; p++)
+        *p = toupper(*p);
+
+    return uargv;
+}
+
+int
+main(int argc, char *argv[])
+{
+    int s, opt, num_threads;
+    pthread_attr_t attr;
+    size_t stack_size;
+    void *res;
+
+    /* The "\-s" option specifies a stack size for our threads */
+
+    stack_size = \-1;
+    while ((opt = getopt(argc, argv, "s:")) != \-1) {
+        switch (opt) {
+        case \(aqs\(aq:
+            stack_size = strtoul(optarg, NULL, 0);
+            break;
+
+        default:
+            fprintf(stderr, "Usage: %s [\-s stack\-size] arg...\en",
+                    argv[0]);
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    num_threads = argc \- optind;
+
+    /* Initialize thread creation attributes */
+
+    s = pthread_attr_init(&attr);
+    if (s != 0)
+        handle_error_en(s, "pthread_attr_init");
+
+    if (stack_size > 0) {
+        s = pthread_attr_setstacksize(&attr, stack_size);
+        if (s != 0)
+            handle_error_en(s, "pthread_attr_setstacksize");
+    }
+
+    /* Allocate memory for pthread_create() arguments */
+
+    struct thread_info *tinfo = calloc(num_threads, sizeof(*tinfo));
+    if (tinfo == NULL)
+        handle_error("calloc");
+
+    /* Create one thread for each command\-line argument */
+
+    for (int tnum = 0; tnum < num_threads; tnum++) {
+        tinfo[tnum].thread_num = tnum + 1;
+        tinfo[tnum].argv_string = argv[optind + tnum];
+
+        /* The pthread_create() call stores the thread ID into
+           corresponding element of tinfo[] */
+
+        s = pthread_create(&tinfo[tnum].thread_id, &attr,
+                           &thread_start, &tinfo[tnum]);
+        if (s != 0)
+            handle_error_en(s, "pthread_create");
+    }
+
+    /* Destroy the thread attributes object, since it is no
+       longer needed */
+
+    s = pthread_attr_destroy(&attr);
+    if (s != 0)
+        handle_error_en(s, "pthread_attr_destroy");
+
+    /* Now join with each thread, and display its returned value */
+
+    for (int tnum = 0; tnum < num_threads; tnum++) {
+        s = pthread_join(tinfo[tnum].thread_id, &res);
+        if (s != 0)
+            handle_error_en(s, "pthread_join");
+
+        printf("Joined with thread %d; returned value was %s\en",
+                tinfo[tnum].thread_num, (char *) res);
+        free(res);      /* Free memory allocated by thread */
+    }
+
+    free(tinfo);
+    exit(EXIT_SUCCESS);
+}
+.EE
+.SH 関連項目
+.ad l
+.nh
+\fBgetrlimit\fP(2), \fBpthread_attr_init\fP(3), \fBpthread_cancel\fP(3),
+\fBpthread_detach\fP(3), \fBpthread_equal\fP(3), \fBpthread_exit\fP(3),
+\fBpthread_getattr_np\fP(3), \fBpthread_join\fP(3), \fBpthread_self\fP(3),
+\fBpthread_setattr_default_np\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index 6d880f0..f4188cc 100644 (file)
@@ -96,7 +96,7 @@ thread that an application creates, so that system resources for the thread
 can be released.  (But note that the resources of any threads for which one
 of these actions has not been done will be freed when the process
 terminates.)
-.SH EXAMPLES
+.SH 
 以下の文は、呼び出したスレッド自身を detach する。
 .PP
     pthread_detach(pthread_self());
diff --git a/manual/LDP_man-pages/draft/man3/pthread_getattr_default_np.3 b/manual/LDP_man-pages/draft/man3/pthread_getattr_default_np.3
new file mode 100644 (file)
index 0000000..1b753ec
--- /dev/null
@@ -0,0 +1,196 @@
+.\" Copyright (c) 2016 Michael Kerrisk <mtk.manpages@gmail.com>
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_GETATTR_DEFAULT_NP 3 2020\-06\-09 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_getattr_default_np, pthread_setattr_default_np, \- get or set default
+thread\-creation attributes
+.SH 書式
+.nf
+\fB#define _GNU_SOURCE\fP             /* See feature_test_macros(7) */
+\fB#include <pthread.h>\fP
+.PP
+\fBint pthread_getattr_default_np(pthread_attr_t *\fP\fIattr\fP\fB);\fP
+\fBint pthread_setattr_default_np(pthread_attr_t *\fP\fIattr\fP\fB);\fP
+.PP
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+The \fBpthread_setattr_default_np\fP()  function sets the default attributes
+used for creation of a new thread\(emthat is, the attributes that are used
+when \fBpthread_create\fP(3)  is called with a second argument that is NULL.
+The default attributes are set using the attributes supplied in \fI*attr\fP, a
+previously initialized thread attributes object.  Note the following details
+about the supplied attributes object:
+.IP * 3
+The attribute settings in the object must be valid.
+.IP *
+The \fIstack address\fP attribute must not be set in the object.
+.IP *
+Setting the \fIstack size\fP attribute to zero means leave the default stack
+size unchanged.
+.PP
+The \fBpthread_getattr_default_np\fP()  function initializes the thread
+attributes object referred to by \fIattr\fP so that it contains the default
+attributes used for thread creation.
+.SH エラー
+.TP 
+\fBEINVAL\fP
+(\fBpthread_setattr_default_np\fP())  One of the attribute settings in \fIattr\fP
+is invalid, or the stack address attribute is set in \fIattr\fP.
+.TP 
+\fBENOMEM\fP
+.\" Can happen (but unlikely) while trying to allocate memory for cpuset
+(\fBpthread_setattr_default_np\fP())  Insufficient memory.
+.SH バージョン
+これらの関数は glibc バージョン 2.18 以降で利用できる。
+.SH 属性
+この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
+.ad l
+.TS
+allbox;
+lbw30 lb lb
+l l l.
+インターフェース       属性  値
+T{
+\fBpthread_getattr_default_np\fP(),
+\fBpthread_setattr_default_np\fP()
+T}     Thread safety   MT\-Safe
+.TE
+.ad
+.SH 準拠
+これらの関数は非標準の GNU による拡張である。そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が付いている。
+.SH 例
+The program below uses \fBpthread_getattr_default_np\fP()  to fetch the default
+thread\-creation attributes and then displays various settings from the
+returned thread attributes object.  When running the program, we see the
+following output:
+.PP
+.in +4n
+.EX
+$ \fB./a.out\fP
+Stack size:          8388608
+Guard size:          4096
+Scheduling policy:   SCHED_OTHER
+Scheduling priority: 0
+Detach state:        JOINABLE
+Inherit scheduler:   INHERIT
+.EE
+.in
+.SS プログラムのソース
+\&
+.EX
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#define errExitEN(en, msg) \e
+                        do { errno = en; perror(msg); \e
+                             exit(EXIT_FAILURE); } while (0)
+
+static void
+display_pthread_attr(pthread_attr_t *attr)
+{
+    int s;
+    size_t stacksize;
+    size_t guardsize;
+    int policy;
+    struct sched_param schedparam;
+    int detachstate;
+    int inheritsched;
+
+    s = pthread_attr_getstacksize(attr, &stacksize);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getstacksize");
+    printf("Stack size:          %zd\en", stacksize);
+
+    s = pthread_attr_getguardsize(attr, &guardsize);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getguardsize");
+    printf("Guard size:          %zd\en", guardsize);
+
+    s = pthread_attr_getschedpolicy(attr, &policy);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getschedpolicy");
+    printf("Scheduling policy:   %s\en",
+            (policy == SCHED_FIFO) ? "SCHED_FIFO" :
+            (policy == SCHED_RR) ? "SCHED_RR" :
+            (policy == SCHED_OTHER) ? "SCHED_OTHER" : "[unknown]");
+
+    s = pthread_attr_getschedparam(attr, &schedparam);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getschedparam");
+    printf("Scheduling priority: %d\en", schedparam.sched_priority);
+
+    s = pthread_attr_getdetachstate(attr, &detachstate);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getdetachstate");
+    printf("Detach state:        %s\en",
+            (detachstate == PTHREAD_CREATE_DETACHED) ? "DETACHED" :
+            (detachstate == PTHREAD_CREATE_JOINABLE) ? "JOINABLE" :
+            "???");
+
+    s = pthread_attr_getinheritsched(attr, &inheritsched);
+    if (s != 0)
+        errExitEN(s, "pthread_attr_getinheritsched");
+    printf("Inherit scheduler:   %s\en",
+            (inheritsched == PTHREAD_INHERIT_SCHED) ? "INHERIT" :
+            (inheritsched == PTHREAD_EXPLICIT_SCHED) ? "EXPLICIT" :
+            "???");
+}
+
+int
+main(int argc, char *argv[])
+{
+    int s;
+    pthread_attr_t attr;
+
+    s = pthread_getattr_default_np(&attr);
+    if (s != 0)
+        errExitEN(s, "pthread_getattr_default_np");
+
+    display_pthread_attr(&attr);
+
+    exit(EXIT_SUCCESS);
+}
+.EE
+.SH 関連項目
+.ad l
+.nh
+\fBpthread_attr_getaffinity_np\fP(3), \fBpthread_attr_getdetachstate\fP(3),
+\fBpthread_attr_getguardsize\fP(3), \fBpthread_attr_getinheritsched\fP(3),
+\fBpthread_attr_getschedparam\fP(3), \fBpthread_attr_getschedpolicy\fP(3),
+\fBpthread_attr_getscope\fP(3), \fBpthread_attr_getstack\fP(3),
+\fBpthread_attr_getstackaddr\fP(3), \fBpthread_attr_getstacksize\fP(3),
+\fBpthread_attr_init\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index 9df56b4..abb5da1 100644 (file)
@@ -108,7 +108,7 @@ T}  Thread safety   MT\-Safe
 この関数は非標準の GNU による拡張である。
 そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
 付いている。
-.SH EXAMPLES
+.SH 
 以下のプログラムは \fBpthread_getattr_np\fP() の使用例を示したものである。
 このプログラムは、スレッドを作成し、それから
 \fBpthread_getattr_np\fP() を使ってそのスレッドの属性 guard size、
index ed80a0b..e1a6f11 100644 (file)
@@ -87,7 +87,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 クロック ID \fBCLOCK_THREAD_CPUTIME_ID\fP が指定されていれば、
 \fBclock_gettime\fP(2) と \fBclock_settime\fP(2) が操作するのと同じ時計
 を参照する ID が返される。
-.SH EXAMPLES
+.SH 
 以下のプログラムは、スレッドを作成し、それから
 \fBclock_gettime\fP(2) を使ってプロセス全体の CPU 時間を取得し、
 \fBpthread_getcpuclockid\fP(3) を使って 2 つのスレッドが消費した
index 2cb071e..c6ca1e8 100644 (file)
@@ -50,19 +50,16 @@ pthread_join \- 終了したスレッドを join する
 \fBpthread_join\fP() はすぐに返る。
 \fIthread\fP で指定されたスレッドは join 可能でなければならない。
 .PP
-If \fIretval\fP is not NULL, then \fBpthread_join\fP()  copies the exit status of
-the target thread (i.e., the value that the target thread supplied to
-\fBpthread_exit\fP(3))  into the location pointed to by \fIretval\fP.  If the
-target thread was canceled, then \fBPTHREAD_CANCELED\fP is placed in the
-location pointed to by \fIretval\fP.
+\fIretval\fP が NULL でない場合、 \fBpthread_join\fP() は対象スレッドの終了ステータス (すなわち、対象スレッドが
+\fBpthread_exit\fP(3) に渡した値) を \fIretval\fP が指す場所にコピーする。対象スレッドがキャンセルされた場合、
+\fIretval\fP が指す場所には \fBPTHREAD_CANCELED\fP が格納される。
 .PP
 複数のスレッドが同時に同じスレッドを join しようとした場合、その結果
 は不定である。\fBpthread_join\fP() を呼び出しているスレッドがキャンセル
 された場合、対象スレッドは join 可能のままとなる (detached 状態には
 ならない)。
 .SH 返り値
-成功すると、 \fBpthread_join\fP() は 0 を返す。
-エラーの場合、エラー番号を返す。
+成功すると、 \fBpthread_join\fP() は 0 を返す。エラーの場合、エラー番号を返す。
 .SH エラー
 .TP 
 \fBEDEADLK\fP
@@ -116,7 +113,7 @@ pthreads には、 \fIwaitpid(\-1,\ &status,\ 0)\fP、つまり
 .PP
 プロセス内の全てのスレッドは対等であり、
 どのスレッドでもプロセス内の他のスレッドを join できる。
-.SH EXAMPLES
+.SH 
 \fBpthread_create\fP(3) を参照。
 .SH 関連項目
 \fBpthread_cancel\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
index 2fcdc96..3145d9b 100644 (file)
@@ -99,9 +99,8 @@ deadlocks.
 \fBpthread_rwlockattr_getkind_np\fP() 関数は、 \fIattr\fP
 が参照する読み書きロック属性オブジェクトのロック種別属性の値をポインター \fIpref\fP に入れて返す。
 .SH 返り値
-On success, these functions return 0.  Given valid pointer arguments,
-\fBpthread_rwlockattr_getkind_np\fP()  always succeeds.  On error,
-\fBpthread_rwlockattr_setkind_np\fP()  returns a nonzero error number.
+成功すると、これらの関数は 0 を返す。 有効なポインター引き数が渡された場合、 \fBpthread_rwlockattr_getkind_np\fP()
+は常に成功する。 エラーの場合、 \fBpthread_rwlockattr_setkind_np\fP() は 0 以外のエラー番号を返す。
 .SH エラー
 .TP 
 \fBEINVAL\fP
@@ -110,8 +109,8 @@ On success, these functions return 0.  Given valid pointer arguments,
 関数 \fBpthread_rwlockattr_getkind_np\fP() と \fBpthread_rwlockattr_setkind_np\fP() は
 glibc 2.1 で初めて登場した。
 .SH 準拠
-These functions are non\-standard GNU extensions; hence the suffix "_np"
-(nonportable) in the names.
+これらの関数は非標準の GNU による拡張である。 そのため、名前に "_np" (non\-portable; 移植性がない)
+という接尾辞が付いている。
 .SH 関連項目
 \fBpthreads\fP(7)
 .SH この文書について
index d615c1c..767c23f 100644 (file)
@@ -135,7 +135,7 @@ T}  Thread safety   MT\-Safe
 .PP
 \fBpthread_create\fP(3) で作成される新しいスレッドは、
 作成者の CPU affinity マスクを継承する。
-.SH EXAMPLES
+.SH 
 以下のプログラムでは、メインスレッドは
 \fBpthread_setaffinity_np\fP() を使って自分の CPU affinity マスクに
 CPU 0 から 7 が含まれるように設定し
index e874f68..9d16db6 100644 (file)
@@ -145,23 +145,21 @@ mutex、セマフォ、ロックなどの獲得を行うことができない。
 (例えば、\fBmalloc\fP(3) 関連の関数が管理している未使用ブロックのリンクリスト)
 が一貫性のない状態のままになってしまう可能性がある。その結果、クリーンアップハンドラーが役に立たないものになってしまう。
 .PP
-Functions that can be safely asynchronously canceled are called
-\fIasync\-cancel\-safe functions\fP.  POSIX.1\-2001 and POSIX.1\-2008 require only
-that \fBpthread_cancel\fP(3), \fBpthread_setcancelstate\fP(), and
-\fBpthread_setcanceltype\fP()  be async\-cancel\-safe.  In general, other library
-functions can't be safely called from an asynchronously cancelable thread.
+非同期で安全にキャンセルできる関数は \fIasync\-cancel\-safe functions\fP と呼ばれる。 POSIX.1\-2001 と
+POSIX.1\-2008 で、非同期で安全にキャンセルできるように求められている関数は \fBpthread_cancel\fP(3),
+\fBpthread_setcancelstate\fP(), \fBpthread_setcanceltype\fP() だけである。
+一般的には、それ以外のライブラリ関数は、非同期にキャンセルできるスレッドから安全に呼び出すことはできない。
 .PP
 非同期でのキャンセルが有効な数少ない状況としては、純粋に計算だけを行うループに入っているスレッドをキャンセルするといった場面がある。
 .SS 移植性に関する注意
 .\" It looks like at least Solaris, FreeBSD and Tru64 support this.
-The Linux threading implementations permit the \fIoldstate\fP argument of
-\fBpthread_setcancelstate\fP()  to be NULL, in which case the information about
-the previous cancelability state is not returned to the caller.  Many other
-implementations also permit a NULL \fIoldstat\fP argument, but POSIX.1 does not
-specify this point, so portable applications should always specify a
-non\-NULL value in \fIoldstate\fP.  A precisely analogous set of statements
-applies for the \fIoldtype\fP argument of \fBpthread_setcanceltype\fP().
-.SH EXAMPLES
+Linux のスレッド実装では、 \fBpthread_setcancelstate\fP() の \fIoldstate\fP 引き数に NULL
+を指定することを認めている。 NULL が指定された場合、変更前の cancelability state
+の情報が呼び出し側に返されない。他の多くの実装でも \fIoldstate\fP 引き数に NULL を指定することを認めているが、 POSIX.1
+ではこの点については規定されていない。したがって、移植性が必要なアプリケーションでは常に \fIoldstate\fP に NULL
+以外の値を指定するようにすべきである。 \fBpthread_setcanceltype\fP() の \fIoldtype\fP
+引き数についても、全く同じことが言える。
+.SH 例
 \fBpthread_cancel\fP(3) を参照。
 .SH 関連項目
 \fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3), \fBpthread_testcancel\fP(3),
index bc408e7..37bcf30 100644 (file)
@@ -97,7 +97,7 @@ T}    Thread safety   MT\-Safe
 \fBpthread_setname_np\fP() は内部で \fI/proc\fP ファイルシステムのスレッド固有の \fIcomm\fP ファイル
 (\fI/proc/self/task/[tid]/comm\fP) に書き込みを行う。 \fBpthread_getname_np\fP()
 はこのファイルから読み出しを行う。
-.SH EXAMPLES
+.SH 
 以下のプログラムは、 \fBpthread_setname_np\fP() と \fBpthread_getname_np\fP()
 の使用例を示している。
 .PP
index c6428d0..ef2fe0e 100644 (file)
@@ -110,9 +110,9 @@ ID が \fIthread\fP のスレッドが見つからなかった。
 .PP
 .\" .SH VERSIONS
 .\" Available since glibc 2.0
-POSIX.1 also documents an \fBENOTSUP\fP ("attempt was made to set the policy or
-scheduling parameters to an unsupported value") error for
-\fBpthread_setschedparam\fP().
+POSIX.1 では、 \fBpthread_setschedparam\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値をスケジューリングポリシーや
+パラメーターに設定しようとした") も追加で規定されている。
 .SH 属性
 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
 .TS
@@ -130,7 +130,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 .SH 注意
 スレッドのスケジューリングポリシーや優先度を変更するために必要な許可や変更した場合の影響、および各スケジューリングポリシーで認められる優先度の範囲の詳細については、
 \fBsched\fP(7) を参照。
-.SH EXAMPLES
+.SH 
 以下のプログラムは \fBpthread_setschedparam\fP() と
 \fBpthread_getschedparam\fP() やスケジューリングに関連する pthreads の
 他のいろいろな関数の使用例を示すものである。
index ca13c04..d48ffe5 100644 (file)
@@ -71,8 +71,9 @@ pthread_setschedprio \- スレッドのスケジューリング優先度を設
 \fBESRCH\fP
 ID が \fIthread\fP のスレッドが見つからなかった。
 .PP
-POSIX.1 also documents an \fBENOTSUP\fP ("attempt was made to set the priority
-to an unsupported value") error for \fBpthread_setschedparam\fP(3).
+POSIX.1 では、 \fBpthread_setschedprio\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値を優先度
+に設定しようとした") も追加で規定されている。
 .SH バージョン
 この関数は glibc バージョン 2.3.4 以降で利用できる。
 .SH 属性
index 209ab32..a722f85 100644 (file)
@@ -56,9 +56,8 @@ _POSIX_C_SOURCE\ >=\ 199506L || _XOPEN_SOURCE\ >=\ 500
 .RE
 .ad b
 .SH 説明
-The \fBpthread_sigmask\fP()  function is just like \fBsigprocmask\fP(2), with the
-difference that its use in multithreaded programs is explicitly specified by
-POSIX.1.  Other differences are noted in this page.
+\fBpthread_sigmask\fP() 関数は \fBsigprocmask\fP(2) と全く同様だが、マルチスレッドプログラムでの利用が POSIX.1
+で明示的に規定されている点が異なる。他の違いはこのマニュアルページで説明する。
 .PP
 この関数の引き数と動作の説明は \fBsigprocmask\fP(2) を参照。
 .SH 返り値
@@ -86,7 +85,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 The glibc \fBpthread_sigmask\fP()  function silently ignores attempts to block
 the two real\-time signals that are used internally by the NPTL threading
 implementation.  See \fBnptl\fP(7)  for details.
-.SH EXAMPLES
+.SH 
 以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block)
 するように設定を行い、 \fBsigwait\fP(3) 経由でそれらのシグナルを集める
 専用のスレッドを作成する。
index 595c91e..7ad3a1a 100644 (file)
@@ -73,7 +73,7 @@ T}    Thread safety   MT\-Safe
 .TE
 .SH 準拠
 POSIX.1\-2001, POSIX.1\-2008.
-.SH EXAMPLES
+.SH 
 \fBpthread_cleanup_push\fP(3) を参照。
 .SH 関連項目
 \fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3),
index 3e0faf3..128070d 100644 (file)
@@ -112,7 +112,7 @@ T}  Thread safety   MT\-Safe
 これらの関数は非標準の GNU による拡張である。
 そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
 付いている。
-.SH EXAMPLES
+.SH 
 以下のコードは、最大 5 秒まで join を待つ。
 .PP
 .in +4n
index 29b098a..c96bb88 100644 (file)
@@ -100,10 +100,8 @@ library functions.  Note that the pthreads functions do not set \fIerrno\fP.
 For each of the pthreads functions that can return an error, POSIX.1\-2001
 specifies that the function can never fail with the error \fBEINTR\fP.
 .SS "スレッド ID"
-Each of the threads in a process has a unique thread identifier (stored in
-the type \fIpthread_t\fP).  This identifier is returned to the caller of
-\fBpthread_create\fP(3), and a thread can obtain its own thread identifier
-using \fBpthread_self\fP(3).
+あるプロセス内の各スレッドは (\fIpthread_t\fP 型の) 一意なスレッド識別子を持つ。 この識別子は、 \fBpthread_create\fP(3)
+の呼び出し元に返される。また、スレッドは自身のスレッド識別子を \fBpthread_self\fP(3) を使って取得できる。
 .PP
 Thread IDs are guaranteed to be unique only within a process.  (In all
 pthreads functions that accept a thread ID as an argument, that ID by
@@ -125,7 +123,7 @@ asctime()
 basename()
 catgets()
 crypt()
-ctermid() if passed a non\-NULL argument
+ctermid() (NULL でない引き数を渡された場合)
 ctime()
 dbm_clearerr()
 dbm_close()
@@ -139,14 +137,14 @@ dbm_store()
 dirname()
 dlerror()
 drand48()
-ecvt() [POSIX.1\-2001 only (function removed in POSIX.1\-2008)]
+ecvt() [POSIX.1\-2001 のみ (POSIX.1\-2008 で削除された)]
 encrypt()
 endgrent()
 endpwent()
 endutxent()
-fcvt() [POSIX.1\-2001 only (function removed in POSIX.1\-2008)]
+fcvt() [POSIX.1\-2001 のみ (POSIX.1\-2008 で削除された)]
 ftw()
-gcvt() [POSIX.1\-2001 only (function removed in POSIX.1\-2008)]
+gcvt() [POSIX.1\-2001 のみ (POSIX.1\-2008 で削除された)]
 getc_unlocked()
 getchar_unlocked()
 getdate()
@@ -154,10 +152,8 @@ getenv()
 getgrent()
 getgrgid()
 getgrnam()
-gethostbyaddr() [POSIX.1\-2001 only (function removed in
-                 POSIX.1\-2008)]
-gethostbyname() [POSIX.1\-2001 only (function removed in
-                 POSIX.1\-2008)]
+gethostbyaddr() [POSIX.1\-2001 のみ (POSIX.1\-2008 で削除された)]
+gethostbyname() [POSIX.1\-2001 のみ (POSIX.1\-2008 で削除された)]
 gethostent()
 getlogin()
 getnetbyaddr()
@@ -204,14 +200,14 @@ setkey()
 setpwent()
 setutxent()
 strerror()
-strsignal() [Added in POSIX.1\-2008]
+strsignal() [POSIX.1\-2008 で追加された]
 strtok()
-system() [Added in POSIX.1\-2008]
-tmpnam() if passed a non\-NULL argument
+system() [POSIX.1\-2008 で追加された]
+tmpnam() (NULL でない引き数を渡された場合)
 ttyname()
 unsetenv()
-wcrtomb() if its final argument is NULL
-wcsrtombs() if its final argument is NULL
+wcrtomb() (最後の引き数が NULL の場合)
+wcsrtombs() (最後の引き数が NULL の場合)
 wcstombs()
 wctomb()
 .EE
@@ -316,8 +312,8 @@ asctime_r()
 catclose()
 catgets()
 catopen()
-chmod() [Added in POSIX.1\-2008]
-chown() [Added in POSIX.1\-2008]
+chmod() [POSIX.1\-2008 で追加された]
+chown() [POSIX.1\-2008 で追加された]
 closedir()
 closelog()
 ctermid()
@@ -331,7 +327,7 @@ dbm_open()
 dbm_store()
 dlclose()
 dlopen()
-dprintf() [Added in POSIX.1\-2008]
+dprintf() [POSIX.1\-2008 で追加された]
 endgrent()
 endhostent()
 endnetent()
@@ -339,13 +335,13 @@ endprotoent()
 endpwent()
 endservent()
 endutxent()
-faccessat() [Added in POSIX.1\-2008]
-fchmod() [Added in POSIX.1\-2008]
-fchmodat() [Added in POSIX.1\-2008]
-fchown() [Added in POSIX.1\-2008]
-fchownat() [Added in POSIX.1\-2008]
+faccessat() [POSIX.1\-2008 で追加された]
+fchmod() [POSIX.1\-2008 で追加された]
+fchmodat() [POSIX.1\-2008 で追加された]
+fchown() [POSIX.1\-2008 で追加された]
+fchownat() [POSIX.1\-2008 で追加された]
 fclose()
-fcntl() (for any value of cmd argument)
+fcntl() (cmd 引き数が何であっても)
 fflush()
 fgetc()
 fgetpos()
@@ -367,11 +363,11 @@ fseek()
 fseeko()
 fsetpos()
 fstat()
-fstatat() [Added in POSIX.1\-2008]
+fstatat() [POSIX.1\-2008 で追加された]
 ftell()
 ftello()
 ftw()
-futimens() [Added in POSIX.1\-2008]
+futimens() [POSIX.1\-2008 で追加された]
 fwprintf()
 fwrite()
 fwscanf()
@@ -382,27 +378,27 @@ getchar()
 getchar_unlocked()
 getcwd()
 getdate()
-getdelim() [Added in POSIX.1\-2008]
+getdelim() [POSIX.1\-2008 で追加された]
 getgrent()
 getgrgid()
 getgrgid_r()
 getgrnam()
 getgrnam_r()
-gethostbyaddr() [POSIX.1\-2001 only (function removed in
-                 POSIX.1\-2008)]
-gethostbyname() [POSIX.1\-2001 only (function removed in
-                 POSIX.1\-2008)]
+gethostbyaddr() [POSIX.1\-2001 のみ (この関数は
+                 POSIX.1\-2008 で削除されている)]
+gethostbyname() [POSIX.1\-2001 のみ (この関数は
+                 POSIX.1\-2008 で削除されている)]
 gethostent()
 gethostid()
 gethostname()
-getline() [Added in POSIX.1\-2008]
+getline() [POSIX.1\-2008 で追加された]
 getlogin()
 getlogin_r()
 getnameinfo()
 getnetbyaddr()
 getnetbyname()
 getnetent()
-getopt() (if opterr is nonzero)
+getopt() (opterr が 0 以外の場合)
 getprotobyname()
 getprotobynumber()
 getprotoent()
@@ -420,26 +416,27 @@ getutxid()
 getutxline()
 getwc()
 getwchar()
-getwd() [POSIX.1\-2001 only (function removed in POSIX.1\-2008)]
+getwd() [POSIX.1\-2001 のみ (この関数は
+         POSIX.1\-2008 で削除されている)]
 glob()
 iconv_close()
 iconv_open()
 ioctl()
 link()
-linkat() [Added in POSIX.1\-2008]
-lio_listio() [Added in POSIX.1\-2008]
+linkat() [POSIX.1\-2008 で追加された]
+lio_listio() [POSIX.1\-2008 で追加された]
 localtime()
 localtime_r()
-lockf() [Added in POSIX.1\-2008]
+lockf() [POSIX.1\-2008 で追加された]
 lseek()
 lstat()
-mkdir() [Added in POSIX.1\-2008]
-mkdirat() [Added in POSIX.1\-2008]
-mkdtemp() [Added in POSIX.1\-2008]
-mkfifo() [Added in POSIX.1\-2008]
-mkfifoat() [Added in POSIX.1\-2008]
-mknod() [Added in POSIX.1\-2008]
-mknodat() [Added in POSIX.1\-2008]
+mkdir() [POSIX.1\-2008 で追加された]
+mkdirat() [POSIX.1\-2008 で追加された]
+mkdtemp() [POSIX.1\-2008 で追加された]
+mkfifo() [POSIX.1\-2008 で追加された]
+mkfifoat() [POSIX.1\-2008 で追加された]
+mknod() [POSIX.1\-2008 で追加された]
+mknodat() [POSIX.1\-2008 で追加された]
 mkstemp()
 mktime()
 nftw()
@@ -473,8 +470,8 @@ posix_trace_shutdown()
 posix_trace_timedgetnext_event()
 posix_typed_mem_open()
 printf()
-psiginfo() [Added in POSIX.1\-2008]
-psignal() [Added in POSIX.1\-2008]
+psiginfo() [POSIX.1\-2008 で追加された]
+psignal() [POSIX.1\-2008 で追加された]
 pthread_rwlock_rdlock()
 pthread_rwlock_timedrdlock()
 pthread_rwlock_timedwrlock()
@@ -489,14 +486,14 @@ putwc()
 putwchar()
 readdir()
 readdir_r()
-readlink() [Added in POSIX.1\-2008]
-readlinkat() [Added in POSIX.1\-2008]
+readlink() [POSIX.1\-2008 で追加された]
+readlinkat() [POSIX.1\-2008 で追加された]
 remove()
 rename()
-renameat() [Added in POSIX.1\-2008]
+renameat() [POSIX.1\-2008 で追加された]
 rewind()
 rewinddir()
-scandir() [Added in POSIX.1\-2008]
+scandir() [POSIX.1\-2008 で追加された]
 scanf()
 seekdir()
 semop()
@@ -507,13 +504,13 @@ setprotoent()
 setpwent()
 setservent()
 setutxent()
-sigpause() [Added in POSIX.1\-2008]
+sigpause() [POSIX.1\-2008 で追加された]
 stat()
 strerror()
 strerror_r()
 strftime()
 symlink()
-symlinkat() [Added in POSIX.1\-2008]
+symlinkat() [POSIX.1\-2008 で追加された]
 sync()
 syslog()
 tmpfile()
@@ -524,11 +521,11 @@ tzset()
 ungetc()
 ungetwc()
 unlink()
-unlinkat() [Added in POSIX.1\-2008]
-utime() [Added in POSIX.1\-2008]
-utimensat() [Added in POSIX.1\-2008]
-utimes() [Added in POSIX.1\-2008]
-vdprintf() [Added in POSIX.1\-2008]
+unlinkat() [POSIX.1\-2008 で追加された]
+utime() [POSIX.1\-2008 で追加された]
+utimensat() [POSIX.1\-2008 で追加された]
+utimes() [POSIX.1\-2008 で追加された]
+vdprintf() [POSIX.1\-2008 で追加された]
 vfprintf()
 vfwprintf()
 vprintf()
@@ -711,12 +708,11 @@ POSXI.1 では、全体としてのプロセスに送られるシグナルと、
 (仕様では、新しいスレッドは代替シグナルスタックが定義されていない状態 で開始されるべきとされている。
 2つのスレッドが共有されている代替シグナルスタック上で同時に シグナルの処理を行った場合、予測不可能なプログラムのエラーが 起こり得る。)
 .SS NPTL
-With NPTL, all of the threads in a process are placed in the same thread
-group; all members of a thread group share the same PID.  NPTL does not
-employ a manager thread.
+NPTL では、一つのプロセスの全てのスレッドは同じスレッドグループ に属する; スレッドグループの全メンバーは同じ PID を共有する。 NPTL
+は管理スレッド (manager thread) を利用しない。
 .PP
-NPTL makes internal use of the first two real\-time signals; these signals
-cannot be used in applications.  See \fBnptl\fP(7)  for further details.
+ NPTL は内部でリアルタイムシグナルのうち最初の 2つの番号を使用しており、これらのシグナルはアプリケーションでは使用できない。詳細は
+\fBnptl\fP(7) を参照のこと。
 .PP
 NPTL にも POSIX.1 に準拠していない点が少なくとも一つある:
 .IP \- 3
@@ -790,17 +786,16 @@ bash$ $( LD_ASSUME_KERNEL=2.2.5 ldd /bin/ls | grep libc.so | \e
 \fBclone\fP(2), \fBfork\fP(2), \fBfutex\fP(2), \fBgettid\fP(2), \fBproc\fP(5),
 \fBattributes\fP(7), \fBfutex\fP(7), \fBnptl\fP(7), \fBsigevent\fP(7), \fBsignal\fP(7)
 .PP
-Various Pthreads manual pages, for example: \fBpthread_atfork\fP(3),
-\fBpthread_attr_init\fP(3), \fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3),
-\fBpthread_cond_signal\fP(3), \fBpthread_cond_wait\fP(3), \fBpthread_create\fP(3),
-\fBpthread_detach\fP(3), \fBpthread_equal\fP(3), \fBpthread_exit\fP(3),
-\fBpthread_key_create\fP(3), \fBpthread_kill\fP(3), \fBpthread_mutex_lock\fP(3),
-\fBpthread_mutex_unlock\fP(3), \fBpthread_mutexattr_destroy\fP(3),
-\fBpthread_mutexattr_init\fP(3), \fBpthread_once\fP(3), \fBpthread_spin_init\fP(3),
-\fBpthread_spin_lock\fP(3), \fBpthread_rwlockattr_setkind_np\fP(3),
-\fBpthread_setcancelstate\fP(3), \fBpthread_setcanceltype\fP(3),
-\fBpthread_setspecific\fP(3), \fBpthread_sigmask\fP(3), \fBpthread_sigqueue\fP(3),
-and \fBpthread_testcancel\fP(3)
+pthreads の各種マニュアルページ、例えば: \fBpthread_atfork\fP(3), \fBpthread_attr_init\fP(3),
+\fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3), \fBpthread_cond_signal\fP(3),
+\fBpthread_cond_wait\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
+\fBpthread_equal\fP(3), \fBpthread_exit\fP(3), \fBpthread_key_create\fP(3),
+\fBpthread_kill\fP(3), \fBpthread_mutex_lock\fP(3), \fBpthread_mutex_unlock\fP(3),
+\fBpthread_mutexattr_destroy\fP(3), \fBpthread_mutexattr_init\fP(3),
+\fBpthread_once\fP(3), \fBpthread_spin_init\fP(3), \fBpthread_spin_lock\fP(3),
+\fBpthread_rwlockattr_setkind_np\fP(3), \fBpthread_setcancelstate\fP(3),
+\fBpthread_setcanceltype\fP(3), \fBpthread_setspecific\fP(3),
+\fBpthread_sigmask\fP(3), \fBpthread_sigqueue\fP(3), and \fBpthread_testcancel\fP(3)
 .SH この文書について
 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
 \%https://www.kernel.org/doc/man\-pages/ に書かれている。