OSDN Git Service

(split) LDP: Restore and add Copyrights for draft pages
[linuxjm/LDP_man-pages.git] / draft / man3 / pthread_attr_setstack.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 .\"
32 .\" Japanese Version Copyright (c) 2012  Akihiro MOTOKI
33 .\"         all rights reserved.
34 .\" Translated 2012-05-03, Akihiro MOTOKI <amotoki@gmail.com>
35 .\"
36 .TH PTHREAD_ATTR_SETSTACK 3 2008\-10\-24 Linux "Linux Programmer's Manual"
37 .SH 名前
38 pthread_attr_setstack, pthread_attr_getstack \-
39 スレッド属性オブジェクトのスタック属性の設定/取得を行う
40 .SH 書式
41 .nf
42 \fB#include <pthread.h>\fP
43
44 \fBint pthread_attr_setstack(pthread_attr_t *\fP\fIattr\fP\fB,\fP
45 \fB                          void *\fP\fIstackaddr\fP\fB, size_t \fP\fIstacksize\fP\fB);\fP
46 \fBint pthread_attr_getstack(pthread_attr_t *\fP\fIattr\fP\fB,\fP
47 \fB                          void **\fP\fIstackaddr\fP\fB, size_t *\fP\fIstacksize\fP\fB);\fP
48 .sp
49 \fI\-pthread\fP でコンパイルしてリンクする。
50 .fi
51 .sp
52 .in -4n
53 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
54 .in
55 .sp
56 .ad l
57 \fBpthread_attr_getstack\fP(), \fBpthread_attr_setstack\fP():
58 .RS 4
59 _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
60 .RE
61 .ad b
62 .SH 説明
63 \fBpthread_attr_setstack\fP() 関数は、
64 \fIattr\fP が参照するスレッド属性オブジェクトのスタックアドレス属性と
65 スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP で
66 指定された値に設定する。
67 これらの属性により、スレッド属性オブジェクト \fIattr\fP を使って
68 作成されるスレッドが使用すべきスタックの位置とサイズが指定される。
69
70 \fIstackaddr\fP は、呼び出し側で割り当てた、大きさが \fIstacksize\fP バイトの
71 バッファ内の指定できる最小のアドレスバイトを指すべきである。
72 割り当てられたバッファのページは読み書き両方が可能なページとなっている
73 べきである。
74
75 \fBpthread_attr_getstack\fP() 関数は、
76 スレッド属性オブジェクト \fIattr\fP のスタックアドレス属性と
77 スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP が
78 指すバッファに入れて返す。
79 .SH 返り値
80 成功すると、これらの関数は 0 を返す。
81 エラーの場合、0 以外のエラー番号を返す。
82 .SH エラー
83 \fBpthread_attr_setstack\fP() は以下のエラーで失敗する場合がある。
84 .TP 
85 \fBEINVAL\fP
86 \fIstacksize\fP が \fBPTHREAD_STACK_MIN\fP (16384) よりも小さい。
87 システムによっては、 \fIstackaddr\fP か
88 \fIstackaddr\ +\ stacksize\fP のアライメントが適切でない場合にも
89 このエラーが発生する。
90 .PP
91 POSIX.1\-2001 では エラー \fBEACCES\fP も規定されており、
92 このエラーは \fIstackaddr\fP と \fIstacksize\fP で規定されるスタック領域に
93 呼び出し側から読み書き両方のアクセスができない状況を表す。
94 .SH バージョン
95 これらの関数は glibc バージョン 2.2 以降で提供されている。
96 .SH 準拠
97 POSIX.1\-2001.
98 .SH 注意
99 これらの関数は、スレッドのスタックが特定の場所に配置されることを保証
100 しなければならないアプリケーションのために提供されている。
101 ほとんどのアプリケーションでは、このようなことは必要なく、
102 これらの関数を使うのは避けるべきである。
103 (アプリケーションが単にスタックサイズだけをデフォルトの値から変更する
104 必要がある場合には \fBpthread_attr_setstacksize\fP(3) を使うこと)
105
106 アプリケーションが \fBpthread_attr_setstack\fP() を利用する際には、
107 スタックの割り当てに責任を持つ必要がある。
108 \fBpthread_attr_setguardsize\fP(3) を使って設定された
109 guard size の値は無視される。
110 必要と思われる場合は、アプリケーションが責任を持ってガード領域 (読み書
111 きが行われないように保護された 1 個かそれ以上のページ) の割り当てを行い、
112 スタックオーバーフローの可能性に対処するようにする必要がある。
113
114 \fIstackaddr\fP に指定するアドレスは適切なアライメントとなっているべきである。
115 完全な移植性を持たせるためには、
116 ページ境界 (\fIsysconf(_SC_PAGESIZE)\fP) に揃えること。
117 割り当てには \fBposix_memalign\fP(3) を使うとよい。
118 たいていは、 \fIstacksize\fP はシステムのページサイズの倍数とすべきである。
119
120 一つの \fIattr\fP を使って複数のスレッドを作成する場合、
121 \fBpthread_create\fP(3) の次の呼び出しを行う前に、
122 呼び出し側でスタックアドレス属性を変更しなければならない。
123 さもなければ、複数のスレッドがスタックとして同じメモリ領域を
124 使おうとするため、訳の分からない状況が発生してしまう。
125 .SH 例
126 \fBpthread_attr_init\fP(3) を参照。
127 .SH 関連項目
128 .ad l
129 .nh
130 \fBmmap\fP(2), \fBmprotect\fP(2), \fBposix_memalign\fP(3), \fBpthread_attr_init\fP(3),
131 \fBpthread_attr_setguardsize\fP(3), \fBpthread_attr_setstackaddr\fP(3),
132 \fBpthread_attr_setstacksize\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
133 .SH この文書について
134 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
135 である。プロジェクトの説明とバグ報告に関する情報は
136 http://www.kernel.org/doc/man\-pages/ に書かれている。