OSDN Git Service

75b39276ea296ccb62ac388c4237c36e032d16ce
[linuxjm/jm.git] / manual / LDP_man-pages / 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 2020\-06\-09 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 .PP
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(const pthread_attr_t *\fP\fIattr\fP\fB,\fP
47 \fB                          void **\fP\fIstackaddr\fP\fB, size_t *\fP\fIstacksize\fP\fB);\fP
48 .PP
49 \fI\-pthread\fP でコンパイルしてリンクする。
50 .fi
51 .PP
52 .RS -4
53 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
54 .RE
55 .PP
56 .ad l
57 \fBpthread_attr_getstack\fP(), \fBpthread_attr_setstack\fP():
58 .RS 4
59 _POSIX_C_SOURCE\ >=\ 200112L
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 .PP
70 \fIstackaddr\fP は、呼び出し側で割り当てた、大きさが \fIstacksize\fP バイトの
71 バッファー内の指定できる最小のアドレスバイトを指すべきである。
72 割り当てられたバッファーのページは読み書き両方が可能なページとなっている
73 べきである。
74 .PP
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 also documents an \fBEACCES\fP error if the stack area described by
92 \fIstackaddr\fP and \fIstacksize\fP is not both readable and writable by the
93 caller.
94 .SH バージョン
95 これらの関数は glibc バージョン 2.2 以降で提供されている。
96 .SH 属性
97 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
98 .TS
99 allbox;
100 lbw24 lb lb
101 l l l.
102 インターフェース        属性  値
103 T{
104 \fBpthread_attr_setstack\fP(),
105 \fBpthread_attr_getstack\fP()
106 T}      Thread safety   MT\-Safe
107 .TE
108 .SH 準拠
109 POSIX.1\-2001, POSIX.1\-2008.
110 .SH 注意
111 これらの関数は、スレッドのスタックが特定の場所に配置されることを保証
112 しなければならないアプリケーションのために提供されている。
113 ほとんどのアプリケーションでは、このようなことは必要なく、
114 これらの関数を使うのは避けるべきである。
115 (アプリケーションが単にスタックサイズだけをデフォルトの値から変更する
116 必要がある場合には \fBpthread_attr_setstacksize\fP(3) を使うこと)
117 .PP
118 アプリケーションが \fBpthread_attr_setstack\fP() を利用する際には、
119 スタックの割り当てに責任を持つ必要がある。
120 \fBpthread_attr_setguardsize\fP(3) を使って設定された
121 guard size の値は無視される。
122 必要と思われる場合は、アプリケーションが責任を持ってガード領域 (読み書
123 きが行われないように保護された 1 個かそれ以上のページ) の割り当てを行い、
124 スタックオーバーフローの可能性に対処するようにする必要がある。
125 .PP
126 \fIstackaddr\fP に指定するアドレスは適切なアライメントとなっているべきである。
127 完全な移植性を持たせるためには、
128 ページ境界 (\fIsysconf(_SC_PAGESIZE)\fP) に揃えること。
129 割り当てには \fBposix_memalign\fP(3) を使うとよい。
130 たいていは、 \fIstacksize\fP はシステムのページサイズの倍数とすべきである。
131 .PP
132 一つの \fIattr\fP を使って複数のスレッドを作成する場合、
133 \fBpthread_create\fP(3) の次の呼び出しを行う前に、
134 呼び出し側でスタックアドレス属性を変更しなければならない。
135 さもなければ、複数のスレッドがスタックとして同じメモリー領域を
136 使おうとするため、訳の分からない状況が発生してしまう。
137 .SH EXAMPLES
138 \fBpthread_attr_init\fP(3) を参照。
139 .SH 関連項目
140 .ad l
141 .nh
142 \fBmmap\fP(2), \fBmprotect\fP(2), \fBposix_memalign\fP(3), \fBpthread_attr_init\fP(3),
143 \fBpthread_attr_setguardsize\fP(3), \fBpthread_attr_setstackaddr\fP(3),
144 \fBpthread_attr_setstacksize\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
145 .SH この文書について
146 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
147 \%https://www.kernel.org/doc/man\-pages/ に書かれている。