1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"*******************************************************************
28 .\" This file was generated with po4a. Translate the source file.
30 .\"*******************************************************************
32 .\" Japanese Version Copyright (c) 2012 Akihiro MOTOKI
33 .\" all rights reserved.
34 .\" Translated 2012-05-03, Akihiro MOTOKI <amotoki@gmail.com>
36 .TH PTHREAD_ATTR_SETSTACK 3 2020\-06\-09 Linux "Linux Programmer's Manual"
38 pthread_attr_setstack, pthread_attr_getstack \-
39 スレッド属性オブジェクトのスタック属性の設定/取得を行う
42 \fB#include <pthread.h>\fP
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
49 \fI\-pthread\fP でコンパイルしてリンクする。
53 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
57 \fBpthread_attr_getstack\fP(), \fBpthread_attr_setstack\fP():
59 _POSIX_C_SOURCE\ >=\ 200112L
63 \fBpthread_attr_setstack\fP() 関数は、
64 \fIattr\fP が参照するスレッド属性オブジェクトのスタックアドレス属性と
65 スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP で
67 これらの属性により、スレッド属性オブジェクト \fIattr\fP を使って
68 作成されるスレッドが使用すべきスタックの位置とサイズが指定される。
70 \fIstackaddr\fP は、呼び出し側で割り当てた、大きさが \fIstacksize\fP バイトの
71 バッファー内の指定できる最小のアドレスバイトを指すべきである。
72 割り当てられたバッファーのページは読み書き両方が可能なページとなっている
75 \fBpthread_attr_getstack\fP() 関数は、
76 スレッド属性オブジェクト \fIattr\fP のスタックアドレス属性と
77 スタックサイズ属性をそれぞれ \fIstackaddr\fP と \fIstacksize\fP が
83 \fBpthread_attr_setstack\fP() は以下のエラーで失敗する場合がある。
86 \fIstacksize\fP が \fBPTHREAD_STACK_MIN\fP (16384) よりも小さい。
87 システムによっては、 \fIstackaddr\fP か
88 \fIstackaddr\ +\ stacksize\fP のアライメントが適切でない場合にも
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
95 これらの関数は glibc バージョン 2.2 以降で提供されている。
97 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
104 \fBpthread_attr_setstack\fP(),
105 \fBpthread_attr_getstack\fP()
106 T} Thread safety MT\-Safe
109 POSIX.1\-2001, POSIX.1\-2008.
111 これらの関数は、スレッドのスタックが特定の場所に配置されることを保証
112 しなければならないアプリケーションのために提供されている。
113 ほとんどのアプリケーションでは、このようなことは必要なく、
115 (アプリケーションが単にスタックサイズだけをデフォルトの値から変更する
116 必要がある場合には \fBpthread_attr_setstacksize\fP(3) を使うこと)
118 アプリケーションが \fBpthread_attr_setstack\fP() を利用する際には、
119 スタックの割り当てに責任を持つ必要がある。
120 \fBpthread_attr_setguardsize\fP(3) を使って設定された
122 必要と思われる場合は、アプリケーションが責任を持ってガード領域 (読み書
123 きが行われないように保護された 1 個かそれ以上のページ) の割り当てを行い、
124 スタックオーバーフローの可能性に対処するようにする必要がある。
126 \fIstackaddr\fP に指定するアドレスは適切なアライメントとなっているべきである。
128 ページ境界 (\fIsysconf(_SC_PAGESIZE)\fP) に揃えること。
129 割り当てには \fBposix_memalign\fP(3) を使うとよい。
130 たいていは、 \fIstacksize\fP はシステムのページサイズの倍数とすべきである。
132 一つの \fIattr\fP を使って複数のスレッドを作成する場合、
133 \fBpthread_create\fP(3) の次の呼び出しを行う前に、
134 呼び出し側でスタックアドレス属性を変更しなければならない。
135 さもなければ、複数のスレッドがスタックとして同じメモリー領域を
136 使おうとするため、訳の分からない状況が発生してしまう。
138 \fBpthread_attr_init\fP(3) を参照。
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)
146 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
147 \%https://www.kernel.org/doc/man\-pages/ に書かれている。