OSDN Git Service

4b0b7859445be5276f234924a8f3edf51f1712b3
[linuxjm/LDP_man-pages.git] / release / man3 / pthread_self.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .TH PTHREAD_SELF 3 2008\-10\-24 Linux "Linux Programmer's Manual"
32 .SH 名前
33 pthread_self \- 呼び出したスレッドの ID を取得する
34 .SH 書式
35 .nf
36 \fB#include <pthread.h>\fP
37
38 \fBpthread_t pthread_self(void);\fP
39 .sp
40 \fI\-pthread\fP でコンパイルしてリンクする。
41 .fi
42 .SH 説明
43 \fBpthread_self\fP() 関数は、呼び出したスレッドの ID を返す。
44 得られる ID は、このスレッドが作成された \fBpthread_create\fP(3) の
45 呼び出しで \fI*thread\fP で返されるのと同じ値である。
46 .SH 返り値
47 この関数は常に成功し、呼び出したスレッドの ID を返す。
48 .SH エラー
49 この関数は常に成功する。
50 .SH 準拠
51 POSIX.1\-2001.
52 .SH 注意
53 POSIX.1 では、スレッド ID を表現するのに使用する型は、
54 スレッド実装が完全に自由に選択してよいことになっている。
55 例えば、スレッド ID を表現するのに数値型を使っても構造体を使ってもよい。
56 そのため、移植性を確保しつつ、 C 言語の等価演算子 (\fB==\fP) を使って、
57 \fIpthread_t\fP 型の変数の比較を行うことはできない。
58 代わりに \fBpthread_equal\fP(3) を使うこと。
59
60 スレッド識別子はその内部構造を意識すべきではない。
61 pthreads 関数以外でスレッド ID を利用しようとした場合、
62 移植性がなくなり、どのような結果が得られるかも分からない。
63
64 スレッド ID の一意性が保証されるのは、あるプロセス内においてのみである。
65 終了したスレッドが join されたり、
66 切り離された (detached) スレッドが終了されたりした後は、
67 そのスレッド ID は再利用されることがある。
68
69 \fBpthread_self\fP() が返すスレッド ID は、
70 \fBgettid\fP(2) が返すカーネルスレッド ID とは違うものである。
71 .SH 関連項目
72 \fBpthread_create\fP(3), \fBpthread_equal\fP(3), \fBpthreads\fP(7)
73 .SH この文書について
74 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
75 である。プロジェクトの説明とバグ報告に関する情報は
76 http://www.kernel.org/doc/man\-pages/ に書かれている。