--- /dev/null
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Copyright (C) 2010 Intel Corporation
+.\" Author: Andi Kleen
+.\"
+.\" 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.
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH KEXEC_LOAD 2 2010\-11\-04 Linux "Linux Programmer's Manual"
+.SH 名前
+kexec_load \- 新しいカーネルを後で実行するためにロードする
+.SH 書式
+\fB#include <linux/kexec.h>\fP
+.br
+\fBlong kexec_load(unsigned long \fP\fIentry\fP\fB, unsigned long
+\fP\fInr_segments\fP\fB,\fP
+.br
+\fB struct kexec_segment *\fP\fIsegments\fP\fB, unsigned long \fP\fIflags\fP\fB);\fP
+.SH 説明
+\fBkexec_load\fP() システムコールは、新しいカーネルをロードし、
+その後の \fBreboot\fP(2) で実行できるようにする。
+.PP
+\fIflags\fP 引き数はマスクビットで、
+その上位ビットでシステムコールの呼び出しの動作を制御する。
+\fIflags\fP には以下の値を指定できる。
+.TP
+\fBKEXEC_ON_CRASH\fP (Linux 2.6.13 以降)
+.\" FIXME figure out how this is really used
+システムのクラッシュ時に、新しいカーネルを自動的に実行する。
+.TP
+\fBKEXEC_PRESERVE_CONTEXT\fP (Linux 2.7.27 以降)
+新しいカーネルを実行する前に、
+システムのハードウェアとソフトウェアの状態を保存する。
+システムの中断時 (suspend) などで使用できる。
+このフラグは、カーネルの設定で \fBCONFIG_KEXEC_JUMP\fP が有効の場合のみ
+利用可能であり、 \fInr_segments\fP が 0 より大きい場合のみ効果がある。
+.PP
+\fIflags\fP の下位ビットには、実行されるカーネルのアーキテクチャが入る。
+現在のアーキテクチャを使うことを意味する定数 \fBKEXEC_ARCH_DEFAULT\fP か、
+アーキテクチャ定数 \fBKEXEC_ARCH_386\fP, \fBKEXEC_ARCH_X86_64\fP,
+\fBKEXEC_ARCH_PPC\fP, \fBKEXEC_ARCH_PPC64\fP, \fBKEXEC_ARCH_IA_64\fP,
+\fBKEXEC_ARCH_ARM\fP, \fBKEXEC_ARCH_S390\fP, \fBKEXEC_ARCH_SH\fP,
+\fBKEXEC_ARCH_MIPS\fP, \fBKEXEC_ARCH_MIPS_LE\fP の
+いずれか一つを (OR で) 指定する。指定するアーキテクチャは、
+システムの CPU で実行可能なものでなければならない。
+
+\fIentry\fP 引き数は、カーネルイメージの物理エントリーアドレスである。
+\fInr_segments\fP 引き数は、 \fIsegments\fP ポインタが指すセグメントの
+数である。 \fIsegments\fP 引き数は \fIkexec_segment\fP 構造体の配列で、
+この構造体によりカーネルの配置が定義される。
+.in +4n
+.nf
+
+struct kexec_segment {
+ void *buf; /* Buffer in user space */
+ size_t bufsz; /* Buffer length in user space */
+ void *mem; /* Physical address of kernel */
+ size_t memsz; /* Physical address length */
+};
+.fi
+.in
+.PP
+.\" FIXME elaborate on the following:
+\fIsegments\fP で定義されたカーネルイメージは、
+呼び出したプロセスから予約済みメモリにコピーされる。
+.SH 返り値
+成功すると、 \fBkexec_load\fP は 0 を返す。
+エラーの場合、 \-1 が返り、 \fIerrno\fP にエラーを示す値が設定される。
+.SH エラー
+.TP
+\fBEBUSY\fP
+別のクラッシュカーネルがすでにロードされているか、
+クラッシュカーネルがすでに使用されている。
+.TP
+\fBEINVAL\fP
+.\" KEXEC_SEGMENT_MAX == 16
+\fIflags\fP が無効である。 \fInr_segments\fP が大きすぎる。
+.TP
+\fBEPERM\fP
+呼び出し側が \fBCAP_SYS_BOOT\fP ケーパビリティを持っていない。
+.SH バージョン
+\fBkexec_load\fP() システムコールは Linux 2.6.13 で初めて登場した。
+.SH 準拠
+このシステムコールは Linux 固有である。
+.SH 注意
+現在のところ、 \fBkexec_load\fP() は glibc ではサポートされていない。
+\fBsyscall\fP(2) を使って呼び出すこと。
+.PP
+.\" FIXME Andi submitted a patch for this.
+.\" Check if it got accepted later.
+必要な定数はカーネルのソースファイル \fIlinux/kexec.h\fP で定義されている
+が、現在のところ glibc には公開されていない。
+そのため、これらの定数は手動で定義しなければならない。
+
+このシステムコールは、カーネルの設定で \fBCONFIG_KEXEC\fP が有効になって
+いる場合にのみ利用できる。
+.SH 関連項目
+\fBreboot\fP(2), \fBsyscall\fP(2)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (C) 2009, Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\" a few pieces remain from an earlier version
+.\" Copyright (C) 2008, Nanno Langstraat <nal@ii.nl>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH ENDIAN 3 2010\-09\-10 GNU "Linux Programmer's Manual"
+.SH 名前
+htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh,
+le32toh, htobe64, htole64, be64toh, le64toh \- ホストバイトオーダーと
+ビッグ/リトルエンディアンバイトオーダーの間で値の変換を行う
+.SH 書式
+.nf
+\fB#define _BSD_SOURCE\fP /* feature_test_macros(7) 参照 */
+\fB#include <endian.h>\fP
+
+\fBuint16_t htobe16(uint16_t \fP\fIhost_16bits\fP\fB);\fP
+\fBuint16_t htole16(uint16_t \fP\fIhost_16bits\fP\fB);\fP
+\fBuint16_t be16toh(uint16_t \fP\fIbig_endian_16bits\fP\fB);\fP
+\fBuint16_t le16toh(uint16_t \fP\fIlittle_endian_16bits\fP\fB);\fP
+
+\fBuint32_t htobe32(uint32_t \fP\fIhost_32bits\fP\fB);\fP
+\fBuint32_t htole32(uint32_t \fP\fIhost_32bits\fP\fB);\fP
+\fBuint32_t be32toh(uint32_t \fP\fIbig_endian_32bits\fP\fB);\fP
+\fBuint32_t le32toh(uint32_t \fP\fIlittle_endian_32bits\fP\fB);\fP
+
+\fBuint64_t htobe64(uint64_t \fP\fIhost_64bits\fP\fB);\fP
+\fBuint64_t htole64(uint64_t \fP\fIhost_64bits\fP\fB);\fP
+\fBuint64_t be64toh(uint64_t \fP\fIbig_endian_64bits\fP\fB);\fP
+\fBuint64_t le64toh(uint64_t \fP\fIlittle_endian_64bits\fP\fB);\fP
+.fi
+.SH 説明
+これらの関数は、整数値のバイトエンコーディングを、
+使用中の CPU ("ホスト") のバイトオーダーから
+リトルエンディアンやビッグエンディアンバイトオーダーへの変換や
+その逆の変換を行う。
+
+各関数の名前に付いている数字 \fInn\fP は、その関数が扱う整数のサイズ
+(16, 32, 64 ビットのどれか) を示している。
+
+名前が "htobe\fInn\fP" という形の関数は、ホストバイトオーダーから
+ビッグエンディアンバイトオーダーへの変換を行う。
+
+名前が "htole\fInn\fP" という形の関数は、ホストバイトオーダーから
+リトルエンディアンバイトオーダーへの変換を行う。
+
+名前が "be\fInn\fPtoh" という形の関数は、ビッグエンディアンバイトオーダー
+からホストバイトオーダーへの変換を行う。
+
+名前が "le\fInn\fPtoh" という形の関数は、リトルエンディアンバイトオーダー
+からホストバイトオーダーへの変換を行う。
+.SH バージョン
+これらの関数は glibc バージョン 2.9 で追加された。
+.SH 準拠
+これらの関数は非標準である。
+BSD には同様の関数が存在するが、 BSD では
+必要なヘッダファイルは \fI<endian.h>\fP ではなく
+\fI<sys/endian.h>\fP である。
+不幸なことに、 NetBSD, FreeBSD, glibc では、
+これらの関数の元々の OpenBSD での、 \fInn\fP は常に関数名の末尾に置く
+という名前付けルールが踏襲されていない
+(そのため、例を挙げると、 OpenBSD の "betoh32" と等価な関数は
+NetBSD, FreeBSD, glibc では "be32toh" となる)。
+.SH 注意
+これらの関数は、前からある \fBbyteorder\fP(3) 系の関数と同じである。
+例えば、 \fBbe32toh\fP() は \fBntohl\fP() と等価である。
+
+\fBbyteorder\fP(3) 系の関数のメリットは、これらが
+全ての UNIX システムで利用可能な標準関数である点である。
+一方で、これらの関数は TCP/IP 処理で使用されることを想定して
+設計されたため、このページで説明している 64 ビット版や
+リトルエンディアン版などが存在しない。
+.SH 例
+以下のプログラムは、整数をホストバイトオーダーからリトルエンディアンと
+ビットエンディアンの両方のバイトオーダーに変換し、その結果を表示する。
+ホストバイトオーダーはリトルエンディアンかビットエンディアンのいずれか
+なので、変換に意味があるのはどちらか一方だけである。
+このプログラムを x86\-32 などのリトルエンディアンのシステムで実行した
+場合の実行結果は下記のようになる。
+.in +4n
+.nf
+
+$ \fB./a.out\fP
+x.u32 = 0x44332211
+htole32(x.u32) = 0x44332211
+htobe32(x.u32) = 0x11223344
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#include <endian.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ union {
+ uint32_t u32;
+ uint8_t arr[4];
+ } x;
+
+ x.arr[0] = 0x11; /* Lowest\-address byte */
+ x.arr[1] = 0x22;
+ x.arr[2] = 0x33;
+ x.arr[3] = 0x44; /* Highest\-address byte */
+
+ printf("x.u32 = 0x%x\en", x.u32);
+ printf("htole32(x.u32) = 0x%x\en", htole32(x.u32));
+ printf("htobe32(x.u32) = 0x%x\en", htobe32(x.u32));
+
+ exit(EXIT_SUCCESS);
+}
+.fi
+.SH 関連項目
+\fBbyteorder\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (C) 2010, Michael Kerrisk <mtk.manpages@gmail.com>
+.\"
+.\" This is free documentation; you can redistribute it and/or
+.\" modify it under the terms of the GNU General Public License as
+.\" published by the Free Software Foundation; either version 2 of
+.\" the License, or (at your option) any later version.
+.\"
+.\" The GNU General Public License's references to "object code"
+.\" and "executables" are to be interpreted as the output of any
+.\" document formatting or typesetting system, including
+.\" intermediate and printed output.
+.\"
+.\" This manual is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public
+.\" License along with this manual; if not, write to the Free
+.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
+.\" USA.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH LIO_LISTIO 3 2010\-10\-20 "" "Linux Programmer's Manual"
+.SH 名前
+lio_listio \- リストの I/O リクエストを開始する
+.SH 書式
+.nf
+\fB#include <aio.h>\fP
+
+\fBint lio_listio(int \fP\fImode\fP\fB, struct aiocb *const \fP\fIaiocb_list\fP\fB[],\fP
+\fB int \fP\fInitems\fP\fB, struct sigevent *\fP\fIsevp\fP\fB);\fP
+
+\fI\-lrt\fP でリンクする。
+.fi
+.SH 説明
+\fBlio_listio\fP() 関数は、配列 \fIaiocb_list\fP で指定された I/O 操作の
+リストをそれぞれ開始する。
+
+\fImode\fP 引き数には以下のいずれかの値を指定する。
+.TP 12
+\fBLIO_WAIT\fP
+全ての操作が完了するまで、呼び出しは停止 (block) する。
+\fIsevp\fP 引き数は無視される。
+.TP
+\fBLIO_NOWAIT\fP
+I/O 操作は処理を行うためのキューに入れられ、呼び出しは直ちに返る。
+I/O 操作が完了すると、 \fIsevp\fP 引き数で指定した非同期通知が行われる。
+詳細は \fBsigevent\fP(7) を参照。
+\fIsevp\fP が NULL の場合、非同期通知は行われない。
+.PP
+\fIaiocb_list\fP 引き数は、I/O 操作を指定する \fIaiocb\fP 構造体へのポインタ
+の配列である。指定された操作の実行順序は規定されていない。
+\fInitems\fP 引き数は、配列 \fIaiocb_list\fP の大きさを指定する。
+\fIaiocb_list\fP 内の NULL ポインタは無視される。
+
+\fIaiocb_list\fP の各制御ブロックでは、
+\fIaio_lio_opcode\fP フィールドで開始する I/O 操作を指定する。
+\fIaio_lio_opcode\fP には以下の値が指定できる。
+.TP 10
+\fBLIO_READ\fP
+読み出し操作を開始する。操作はキューに入れられ、
+この制御ブロックを指定して \fBaio_read\fP(3) の呼び出しが行われる。
+.TP
+\fBLIO_WRITE\fP
+書き込み操作を開始する。操作はキューに入れられ、
+この制御ブロックを指定して \fBaio_write\fP(3) の呼び出しが行われる。
+.TP
+\fBLIO_NOP\fP
+この制御ブロックを無視する。
+.PP
+各制御ブロックの残りのフィールドは、
+\fBaio_read\fP(3) や \fBaio_write\fP(3) の場合と同じ意味を持つ。
+各制御ブロックの \fIaio_sigevent\fP フィールドは、
+個々の I/O 操作で通知方法を指定するのに使用される
+(\fBsigevent\fP(7) 参照)。
+.SH 返り値
+\fImode\fP が \fBLIO_NOWAIT\fP の場合、 \fBlio_listio\fP() は全ての操作が
+正常にキューに入れられた場合に 0 を返す。
+そうでない場合は、\-1 が返り、 \fIerrno\fP にエラーを示す値が設定される。
+
+\fImode\fP が \fBLIO_WAIT\fP の場合、 \fBlio_listio\fP() は全ての操作が
+正常に完了した場合に 0 を返す。
+そうでない場合は、\-1 が返り、 \fIerrno\fP にエラーを示す値が設定される。
+
+\fBlio_listio\fP() の返り値から得られる情報は、関数呼び出し自体に関する
+ものだけであり、個々の I/O 操作に関する情報は得られない。
+個々の I/O 操作は失敗することがあるが、これにより他の I/O 操作が完了
+しなくなるといったことはない。 \fBaio_error\fP(3) を使うと、
+\fIaiocb_list\fP の個々の I/O 操作のステータスを知ることができる。
+ある I/O 操作が完了すると、その終了ステータスは\fBaio_return\fP(3) を使う
+ことで取得できる。個々の I/O 操作は \fBaio_read\fP(3) や \fBaio_write\fP(3)
+に書かれている理由で失敗する場合がある。
+.SH エラー
+\fBlio_listio\fP() 関数は以下の理由で失敗する。
+.TP
+\fBEAGAIN\fP
+リソースが足りない。
+.TP
+\fBEAGAIN\fP
+.\" Doesn't happen in glibc(?)
+\fInitems\fP で指定された数の I/O 操作を行うと、
+非同期 I/O 操作の数が上限 \fBAIO_MAX\fP を超えてしまう状況であった。
+.TP
+\fBEINVAL\fP
+.\" Doesn't happen in glibc(?)
+\fImode\fP が不正であるか、
+\fInitems\fP が上限 \fBAIO_LISTIO_MAX\fP を超えている。
+.TP
+\fBEINTR\fP
+\fImode\fP が \fBLIO_WAIT\fP で、全ての I/O 操作が完了する前にシグナルが
+捕捉された (非同期 I/O の完了通知に使用されるシグナルの場合もこれに
+該当する)。
+.TP
+\fBEIO\fP
+.\" e.g., ioa_reqprio or aio_lio_opcode was invalid
+\fIaiocb_list\fP で指定された操作の中に失敗したものがあった。
+アプリケーションは、 \fBaio_return\fP(3) を使用して、
+個々の操作のステータスを確認することができる。
+.PP
+\fBlio_listio\fP がエラー \fBEAGAIN\fP, \fBEINTR\fP, \fBEIO\fP で失敗した場合、
+\fIaiocb_list\fP で指定した操作のいくつかは開始されていることがある。
+\fBlio_listio\fP が他の理由で失敗した場合には、
+どの I/O 操作も開始されていない。
+.SH バージョン
+The \fBlio_listio\fP() 関数は glibc 2.1 以降で利用できる。
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008.
+.SH 注意
+.\" or the control block of the operation
+使用前に制御ブロックを 0 で埋めるのは良い考えである。
+I/O 操作の実行中は制御ブロックを変更してはならない。データの読み書き先
+のバッファ領域に I/O 操作の実行中にアクセスしてはならない。さもないと、
+どのような結果になるか分からない。また、関係するメモリ領域も有効な状態
+のままにしておかなければならない。
+
+同じ \fIaiocb\fP 構造体を指定して同時に複数の I/O 操作を行った場合、
+どのような結果になるかは不定である。
+.SH 関連項目
+\fBaio_cancel\fP(3), \fBaio_error\fP(3), \fBaio_fsync\fP(3), \fBaio_return\fP(3),
+\fBaio_suspend\fP(3), \fBaio_write\fP(3), \fBaio\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_INIT 3 2008\-11\-11 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_init, pthread_attr_destroy \-
+スレッド属性オブジェクトの初期化と破棄を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_init(pthread_attr_t *\fP\fIattr\fP\fB);\fP
+\fBint pthread_attr_destroy(pthread_attr_t *\fP\fIattr\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_init\fP() 関数は \fIattr\fP が指すスレッド属性オブジェクト
+(thread attributes object) をデフォルトの属性値で初期化する。
+この呼び出しの後、オブジェクトの各属性は (関連項目に載っている) 種々の
+関数を使って設定することができ、このオブジェクトはスレッドの作成を行う
+\fBpthread_create\fP(3) の呼び出しにおいて使用することができる (一つの
+オブジェクトを複数の \fBpthread_create\fP(3) に渡してもよい)。
+
+すでに初期化されているスレッド属性オブジェクトに対して
+\fBpthread_attr_init\fP() を呼び出した場合、
+どのような動作になるかは不定である。
+
+スレッド属性オブジェクトがもはや必要なくなった際には、
+そのオブジェクトは \fBpthread_attr_destroy\fP() 関数を使って破棄すべきである。
+スレッド属性オブジェクトを破棄しても、
+そのオブジェクトを使って作成されたスレッドには影響はない。
+
+いったん破棄したスレッド属性オブジェクトは、
+\fBpthread_attr_init\fP() を使って再初期化することができる。
+破棄したスレッド属性オブジェクトをこれ以外の用途で
+使った場合の結果は不定である。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+POSIX.1\-2001 では \fBpthread_attr_init\fP() にはエラー \fBENOMEM\fP が
+記載されている。
+Linux では、これらの関数は常に成功する
+(ただし、移植性や将来も動作することを保証したいアプリケーションでは
+正のエラーの返り値を処理するようにすべきである)。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fIpthread_attr_t\fP 型の内部構造は意識すべきではない。
+pthreads 関数経由以外でのオブジェクトへのアクセスは移植性がなく、
+どのような結果が得られるかも分からない。
+.SH 例
+下記のプログラムは、\fBpthread_attr_init\fP() と種々の関連関数を使って、
+スレッド属性オブジェクトの初期化を行い、
+そのオブジェクトを使ってスレッドを一つ作成する。
+作成されたスレッドは、作成後に \fBpthread_getattr_np\fP(3) 関数
+(非標準の GNU 拡張) を使ってスレッドの属性を取得し、
+取得した属性を表示する。
+
+コマンドライン引き数なしでプログラムを実行した場合、
+\fBpthread_create\fP(3) の \fIattr\fP 引き数には NULL が渡される。
+この場合、スレッドはデフォルトの属性で作成される。
+このプログラムを NPTL スレッド実装が使われている Linux/x86\-32 で
+動作させると、以下のような出力が得られる。
+
+.in +4n
+.nf
+.\" Results from glibc 2.8, SUSE 11.0; Oct 2008
+$\fB ulimit \-s\fP # No stack imit ==> default stack size is 2MB
+unlimited
+$\fB ./a.out\fP
+Thread attributes:
+ Detach state = PTHREAD_CREATE_JOINABLE
+ Scope = PTHREAD_SCOPE_SYSTEM
+ Inherit scheduler = PTHREAD_INHERIT_SCHED
+ Scheduling policy = SCHED_OTHER
+ Scheduling priority = 0
+ Guard size = 4096 bytes
+ Stack address = 0x40196000
+ Stack size = 0x201000 bytes
+.fi
+.in
+
+コマンドライン引き数でスタックサイズが与えられた場合、
+このプログラムは、スレッド属性オブジェクトを初期化し、
+そのオブジェクトの各種属性を設定し、
+\fBpthread_create\fP(3) の呼び出しでこのオブジェクトへのポインタを渡す。
+このプログラムを NPTL スレッド実装が使われている Linux/x86\-32 で
+動作させると、以下のような出力が得られる。
+
+.in +4n
+.nf
+.\" Results from glibc 2.8, SUSE 11.0; Oct 2008
+$\fB ./a.out 0x3000000\fP
+posix_memalign() allocated at 0x40197000
+Thread attributes:
+ Detach state = PTHREAD_CREATE_DETACHED
+ Scope = PTHREAD_SCOPE_SYSTEM
+ Inherit scheduler = PTHREAD_EXPLICIT_SCHED
+ Scheduling policy = SCHED_OTHER
+ Scheduling priority = 0
+ Guard size = 0 bytes
+ Stack address = 0x40197000
+ Stack size = 0x3000000 bytes
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+static void
+display_pthread_attr(pthread_attr_t *attr, char *prefix)
+{
+ int s, i;
+ size_t v;
+ void *stkaddr;
+ struct sched_param sp;
+
+ s = pthread_attr_getdetachstate(attr, &i);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getdetachstate");
+ printf("%sDetach state = %s\en", prefix,
+ (i == PTHREAD_CREATE_DETACHED) ? "PTHREAD_CREATE_DETACHED" :
+ (i == PTHREAD_CREATE_JOINABLE) ? "PTHREAD_CREATE_JOINABLE" :
+ "???");
+
+ s = pthread_attr_getscope(attr, &i);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getscope");
+ printf("%sScope = %s\en", prefix,
+ (i == PTHREAD_SCOPE_SYSTEM) ? "PTHREAD_SCOPE_SYSTEM" :
+ (i == PTHREAD_SCOPE_PROCESS) ? "PTHREAD_SCOPE_PROCESS" :
+ "???");
+
+ s = pthread_attr_getinheritsched(attr, &i);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getinheritsched");
+ printf("%sInherit scheduler = %s\en", prefix,
+ (i == PTHREAD_INHERIT_SCHED) ? "PTHREAD_INHERIT_SCHED" :
+ (i == PTHREAD_EXPLICIT_SCHED) ? "PTHREAD_EXPLICIT_SCHED" :
+ "???");
+
+ s = pthread_attr_getschedpolicy(attr, &i);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getschedpolicy");
+ printf("%sScheduling policy = %s\en", prefix,
+ (i == SCHED_OTHER) ? "SCHED_OTHER" :
+ (i == SCHED_FIFO) ? "SCHED_FIFO" :
+ (i == SCHED_RR) ? "SCHED_RR" :
+ "???");
+
+ s = pthread_attr_getschedparam(attr, &sp);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getschedparam");
+ printf("%sScheduling priority = %d\en", prefix, sp.sched_priority);
+
+ s = pthread_attr_getguardsize(attr, &v);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getguardsize");
+ printf("%sGuard size = %d bytes\en", prefix, v);
+
+ s = pthread_attr_getstack(attr, &stkaddr, &v);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getstack");
+ printf("%sStack address = %p\en", prefix, stkaddr);
+ printf("%sStack size = 0x%x bytes\en", prefix, v);
+}
+
+static void *
+thread_start(void *arg)
+{
+ int s;
+ pthread_attr_t gattr;
+
+ /* pthread_getattr_np() is a non\-standard GNU extension that
+ retrieves the attributes of the thread specified in its
+ first argument */
+
+ s = pthread_getattr_np(pthread_self(), &gattr);
+ if (s != 0)
+ handle_error_en(s, "pthread_getattr_np");
+
+ printf("Thread attributes:\en");
+ display_pthread_attr(&gattr, "\et");
+
+ exit(EXIT_SUCCESS); /* Terminate all threads */
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t thr;
+ pthread_attr_t attr;
+ pthread_attr_t *attrp; /* NULL or &attr */
+ int s;
+
+ attrp = NULL;
+
+ /* If a command\-line argument was supplied, use it to set the
+ stack\-size attribute and set a few other thread attributes,
+ and set attrp pointing to thread attributes object */
+
+ if (argc > 1) {
+ int stack_size;
+ void *sp;
+
+ attrp = &attr;
+
+ s = pthread_attr_init(&attr);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_init");
+
+ s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setdetachstate");
+
+ s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setinheritsched");
+
+ stack_size = strtoul(argv[1], NULL, 0);
+
+ s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);
+ if (s != 0)
+ handle_error_en(s, "posix_memalign");
+
+ printf("posix_memalign() allocated at %p\en", sp);
+
+ s = pthread_attr_setstack(&attr, sp, stack_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setstack");
+ }
+
+ s = pthread_create(&thr, attrp, &thread_start, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_create");
+
+ if (attrp != NULL) {
+ s = pthread_attr_destroy(attrp);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_destroy");
+ }
+
+ pause(); /* Terminates when other thread calls exit() */
+}
+.fi
+.SH 関連項目
+\fBpthread_attr_setaffinity_np\fP(3), \fBpthread_attr_setdetachstate\fP(3),
+\fBpthread_attr_setguardsize\fP(3), \fBpthread_attr_setinheritsched\fP(3),
+\fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3),
+\fBpthread_attr_setscope\fP(3), \fBpthread_attr_setstack\fP(3),
+\fBpthread_attr_setstackaddr\fP(3), \fBpthread_attr_setstacksize\fP(3),
+\fBpthread_create\fP(3), \fBpthread_getattr_np\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETAFFINITY_NP 3 2010\-09\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setaffinity_np, pthread_attr_getaffinity_np \-
+スレッド属性オブジェクトの CPU affinity 属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setaffinity_np(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB size_t \fP\fIcpusetsize\fP\fB, const cpu_set_t *\fP\fIcpuset\fP\fB);\fP
+\fBint pthread_attr_getaffinity_np(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB size_t \fP\fIcpusetsize\fP\fB, cpu_set_t *\fP\fIcpuset\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setaffinity_np\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトの CPU affinity マスク属性を
+\fIcpuset\fP で指定された値に設定する。
+この属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されたスレッドの CPU affinity マスクが決定される。
+
+\fBpthread_attr_getaffinity_np\fP() 関数は、 \fIattr\fP が参照する
+スレッド属性オブジェクトの CPU affinity マスク属性を
+\fIcpuset\fP が指すバッファに入れて返す。
+
+\fIcpusetsize\fP 引き数は \fIcpuset\fP が指すバッファの (バイト単位の)
+大きさである。通常は、この引き数には \fIsizeof(cpu_set_t)\fP を
+指定することだろう。
+
+CPU affinity マスクの詳細については、
+\fBsched_setaffinity\fP(2) を参照してほしい。
+CPU 集合の操作や取得を行う際に利用できるマクロ群の説明は
+\fBCPU_SET\fP(3) を参照してほしい。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+.TP
+\fBEINVAL\fP
+.\" cpumask_t
+.\" The raw sched_getaffinity() system call returns the size (in bytes)
+.\" of the cpumask_t type.
+(\fBpthread_attr_setaffinity_np\fP())
+\fIcpuset\fP がカーネルがサポートする CPU 集合にない CPU を指定していた。
+(CPU 集合を表現するのに使われるカーネルのデータ型がサポートする集合の範囲は、
+カーネルの設定オプション \fBCONFIG_NR_CPUS\fP により定義される)。
+.TP
+\fBEINVAL\fP
+(\fBpthread_attr_getaffinity_np\fP())
+\fIattr\fP が参照するスレッド属性オブジェクトの affinity マスク内の CPU が、
+\fIcpusetsize\fP により指定された範囲の中になかった
+(すなわち、\fIcpuset\fP/\fIcpusetsize\fP が小さすぎる)。
+.TP
+\fBENOMEM\fP
+(\fBpthread_attr_setaffinity_np\fP()) メモリを割り当てることができなかった。
+.SH バージョン
+これらの関数は glibc バージョン 2.3.4 以降で提供されている。
+.SH 準拠
+これらの関数は非標準の GNU による拡張である。
+そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
+付いている。
+.SH 注意
+(このバージョンだけであるが) glibc 2.3.3 では、
+これらの関数は \fIcpusetsize\fP 引き数を持っていなかった。
+内部で呼ばれるシステムコールに渡される CPU セットの大きさは
+常に \fIsizeof(cpu_set_t)\fP であった。
+.SH 関連項目
+\fBsched_setaffinity\fP(2), \fBpthread_attr_init\fP(3),
+\fBpthread_setaffinity_np\fP(3), \fBcpuset\fP(7), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETDETACHSTATE 3 2010\-02\-03 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
+スレッド属性オブジェクトの detach state 属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setdetachstate(pthread_attr_t *\fP\fIattr\fP\fB, int \fP\fIdetachstate\fP\fB);\fP
+\fBint pthread_attr_getdetachstate(pthread_attr_t *\fP\fIattr\fP\fB, int *\fP\fIdetachstate\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setdetachstate\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトの detach state 属性を
+\fIdetachstate\fP で指定された値に設定する。
+detach state 属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドが、 join 可能な状態で作成されるか、
+detached (切り離された) 状態で作成されるかが決定される。
+
+\fIdetachstate\fP には以下の値を指定できる。
+.TP
+\fBPTHREAD_CREATE_DETACHED\fP
+\fIattr\fP を使って作成されるスレッドは detached 状態で作成される。
+.TP
+\fBPTHREAD_CREATE_JOINABLE\fP
+\fIattr\fP を使って作成されるスレッドは join 可能な状態で作成される。
+.PP
+新規に初期化されたスレッド属性オブジェクトの detach state 属性の
+デフォルト設定は \fBPTHREAD_CREATE_JOINABLE\fP である。
+
+\fBpthread_attr_getdetachstate\fP() は、
+スレッド属性オブジェクト \fIattr\fP の detach state 属性を
+\fIdetachstate\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setdetachstate\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+無効な値が \fIdetachstate\fP で指定された。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+detached 状態のスレッド、join 可能状態のスレッドの詳細については、
+\fBpthread_create\fP(3) を参照。
+
+join 可能状態で作成されたスレッドは、最終的に
+\fBpthread_join\fP(3) を使って join するか、
+\fBpthread_detach\fP(3) を使って切り離すか、
+のどちらかを行うべきである。
+
+detached 状態で作成されたスレッドのスレッド ID を指定して、
+\fBpthread_detach\fP(3) や \fBpthread_join\fP(3) を後から呼び出すのは
+エラーである。
+.SH 例
+\fBpthread_attr_init\fP(3) を参照。
+.SH 関連項目
+\fBpthread_attr_init\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
+\fBpthread_join\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETGUARDSIZE 3 2008\-10\-24 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setguardsize, pthread_attr_getguardsize \-
+スレッド属性オブジェクトの guard size 属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setguardsize(pthread_attr_t *\fP\fIattr\fP\fB, size_t \fP\fIguardsize\fP\fB);\fP
+\fBint pthread_attr_getguardsize(pthread_attr_t *\fP\fIattr\fP\fB, size_t *\fP\fIguardsize\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setguardsize\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトの guard size 属性を
+\fIguardsize\fP で指定された値に設定する。
+
+\fIguardsize\fP が 0 より大きい場合、
+\fIattr\fP を使って新しく作成された各スレッドに対して、
+システムはスレッドのスタックの末尾に少なくとも \fIguardsize\fP バイトの
+追加領域を割り当てる。この追加領域はスタックに対するガード領域として
+機能する (ただし「バグ」の節も参照)。
+
+\fIguardsize\fP が 0 の場合、
+\fIattr\fP を使って新しく作成されたスレッドはガード領域を持たない。
+
+デフォルトの guard size はシステムのページサイズと同じである。
+
+(\fBpthread_attr_setstack\fP(3) や \fBpthread_attr_setstackaddr\fP(3)を使って)
+\fIattr\fP でスタックアドレス属性が設定されている場合には、呼び出し側がそ
+のスレッドのスタックを割り当てていることを意味するので、guard size 属性
+は無視される (すなわち、システムによるガード領域の作成は行われない)。
+この場合、スタックオーバーフローが起こらないように対処するのはアプリ
+ケーション側の責任となる (おそらく \fBmprotect\fP(2) を使って、割り当て
+られたスタックの最後に手動でガード領域を定義することになるだろう)。
+
+\fBpthread_attr_getguardsize\fP() は、
+スレッド属性オブジェクト \fIattr\fP の guard size 属性を
+\fIguardsize\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+POSIX.1\-2001 では、エラー \fBEINVAL\fP が
+ \fIattr\fP か \fIguardsize\fP が無効な場合に対して規定されている。
+Linux では、これらの関数は常に成功する
+(ただし、移植性や将来も動作することを保証したいアプリケーションでは
+正のエラーの返り値を処理するようにすべきである)。
+.SH バージョン
+これらの関数は glibc バージョン 2.1 以降で提供されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+ガード領域は、読み出し/書き込みアクセスが行われないように保護がかけ
+られた仮想メモリページで構成で構成される。スレッドがスタックをガード
+領域までオーバーフローさせた場合、ほとんどのハードウェアアーキテクチャ
+では、スレッドに \fBSIGSEGV\fP シグナルが送られ、オーバーフローが発生した
+ことが通知される。ガード領域はページ境界から開始され、ガード領域の
+大きさはスレッド作成時に内部的にシステムのページサイズに切り上げられる
+(その場合も \fBpthread_attr_getguardsize\fP() では
+\fBpthread_attr_setguardsize\fP() で設定された guard size が返される)。
+
+多くのスレッドを作成するアプリケーションで、かつ、スタックオーバーフロー
+が決して発生しないことが分かっている場合には、guard size を 0 に設定
+することで、メモリを節約できることもある。
+
+スレッドがスタックに大きなデータ構造を割り当てる場合には、
+スタックオーバーフローを検出するためには、デフォルトサイズよりも
+大きな guard size を選ぶ必要があるかもしれない。
+.SH バグ
+glibc 2.8 の時点では、 NPTL スレッド実装ではガード領域はスタックサイズ
+で割り当てられる領域の中に含まれている。一方、POSIX.1 では、スタックの
+末尾に追加の領域を割り当てることが求められている。
+(このため、ガード領域が大きすぎて、
+実際のスタック用の場所がなくなってしまう場合、
+\fBpthread_create\fP(3) で \fBEINVAL\fP エラーが発生することになる。)
+
+.\" glibc includes the guardsize within the allocated stack size,
+.\" which looks pretty clearly to be in violation of POSIX.
+.\"
+.\" Filed bug, 22 Oct 2008:
+.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6973
+.\"
+.\" Older reports:
+.\" https//bugzilla.redhat.com/show_bug.cgi?id=435337
+.\" Reportedly, LinuxThreads did the right thing, allocating
+.\" extra space at the end of the stack:
+.\" http://sourceware.org/ml/libc-alpha/2008-05/msg00086.html
+廃止予定の LinuxThreads 実装では、
+POSIX.1 で求められている通りの動作で、
+ガード領域がスタックの末尾に追加の領域が割り当てられる。
+.SH 例
+\fBpthread_getattr_np\fP(3) を参照。
+.SH 関連項目
+\fBmmap\fP(2), \fBmprotect\fP(2), \fBpthread_attr_init\fP(3),
+\fBpthread_attr_setstack\fP(3), \fBpthread_attr_setstacksize\fP(3),
+\fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETINHERITSCHED 3 2012\-03\-15 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setinheritsched, pthread_attr_getinheritsched \-
+スレッド属性オブジェクトの inherit scheduler 属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setinheritsched(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB int \fP\fIinheritsched\fP\fB);\fP
+\fBint pthread_attr_getinheritsched(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB int *\fP\fIinheritsched\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setinheritsched\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトの inherit scheduler 属性を
+\fIinheritsched\fP で指定された値に設定する。
+inherit scheduler 属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドが、呼び出したスレッドのスケジューリング属性を継承
+するか、\fIattr\fP からスケジューリング属性を取得するかが決定される。
+
+以下の値を \fIinheritsched\fP に指定できる。
+.TP
+\fBPTHREAD_INHERIT_SCHED\fP
+\fIattr\fP を使って作成されたスレッドは、
+スレッドを作成するスレッドからスケジューリング属性を継承する。
+\fIattr\fP 内のスケジューリング属性は無視される。
+.TP
+\fBPTHREAD_EXPLICIT_SCHED\fP
+.\" FIXME what are the defaults for scheduler settings?
+\fIattr\fP を使って作成されたスレッドは、スレッド属性オブジェクトで
+指定された値からスケジューリング属性を取得する。
+.PP
+新たに初期化されたスレッド属性オブジェクトの inherit scheduler 属性の
+デフォルト設定は \fBPTHREAD_INHERIT_SCHED\fP である。
+
+\fBpthread_attr_getinheritsched\fP() は、
+スレッド属性オブジェクト \fIattr\fP の inherit scheduler 属性を
+\fIinheritsched\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setinheritsched\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+\fIinheritsched\fP に無効な値が指定された。
+.PP
+.\" .SH VERSIONS
+.\" Available since glibc 2.0.
+POSIX.1\-2001 では、 \fBpthread_attr_setinheritsched\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値を属性に設定しようとした")
+も追加で規定されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH バグ
+.\" FIXME . Track status of the following bug:
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
+glibc 2.8 の時点では、スレッド属性オブジェクトが
+\fBpthread_attr_init\fP(3) を使って初期化された場合、
+スレッド属性オブジェクトのスケジューリングポリシーが \fBSCHED_OTHER\fP に、
+スケジューリング優先度が 0 に設定される。一方、その後 inherit
+scheduling 属性に \fBPTHREAD_EXPLICIT_SCHED\fP が設定されると、このスレッ
+ド属性オブジェクトを使って作成されたスレッドでは、スレッドを作成するス
+レッドのスケジューリング属性が間違って継承されてしまう。
+\fBpthread_create\fP(3) を呼び出す前にスケジューリングポリシー属性か
+スケジューリング優先度属性のどちらかが明示的に設定された場合には、
+このバグは発生しない。
+.SH 例
+\fBpthread_setschedparam\fP(3) を参照。
+.SH 関連項目
+\fBsched_setscheduler\fP(2), \fBpthread_attr_init\fP(3),
+\fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3),
+\fBpthread_create\fP(3), \fBpthread_setschedparam\fP(3),
+\fBpthread_setschedprio\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSCHEDPARAM 3 2012\-03\-15 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setschedparam, pthread_attr_getschedparam \-
+スレッド属性オブジェクトのスケジューリングパラメータ属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setschedparam(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB const struct sched_param *\fP\fIparam\fP\fB);\fP
+\fBint pthread_attr_getschedparam(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB struct sched_param *\fP\fIparam\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setschedparam\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトのスケジューリング
+パラメータ属性を \fIparam\fP が指すバッファで指定された値に設定する。
+これらの属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドのスケジューリングパラメータが決定される。
+
+\fBpthread_attr_getschedparam\fP() は、
+スレッド属性オブジェクト \fIattr\fP のスケジューリングパラメータ属性を
+\fIparam\fP が指すバッファに入れて返す。
+
+スケジューリングパラメータは以下の構造体で管理される。
+
+.in +4n
+.nf
+struct sched_param {
+ int sched_priority; /* Scheduling priority */
+};
+.fi
+.in
+
+見て分かる通り、サポートされているスケジューリングパラメータは一つだけ
+である。各スケジューリングポリシーで許可されるスケジューリング優先度の
+詳細については、\fBsched_setscheduler\fP(2) を参照のこと。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+.\" .SH VERSIONS
+.\" Available since glibc 2.0.
+POSIX.1 では、
+\fBpthread_attr_setschedparam\fP() について
+\fBEINVAL\fP と \fBENOTSUP\fP が規定されている。
+Linux では、これらの関数は常に成功する
+(ただし、移植性や将来も動作することを保証したいアプリケーションでは
+正のエラーの返り値を処理するようにすべきである)。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+Linux でサポートされているスレッドのスケジューリングポリシーのリストに
+ついては、 \fBpthread_attr_setschedpolicy\fP(3) を参照。
+.SH 例
+\fBpthread_setschedparam\fP(3) を参照。
+.SH 関連項目
+\fBsched_get_priority_min\fP(2), \fBsched_setscheduler\fP(2),
+\fBpthread_attr_init\fP(3), \fBpthread_attr_setinheritsched\fP(3),
+\fBpthread_attr_setschedpolicy\fP(3), \fBpthread_create\fP(3),
+\fBpthread_setschedparam\fP(3), \fBpthread_setschedprio\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSCHEDPOLICY 3 2010\-02\-03 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setschedpolicy, pthread_attr_getschedpolicy \- スレッド属性
+オブジェクトのスケジューリングポリシー属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setschedpolicy(pthread_attr_t *\fP\fIattr\fP\fB, int \fP\fIpolicy\fP\fB);\fP
+\fBint pthread_attr_getschedpolicy(pthread_attr_t *\fP\fIattr\fP\fB, int \fP\fI*policy\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setschedpolicy\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトのスケジューリング
+ポリシー属性を \fIpolicy\fP で指定された値に設定する。
+この属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドのスケジューリングポリシーが決定される。
+
+.\" FIXME . pthread_setschedparam() places no restriction on the policy,
+.\" but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7013
+\fIpolicy\fP に指定できる値は \fBSCHED_FIFO\fP, \fBSCHED_RR\fP, \fBSCHED_OTHER\fP
+である。それぞれの意味は \fBsched_setscheduler\fP(2) で説明している通り
+である。
+
+\fBpthread_attr_getschedpolicy\fP() は、
+スレッド属性オブジェクト \fIattr\fP のスケジューリングポリシー属性を
+\fIpolicy\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setschedpolicy\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+\fIpolicy\fP に無効な値が指定された。
+.PP
+.\" .SH VERSIONS
+.\" Available since glibc 2.0.
+POSIX.1\-2001 では、 \fBpthread_attr_setschedpolicy\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値を属性に設定しようとした")
+も追加で規定されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH 例
+\fBpthread_setschedparam\fP(3) を参照。
+.SH 関連項目
+\fBsched_setscheduler\fP(2), \fBpthread_attr_init\fP(3),
+\fBpthread_attr_setinheritsched\fP(3), \fBpthread_attr_setschedparam\fP(3),
+\fBpthread_create\fP(3), \fBpthread_setschedparam\fP(3),
+\fBpthread_setschedprio\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSCOPE 3 2008\-10\-24 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setscope, pthread_attr_getscope \-
+スレッド属性オブジェクトの contention scope 属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setscope(pthread_attr_t *\fP\fIattr\fP\fB, int \fP\fIscope\fP\fB);\fP
+\fBint pthread_attr_getscope(pthread_attr_t *\fP\fIattr\fP\fB, int *\fP\fIscope\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setscope\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトの contention scope
+属性を \fIscope\fP で指定された値に設定する。
+contention scope 属性により、
+スレッドが CPU などのリソースを取り合うスレッド集合が規定される。
+POSIX.1\-2001 では \fIscope\fP に指定する値として 2 つの値が規定されている。
+.TP
+\fBPTHREAD_SCOPE_SYSTEM\fP
+スレッドは、同じスケジューリング割り当てドメイン (一つ以上のプロセッサ
+のグループ) にある、システム上の全てのプロセスの自分以外の全ての
+スレッドとリソースを取り合う。
+\fBPTHREAD_SCOPE_SYSTEM\fP のスレッドは、スケジューリングポリシーと
+優先度に基づき、互いに相対的にスケジューリングされる。
+.TP
+\fBPTHREAD_SCOPE_PROCESS\fP
+スレッドは、contention scope が \fBPTHREAD_SCOPE_PROCESS\fP で作成された
+同じプロセスの自分以外の全てのスレッドとリソースを取り合う。
+\fBPTHREAD_SCOPE_PROCESS\fP のスレッドは、スケジューリングポリシーと優先度
+に基づき、同じプロセスの他のスレッドと相対的にスケジューリングされる。
+POSIX.1\-2001 では、これらのスレッドがシステム上の他のプロセスのスレッド
+や同じプロセス内の contention scope が \fBPTHREAD_SCOPE_SYSTEM\fP で作成
+された他のスレッドとどのようにリソースを取り合うかは、
+規定されないままになっている。
+.PP
+POSIX.1\-2001 で求められているのは、スレッド実装がこれらの contention
+scope のうち 1 つをサポートすることだけであるが、
+両方をサポートすることも認めている。
+Linux は \fBPTHREAD_SCOPE_SYSTEM\fP をサポートしているが、
+\fBPTHREAD_SCOPE_PROCESS\fP はサポートしていない。
+
+\fBpthread_attr_getscope\fP() は、
+スレッド属性オブジェクト \fIattr\fP の contention scope 属性を
+\fIscope\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setscope\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+\fIscope\fP に無効な値が指定された。
+.TP
+\fBENOTSUP\fP
+\fIscope\fP に値 \fBPTHREAD_SCOPE_PROCESS\fP が指定された。
+この値は Linux でサポートされていない。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fBPTHREAD_SCOPE_SYSTEM\fP contention scope では、通常は、一つの
+ユーザ空間スレッドは一つのカーネルスケジューリング・エンティティに
+直接結び付けられる。
+Linux では、廃止予定の LinuxThreads 実装も新しい NPTL 実装もこれに
+該当し、両方とも 1:1 で結び付けられるスレッド実装となっている。
+
+POSIX.1\-2001 では、 contention scope 属性のデフォルト値は
+実装時で定義されるものと規定されている。
+.SH 関連項目
+\fBpthread_attr_init\fP(3), \fBpthread_attr_setaffinity_np\fP(3),
+\fBpthread_attr_setinheritsched\fP(3), \fBpthread_attr_setschedparam\fP(3),
+\fBpthread_attr_setschedpolicy\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSTACK 3 2008\-10\-24 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setstack, pthread_attr_getstack \-
+スレッド属性オブジェクトのスタック属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setstack(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB void *\fP\fIstackaddr\fP\fB, size_t \fP\fIstacksize\fP\fB);\fP
+\fBint pthread_attr_getstack(pthread_attr_t *\fP\fIattr\fP\fB,\fP
+\fB void **\fP\fIstackaddr\fP\fB, size_t *\fP\fIstacksize\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.sp
+.in -4n
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
+.in
+.sp
+.ad l
+\fBpthread_attr_getstack\fP(), \fBpthread_attr_setstack\fP():
+.RS 4
+_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
+.RE
+.ad b
+.SH 説明
+\fBpthread_attr_setstack\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトのスタックアドレス属性と
+スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP で
+指定された値に設定する。
+これらの属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドが使用すべきスタックの位置とサイズが指定される。
+
+\fIstackaddr\fP は、呼び出し側で割り当てた、大きさが \fIstacksize\fP バイトの
+バッファ内の指定できる最小のアドレスバイトを指すべきである。
+割り当てられたバッファのページは読み書き両方が可能なページとなっている
+べきである。
+
+\fBpthread_attr_getstack\fP() 関数は、
+スレッド属性オブジェクト \fIattr\fP のスタックアドレス属性と
+スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP が
+指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setstack\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+\fIstacksize\fP が \fBPTHREAD_STACK_MIN\fP (16384) よりも小さい。
+システムによっては、 \fIstackaddr\fP か
+\fIstackaddr\ +\ stacksize\fP のアライメントが適切でない場合にも
+このエラーが発生する。
+.PP
+POSIX.1\-2001 では エラー \fBEACCES\fP も規定されており、
+このエラーは \fIstackaddr\fP と \fIstacksize\fP で規定されるスタック領域に
+呼び出し側から読み書き両方のアクセスができない状況を表す。
+.SH バージョン
+これらの関数は glibc バージョン 2.2 以降で提供されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+これらの関数は、スレッドのスタックが特定の場所に配置されることを保証
+しなければならないアプリケーションのために提供されている。
+ほとんどのアプリケーションでは、このようなことは必要なく、
+これらの関数を使うのは避けるべきである。
+(アプリケーションが単にスタックサイズだけをデフォルトの値から変更する
+必要がある場合には \fBpthread_attr_setstacksize\fP(3) を使うこと)
+
+アプリケーションが \fBpthread_attr_setstack\fP() を利用する際には、
+スタックの割り当てに責任を持つ必要がある。
+\fBpthread_attr_setguardsize\fP(3) を使って設定された
+guard size の値は無視される。
+必要と思われる場合は、アプリケーションが責任を持ってガード領域 (読み書
+きが行われないように保護された 1 個かそれ以上のページ) の割り当てを行い、
+スタックオーバーフローの可能性に対処するようにする必要がある。
+
+\fIstackaddr\fP に指定するアドレスは適切なアライメントとなっているべきである。
+完全な移植性を持たせるためには、
+ページ境界 (\fIsysconf(_SC_PAGESIZE)\fP) に揃えること。
+割り当てには \fBposix_memalign\fP(3) を使うとよい。
+たいていは、 \fIstacksize\fP はシステムのページサイズの倍数とすべきである。
+
+一つの \fIattr\fP を使って複数のスレッドを作成する場合、
+\fBpthread_create\fP(3) の次の呼び出しを行う前に、
+呼び出し側でスタックアドレス属性を変更しなければならない。
+さもなければ、複数のスレッドがスタックとして同じメモリ領域を
+使おうとするため、訳の分からない状況が発生してしまう。
+.SH 例
+\fBpthread_attr_init\fP(3) を参照。
+.SH 関連項目
+\fBmmap\fP(2), \fBmprotect\fP(2), \fBposix_memalign\fP(3), \fBpthread_attr_init\fP(3),
+\fBpthread_attr_setguardsize\fP(3), \fBpthread_attr_setstackaddr\fP(3),
+\fBpthread_attr_setstacksize\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSTACKADDR 3 2008\-10\-24 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setstackaddr, pthread_attr_getstackaddr \-
+スレッド属性オブジェクトのスタックアドレス属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setstackaddr(pthread_attr_t *\fP\fIattr\fP\fB, void *\fP\fIstackaddr\fP\fB);\fP
+\fBint pthread_attr_getstackaddr(pthread_attr_t *\fP\fIattr\fP\fB, void **\fP\fIstackaddr\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+これらの関数は廃止予定であり、\fB使用しないこと\fP。
+代わりに Use \fBpthread_attr_setstack\fP(3) と \fBpthread_attr_getstack\fP(3) を使うこと。
+
+\fBpthread_attr_setstackaddr\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトのスタックアドレス
+属性を \fIstackaddr\fP で指定された値に設定する。
+この属性により、スレッド属性オブジェクト \fIattr\fP を使って
+作成されるスレッドが使用すべきスタックの位置が指定される。
+
+\fIstackaddr\fP は呼び出し側が割り当てたバッファ (大きさは
+少なくとも \fBPTHREAD_STACK_MIN\fP バイト)を指すべきである。
+割り当てられたバッファのページは読み書き両方が可能なページと
+なっているべきである。
+
+\fBpthread_attr_getstackaddr\fP() は、
+スレッド属性オブジェクト \fIattr\fP のスタックアドレス属性を
+\fIstackaddr\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+エラーは定義されていない (ただし、アプリケーションは正のエラーの
+返り値を処理するようにすべきである)。
+.SH バージョン
+これらの関数は glibc バージョン 2.1 以降で提供されている。
+.SH 準拠
+POSIX.1\-2001 では、これらの関数が規定されているが、廃止予定となっている。
+POSIX.1\-2008 では、これらの関数の規定は削除されている。
+.SH 注意
+\fIこれらの関数を使用しないこと!\fP これらの関数は移植性がある形では使用で
+きない。なぜなら、これらの関数ではスタック領域がどちらの方向に伸びるの
+かを指定する手段が提供されていないからである。
+例えば、スタックが下向き (アドレスが小さい方向) に伸びるアーキテクチャ
+では、\fIstackaddr\fP には割り当てられたスタック領域の\fI最も大きな\fPアドレ
+スの次のアドレスを指定する。一方、スタックが上向き (アドレスが大きい
+方向) に伸びるアーキテクチャでは、\fIstackaddr\fP には割り当てられた
+スタック領域の\fI最も小さい\fPアドレスを指定する。これに対して、
+\fBpthread_attr_setstack\fP(3) と \fBpthread_attr_getstack\fP(3) が使用する
+\fIstackaddr\fP は、常に割り当てられたスタック領域の最も小さいアドレス
+へのポインタである (\fIstacksize\fP 引き数はスタックの範囲を指定する)。
+.SH 関連項目
+\fBpthread_attr_init\fP(3), \fBpthread_attr_setstack\fP(3),
+\fBpthread_attr_setstacksize\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_ATTR_SETSTACKSIZE 3 2012\-03\-15 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_attr_setstacksize, pthread_attr_getstacksize \-
+スレッド属性オブジェクトのスタックサイズ属性の設定/取得を行う
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_attr_setstacksize(pthread_attr_t *\fP\fIattr\fP\fB, size_t \fP\fIstacksize\fP\fB);\fP
+\fBint pthread_attr_getstacksize(pthread_attr_t *\fP\fIattr\fP\fB, size_t *\fP\fIstacksize\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_attr_setstacksize\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトのスタックアドレス
+属性を \fIstacksize\fP で指定された値に設定する。
+
+スタックサイズ属性により、
+スレッド属性オブジェクト \fIattr\fP を使って作成されたスレッド
+に割り当てられる最小サイズ (バイト単位) が決定される。
+
+\fBpthread_attr_getstacksize\fP() は、
+スレッド属性オブジェクト \fIattr\fP のスタックアドレス属性を
+\fIstacksize\fP が指すバッファに入れて返す。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+\fBpthread_attr_setstacksize\fP() は以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+スタックサイズが \fBPTHREAD_STACK_MIN\fP (16384) バイト未満である。
+.PP
+.\" e.g., MacOS
+いくつかのシステムでは、 \fBpthread_attr_setstacksize\fP() は
+\fIstacksize\fP がシステムのページサイズの倍数でない場合にも
+エラー \fBEINVAL\fP で失敗する。
+.SH バージョン
+これらの関数は glibc バージョン 2.1 以降で提供されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+新しいスレッドのデフォルトのスタックサイズの詳細については
+\fBpthread_create\fP(3) を参照。
+
+スレッドのスタックサイズは、スレッド作成時点では固定である。
+メインスレッドだけがスタックを動的に伸ばすことができる。
+
+\fBpthread_attr_setstack\fP(3) 関数を使うと、
+アプリケーションは、スレッドが使用するスタックとして、
+呼び出し側で割り当てたスタックのサイズと場所を指定できる。
+.SH バグ
+glibc 2.8 の時点では、指定された \fIstacksize\fP が \fBSTACK_ALIGN\fP
+(ほとんどのアーキテクチャでは 16 バイト) の倍数でない場合、
+\fIstacksize\fP は\fI小さくなる方向に\fPに丸められる。
+これは POSIX.1\-2001 に違反している。
+POSIX.1\-2001 では、割り当てらたスタックの大きさは
+少なくとも \fIstacksize\fP バイトになると書かれている。
+.SH 例
+\fBpthread_create\fP(3) を参照。
+.SH 関連項目
+\fBgetrlimit\fP(2), \fBpthread_attr_init\fP(3), \fBpthread_attr_setguardsize\fP(3),
+\fBpthread_attr_setstack\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_CREATE 3 2012\-03\-15 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_create \- 新しいスレッドを作成する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\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
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_create\fP() 関数は、呼び出したプロセス内に新しいスレッドを作成する。
+新しいスレッドの実行は、 \fIstart_routine\fP() を起動することで開始される。
+\fIstart_routine\fP() は引き数を一つだけ取り、
+\fIarg\fP が \fIstart_routine\fP() の引き数として渡される。
+
+新しく作成されたスレッドは、以下のいずれかで終了する。
+.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 の場合、新しいスレッドはデフォルトの属性で作成される。
+
+成功した場合は、 \fBpthread_create\fP() は返る前に新しいスレッドの ID を
+\fIthread\fP が指すバッファに格納する。この ID は、これ以降に他の
+pthreads 関数の呼び出しでスレッドを参照するのに使用される。
+
+新しいスレッドは、スレッドを作成したスレッドのシグナルマスク
+(\fBpthread_sigmask\fP(3) 参照) のコピーを継承する。
+新しいスレッドの処理待ちシグナル (\fBsigpending\fP(2)) の集合は空となる。
+新しいスレッドはスレッドを作成したスレッドの代替シグナルスタック
+(\fBsigaltstack\fP(2)) を継承しない。
+
+新しいスレッドは呼び出したスレッドの浮動小数点環境 (\fBfenv\fP(3))
+を継承する。
+
+.\" 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
+別のスレッドを作成するのに十分なリソースがないか、システムで設定された
+スレッド数の上限に達していた。後者が起こるのは 2 つの場合がある。
+一つは、実ユーザ ID 当たりのプロセス数の上限である、\fBRLIMIT_NPROC\fP
+ソフトリソース上限 (\fBsetrlimit\fP(2) で設定できる) に達していた場合
+である。もう一つはカーネルのシステム全体のスレッド数の上限である
+\fI/proc/sys/kernel/threads\-max\fP が達していた場合である。
+.TP
+\fBEINVAL\fP
+\fIattr\fP で指定された設定が不正である。
+.TP
+.\" FIXME . Test the following
+\fBEPERM\fP
+\fIattr\fP に指定されたスケジューリングポリシーとパラメータを
+設定する許可がない。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fBpthread_create\fP() が \fI*thread\fP で返すスレッド ID についての
+詳しい情報は \fBpthread_self\fP(3) を参照のこと。
+リアルタイムスケジューリングポリシーが使用されない限り、
+\fBpthread_create\fP() の呼び出し後に、
+どのスレッドが\(em呼び出したスレッドか新しいスレッドか\(em
+次に実行されるかは決まっていない。
+
+スレッドは \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 可能な状態で
+作成される。
+
+.\" FIXME . Perhaps some of the following detail should be in
+.\" a future pthread_attr_setstacksize(3) page.
+Linux/x86\-32 では、新しいスレッドのデフォルトのスタックサイズは 2MB で
+ある。NPTL スレッド実装の下では、\fIプログラム開始時の\fP \fBRLIMIT_STACK\fP
+ソフトリソース上限が"unlimited" 以外の場合、その値が新しいスレッドのデ
+フォルトのスタックサイズとなる。
+\fBpthread_attr_setstacksize\fP(3) を使って、スレッドを作成する際の
+\fIattr\fP 引き数に明示的にスタックサイズ属性を設定することで、
+デフォルト値以外のスタックサイズを得ることができる。
+.SH バグ
+廃止予定の LinuxThreads 実装では、プロセス内の各スレッドは異なる
+プロセス ID を持つ。これは POSIX スレッドの規格に違反しており、
+他の多くの標準非準拠の点の原因になっている。
+\fBpthreads\fP(7) を参照のこと。
+.SH 例
+以下のプログラムは、 \fBpthread_create\fP() や
+pthreads API の他のいろいろな関数の使用例を示している。
+
+以下の実行例は、 NPTL スレッド実装が提供されているシステムでのもので、
+スタックサイズがデフォルト値の "stack size" リソース上限で指定される値
+になる。
+
+.in +4n
+.nf
+$\fB ulimit \-s\fP
+8192 # The stack size limit is 8 MB (0x80000 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
+.fi
+.in
+
+次の実行例では、プログラム内で、作成されるスレッドに対して
+(\fBpthread_attr_setstacksize\fP(3) を使って1MB のスタックサイズを
+明示的に設定している。
+
+.in +4n
+.nf
+$\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
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#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 = (struct thread_info *) arg;
+ char *uargv, *p;
+
+ 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 (p = uargv; *p != \(aq\e0\(aq; p++)
+ *p = toupper(*p);
+
+ return uargv;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int s, tnum, opt, num_threads;
+ struct thread_info *tinfo;
+ pthread_attr_t attr;
+ int 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 */
+
+ tinfo = calloc(num_threads, sizeof(struct thread_info));
+ if (tinfo == NULL)
+ handle_error("calloc");
+
+ /* Create one thread for each command\-line argument */
+
+ for (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 (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);
+}
+.fi
+.SH 関連項目
+\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),
+\fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_DETACH 3 2008\-11\-27 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_detach \- スレッドを切り離す (detach する)
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_detach(pthread_t \fP\fIthread\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_detach\fP() 関数は \fIthread\fP で識別されるスレッドに
+detached (切り離された状態) という印を付ける。
+detached 状態のスレッドが終了すると、
+別のスレッドが終了されたスレッドを join しなくても、
+そのスレッドのリソースは自動的に解放されてシステムに戻される。
+
+すでに detach 状態のスレッドを detach しようとした場合に
+どのような結果となるかは規定されていない。
+.SH 返り値
+成功すると、\fBpthread_detach\fP() は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+.TP
+\fBEINVAL\fP
+\fIthread\fP が join 可能なスレッドではない。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+いったんスレッドを detached 状態にすると、
+そのスレッドを \fBpthread_join\fP(3) で join したり、
+もう一度 join 可能にしたりすることはできない。
+
+\fBpthread_attr_setdetachstate\fP(3) を使って
+\fBpthread_create\fP(3) の \fIattr\fP 引き数の detached 属性を設定することで、
+新しいスレッドを detached 状態で作成することができる。
+
+detached 属性は、スレッドが終了した際のシステムの動作を決めるだけである。
+プロセスが \fBexit\fP(3) を使って終了した場合に、そのスレッドが終了され
+なくなるようなことはない (なお、メインスレッドが return した場合も
+プロセスが \fBexit\fP(3) を使って終了した場合と全く同じである)。
+
+アプリケーションが作成した各スレッドについて、そのスレッドが使用して
+いるシステムリソースを解放できるように、\fBpthread_join\fP(3) か
+\fBpthread_detach\fP() のどちらかを呼び出すべきである (ただし、プロセスが
+終了するときには、全てのスレッドのリソースが解放される)。
+.SH 例
+以下の文は、呼び出したスレッド自身を detach する。
+
+ pthread_detach(pthread_self());
+.SH 関連項目
+\fBpthread_attr_setdetachstate\fP(3), \fBpthread_cancel\fP(3),
+\fBpthread_create\fP(3), \fBpthread_exit\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_EQUAL 3 2009\-03\-30 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_equal \- スレッド ID を比較する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_equal(pthread_t \fP\fIt1\fP\fB, pthread_t \fP\fIt2\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_equal\fP() 関数は 2 つのスレッド識別子の比較を行う。
+.SH 返り値
+\fBpthread_equal\fP() は、2 つのスレッド ID が等しければ 0 以外の値を返し、
+そうでなければ 0 を返す。
+.SH エラー
+この関数は常に成功する。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fBpthread_equal\fP() 関数が必要なのは、
+スレッド ID はその内部構造を意識すべきではないためである。
+アプリケーションが 2 つの \fIpthread_t\fP の値を直接比較する場合、
+移植性を確保できる形で比較する方法はない。
+.SH 関連項目
+\fBpthread_create\fP(3), \fBpthread_self\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_EXIT 3 2009\-03\-30 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_exit \- 呼び出したスレッドを終了する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBvoid pthread_exit(void *\fP\fIretval\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_exit\fP() 関数は、呼び出したスレッドを終了し、
+\fIretval\fP 経由で値を返す。
+この値は (そのスレッドが join 可能な場合に) \fBpthread_join\fP(3) を
+呼び出した同じプロセス内の別のスレッドが参照できる値と同じである。
+
+\fBpthread_cleanup_push\fP(3) で設定されたクリーンアップハンドラのうち、
+まだ pop (取り出されていない) ハンドラを (push されたのと逆の順序で)
+取り出して実行する。そのスレッドがスレッド固有のデータを持っている
+場合は、クリーンアップハンドラが実行された後に、スレッド固有のデータ
+に対応するデストラクタ (destructor) 関数が呼び出される (呼び出し順序
+は規定されていない)。
+
+スレッドが終了する際に、プロセスの共有リソース (例えば、mutex、状態変数
+(condition variables)、セマフォ、ファイルディスクリプタ)が解放される。
+\fBatexit\fP(3) を使って登録された関数は呼び出されない。
+
+プロセスの最後のスレッドが終了すると、そのプロセスは、終了ステータス 0
+で \fBexit\fP(3) を呼び出した場合と全く同じように終了する。したがって、
+プロセスの共有リソースは解放され、\fBatexit\fP(3) を使って登録された関数
+が呼び出される。
+.SH 返り値
+この関数は呼び出し側には返らない。
+.SH エラー
+この関数は常に成功する。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+メインスレッド以外のスレッドの開始関数 (start function) がreturn を
+行うと、暗黙のうちに \fBpthread_exit\fP() が呼び出され、
+関数の返り値がスレッドの終了ステータスとして使用される。
+
+他のスレッドが実行を継続できるように、メインスレッドは \fBexit\fP(3) では
+なく \fBpthread_exit\fP() を呼び出して終了すべきである。
+
+\fIretval\fP が指す値は、呼び出したスレッドのスタックに置くべきではない。
+呼び出したスレッドが終了した後は、そのスタックの内容が不定となるから
+である。
+.SH バグ
+.\" Linux 2.6.27
+.\" FIXME . review a later kernel to see if this gets fixed
+.\" http://thread.gmane.org/gmane.linux.kernel/611611
+.\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
+現在のところ、停止 (stop) されたスレッドグループを、すでに終了した
+(dead) スレッドグループリーダーで \fBwait\fP(2) する場合の、
+カーネル実装の論理には制限がある。
+この制限は、すでにスレッドグループリーダーが \fBpthread_exit\fP() を
+呼び出しているようなフォアグラウンドプロセスにストップシグナルが送信
+された場合に、端末がロックされてしまう、といった問題として表に見える
+場合がある。
+.SH 関連項目
+\fBpthread_create\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_GETATTR_NP 3 2010\-09\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_getattr_np \- 作成されたスレッドの属性を取得する
+.SH 書式
+.nf
+\fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */
+\fB#include <pthread.h>\fP
+
+\fBint pthread_getattr_np(pthread_t \fP\fIthread\fP\fB, pthread_attr_t *\fP\fIattr\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_getattr_np\fP() 関数は、
+\fIattr\fP が参照するスレッド属性オブジェクトを初期化し、
+そのオブジェクトに実行中のスレッド \fIthread\fP の実際の属性値を
+格納して返す。
+
+返される属性値は、\fBpthread_create\fP(3) でスレッドを作成する際に
+使われた\fIattr\fP オブジェクトで渡された属性値と異なる場合がある。
+特に、以下の属性は異なる場合がある。
+.IP * 2
+detach state. join 可能なスレッドは作成後に自分自身を
+切り離す (detach する) ことができるからである。
+.IP *
+スタックサイズ。
+スレッドの実装によって適切な境界に揃えられる可能があるためである。
+.IP *
+guard size.
+スレッドの実装によりページサイズの倍数に切り上げられたり、
+アプリケーションが自分でスタックを割り当てる場合には無視される
+(0 として扱われる) ことがあるからである。
+.PP
+さらに、スレッドを作成する際に使用されたスレッド属性オブジェクトで
+スタックアドレスが設定されていなかった場合、
+返されたスレッド属性オブジェクトではスレッドの実装がそのスレッドに
+割り当てた実際のスタックアドレスが報告される。
+
+\fBpthread_getattr_np\fP() が返したスレッド属性オブジェクトが
+必要なくなった際には、 \fBpthread_attr_destroy\fP(3) を使って
+そのオブジェクトを破棄すべきである。
+.SH 返り値
+成功すると、この関数は 0 を返す。
+エラーの場合、 0 以外のエラー番号を返す。
+.SH エラー
+.TP
+\fBENOMEM\fP
+.\" Can happen (but unlikely) while trying to allocate memory for cpuset
+メモリが十分になかった。
+.PP
+さらに、 \fIthread\fP がメインスレッドを参照している場合には、
+\fBpthread_getattr_np\fP() は内部で行われる様々な呼び出しでの
+エラーで失敗する可能性がある。
+\fI/proc/self/maps\fP がオープンできない場合には \fBfopen\fP(3)
+でエラーが発生し、リソース上限 \fBRLIMIT_STACK\fP が
+サポートされていない場合には \fBgetrlimit\fP(2) でエラーが発生する。
+.SH バージョン
+この関数は glibc バージョン 2.2.3 以降で利用できる。
+.SH 準拠
+この関数は非標準の GNU による拡張である。
+そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
+付いている。
+.SH 例
+以下のプログラムは \fBpthread_getattr_np\fP() の使用例を示したものである。
+このプログラムは、スレッドを作成し、それから
+\fBpthread_getattr_np\fP() を使ってそのスレッドの属性 guard size、
+スタックアドレス、スタックサイズを取得し表示する。
+コマンドライン引き数での指定で、スレッドを作成する際に
+上記の属性にデフォルト値以外の値を設定することができる。
+下記のシェルのセッションはこのプログラムの使用例である。
+
+最初の実行例は、デフォルトの属性でスレッドが作成されている
+(x86\-32 システム上で実行)。
+
+.in +4n
+.nf
+$\fB ulimit \-s\fP # No stack limit ==> default stack size is 2MB
+unlimited
+$\fB ./a.out\fP
+Attributes of created thread:
+ Guard size = 4096 bytes
+ Stack address = 0x40196000 (EOS = 0x40397000)
+ Stack size = 0x201000 (2101248) bytes
+.fi
+.in
+
+次の実行例では、guard size が指定された場合、
+guard size はシステムのページサイズの倍数に切り上げられることが分かる
+(x86\-32 ではシステムのページサイズは 4096 バイトである)。
+
+.in +4n
+.nf
+$\fB ./a.out \-g 4097\fP
+Thread attributes object after initializations:
+ Guard size = 4097 bytes
+ Stack address = (nil)
+ Stack size = 0x0 (0) bytes
+
+Attributes of created thread:
+ Guard size = 8192 bytes
+ Stack address = 0x40196000 (EOS = 0x40397000)
+ Stack size = 0x201000 (2101248) bytes
+.fi
+.in
+
+.\".in +4n
+.\".nf
+.\"$ ./a.out \-s 0x8000
+.\"Thread attributes object after initializations:
+.\" Guard size = 4096 bytes
+.\" Stack address = 0xffff8000 (EOS = (nil))
+.\" Stack size = 0x8000 (32768) bytes
+.\"
+.\"Attributes of created thread:
+.\" Guard size = 4096 bytes
+.\" Stack address = 0x4001e000 (EOS = 0x40026000)
+.\" Stack size = 0x8000 (32768) bytes
+.\".fi
+.\".in
+最後の実行例では、プログラムでスレッド用のスタックを手動で割り当てている。
+この場合には、guard size 属性は無視される。
+
+.in +4n
+.nf
+$\fB ./a.out \-g 4096 \-s 0x8000 \-a\fP
+Allocated thread stack at 0x804d000
+
+Thread attributes object after initializations:
+ Guard size = 4096 bytes
+ Stack address = 0x804d000 (EOS = 0x8055000)
+ Stack size = 0x8000 (32768) bytes
+
+Attributes of created thread:
+ Guard size = 0 bytes
+ Stack address = 0x804d000 (EOS = 0x8055000)
+ Stack size = 0x8000 (32768) bytes
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+static void
+display_stack_related_attributes(pthread_attr_t *attr, char *prefix)
+{
+ int s;
+ size_t stack_size, guard_size;
+ void *stack_addr;
+
+ s = pthread_attr_getguardsize(attr, &guard_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getguardsize");
+ printf("%sGuard size = %d bytes\en", prefix, guard_size);
+
+ s = pthread_attr_getstack(attr, &stack_addr, &stack_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getstack");
+ printf("%sStack address = %p", prefix, stack_addr);
+ if (stack_size > 0)
+ printf(" (EOS = %p)", (char *) stack_addr + stack_size);
+ printf("\en");
+ printf("%sStack size = 0x%x (%d) bytes\en",
+ prefix, stack_size, stack_size);
+}
+
+static void
+display_thread_attributes(pthread_t thread, char *prefix)
+{
+ int s;
+ pthread_attr_t attr;
+
+ s = pthread_getattr_np(thread, &attr);
+ if (s != 0)
+ handle_error_en(s, "pthread_getattr_np");
+
+ display_stack_related_attributes(&attr, prefix);
+
+ s = pthread_attr_destroy(&attr);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_destroy");
+}
+
+static void * /* Start function for thread we create */
+thread_start(void *arg)
+{
+ printf("Attributes of created thread:\en");
+ display_thread_attributes(pthread_self(), "\et");
+
+ exit(EXIT_SUCCESS); /* Terminate all threads */
+}
+
+static void
+usage(char *pname, char *msg)
+{
+ if (msg != NULL)
+ fputs(msg, stderr);
+ fprintf(stderr, "Usage: %s [\-s stack\-size [\-a]]"
+ " [\-g guard\-size]\en", pname);
+ fprintf(stderr, "\et\et\-a means program should allocate stack\en");
+ exit(EXIT_FAILURE);
+}
+
+static pthread_attr_t * /* Get thread attributes from command line */
+get_thread_attributes_from_cl(int argc, char *argv[],
+ pthread_attr_t *attrp)
+{
+ int s, opt, allocate_stack;
+ long stack_size, guard_size;
+ void *stack_addr;
+ pthread_attr_t *ret_attrp = NULL; /* Set to attrp if we initialize
+ a thread attributes object */
+ allocate_stack = 0;
+ stack_size = \-1;
+ guard_size = \-1;
+
+ while ((opt = getopt(argc, argv, "ag:s:")) != \-1) {
+ switch (opt) {
+ case \(aqa\(aq: allocate_stack = 1; break;
+ case \(aqg\(aq: guard_size = strtoul(optarg, NULL, 0); break;
+ case \(aqs\(aq: stack_size = strtoul(optarg, NULL, 0); break;
+ default: usage(argv[0], NULL);
+ }
+ }
+
+ if (allocate_stack && stack_size == \-1)
+ usage(argv[0], "Specifying \-a without \-s makes no sense\en");
+
+ if (argc > optind)
+ usage(argv[0], "Extraneous command\-line arguments\en");
+
+ if (stack_size >= 0 || guard_size > 0) {
+ ret_attrp = attrp;
+
+ s = pthread_attr_init(attrp);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_init");
+ }
+
+ if (stack_size >= 0) {
+ if (!allocate_stack) {
+ s = pthread_attr_setstacksize(attrp, stack_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setstacksize");
+ } else {
+ s = posix_memalign(&stack_addr, sysconf(_SC_PAGESIZE),
+ stack_size);
+ if (s != 0)
+ handle_error_en(s, "posix_memalign");
+ printf("Allocated thread stack at %p\en\en", stack_addr);
+
+ s = pthread_attr_setstack(attrp, stack_addr, stack_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setstacksize");
+ }
+ }
+
+ if (guard_size >= 0) {
+ s = pthread_attr_setguardsize(attrp, guard_size);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setstacksize");
+ }
+
+ return ret_attrp;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int s;
+ pthread_t thr;
+ pthread_attr_t attr;
+ pthread_attr_t *attrp = NULL; /* Set to &attr if we initialize
+ a thread attributes object */
+
+ attrp = get_thread_attributes_from_cl(argc, argv, &attr);
+
+ if (attrp != NULL) {
+ printf("Thread attributes object after initializations:\en");
+ display_stack_related_attributes(attrp, "\et");
+ printf("\en");
+ }
+
+ s = pthread_create(&thr, attrp, &thread_start, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_create");
+
+ if (attrp != NULL) {
+ s = pthread_attr_destroy(attrp);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_destroy");
+ }
+
+ pause(); /* Terminates when other thread calls exit() */
+}
+.fi
+.SH 関連項目
+\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 プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_GETCPUCLOCKID 3 2009\-02\-08 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_getcpuclockid \- スレッドの CPU 時間時計の ID を取得する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+\fB#include <time.h>\fP
+
+\fBint pthread_getcpuclockid(pthread_t \fP\fIthread\fP\fB, clockid_t *\fP\fIclock_id);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+.\" The clockid is constructed as follows:
+.\" *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE)
+.\" where CLOCK_IDFIELD_SIZE is 3.
+\fBpthread_getcpuclockid\fP() 関数は、
+スレッド \fIthread\fP の CPU 時間時計のクロック ID を返す。
+.SH 返り値
+成功すると、この関数は 0 を返す。
+エラーの場合、 0 以外のエラー番号を返す。
+.SH エラー
+.TP
+\fBENOENT\fP
+.\" CLOCK_THREAD_CPUTIME_ID not defined
+.\"
+.\" Looking at nptl/pthread_getcpuclockid.c an ERANGE error would
+.\" be possible if kernel thread IDs took more than 29 bits (which
+.\" they currently cannot).
+スレッド単位の CPU 時間時計はこのシステムではサポートされていない。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.SH バージョン
+この関数は glibc バージョン 2.2 以降で利用できる。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fIthread\fP が呼び出したスレッドを参照している場合、
+クロック ID \fBCLOCK_THREAD_CPUTIME_ID\fP が指定されていれば、
+\fBclock_gettime\fP(2) と \fBclock_settime\fP(2) が操作するのと同じ時計
+を参照する ID が返される。
+.SH 例
+以下のプログラムは、スレッドを作成し、それから
+\fBclock_gettime\fP(2) を使ってプロセス全体の CPU 時間を取得し、
+\fBpthread_getcpuclockid\fP(3) を使って 2 つのスレッドが消費した
+スレッド毎の CPU 時間を取得する。
+下記のシェルのセッションは実行例である。
+.in +4n
+.nf
+$ \fB./a.out\fP
+Main thread sleeping
+Subthread starting infinite loop
+Main thread consuming some CPU time...
+Process total CPU time: 1.368
+Main thread CPU time: 0.376
+Subthread CPU time: 0.992
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+/* "\-lrt" でリンクする */
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <errno.h>
+
+#define handle_error(msg) \e
+ do { perror(msg); exit(EXIT_FAILURE); } while (0)
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+static void *
+thread_start(void *arg)
+{
+ printf("Subthread starting infinite loop\en");
+ for (;;)
+ continue;
+}
+
+static void
+pclock(char *msg, clockid_t cid)
+{
+ struct timespec ts;
+
+ printf("%s", msg);
+ if (clock_gettime(cid, &ts) == \-1)
+ handle_error("clock_gettime");
+ printf("%4ld.%03ld\en", ts.tv_sec, ts.tv_nsec / 1000000);
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t thread;
+ clockid_t cid;
+ int j, s;
+
+ s = pthread_create(&thread, NULL, thread_start, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_create");
+
+ printf("Main thread sleeping\en");
+ sleep(1);
+
+ printf("Main thread consuming some CPU time...\en");
+ for (j = 0; j < 2000000; j++)
+ getppid();
+
+ pclock("Process total CPU time: ", CLOCK_PROCESS_CPUTIME_ID);
+
+ s = pthread_getcpuclockid(pthread_self(), &cid);
+ if (s != 0)
+ handle_error_en(s, "pthread_getcpuclockid");
+ pclock("Main thread CPU time: ", cid);
+
+ /* The preceding 4 lines of code could have been replaced by:
+ pclock("Main thread CPU time: ", CLOCK_THREAD_CPUTIME_ID); */
+
+ s = pthread_getcpuclockid(thread, &cid);
+ if (s != 0)
+ handle_error_en(s, "pthread_getcpuclockid");
+ pclock("Subthread CPU time: 1 ", cid);
+
+ exit(EXIT_SUCCESS); /* Terminates both threads */
+}
+.fi
+.SH 関連項目
+\fBclock_gettime\fP(2), \fBclock_settime\fP(2), \fBtimer_create\fP(2),
+\fBclock_getcpuclockid\fP(3), \fBpthread_self\fP(3), \fBpthreads\fP(7), \fBtime\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_JOIN 3 2008\-11\-27 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_join \- 終了したスレッドを join する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_join(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_join\fP() 関数は、\fIthread\fP で指定されたスレッドが
+終了するのを待つ。そのスレッドがすでに終了している場合、
+\fBpthread_join\fP() はすぐに返る。
+\fIthread\fP で指定されたスレッドは join 可能でなければならない。
+
+\fIretval\fP が NULL でない場合、 \fBpthread_join\fP() は対象スレッドの終了
+ステータス (すなわち、対象スレッドが \fBpthread_exit\fP(3) に渡した値) を
+\fI*retval\fP が指す場所にコピーする。対象スレッドがキャンセルされた場合、
+\fI*retval\fP には \fBPTHREAD_CANCELED\fP が格納される。
+
+複数のスレッドが同時に同じスレッドを join しようとした場合、その結果
+は不定である。\fBpthread_join\fP() を呼び出しているスレッドがキャンセル
+された場合、対象スレッドは join 可能のままとなる (detached 状態には
+ならない)。
+.SH 返り値
+成功すると、 \fBpthread_join\fP() は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+.TP
+\fBEDEADLK\fP
+.\" The following verified by testing on glibc 2.8/NPTL:
+.\" The following verified by testing on glibc 2.8/NPTL:
+デッドロックが検出された (例えば、二つのスレッドが互いに join しようと
+した場合)、または \fIthread\fP に呼び出したスレッドが指定されている。
+.TP
+\fBEINVAL\fP
+\fIthread\fP が join 可能なスレッドではない。
+.TP
+\fBEINVAL\fP
+.\" POSIX.1-2001 does not specify this error case.
+別のスレッドがすでにこのスレッドの join 待ちである。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+\fBpthread_join\fP() の呼び出しが成功した場合は、
+呼び出し側には、対象スレッドが終了していることが保証される。
+
+すでに join されたスレッドを join した場合の結果は不定である。
+
+join 可能なスレッド (detached 状態でないスレッド) の join に失敗した場合、
+"ゾンビスレッド (zombie thread)" が生成される。
+各ゾンビスレッドはシステムリソースをいくらかは消費し、
+ゾンビスレッドがたくさん生成されてしまうと、
+新しいスレッド (やプロセス) がそれ以上作成できなくなってしまうので、
+このようなことが起きるのは避けること。
+
+pthreads には、 \fIwaitpid(\-1,\ &status,\ 0)\fP、つまり
+"終了されたスレッドのどれかを join する" といった機能はない。
+この機能が必要だと思うような場合には、おそらく
+自分のアプリケーションの設計を考え直す必要があるだろう。
+
+プロセス内の全てのスレッドは対等であり、
+どのスレッドでもプロセス内の他のスレッドを join できる。
+.SH 例
+\fBpthread_create\fP(3) を参照。
+.SH 関連項目
+\fBpthread_cancel\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
+\fBpthread_exit\fP(3), \fBpthread_tryjoin_np\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_KILL 3 2009\-01\-28 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_kill \- スレッドにシグナルを送信する
+.SH 書式
+.nf
+\fB#include <signal.h>\fP
+
+\fBint pthread_kill(pthread_t \fP\fIthread\fP\fB, int \fP\fIsig\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_kill\fP() 関数は、呼び出したスレッドと同じプロセスの
+別のスレッド \fIthread\fP にシグナル \fIsig\fP を送信する。
+シグナルは非同期に \fIthread\fP へ直接送られる。
+
+\fIsig\fP が 0 の場合、シグナルは送信されないが、
+エラーチェックだけは実行される。
+これを使うと、スレッド ID が存在するかの確認を行うことができる。
+.SH 返り値
+成功すると、 \fBpthread_kill\fP() は 0 を返す。
+エラーの場合、エラー番号を返し、シグナルの送信は行わない。
+.SH エラー
+.TP
+\fBEINVAL\fP
+無効なシグナルが指定された。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+シグナルの配送はプロセス全体で行われる。
+シグナルハンドラが設定されている場合、
+そのハンドラがスレッド \fIthread\fP で起動されるが、
+シグナルの配送が "stop", "continue", "terminate" のいずれかの場合、
+シグナルに対するアクションはプロセス全体に影響がある。
+.SH 関連項目
+\fBkill\fP(2) \fBsigaction\fP(2), \fBsigpending\fP(2), \fBpthread_self\fP(3),
+\fBpthread_sigmask\fP(3), \fBraise\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_KILL_OTHER_THREADS_NP 3 2010\-09\-09 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_kill_other_threads_np \- プロセス内の他の全スレッドを終了する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBvoid pthread_kill_other_threads_np(void);\fP
+.fi
+.SH 説明
+.\" .SH VERSIONS
+.\" Available since glibc 2.0
+\fBpthread_kill_other_threads_np\fP() は、
+LinuxThreads スレッド実装においてのみ効果がある。
+LinuxThreads スレッド実装では、この関数を呼び出すと
+アプリケーション内の全てのスレッドがすぐに終了される。
+終了対象のスレッドの cancellation state と cancellation type は
+無視され、それらのスレッドのクリーンアップハンドラは呼び出されない。
+.SH 準拠
+この関数は非標準の GNU による拡張である。
+そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
+付いている。
+.SH 注意
+\fBpthread_kill_other_threads_np\fP() は、
+スレッドが \fBexecve\fP(2) や同様の関数を呼び出す直前に
+呼ばれることを目的として用意されている。
+この関数は、(廃止予定の) LinuxThreads スレッド実装における、
+\fBexecve\fP(2) の際にアプリケーションの他のスレッドが自動的に
+終了されないという制限を解決するために設計された。
+
+NPTL スレッド実装では、 \fBpthread_kill_other_threads_np\fP() は存在するが、
+何もしない(NPTL 実装は \fBexecve\fP(2) の際に適切な動作をするので、
+何もする必要がないということだ)。
+.SH 関連項目
+\fBexecve\fP(2), \fBpthread_cancel\fP(3), \fBpthread_setcancelstate\fP(3),
+\fBpthread_setcanceltype\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SELF 3 2008\-10\-24 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_self \- 呼び出したスレッドの ID を取得する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBpthread_t pthread_self(void);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_self\fP() 関数は、呼び出したスレッドの ID を返す。
+得られる ID は、このスレッドが作成された \fBpthread_create\fP(3) の
+呼び出しで \fI*thread\fP で返されるのと同じ値である。
+.SH 返り値
+この関数は常に成功し、呼び出したスレッドの ID を返す。
+.SH エラー
+この関数は常に成功する。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+POSIX.1 では、スレッド ID を表現するのに使用する型は、
+スレッド実装が完全に自由に選択してよいことになっている。
+例えば、スレッド ID を表現するのに数値型を使っても構造体を使ってもよい。
+そのため、移植性を確保しつつ、 C 言語の等価演算子 (\fB==\fP) を使って、
+\fIpthread_t\fP 型の変数の比較を行うことはできない。
+代わりに \fBpthread_equal\fP(3) を使うこと。
+
+スレッド識別子はその内部構造を意識すべきではない。
+pthreads 関数以外でスレッド ID を利用しようとした場合、
+移植性がなくなり、どのような結果が得られるかも分からない。
+
+スレッド ID の一意性が保証されるのは、あるプロセス内においてのみである。
+終了したスレッドが join されたり、
+切り離された (detached) スレッドが終了されたりした後は、
+そのスレッド ID は再利用されることがある。
+
+\fBpthread_self\fP() が返すスレッド ID は、
+\fBgettid\fP(2) が返すカーネルスレッド ID とは違うものである。
+.SH 関連項目
+\fBpthread_create\fP(3), \fBpthread_equal\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SETAFFINITY_NP 3 2010\-09\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_setaffinity_np, pthread_getaffinity_np \- スレッドの
+CPU affinity の設定/取得を行う
+.SH 書式
+.nf
+\fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */
+\fB#include <pthread.h>\fP
+
+\fBint pthread_setaffinity_np(pthread_t \fP\fIthread\fP\fB, size_t \fP\fIcpusetsize\fP\fB,\fP
+\fB const cpu_set_t *\fP\fIcpuset\fP\fB);\fP
+\fBint pthread_getaffinity_np(pthread_t \fP\fIthread\fP\fB, size_t \fP\fIcpusetsize\fP\fB,\fP
+\fB cpu_set_t *\fP\fIcpuset\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_setaffinity_np\fP() 関数は、スレッド \fIthread\fP の CPU affinity
+マスクに \fIcpuset\fP が指す CPU 集合を設定する。呼び出しが成功し、
+そのスレッドが現在 \fIcpuset\fP で指定された CPU 上でが実行されていない
+場合は、スレッドは指定された CPU のいずれかに移動される。
+
+\fBpthread_getaffinity_np\fP() 関数は、スレッド \fIthread\fP の CPU affinity
+マスクを、\fIcpuset\fP が指すバッファに入れて返す。
+
+CPU affinity マスクの詳細については、
+\fBsched_setaffinity\fP(2) を参照してほしい。
+CPU 集合の操作や取得を行う際に利用できるマクロ群の説明は
+\fBCPU_SET\fP(3) を参照してほしい。
+
+引き数 \fIcpusetsize\fP は \fIcpuset\fP が指すバッファの長さ (バイト単位) で
+ある。通常は、この引き数には \fIsizeof(cpu_set_t)\fP を指定する
+(\fBCPU_SET\fP(3) に書かれているマクロを使って CPU 集合を動的に
+割り当てている場合には、別の値になることもある)。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+.SH エラー
+.TP
+\fBEFAULT\fP
+指定されたメモリアドレスが無効である。
+.TP
+\fBEINVAL\fP
+(\fBpthread_setaffinity_np\fP()) affinity ビットマスク \fImask\fP に、
+その時点でシステム上に物理的に存在して、かつそのスレッドに対して許可
+されているプロセッサが一つも含まれていない。
+スレッドに対してどのプロセッサの利用が許可されるかは、\fBcpuset\fP(7) で
+説明されている "cpuset" 機構に適用される制限に基づいて決まる。
+.TP
+\fBEINVAL\fP
+.\" FIXME . ?
+.\" Loic Domaigne commented: it seems that in the future the
+.\" kernel developers want to make cpumask_t dynamic, so
+.\" CONFIG_NR_CPUS might become obsolete in the future.
+.\" cpumask_t
+.\" The raw sched_getaffinity() system call returns the size (in bytes)
+.\" of the cpumask_t type.
+(\fBpthread_setaffinity_np\fP()) \fIcpuset\fP が、カーネルがサポートする CPU
+集合に含まれない CPU を指定していた。(カーネルの設定オプション
+\fBCONFIG_NR_CPUS\fP により、CPU 集合を表現するのに使われるカーネルの
+データ型がサポートする CPU 集合の範囲が定義される。)
+.TP
+\fBEINVAL\fP
+(\fBpthread_getaffinity_np\fP()) \fIcpusetsize\fP がカーネルが使用する
+affinity マスクの大きさよりも小さい。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.SH バージョン
+これらの関数は glibc バージョン 2.3.4 以降で提供されている。
+.SH 準拠
+これらの関数は非標準の GNU による拡張である。
+そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
+付いている。
+.SH 注意
+\fBpthread_setaffinity_np\fP() を呼び出した後、
+そのスレッドが実際に実行される CPU 集合は、
+\fIcpuset\fP 引き数で指定された集合と
+システムに実際に存在する CPU 集合の共通部分になる。
+また、 \fBcpuset\fP(7) で説明されている "cpuset" 機構が使われている場合
+には、そのスレッドが実行される CPU 集合がシステムによってさらに制限
+される場合がある。そのスレッドが実行される実際の CPU 集合に対する
+これらの制限は、カーネルにより黙って適用される。
+
+これらの関数は、システムコール \fBsched_setaffinity\fP(2) と
+\fBsched_getaffinity\fP(2) を使って実装されている。
+
+(このバージョンだけであるが) glibc 2.3.3 では、
+これらの関数は \fIcpusetsize\fP 引き数を持っていなかった。
+内部で呼ばれるシステムコールに渡される CPU セットの大きさは
+常に \fIsizeof(cpu_set_t)\fP であった。
+
+\fBpthread_create\fP(3) で作成される新しいスレッドは、
+作成者の CPU affinity マスクを継承する。
+.SH 例
+以下のプログラムでは、メインスレッドは
+\fBpthread_setaffinity_np\fP() を使って自分の CPU affinity マスクに
+CPU 0 から 7 が含まれるように設定し
+(システム上には 0 から 7 に対応する CPU が全て存在するとは限らない)、
+その後で \fBpthread_getaffinity_np\fP() を使って
+スレッドに実際に設定された CPU affinity マスクを確認している。
+
+.nf
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+int
+main(int argc, char *argv[])
+{
+ int s, j;
+ cpu_set_t cpuset;
+ pthread_t thread;
+
+ thread = pthread_self();
+
+ /* Set affinity mask to include CPUs 0 to 7 */
+
+ CPU_ZERO(&cpuset);
+ for (j = 0; j < 8; j++)
+ CPU_SET(j, &cpuset);
+
+ s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
+ if (s != 0)
+ handle_error_en(s, "pthread_setaffinity_np");
+
+ /* Check the actual affinity mask assigned to the thread */
+
+ s = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
+ if (s != 0)
+ handle_error_en(s, "pthread_getaffinity_np");
+
+ printf("Set returned by pthread_getaffinity_np() contained:\en");
+ for (j = 0; j < CPU_SETSIZE; j++)
+ if (CPU_ISSET(j, &cpuset))
+ printf(" CPU %d\en", j);
+
+ exit(EXIT_SUCCESS);
+}
+.fi
+.SH 関連項目
+\fBsched_setaffinity\fP(2), \fBsched_setscheduler\fP(2),
+\fBpthread_attr_setaffinity_np\fP(3), \fBpthread_self\fP(3), \fBsched_getcpu\fP(3),
+\fBcpuset\fP(7), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SETSCHEDPARAM 3 2008\-11\-17 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_setschedparam, pthread_getschedparam \- スレッドの
+スケジューリングポリシーとパラメータを設定/取得する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBpthread_setschedparam(pthread_t \fP\fIthread\fP\fB, int \fP\fIpolicy\fP\fB,\fP
+\fB const struct sched_param *\fP\fIparam\fP\fB);\fP
+\fBpthread_getschedparam(pthread_t \fP\fIthread\fP\fB, int *\fP\fIpolicy\fP\fB,\fP
+\fB struct sched_param *\fP\fIparam\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_setschedparam\fP() 関数は、スレッド \fIthread\fP の
+スケジューリングポリシーとスケジューリングパラメータを設定する。
+
+.\" FIXME . pthread_setschedparam() places no restriction on the policy,
+.\" but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7013
+\fIpolicy\fP は \fIthread\fP の新しいスケジューリングポリシーを指定する。
+\fIpolicy\fP に指定できる値とその意味は \fBsched_setscheduler\fP(2) で
+説明されている。
+
+\fIparam\fP が指す構造体は \fIthread\fP の新しいスケジューリングパラメータを
+指定する。スケジューリングパラメータは以下の構造体で管理される。
+
+.in +4n
+.nf
+struct sched_param {
+ int sched_priority; /* Scheduling priority */
+};
+.fi
+.in
+
+見て分かる通り、サポートされているスケジューリングパラメータは一つだけ
+である。各スケジューリングポリシーで許可されるスケジューリング優先度の
+詳細については、\fBsched_setscheduler\fP(2) を参照のこと。
+
+.\" FIXME . nptl/pthread_setschedparam.c has the following
+.\" /* If the thread should have higher priority because of some
+.\" PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+.\" Eventually (perhaps after writing the mutexattr pages), we
+.\" may want to add something on the topic to this page.
+\fBpthread_getschedparam\fP() 関数は、スレッド \fIthread\fP の
+スケジューリングポリシーとパラメータを、
+それぞれ \fIpolicy\fP と \fIparam\fP が指すバッファに入れて返す。
+返された優先度の値は、最も最近実行した \fIthread\fP に影響を与える
+\fBpthread_setschedparam\fP(), \fBpthread_setschedprio\fP,
+\fBpthread_create\fP で設定された値となる。
+返された優先度は、優先度の継承や優先度の上限を設定する関数
+(例えば \fBpthread_mutexattr_setprioceiling\fP(3) や
+\fBpthread_mutexattr_setprotocol\fP(3) を参照) の呼び出しの結果
+行われる一時的な優先度の調整の影響を受けない。
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+\fBpthread_setschedparam\fP() が失敗した場合、 \fIthread\fP の
+スケジューリングポリシーとパラメータは変更されない。
+.SH エラー
+これらの関数はどちらも以下のエラーで失敗する場合がある。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.PP
+\fBpthread_setschedparam\fP() はさらに以下のエラーで失敗する場合がある。
+.TP
+\fBEINVAL\fP
+\fIpolicy\fP が認識できないポリシーであるか、
+\fIparam\fP が \fIpolicy\fP では意味を持たない値である。
+.TP
+\fBEPERM\fP
+呼び出し側が、指定されたスケジューリングポリシーやパラメータを設定する
+のに必要な特権を持たない。
+.PP
+.\" .SH VERSIONS
+.\" Available since glibc 2.0
+POSIX.1\-2001 では、 \fBpthread_setschedparam\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値をスケジューリングポリシーや
+パラメータに設定しようとした") も追加で規定されている。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+スレッドのスケジューリングポリシーや優先度を変更するために必要な許可や
+変更した場合の影響、および各スケジューリングポリシーで認められる優先度
+の範囲の詳細については、 \fBsched_setscheduler\fP(2) を参照。
+.SH 例
+以下のプログラムは \fBpthread_setschedparam\fP() と
+\fBpthread_getschedparam\fP() やスケジューリングに関連する pthreads の
+他のいろいろな関数の使用例を示すものである。
+
+以下の実行例では、メインスレッドは、自分のスケジューリングポリシーを
+優先度 10 の \fBSCHED_FIFO\fP を設定し、スレッド属性オブジェクトを
+スケジューリングポリシー属性 \fBSCHED_RR\fP とスケジューリング優先度
+属性 20 で初期化する。
+次に、このプログラムは (\fBpthread_attr_setinheritsched\fP(3) を使って)
+そのスレッド属性オブジェクトの inherit scheduler 属性に
+\fBPTHREAD_EXPLICIT_SCHED\fP を設定する。\fBPTHREAD_EXPLICIT_SCHED\fP は、
+そのスレッド属性オブジェクトを使って作成されたスレッドはスレッド属性
+オブジェクトからスケジューリング属性を取得して使うことを意味する。
+それから、このスレッド属性オブジェクトを使ってスレッドを作成し、
+作成したスレッドのスケジューリングポリシーと優先度を表示する。
+.in +4n
+.nf
+
+$ \fBsu\fP # Need privilege to set real\-time scheduling policies
+Password:
+# \fB./a.out \-mf10 \-ar20 \-i e\fP
+Scheduler settings of main thread
+ policy=SCHED_FIFO, priority=10
+
+Scheduler settings in \(aqattr\(aq
+ policy=SCHED_RR, priority=20
+ inheritsched is EXPLICIT
+
+Scheduler attributes of new thread
+ policy=SCHED_RR, priority=20
+.fi
+.in
+
+上記の出力では、スケジューリングポリシーと優先度がスレッド属性
+オブジェクトで指定された値から取られていることが分かる。
+
+次の実行例は前のものと同じだが、 inherit scheduler 属性が
+\fBPTHREAD_INHERIT_SCHED\fP に設定される点が異なる。
+\fBPTHREAD_INHERIT_SCHED\fP は、そのスレッド属性オブジェクトを使って作成
+されたスレッドは、スレッド属性オブジェクトからスケジューリング属性を
+無視し、代わりに呼び出したスレッドからスケジューリング属性を取得する
+ことを意味する。
+
+.in +4n
+.nf
+# \fB./a.out \-mf10 \-ar20 \-i i\fP
+Scheduler settings of main thread
+ policy=SCHED_FIFO, priority=10
+
+Scheduler settings in \(aqattr\(aq
+ policy=SCHED_RR, priority=20
+ inheritsched is INHERIT
+
+Scheduler attributes of new thread
+ policy=SCHED_FIFO, priority=10
+.fi
+.in
+
+上記の出力では、スケジューリングポリシーと優先度が、
+スレッド属性オブジェクトからではなく、
+スレッドを作成したスレッドから取れれていることが分かる。
+
+なお、 \fI\-i\ i\fP を省略した場合でも、
+\fBPTHREAD_INHERIT_SCHED\fP が inherit scheduler 属性のデフォルト値なので、
+出力は同じになる。
+.SS プログラムのソース
+\&
+.nf
+/* pthreads_sched_test.c */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+static void
+usage(char *prog_name, char *msg)
+{
+ if (msg != NULL)
+ fputs(msg, stderr);
+
+ fprintf(stderr, "Usage: %s [options]\en", prog_name);
+ fprintf(stderr, "Options are:\en");
+#define fpe(msg) fprintf(stderr, "\et%s", msg); /* Shorter */
+ fpe("\-a<policy><prio> Set scheduling policy and priority in\en");
+ fpe(" thread attributes object\en");
+ fpe(" <policy> can be\en");
+ fpe(" f SCHED_FIFO\en");
+ fpe(" r SCHED_RR\en");
+ fpe(" o SCHED_OTHER\en");
+ fpe("\-A Use default thread attributes object\en");
+ fpe("\-i {e|s} Set inherit scheduler attribute to\en");
+ fpe(" \(aqexplicit\(aq or \(aqinherit\(aq\en");
+ fpe("\-m<policy><prio> Set scheduling policy and priority on\en");
+ fpe(" main thread before pthread_create() call\en");
+ exit(EXIT_FAILURE);
+}
+
+static int
+get_policy(char p, int *policy)
+{
+ switch (p) {
+ case \(aqf\(aq: *policy = SCHED_FIFO; return 1;
+ case \(aqr\(aq: *policy = SCHED_RR; return 1;
+ case \(aqo\(aq: *policy = SCHED_OTHER; return 1;
+ default: return 0;
+ }
+}
+
+static void
+display_sched_attr(int policy, struct sched_param *param)
+{
+ printf(" policy=%s, priority=%d\en",
+ (policy == SCHED_FIFO) ? "SCHED_FIFO" :
+ (policy == SCHED_RR) ? "SCHED_RR" :
+ (policy == SCHED_OTHER) ? "SCHED_OTHER" :
+ "???",
+ param\->sched_priority);
+}
+
+static void
+display_thread_sched_attr(char *msg)
+{
+ int policy, s;
+ struct sched_param param;
+
+ s = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ if (s != 0)
+ handle_error_en(s, "pthread_getschedparam");
+
+ printf("%s\en", msg);
+ display_sched_attr(policy, ¶m);
+}
+
+static void *
+thread_start(void *arg)
+{
+ display_thread_sched_attr("Scheduler attributes of new thread");
+
+ return NULL;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int s, opt, inheritsched, use_null_attrib, policy;
+ pthread_t thread;
+ pthread_attr_t attr;
+ pthread_attr_t *attrp;
+ char *attr_sched_str, *main_sched_str, *inheritsched_str;
+ struct sched_param param;
+
+ /* Process command\-line options */
+
+ use_null_attrib = 0;
+ attr_sched_str = NULL;
+ main_sched_str = NULL;
+ inheritsched_str = NULL;
+
+ while ((opt = getopt(argc, argv, "a:Ai:m:")) != \-1) {
+ switch (opt) {
+ case \(aqa\(aq: attr_sched_str = optarg; break;
+ case \(aqA\(aq: use_null_attrib = 1; break;
+ case \(aqi\(aq: inheritsched_str = optarg; break;
+ case \(aqm\(aq: main_sched_str = optarg; break;
+ default: usage(argv[0], "Unrecognized option\en");
+ }
+ }
+
+ if (use_null_attrib &&
+ (inheritsched_str != NULL || attr_sched_str != NULL))
+ usage(argv[0], "Can\(aqt specify \-A with \-i or \-a\en");
+
+ /* Optionally set scheduling attributes of main thread,
+ and display the attributes */
+
+ if (main_sched_str != NULL) {
+ if (!get_policy(main_sched_str[0], &policy))
+ usage(argv[0], "Bad policy for main thread (\-s)\en");
+ param.sched_priority = strtol(&main_sched_str[1], NULL, 0);
+
+ s = pthread_setschedparam(pthread_self(), policy, ¶m);
+ if (s != 0)
+ handle_error_en(s, "pthread_setschedparam");
+ }
+
+ display_thread_sched_attr("Scheduler settings of main thread");
+ printf("\en");
+
+ /* Initialize thread attributes object according to options */
+
+ attrp = NULL;
+
+ if (!use_null_attrib) {
+ s = pthread_attr_init(&attr);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_init");
+ attrp = &attr;
+ }
+
+ if (inheritsched_str != NULL) {
+ if (inheritsched_str[0] == \(aqe\(aq)
+ inheritsched = PTHREAD_EXPLICIT_SCHED;
+ else if (inheritsched_str[0] == \(aqi\(aq)
+ inheritsched = PTHREAD_INHERIT_SCHED;
+ else
+ usage(argv[0], "Value for \-i must be \(aqe\(aq or \(aqi\(aq\en");
+
+ s = pthread_attr_setinheritsched(&attr, inheritsched);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setinheritsched");
+ }
+
+ if (attr_sched_str != NULL) {
+ if (!get_policy(attr_sched_str[0], &policy))
+ usage(argv[0],
+ "Bad policy for \(aqattr\(aq (\-a)\en");
+ param.sched_priority = strtol(&attr_sched_str[1], NULL, 0);
+
+ s = pthread_attr_setschedpolicy(&attr, policy);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setschedpolicy");
+ s = pthread_attr_setschedparam(&attr, ¶m);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_setschedparam");
+ }
+
+ /* If we initialized a thread attributes object, display
+ the scheduling attributes that were set in the object */
+
+ if (attrp != NULL) {
+ s = pthread_attr_getschedparam(&attr, ¶m);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getschedparam");
+ s = pthread_attr_getschedpolicy(&attr, &policy);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_getschedpolicy");
+
+ printf("Scheduler settings in \(aqattr\(aq\en");
+ display_sched_attr(policy, ¶m);
+
+ s = pthread_attr_getinheritsched(&attr, &inheritsched);
+ printf(" inheritsched is %s\en",
+ (inheritsched == PTHREAD_INHERIT_SCHED) ? "INHERIT" :
+ (inheritsched == PTHREAD_EXPLICIT_SCHED) ? "EXPLICIT" :
+ "???");
+ printf("\en");
+ }
+
+ /* Create a thread that will display its scheduling attributes */
+
+ s = pthread_create(&thread, attrp, &thread_start, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_create");
+
+ /* Destroy unneeded thread attributes object */
+
+ s = pthread_attr_destroy(&attr);
+ if (s != 0)
+ handle_error_en(s, "pthread_attr_destroy");
+
+ s = pthread_join(thread, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_join");
+
+ exit(EXIT_SUCCESS);
+}
+.fi
+.SH 関連項目
+\fBgetrlimit\fP(2), \fBsched_get_priority_min\fP(2), \fBsched_setscheduler\fP(2),
+\fBpthread_attr_init\fP(3), \fBpthread_attr_setinheritsched\fP(3),
+\fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3),
+\fBpthread_create\fP(3), \fBpthread_self\fP(3), \fBpthread_setschedprio\fP(3),
+\fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SETSCHEDPRIO 3 2008\-11\-06 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_setschedprio \- スレッドのスケジューリング優先度を設定する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBpthread_setschedprio(pthread_t \fP\fIthread\fP\fB, int \fP\fIprio\fP\fB);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+.\" FIXME . nptl/pthread_setschedprio.c has the following
+.\" /* If the thread should have higher priority because of some
+.\" PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+.\" Eventually (perhaps after writing the mutexattr pages), we
+.\" may want to add something on the topic to this page.
+.\" nptl/pthread_setschedparam.c has a similar case.
+\fBpthread_setschedprio\fP() 関数は、スレッド \fIthread\fP のスケジューリング
+優先度に \fIprio\fP で指定された値を設定する
+(一方、\fBpthread_setschedparam\fP(3) はスレッドのスケジューリングポリシー
+と優先度の両方を変更する)。
+.SH 返り値
+成功すると、この関数は 0 を返す。
+エラーの場合、0 以外のエラー番号を返す。
+\fBpthread_setschedprio\fP() が失敗した場合、 \fIthread\fP の
+スケジューリング優先度は変更されない。
+.SH エラー
+.TP
+\fBEINVAL\fP
+指定されたスレッドのスケジューリングポリシーでは、 \fIprio\fP は無効である。
+.TP
+\fBEPERM\fP
+呼び出し側が、指定された優先度を設定するのに必要な特権を持っていない。
+.TP
+\fBESRCH\fP
+ID が \fIthread\fP のスレッドが見つからなかった。
+.PP
+POSIX.1\-2001 では、 \fBpthread_setschedprio\fP() に関して
+エラー \fBENOTSUP\fP ("サポートされていない値を優先度
+に設定しようとした") も追加で規定されている。
+.SH バージョン
+この関数は glibc バージョン 2.3.4 以降で利用できる。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+スレッドのスケジューリング優先度を変更するために必要な許可や
+変更した場合の影響、および各スケジューリングポリシーで認められる優先度
+の範囲の詳細については、 \fBsched_setscheduler\fP(2) を参照。
+.SH 関連項目
+\fBgetrlimit\fP(2), \fBsched_get_priority_min\fP(2), \fBsched_setscheduler\fP(2),
+\fBpthread_attr_init\fP(3), \fBpthread_attr_setinheritsched\fP(3),
+\fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3),
+\fBpthread_create\fP(3), \fBpthread_self\fP(3), \fBpthread_setschedparam\fP(3),
+\fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SIGMASK 3 2011\-10\-16 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_sigmask \- 禁止するシグナルマスクの確認と変更を行う
+.SH 書式
+.nf
+\fB#include <signal.h>\fP
+
+\fBint pthread_sigmask(int \fP\fIhow\fP\fB, const sigset_t *\fP\fIset\fP\fB, sigset_t *\fP\fIoldset\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_sigmask\fP() 関数は \fBsigprocmask\fP(2) と全く同様だが、
+マルチスレッドプログラムでの利用が POSIX.1\-2001 で明示的に規定されて
+いる点が異なる。他の違いはこのマニュアルページで説明する。
+
+この関数の引き数と動作の説明は \fBsigprocmask\fP(2) を参照。
+.SH 返り値
+成功すると、 \fBpthread_sigmask\fP() は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+\fBsigprocmask\fP(2) を参照。
+.SH 準拠
+POSIX.1\-2001.
+.SH 注意
+新しいスレッドは、スレッドを作成したスレッドのシグナルマスクのコピーを
+継承する。
+.SH 例
+以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block)
+するように設定を行い、 \fBsigwait\fP(3) 経由でそれらのシグナルを集める
+専用のスレッドを作成する。
+下記のシェルのセッションはその利用例を示したものである。
+
+.in +4n
+.nf
+$\fB ./a.out &\fP
+[1] 5423
+$\fB kill \-QUIT %1\fP
+Signal handling thread got signal 3
+$\fB kill \-USR1 %1\fP
+Signal handling thread got signal 10
+$\fB kill \-TERM %1\fP
+[1]+ Terminated ./a.out
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+
+/* Simple error handling functions */
+
+#define handle_error_en(en, msg) \e
+ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
+
+static void *
+sig_thread(void *arg)
+{
+ sigset_t *set = (sigset_t *) arg;
+ int s, sig;
+
+ for (;;) {
+ s = sigwait(set, &sig);
+ if (s != 0)
+ handle_error_en(s, "sigwait");
+ printf("Signal handling thread got signal %d\en", sig);
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t thread;
+ sigset_t set;
+ int s;
+
+ /* Block SIGQUIT and SIGUSR1; other threads created by main()
+ will inherit a copy of the signal mask. */
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGUSR1);
+ s = pthread_sigmask(SIG_BLOCK, &set, NULL);
+ if (s != 0)
+ handle_error_en(s, "pthread_sigmask");
+
+ s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);
+ if (s != 0)
+ handle_error_en(s, "pthread_create");
+
+ /* Main thread carries on to create other threads and/or do
+ other work */
+
+ pause(); /* Dummy pause so we can test program */
+}
+.fi
+.SH 関連項目
+\fBsigaction\fP(2), \fBsigpending\fP(2), \fBsigprocmask\fP(2) \fBpthread_create\fP(3),
+\fBpthread_kill\fP(3), \fBsigsetops\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2010 Michael Kerrisk, <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_SIGQUEUE 3 2011\-09\-23 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_sigqueue \- スレッドに対するシグナルとデータをキューに入れる
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_sigqueue(pthread_t *\fP\fIthread\fP\fB, int \fP\fIsig\fP\fB,\fP
+\fB const union sigval \fP\fIvalue\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.sp
+.in -4n
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
+.in
+.sp
+\fBpthread_sigqueue\fP(): _GNU_SOURCE
+.SH 説明
+\fBpthread_sigqueue\fP() 関数は \fBsigqueue\fP(3) と同様の処理を実行するが、
+別のプロセスにシグナルを送信するのではなく、呼び出したスレッドと
+同じプロセス内の他のスレッドにシグナルを送信する。
+
+\fIthread\fP 引き数は、呼び出し側と同じプロセスの別のスレッドの ID である。
+\fIsig\fP 引き数は送信するシグナルを指定する。
+\fIvalue\fP 引き数はシグナルと一緒に渡すデータを指定する。
+詳細は \fBsigqueue\fP(3) を参照。
+.SH 返り値
+成功すると、 \fBpthread_sigmask\fP() は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+.TP
+\fBEAGAIN\fP
+キューに入れられるシグナル数が上限に達していた
+(詳しい情報は (\fBsignal\fP(7) を参照)。
+.TP
+\fBEINVAL\fP
+\fIsig\fP が無効であった。
+.TP
+\fBENOSYS\fP
+\fBpthread_sigqueue\fP() がこのシステムではサポートされていない。
+.TP
+\fBESRCH\fP
+\fIthread\fP が無効である。
+.SH バージョン
+\fBpthread_sigqueue\fP() 関数は glibc 2.11 で初めて登場した。
+.SH 準拠
+この関数は GNU による拡張である。
+.SH 関連項目
+\fBrt_tgsigqueueinfo\fP(2), \fBsigaction\fP(2), \fBpthread_sigmask\fP(3),
+\fBsigqueue\fP(3), \fBsigwait\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_TESTCANCEL 3 2012\-04\-14 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_testcancel \- 処理待ちの取り消し要求の配送を要求する
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBvoid pthread_testcancel(void);\fP
+.sp
+\fI\-pthread\fP でコンパイルしてリンクする。
+.fi
+.SH 説明
+\fBpthread_testcancel\fP() を呼び出すと、呼び出したスレッド内に取り消し
+ポイント (cancellation point) が作成される。
+これにより、これ以外には取り消しポイントを含まないコードを実行して
+いるスレッドが取り消し要求に対応することができるようになる。
+
+(\fBpthread_setcancelstate\fP(3) を使って) キャンセルが無効になっている
+場合や処理待ちの取り消し要求がない場合は、\fBpthread_testcancel\fP(3) を
+呼び出しても何の影響もない。
+.SH 返り値
+この関数は値を返さない。この関数の呼び出しの結果、呼び出したスレッドが
+キャンセルされた場合、この関数が返ることはない。
+.SH エラー
+.\" SH VERSIONS
+.\" Available since glibc 2.0
+この関数は常に成功する。
+.SH 準拠
+POSIX.1\-2001.
+.SH 例
+\fBpthread_cleanup_push\fP(3) を参照。
+.SH 関連項目
+\fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3),
+\fBpthread_setcancelstate\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_TRYJOIN_NP 3 2010\-09\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_tryjoin_np, pthread_timedjoin_np \- 終了したスレッドの join を
+試みる
+.SH 書式
+.nf
+\fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */
+\fB#include <pthread.h>\fP
+
+\fBint pthread_tryjoin_np(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB);\fP
+
+\fBint pthread_timedjoin_np(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB,\fP
+\fB const struct timespec *\fP\fIabstime\fP\fB);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+これらの関数は \fBpthread_join\fP(3) と同じように動作するが、
+このページで説明する違いがある。
+
+\fBpthread_tryjoin_np\fP() 関数は、スレッド \fIthread\fP の非停止
+(nonblocking) での join を実行し、スレッドの終了ステータスを
+\fI*retval\fP に入れて返す。\fIthread\fP がまだ終了していない場合は、
+\fBpthread_join\fP(3) のように停止 (block) せずに、エラーを返す。
+
+\fBpthread_timedjoin_np\fP() 関数は、タイムアウト付きの join を行う。
+\fIthread\fP がまだ終了していない場合、 \fIabstime\fP で指定された最大時間
+まで停止する。 \fIthread\fP が終了する前にタイムアウト時間が経過した場合は、
+エラーを返す。\fIabstime\fP 引き数は以下に示す構造体であり、
+Epoch (時刻紀元; \fBtime\fP(2) 参照) から測った絶対時刻を指定する。
+
+.in +4n
+.nf
+struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+};
+.fi
+.in
+.SH 返り値
+成功すると、これらの関数は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+これらの関数は \fBpthread_join\fP(3) と同じエラーで失敗する。
+\fBpthread_tryjoin_np\fP() はさらに以下のエラーで失敗する場合がある。
+.TP
+\fBEBUSY\fP
+呼び出しを行った時点では \fIthread\fP はまだ終了していない。
+.PP
+\fBpthread_timedjoin_np\fP() はさらに以下のエラーで失敗する場合がある。
+.TP
+\fBETIMEDOUT\fP
+\fIthread\fP が終了する前に呼び出しがタイムアウトとなった。
+.PP
+\fBpthread_timedjoin_np\fP() がエラー \fBEINTR\fP を返すことはない。
+.SH バージョン
+これらの関数は glibc バージョン 2.3.3 で初めて登場した。
+.SH 準拠
+これらの関数は非標準の GNU による拡張である。
+そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が
+付いている。
+.SH 例
+以下のコードは、最大 5 秒まで join を待つ。
+
+.nf
+ struct timespec ts;
+ int s;
+
+ ...
+
+ if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
+ /* Handle error */
+ }
+
+ ts.tv_sec += 5;
+
+ s = pthread_timedjoin_np(thread, NULL, &ts);
+ if (s != 0) {
+ /* Handle error */
+ }
+.fi
+.SH 関連項目
+\fBclock_gettime\fP(2), \fBpthread_exit\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright (c) 2009 Michael Kerrisk, <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH PTHREAD_YIELD 3 2009\-04\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+pthread_yield \- プロセッサを明け渡す (yield)
+.SH 書式
+.nf
+\fB#include <pthread.h>\fP
+
+\fBint pthread_yield(void);\fP
+.fi
+.sp
+\fI\-pthread\fP を付けてコンパイルとリンクを行う。
+.SH 説明
+\fBpthread_yield\fP() を呼び出すと、呼び出したスレッドは CPU を手放す。
+スレッドはそのスレッドの静的優先度の実行キューの末尾に回り、
+別のスレッドが実行されるようにスケジューリングされる。
+詳細は \fBsched_yield\fP(2) を参照。
+.SH 返り値
+成功すると、 \fBpthread_yield\fP() は 0 を返す。
+エラーの場合、エラー番号を返す。
+.SH エラー
+Linux では、この関数の呼び出しは常に成功する
+(ただし、移植性や将来も動作することを保証したいアプリケーションでは
+正のエラーの返り値を処理するようにすべきである)。
+.SH 準拠
+.\" e.g., the BSDs, Tru64, AIX, and Irix.
+この関数は非標準だが、他のいくつかのシステムにも存在する。
+代わりに、標準化されている \fBsched_yield\fP(2) を使うこと。
+.SH 注意
+Linux では、この関数は \fBsched_yield\fP(2) を呼び出す形で実装されている。
+.SH 関連項目
+\fBsched_setscheduler\fP(2), \fBsched_yield\fP(2) \fBpthreads\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
+.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
+.\" <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH SCALBLN 3 2010\-09\-20 "" "Linux Programmer's Manual"
+.SH 名前
+scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl \-
+浮動小数点数に基数の整数乗を掛ける
+.SH 書式
+\fB#include <math.h>\fP
+.sp
+\fBdouble scalbln(double \fP\fIx\fP\fB, long int \fP\fIexp\fP\fB);\fP
+.br
+\fBfloat scalblnf(float \fP\fIx\fP\fB, long int \fP\fIexp\fP\fB);\fP
+.br
+\fBlong double scalblnl(long double \fP\fIx\fP\fB, long int \fP\fIexp\fP\fB);\fP
+.sp
+\fBdouble scalbn(double \fP\fIx\fP\fB, int \fP\fIexp\fP\fB);\fP
+.br
+\fBfloat scalbnf(float \fP\fIx\fP\fB, int \fP\fIexp\fP\fB);\fP
+.br
+\fBlong double scalbnl(long double \fP\fIx\fP\fB, int \fP\fIexp\fP\fB);\fP
+.sp
+\fI\-lm\fP でリンクする。
+.sp
+.in -4n
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
+.in
+.sp
+.ad l
+\fBscalbln\fP(), \fBscalblnf\fP(), \fBscalblnl\fP():
+.RS
+_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L;
+.br
+or \fIcc\ \-std=c99\fP
+.RE
+.br
+\fBscalbn\fP(), \fBscalbnf\fP(), \fBscalbnl\fP():
+.RS
+_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE
+|| _POSIX_C_SOURCE\ >=\ 200112L;
+.br
+or \fIcc\ \-std=c99\fP
+.RE
+.ad b
+.SH 説明
+これらの関数は最初の引き数 \fIx\fP に \fBFLT_RADIX\fP の \fIexp\fP 乗を掛ける (\fBFLT_RADIX\fP はおそらく 2
+である)。つまり、以下の式の値を返す。
+.nf
+
+ x * FLT_RADIX ** exp
+.fi
+
+.\" not in /usr/include but in a gcc lib
+\fBFLT_RADIX\fP の定義は \fI<float.h>\fP をインクルードすることで得られる。
+.SH 返り値
+成功すると、これらの関数は \fIx\fP * \fBFLT_RADIX\fP ** \fIexp\fP を返す。
+
+\fIx\fP が NaN の場合、NaN が返される。
+
+\fIx\fP が正の無限大 (負の無限大) の場合、正の無限大 (負の無限大) が返される。
+
+\fIx\fP が +0 (\-0) の場合、+0 (\-0) が返される。
+
+結果がオーバーフローする場合、 範囲エラー (range error) が発生し、 各関数はそれぞれ \fBHUGE_VAL\fP,
+\fBHUGE_VALF\fP, \fBHUGE_VALL\fP を返す。符号は \fIx\fP と同じになる。
+
+結果がアンダーフローする場合、範囲エラーが発生し、 各関数は 0 を返す。符号は \fIx\fP と同じになる。
+.SH エラー
+これらの関数を呼び出した際にエラーが発生したかの判定方法についての情報は \fBmath_error\fP(7) を参照のこと。
+.PP
+以下のエラーが発生する可能性がある。
+.TP
+範囲エラー (range error)、オーバーフローの場合
+.\" .I errno
+.\" is set to
+.\" .BR ERANGE .
+オーバーフロー浮動小数点例外 (\fBFE_OVERFLOW\fP) が上がる。
+.TP
+範囲エラー (range error)、アンダーフローの場合
+.\" .I errno
+.\" is set to
+.\" .BR ERANGE .
+アンダーフロー浮動小数点例外 (\fBFE_UNDERFLOW\fP) が上がる。
+.PP
+.\" FIXME . Is it intentional that these functions do not set errno?
+.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6803
+これらの関数は \fIerrno\fP を設定しない。
+.SH バージョン
+これらの関数は glibc バージョン 2.1 で初めて登場した。
+.SH 準拠
+C99, POSIX.1\-2001.
+.SH 注意
+これらの関数は、 \fBscalb\fP(3) に説明がある廃止予定の関数群とは二番目の
+引き数の型が異なる。このページで説明する関数群は、二番目の引き数の型が
+整数である。これに対して \fBscalb\fP(3) に説明がある関数群は、二番目の
+引き数の型が \fIdouble\fP である。
+
+\fBFLT_RADIX\fP が 2 の場合 (これが普通だが)、
+その場合は \fBscalbn\fP() は \fBldexp\fP(3) と等価である。
+.SH 関連項目
+\fBldexp\fP(3), \fBscalb\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。
--- /dev/null
+.\" t
+.\" Copyright (c) 2010 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\"
+.\" 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.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.TH AIO 7 2010\-10\-02 Linux "Linux Programmer's Manual"
+.SH 名前
+aio \- POSIX 非同期 I/O の概要
+.SH 説明
+POSIX 非同期 (AIO) インターフェースを使うと、アプリケーションは、非同期
+に (つまり、バックグラウンドで) 実行されるI/O 操作を一つ以上発行できる
+ようになる。アプリケーションは I/O 操作の完了の通知方法を選択することが
+できる。選択できる通知方法は、シグナルの配送、スレッドの起動、通知を行
+わないである。
+
+POSIX AIO インターフェースは以下の関数で構成されている。
+.TP 16
+\fBaio_read\fP(3)
+読み出しリクエストをキューに入れる。
+\fBread\fP(2) の非同期版である。
+.TP
+\fBaio_write\fP(3)
+書き込みリクエストをキューに入れる。
+\fBwrite\fP(2) の非同期版である。
+.TP
+\fBaio_fsync\fP(3)
+ファイルディスクリプタに対して行われた I/O 操作の
+同期 (sync) リクエストをキューに入れる。
+\fBfsync\fP(2) や \fBfdatasync\fP(2) の非同期版である。
+.TP
+\fBaio_error\fP(3)
+キューに入れられた I/O リクエストのエラー状態を取得する。
+.TP
+\fBaio_return\fP(3)
+完了した I/O リクエストの終了ステータスを取得する。
+.TP
+\fBaio_suspend\fP(3)
+指定された I/O リクエストの集合 (要素は一つ以上) が完了するまで、
+呼び出し側の実行を停止 (suspend) する。
+.TP
+\fBaio_cancel\fP(3)
+指定されたファイルディスクリプタに関する
+完了していない I/O リクエストのキャンセルを試みる。
+.TP
+\fBlio_listio\fP(3)
+一回の関数呼び出しで複数の I/O リクエストをキューに入れる。
+.PP
+\fIaiocb\fP ("非同期 I/O 制御ブロック (asynchronous I/O control block)")
+構造体は、I/O 操作を制御するパラメータを定義する。この型の引き数は上記
+の全ての関数で使用されている。この構造体は以下の通りである。
+.PP
+.in +4n
+.nf
+#include <aiocb.h>
+
+struct aiocb {
+ /* The order of these fields is implementation\-dependent */
+
+ int aio_fildes; /* File descriptor */
+ off_t aio_offset; /* File offset */
+ volatile void *aio_buf; /* Location of buffer */
+ size_t aio_nbytes; /* Length of transfer */
+ int aio_reqprio; /* Request priority */
+ struct sigevent aio_sigevent; /* Notification method */
+ int aio_lio_opcode; /* Operation to be performed;
+ lio_listio() only */
+
+ /* Various implementation\-internal fields not shown */
+};
+
+/* Operation codes for \(aqaio_lio_opcode\(aq: */
+
+enum { LIO_READ, LIO_WRITE, LIO_NOP };
+
+.fi
+.in
+この構造体のフィールドは以下の通りである。
+.TP 16
+\fIaio_filedes\fP
+I/O 操作の実行対象となるファイルディスクリプタ。
+.TP
+\fIaio_offset\fP
+I/O 操作を行うファイルオフセットを示す。
+.TP
+\fIaio_buf\fP
+読み出し操作、書き込み操作でデータ転送に使用されるバッファ。
+.TP
+\fIaio_nbytes\fP
+\fIaio_buf\fP が指すバッファのサイズ。
+.TP
+\fIaio_reqprio\fP
+このフィールドでは、呼び出したスレッドのリアルタイム優先度から
+減算する値を指定する。この I/O リクエストの実行の優先度を
+決定するために使用される (\fBpthread_setschedparam\fP(3) 参照)。
+指定する値は 0 と \fIsysconf(_SC_AIO_PRIO_DELTA_MAX)\fP が返す値の間で
+なければならない。このフィールドは、ファイル同期操作では無視される。
+.TP
+\fIaio_sigevent\fP
+このフィールドは、非同期 I/O 操作が完了した際に呼び出し側に
+どのように通知を行うかを指定する構造体である。
+\fIaio_sigevent.sigev_notify\fP に指定できる値は、
+\fBSIGEV_NONE\fP, \fBSIGEV_SIGNAL\fP, \fBSIGEV_THREAD\fP である。
+詳細は \fBsigevent\fP(7) を参照。
+.TP
+\fIaio_lio_opcode\fP
+実行される操作の種別。
+\fBlio_listio\fP(3) でのみ使用される。
+.PP
+上記のリストにある標準の関数に加えて、GNU C ライブラリでは
+以下に示す POSIX AIO API に対する拡張が提供されている。
+.TP 16
+\fBaio_init\fP(3)
+glibc の POSIX AIO 実装の動作を調整するパラメータを設定する。
+.SH 注意
+使用前に制御ブロックバッファを 0 で埋めるのはよい考えである
+(\fBmemset\fP(3) 参照)。I/O 操作が実行中の間は、制御ブロックバッファと
+\fIaio_buf\fP が指すバッファを変更してはならない。I/O 操作が完了するまで、
+これらのバッファは有効な状態に保たなければならない。
+
+同じ \fIaiocb\fP 構造体を使って、同時に複数の非同期の読み出し操作や
+書き込み操作を行った場合に、どのような結果になるかは未定義である。
+
+.\" http://lse.sourceforge.net/io/aio.html
+.\" http://lse.sourceforge.net/io/aionotes.txt
+.\" http://lwn.net/Articles/148755/
+現在の Linux では、POSIX AIO 実装は glibc によりユーザ空間で提供
+されている。このため、制限がいくつかあり、最も顕著なものは、I/O 操作を
+実行する複数のスレッドの管理コストが高く、スケーラビリティに欠けること
+である。しばらくの間、カーネルのステートマシンによる非同期 I/O の実装
+の作業が行われているが (\fBio_submit\fP(2), \fBio_setup\fP(2),
+\fBio_cancel\fP(2), \fBio_destroy\fP(2), \fBio_getevents\fP(2) 参照)、
+この実装はまだ POSIX AIO 実装をカーネルシステムコールにより
+再実装するほど成熟したものてはない。
+.SH エラー
+.TP
+\fBEINVAL\fP
+\fIaiocb\fP 構造体の \fIaio_reqprio\fP フィールドが、0 より小さいか、
+\fIsysconf(_SC_AIO_PRIO_DELTA_MAX)\fP が返す上限よりも大きかった。
+.SH バージョン
+POSIX AIO インターフェイスは glibc バージョン 2.1 以降で提供されている。
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008.
+.SH 例
+下記のプログラムは、コマンドライン引き数で指定された名前のファイルを
+それぞれオープンし、得られたファイルディスクリプタに対するリクエストを
+\fBaio_read\fP(3) を使ってキューに入れる。その後、このプログラムはループに
+入り、定期的に \fBaio_error\fP(3) を使ってまだ実行中の各 I/O 操作を監視す
+る。各 I/O リクエストは、シグナルの配送による完了通知が行われるように設
+定される。全ての I/O リクエストが完了した後、\fBaio_return\fP(3) を使って
+それぞれのステータスを取得する。
+
+\fBSIGQUIT\fP シグナル (control\-\e をタイプすると生成できる) を送ると、
+このプログラムは \fBaio_cancel\fP(3) を使って
+完了していない各リクエストにキャンセル要求を送る。
+
+以下はこのプログラムを実行した際の出力例である。
+この例では、標準入力に対して 2 つのリクエストを行い、
+"abc" と "x" という 2 行の入力を行っている。
+
+.in +4n
+.nf
+$ \fB./a.out /dev/stdin /dev/stdin\fP
+opened /dev/stdin on descriptor 3
+opened /dev/stdin on descriptor 4
+aio_error():
+ for request 0 (descriptor 3): In progress
+ for request 1 (descriptor 4): In progress
+\fBabc\fP
+I/O completion signal received
+aio_error():
+ for request 0 (descriptor 3): I/O succeeded
+ for request 1 (descriptor 4): In progress
+aio_error():
+ for request 1 (descriptor 4): In progress
+\fBx\fP
+I/O completion signal received
+aio_error():
+ for request 1 (descriptor 4): I/O succeeded
+All I/O requests completed
+aio_return():
+ for request 0 (descriptor 3): 4
+ for request 1 (descriptor 4): 2
+.fi
+.in
+.SS プログラムのソース
+\&
+.nf
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <aio.h>
+#include <signal.h>
+
+#define BUF_SIZE 20 /* Size of buffers for read operations */
+
+#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)
+
+#define errMsg(msg) do { perror(msg); } while (0)
+
+struct ioRequest { /* Application\-defined structure for tracking
+ I/O requests */
+ int reqNum;
+ int status;
+ struct aiocb *aiocbp;
+};
+
+static volatile sig_atomic_t gotSIGQUIT = 0;
+ /* On delivery of SIGQUIT, we attempt to
+ cancel all outstanding I/O requests */
+
+static void /* Handler for SIGQUIT */
+quitHandler(int sig)
+{
+ gotSIGQUIT = 1;
+}
+
+#define IO_SIGNAL SIGUSR1 /* Signal used to notify I/O completion */
+
+static void /* Handler for I/O completion signal */
+aioSigHandler(int sig, siginfo_t *si, void *ucontext)
+{
+ write(STDOUT_FILENO, "I/O completion signal received\en", 31);
+
+ /* The corresponding ioRequest structure would be available as
+ struct ioRequest *ioReq = si\->si_value.sival_ptr;
+ and the file descriptor would then be available via
+ ioReq\->aiocbp\->aio_fildes */
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct ioRequest *ioList;
+ struct aiocb *aiocbList;
+ struct sigaction sa;
+ int s, j;
+ int numReqs; /* Total number of queued I/O requests */
+ int openReqs; /* Number of I/O requests still in progress */
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s <pathname> <pathname>...\en",
+ argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ numReqs = argc \- 1;
+
+ /* Allocate our arrays */
+
+ ioList = calloc(numReqs, sizeof(struct ioRequest));
+ if (ioList == NULL)
+ errExit("calloc");
+
+ aiocbList = calloc(numReqs, sizeof(struct aiocb));
+ if (aiocbList == NULL)
+ errExit("calloc");
+
+ /* Establish handlers for SIGQUIT and the I/O completion signal */
+
+ sa.sa_flags = SA_RESTART;
+ sigemptyset(&sa.sa_mask);
+
+ sa.sa_handler = quitHandler;
+ if (sigaction(SIGQUIT, &sa, NULL) == \-1)
+ errExit("sigaction");
+
+ sa.sa_flags = SA_RESTART | SA_SIGINFO;
+ sa.sa_sigaction = aioSigHandler;
+ if (sigaction(IO_SIGNAL, &sa, NULL) == \-1)
+ errExit("sigaction");
+
+ /* Open each file specified on the command line, and queue
+ a read request on the resulting file descriptor */
+
+ for (j = 0; j < numReqs; j++) {
+ ioList[j].reqNum = j;
+ ioList[j].status = EINPROGRESS;
+ ioList[j].aiocbp = &aiocbList[j];
+
+ ioList[j].aiocbp\->aio_fildes = open(argv[j + 1], O_RDONLY);
+ if (ioList[j].aiocbp\->aio_fildes == \-1)
+ errExit("open");
+ printf("opened %s on descriptor %d\en", argv[j + 1],
+ ioList[j].aiocbp\->aio_fildes);
+
+ ioList[j].aiocbp\->aio_buf = malloc(BUF_SIZE);
+ if (ioList[j].aiocbp\->aio_buf == NULL)
+ errExit("malloc");
+
+ ioList[j].aiocbp\->aio_nbytes = BUF_SIZE;
+ ioList[j].aiocbp\->aio_reqprio = 0;
+ ioList[j].aiocbp\->aio_offset = 0;
+ ioList[j].aiocbp\->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+ ioList[j].aiocbp\->aio_sigevent.sigev_signo = IO_SIGNAL;
+ ioList[j].aiocbp\->aio_sigevent.sigev_value.sival_ptr =
+ &ioList[j];
+
+ s = aio_read(ioList[j].aiocbp);
+ if (s == \-1)
+ errExit("aio_read");
+ }
+
+ openReqs = numReqs;
+
+ /* Loop, monitoring status of I/O requests */
+
+ while (openReqs > 0) {
+ sleep(3); /* Delay between each monitoring step */
+
+ if (gotSIGQUIT) {
+
+ /* On receipt of SIGQUIT, attempt to cancel each of the
+ outstanding I/O requests, and display status returned
+ from the cancellation requests */
+
+ printf("got SIGQUIT; canceling I/O requests: \en");
+
+ for (j = 0; j < numReqs; j++) {
+ if (ioList[j].status == EINPROGRESS) {
+ printf(" Request %d on descriptor %d:", j,
+ ioList[j].aiocbp\->aio_fildes);
+ s = aio_cancel(ioList[j].aiocbp\->aio_fildes,
+ ioList[j].aiocbp);
+ if (s == AIO_CANCELED)
+ printf("I/O canceled\en");
+ else if (s == AIO_NOTCANCELED)
+ printf("I/O not canceled\en");
+ else if (s == AIO_ALLDONE)
+ printf("I/O all done\en");
+ else
+ errMsg("aio_cancel");
+ }
+ }
+
+ gotSIGQUIT = 0;
+ }
+
+ /* Check the status of each I/O request that is still
+ in progress */
+
+ printf("aio_error():\en");
+ for (j = 0; j < numReqs; j++) {
+ if (ioList[j].status == EINPROGRESS) {
+ printf(" for request %d (descriptor %d): ",
+ j, ioList[j].aiocbp\->aio_fildes);
+ ioList[j].status = aio_error(ioList[j].aiocbp);
+
+ switch (ioList[j].status) {
+ case 0:
+ printf("I/O succeeded\en");
+ break;
+ case EINPROGRESS:
+ printf("In progress\en");
+ break;
+ case ECANCELED:
+ printf("Canceled\en");
+ break;
+ default:
+ errMsg("aio_error");
+ break;
+ }
+
+ if (ioList[j].status != EINPROGRESS)
+ openReqs\-\-;
+ }
+ }
+ }
+
+ printf("All I/O requests completed\en");
+
+ /* Check status return of all I/O requests */
+
+ printf("aio_return():\en");
+ for (j = 0; j < numReqs; j++) {
+ ssize_t s;
+
+ s = aio_return(ioList[j].aiocbp);
+ printf(" for request %d (descriptor %d): %ld\en",
+ j, ioList[j].aiocbp\->aio_fildes, (long) s);
+ }
+
+ exit(EXIT_SUCCESS);
+}
+.fi
+.SH 関連項目
+.ad l
+\fBio_cancel\fP(2), \fBio_destroy\fP(2), \fBio_getevents\fP(2), \fBio_setup\fP(2),
+\fBio_submit\fP(2), \fBaio_cancel\fP(3), \fBaio_error\fP(3), \fBaio_init\fP(3),
+\fBaio_read\fP(3), \fBaio_return\fP(3), \fBaio_write\fP(3), \fBlio_listio\fP(3),
+http://www.squid\-cache.org/~adrian/Reprint\-Pulavarty\-OLS2003.pdf
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。