1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
8 "Project-Id-Version: PACKAGE VERSION\n"
9 "POT-Creation-Date: 2012-03-22 04:26+0900\n"
10 "PO-Revision-Date: 2012-03-22 03:49+0900\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
19 #: build/C/man2/getcontext.2:23
25 #: build/C/man2/getcontext.2:23
31 #: build/C/man2/getcontext.2:23 build/C/man3/pthread_attr_init.3:24
32 #: build/C/man3/pthread_attr_setaffinity_np.3:24
33 #: build/C/man3/pthread_attr_setdetachstate.3:24
34 #: build/C/man3/pthread_attr_setguardsize.3:24
35 #: build/C/man3/pthread_attr_setinheritsched.3:24
36 #: build/C/man3/pthread_attr_setschedparam.3:24
37 #: build/C/man3/pthread_attr_setschedpolicy.3:24
38 #: build/C/man3/pthread_attr_setscope.3:24
39 #: build/C/man3/pthread_attr_setstack.3:24
40 #: build/C/man3/pthread_attr_setstackaddr.3:24
41 #: build/C/man3/pthread_attr_setstacksize.3:24
42 #: build/C/man3/pthread_cancel.3:24 build/C/man3/pthread_cleanup_push.3:24
43 #: build/C/man3/pthread_cleanup_push_defer_np.3:24
44 #: build/C/man3/pthread_create.3:24 build/C/man3/pthread_detach.3:24
45 #: build/C/man3/pthread_equal.3:24 build/C/man3/pthread_exit.3:24
46 #: build/C/man3/pthread_getattr_np.3:24
47 #: build/C/man3/pthread_getcpuclockid.3:24 build/C/man3/pthread_join.3:24
48 #: build/C/man3/pthread_kill.3:24
49 #: build/C/man3/pthread_kill_other_threads_np.3:24
50 #: build/C/man3/pthread_self.3:24 build/C/man3/pthread_setaffinity_np.3:24
51 #: build/C/man3/pthread_setcancelstate.3:24
52 #: build/C/man3/pthread_setconcurrency.3:23
53 #: build/C/man3/pthread_setschedparam.3:24
54 #: build/C/man3/pthread_setschedprio.3:24 build/C/man3/pthread_sigmask.3:24
55 #: build/C/man3/pthread_sigqueue.3:23 build/C/man3/pthread_testcancel.3:24
56 #: build/C/man3/pthread_tryjoin_np.3:24 build/C/man3/pthread_yield.3:23
57 #: build/C/man7/pthreads.7:24
63 #: build/C/man2/getcontext.2:23 build/C/man3/makecontext.3:25
64 #: build/C/man3/pthread_attr_init.3:24
65 #: build/C/man3/pthread_attr_setaffinity_np.3:24
66 #: build/C/man3/pthread_attr_setdetachstate.3:24
67 #: build/C/man3/pthread_attr_setguardsize.3:24
68 #: build/C/man3/pthread_attr_setinheritsched.3:24
69 #: build/C/man3/pthread_attr_setschedparam.3:24
70 #: build/C/man3/pthread_attr_setschedpolicy.3:24
71 #: build/C/man3/pthread_attr_setscope.3:24
72 #: build/C/man3/pthread_attr_setstack.3:24
73 #: build/C/man3/pthread_attr_setstackaddr.3:24
74 #: build/C/man3/pthread_attr_setstacksize.3:24
75 #: build/C/man3/pthread_cancel.3:24 build/C/man3/pthread_cleanup_push.3:24
76 #: build/C/man3/pthread_cleanup_push_defer_np.3:24
77 #: build/C/man3/pthread_create.3:24 build/C/man3/pthread_detach.3:24
78 #: build/C/man3/pthread_equal.3:24 build/C/man3/pthread_exit.3:24
79 #: build/C/man3/pthread_getattr_np.3:24
80 #: build/C/man3/pthread_getcpuclockid.3:24 build/C/man3/pthread_join.3:24
81 #: build/C/man3/pthread_kill.3:24
82 #: build/C/man3/pthread_kill_other_threads_np.3:24
83 #: build/C/man3/pthread_self.3:24 build/C/man3/pthread_setaffinity_np.3:24
84 #: build/C/man3/pthread_setcancelstate.3:24
85 #: build/C/man3/pthread_setconcurrency.3:23
86 #: build/C/man3/pthread_setschedparam.3:24
87 #: build/C/man3/pthread_setschedprio.3:24 build/C/man3/pthread_sigmask.3:24
88 #: build/C/man3/pthread_sigqueue.3:23 build/C/man3/pthread_testcancel.3:24
89 #: build/C/man3/pthread_tryjoin_np.3:24 build/C/man3/pthread_yield.3:23
90 #: build/C/man7/pthreads.7:24
92 msgid "Linux Programmer's Manual"
93 msgstr "Linux Programmer's Manual"
96 #: build/C/man2/getcontext.2:24 build/C/man3/makecontext.3:26
97 #: build/C/man3/pthread_attr_init.3:25
98 #: build/C/man3/pthread_attr_setaffinity_np.3:25
99 #: build/C/man3/pthread_attr_setdetachstate.3:25
100 #: build/C/man3/pthread_attr_setguardsize.3:25
101 #: build/C/man3/pthread_attr_setinheritsched.3:25
102 #: build/C/man3/pthread_attr_setschedparam.3:25
103 #: build/C/man3/pthread_attr_setschedpolicy.3:25
104 #: build/C/man3/pthread_attr_setscope.3:25
105 #: build/C/man3/pthread_attr_setstack.3:25
106 #: build/C/man3/pthread_attr_setstackaddr.3:25
107 #: build/C/man3/pthread_attr_setstacksize.3:25
108 #: build/C/man3/pthread_cancel.3:25 build/C/man3/pthread_cleanup_push.3:25
109 #: build/C/man3/pthread_cleanup_push_defer_np.3:25
110 #: build/C/man3/pthread_create.3:25 build/C/man3/pthread_detach.3:25
111 #: build/C/man3/pthread_equal.3:25 build/C/man3/pthread_exit.3:25
112 #: build/C/man3/pthread_getattr_np.3:25
113 #: build/C/man3/pthread_getcpuclockid.3:25 build/C/man3/pthread_join.3:25
114 #: build/C/man3/pthread_kill.3:25
115 #: build/C/man3/pthread_kill_other_threads_np.3:25
116 #: build/C/man3/pthread_self.3:25 build/C/man3/pthread_setaffinity_np.3:25
117 #: build/C/man3/pthread_setcancelstate.3:25
118 #: build/C/man3/pthread_setconcurrency.3:24
119 #: build/C/man3/pthread_setschedparam.3:25
120 #: build/C/man3/pthread_setschedprio.3:25 build/C/man3/pthread_sigmask.3:25
121 #: build/C/man3/pthread_sigqueue.3:24 build/C/man3/pthread_testcancel.3:25
122 #: build/C/man3/pthread_tryjoin_np.3:25 build/C/man3/pthread_yield.3:24
123 #: build/C/man7/pthreads.7:25
129 #: build/C/man2/getcontext.2:26
130 msgid "getcontext, setcontext - get or set the user context"
131 msgstr "getcontext, setcontext - ユーザコンテキストを取得/設定する"
134 #: build/C/man2/getcontext.2:26 build/C/man3/makecontext.3:28
135 #: build/C/man3/pthread_attr_init.3:28
136 #: build/C/man3/pthread_attr_setaffinity_np.3:28
137 #: build/C/man3/pthread_attr_setdetachstate.3:28
138 #: build/C/man3/pthread_attr_setguardsize.3:28
139 #: build/C/man3/pthread_attr_setinheritsched.3:28
140 #: build/C/man3/pthread_attr_setschedparam.3:28
141 #: build/C/man3/pthread_attr_setschedpolicy.3:28
142 #: build/C/man3/pthread_attr_setscope.3:28
143 #: build/C/man3/pthread_attr_setstack.3:28
144 #: build/C/man3/pthread_attr_setstackaddr.3:28
145 #: build/C/man3/pthread_attr_setstacksize.3:28
146 #: build/C/man3/pthread_cancel.3:27 build/C/man3/pthread_cleanup_push.3:28
147 #: build/C/man3/pthread_cleanup_push_defer_np.3:28
148 #: build/C/man3/pthread_create.3:27 build/C/man3/pthread_detach.3:27
149 #: build/C/man3/pthread_equal.3:27 build/C/man3/pthread_exit.3:27
150 #: build/C/man3/pthread_getattr_np.3:27
151 #: build/C/man3/pthread_getcpuclockid.3:27 build/C/man3/pthread_join.3:27
152 #: build/C/man3/pthread_kill.3:27
153 #: build/C/man3/pthread_kill_other_threads_np.3:27
154 #: build/C/man3/pthread_self.3:27 build/C/man3/pthread_setaffinity_np.3:28
155 #: build/C/man3/pthread_setcancelstate.3:28
156 #: build/C/man3/pthread_setconcurrency.3:27
157 #: build/C/man3/pthread_setschedparam.3:28
158 #: build/C/man3/pthread_setschedprio.3:27 build/C/man3/pthread_sigmask.3:27
159 #: build/C/man3/pthread_sigqueue.3:26 build/C/man3/pthread_testcancel.3:27
160 #: build/C/man3/pthread_tryjoin_np.3:28 build/C/man3/pthread_yield.3:26
166 #: build/C/man2/getcontext.2:28 build/C/man3/makecontext.3:30
167 msgid "B<#include E<lt>ucontext.hE<gt>>"
168 msgstr "B<#include E<lt>ucontext.hE<gt>>"
171 #: build/C/man2/getcontext.2:30
172 msgid "B<int getcontext(ucontext_t *>I<ucp>B<);>"
173 msgstr "B<int getcontext(ucontext_t *>I<ucp>B<);>"
176 #: build/C/man2/getcontext.2:32
177 msgid "B<int setcontext(const ucontext_t *>I<ucp>B<);>"
178 msgstr "B<int setcontext(const ucontext_t *>I<ucp>B<);>"
181 #: build/C/man2/getcontext.2:32 build/C/man3/makecontext.3:35
182 #: build/C/man3/pthread_attr_init.3:36
183 #: build/C/man3/pthread_attr_setaffinity_np.3:39
184 #: build/C/man3/pthread_attr_setdetachstate.3:38
185 #: build/C/man3/pthread_attr_setguardsize.3:38
186 #: build/C/man3/pthread_attr_setinheritsched.3:38
187 #: build/C/man3/pthread_attr_setschedparam.3:38
188 #: build/C/man3/pthread_attr_setschedpolicy.3:38
189 #: build/C/man3/pthread_attr_setscope.3:38
190 #: build/C/man3/pthread_attr_setstack.3:52
191 #: build/C/man3/pthread_attr_setstackaddr.3:38
192 #: build/C/man3/pthread_attr_setstacksize.3:38
193 #: build/C/man3/pthread_cancel.3:34 build/C/man3/pthread_cleanup_push.3:37
194 #: build/C/man3/pthread_cleanup_push_defer_np.3:37
195 #: build/C/man3/pthread_create.3:36 build/C/man3/pthread_detach.3:35
196 #: build/C/man3/pthread_equal.3:34 build/C/man3/pthread_exit.3:34
197 #: build/C/man3/pthread_getattr_np.3:35
198 #: build/C/man3/pthread_getcpuclockid.3:35 build/C/man3/pthread_join.3:35
199 #: build/C/man3/pthread_kill.3:35
200 #: build/C/man3/pthread_kill_other_threads_np.3:33
201 #: build/C/man3/pthread_self.3:34 build/C/man3/pthread_setaffinity_np.3:39
202 #: build/C/man3/pthread_setcancelstate.3:36
203 #: build/C/man3/pthread_setconcurrency.3:35
204 #: build/C/man3/pthread_setschedparam.3:38
205 #: build/C/man3/pthread_setschedprio.3:34 build/C/man3/pthread_sigmask.3:36
206 #: build/C/man3/pthread_sigqueue.3:43 build/C/man3/pthread_testcancel.3:34
207 #: build/C/man3/pthread_tryjoin_np.3:40 build/C/man3/pthread_yield.3:34
208 #: build/C/man7/pthreads.7:27
214 #: build/C/man2/getcontext.2:44
216 "In a System V-like environment, one has the two types I<mcontext_t> and "
217 "I<ucontext_t> defined in I<E<lt>ucontext.hE<gt>> and the four functions "
218 "B<getcontext>(), B<setcontext>(), B<makecontext>(3) and B<swapcontext>(3) "
219 "that allow user-level context switching between multiple threads of control "
222 "System V 的な環境では、 I<mcontext_t> および I<ucontext_t> という 2 つの型"
223 "と、 B<getcontext>(), B<setcontext>(), B<makecontext>(3), B<swapcontext>(3) "
224 "という 4 つの関数が I<E<lt>ucontext.hE<gt>> で定義されており、あるプロセス内"
225 "部で制御下にある複数のスレッド間で、 ユーザレベルのコンテキスト切替えができる"
229 #: build/C/man2/getcontext.2:48
231 "The I<mcontext_t> type is machine-dependent and opaque. The I<ucontext_t> "
232 "type is a structure that has at least the following fields:"
234 "I<mcontext_t> 型はマシン依存で、外部からは隠蔽されている。 I<ucontext_t> 型は"
235 "構造体で、少なくとも以下の 4 つのフィールドを持つ。"
238 #: build/C/man2/getcontext.2:58
241 "typedef struct ucontext {\n"
242 " struct ucontext *uc_link;\n"
243 " sigset_t uc_sigmask;\n"
244 " stack_t uc_stack;\n"
245 " mcontext_t uc_mcontext;\n"
249 "typedef struct ucontext {\n"
250 " struct ucontext *uc_link;\n"
251 " sigset_t uc_sigmask;\n"
252 " stack_t uc_stack;\n"
253 " mcontext_t uc_mcontext;\n"
258 #: build/C/man2/getcontext.2:75
260 "with I<sigset_t> and I<stack_t> defined in I<E<lt>signal.hE<gt>>. Here "
261 "I<uc_link> points to the context that will be resumed when the current "
262 "context terminates (in case the current context was created using "
263 "B<makecontext>(3)), I<uc_sigmask> is the set of signals blocked in this "
264 "context (see B<sigprocmask>(2)), I<uc_stack> is the stack used by this "
265 "context (see B<sigaltstack>(2)), and I<uc_mcontext> is the machine-specific "
266 "representation of the saved context, that includes the calling thread's "
269 "I<sigset_t> と I<stack_t> は I<E<lt>signal.hE<gt>> で定義されている。 ここで "
270 "I<uc_link> は、 現在のコンテキストが終了したとき、 続いて切り替わるコンテキス"
271 "トへのポインタである (現在のコンテキストが B<makecontext>(3) で生成されたも"
272 "のの場合)。 I<uc_sigmask> はこのコンテキストでブロックされている シグナル群で"
273 "ある (B<sigprocmask>(2) を見よ)。 I<uc_stack> はこのコンテキストが用いている"
274 "スタックである (B<signalstack>(2) を見よ)。 I<uc_mcontext> は保存されている"
275 "コンテキストの マシン特有の表現形式であり、 ここには呼び出したスレッドのマシ"
279 #: build/C/man2/getcontext.2:80
281 "The function B<getcontext>() initializes the structure pointed at by I<ucp> "
282 "to the currently active context."
284 "B<getcontext>() 関数は、 ポインタ I<ucp> が指す構造体を、 現在アクティブなコ"
288 #: build/C/man2/getcontext.2:92
290 "The function B<setcontext>() restores the user context pointed at by "
291 "I<ucp>. A successful call does not return. The context should have been "
292 "obtained by a call of B<getcontext>(), or B<makecontext>(3), or passed as "
293 "third argument to a signal handler."
295 "B<setcontext>() 関数は、ポインタ I<ucp> が指すユーザコンテキストをリストアす"
296 "る。 呼び出しに成功すると返らない。 このコンテキストは、以前に B<getcontext>"
297 "() または B<makecontext>(3) で得られたものか、 あるいはシグナルの第三引数と"
301 #: build/C/man2/getcontext.2:96
303 "If the context was obtained by a call of B<getcontext>(), program execution "
304 "continues as if this call just returned."
306 "コンテキストが B<getcontext>() の呼び出しによって得られていたものの場合は、 "
307 "プログラムはこの呼び出しから返った直後からのように実行を継続する。"
310 #: build/C/man2/getcontext.2:107
312 "If the context was obtained by a call of B<makecontext>(3), program "
313 "execution continues by a call to the function I<func> specified as the "
314 "second argument of that call to B<makecontext>(3). When the function "
315 "I<func> returns, we continue with the I<uc_link> member of the structure "
316 "I<ucp> specified as the first argument of that call to B<makecontext>(3). "
317 "When this member is NULL, the thread exits."
319 "コンテキストが B<makecontext>(3) の呼び出しによって得られていたものの場合"
320 "は、 プログラムの実行はその B<makecontext>(3) 呼び出しの第二引数で指定された"
321 "関数 I<func> を呼び出すかたちで継続する。 I<func> から返ると、 B<makecontext>"
322 "(3) 呼び出しの第一引数で指定されていた I<ucp> 構造体の I<uc_link> メンバで継"
323 "続する。 このメンバが NULL だった場合は、そのスレッドは終了する。"
326 #: build/C/man2/getcontext.2:114
328 "If the context was obtained by a call to a signal handler, then old standard "
329 "text says that \"program execution continues with the program instruction "
330 "following the instruction interrupted by the signal\". However, this "
331 "sentence was removed in SUSv2, and the present verdict is \"the result is "
334 "コンテキストがシグナルハンドラの呼び出しによって得られていたものの場合は、 古"
335 "い標準によれば 「プログラムの実行はシグナルによって割り込まれた命令の次の命令"
336 "から継続される」。 しかしこの文は SUSv2 で削除されたので、 現在の判断は「結果"
340 #: build/C/man2/getcontext.2:114 build/C/man3/makecontext.3:81
341 #: build/C/man3/pthread_attr_init.3:65
342 #: build/C/man3/pthread_attr_setaffinity_np.3:73
343 #: build/C/man3/pthread_attr_setdetachstate.3:74
344 #: build/C/man3/pthread_attr_setguardsize.3:87
345 #: build/C/man3/pthread_attr_setinheritsched.3:81
346 #: build/C/man3/pthread_attr_setschedparam.3:71
347 #: build/C/man3/pthread_attr_setschedpolicy.3:69
348 #: build/C/man3/pthread_attr_setscope.3:88
349 #: build/C/man3/pthread_attr_setstack.3:83
350 #: build/C/man3/pthread_attr_setstackaddr.3:71
351 #: build/C/man3/pthread_attr_setstacksize.3:58
352 #: build/C/man3/pthread_cancel.3:106 build/C/man3/pthread_cleanup_push.3:116
353 #: build/C/man3/pthread_create.3:113 build/C/man3/pthread_detach.3:47
354 #: build/C/man3/pthread_equal.3:38 build/C/man3/pthread_exit.3:68
355 #: build/C/man3/pthread_getattr_np.3:70
356 #: build/C/man3/pthread_getcpuclockid.3:43 build/C/man3/pthread_join.3:68
357 #: build/C/man3/pthread_kill.3:50 build/C/man3/pthread_self.3:43
358 #: build/C/man3/pthread_setaffinity_np.3:74
359 #: build/C/man3/pthread_setcancelstate.3:89
360 #: build/C/man3/pthread_setconcurrency.3:53
361 #: build/C/man3/pthread_setschedparam.3:101
362 #: build/C/man3/pthread_setschedprio.3:50 build/C/man3/pthread_sigmask.3:47
363 #: build/C/man3/pthread_sigqueue.3:63 build/C/man3/pthread_testcancel.3:47
364 #: build/C/man3/pthread_tryjoin_np.3:83 build/C/man3/pthread_yield.3:41
370 #: build/C/man2/getcontext.2:122
372 "When successful, B<getcontext>() returns 0 and B<setcontext>() does not "
373 "return. On error, both return -1 and set I<errno> appropriately."
375 "成功すると、 B<getcontext>() は 0 を返し、 B<setcontext>() は返らない。 失"
376 "敗すると、両者とも -1 を返し、I<errno> をエラーに応じて設定する。"
379 #: build/C/man2/getcontext.2:122 build/C/man3/makecontext.3:93
380 #: build/C/man3/pthread_attr_init.3:68
381 #: build/C/man3/pthread_attr_setaffinity_np.3:76
382 #: build/C/man3/pthread_attr_setdetachstate.3:77
383 #: build/C/man3/pthread_attr_setguardsize.3:90
384 #: build/C/man3/pthread_attr_setinheritsched.3:84
385 #: build/C/man3/pthread_attr_setschedparam.3:74
386 #: build/C/man3/pthread_attr_setschedpolicy.3:72
387 #: build/C/man3/pthread_attr_setscope.3:91
388 #: build/C/man3/pthread_attr_setstack.3:86
389 #: build/C/man3/pthread_attr_setstackaddr.3:74
390 #: build/C/man3/pthread_attr_setstacksize.3:61
391 #: build/C/man3/pthread_cancel.3:111 build/C/man3/pthread_cleanup_push.3:118
392 #: build/C/man3/pthread_create.3:120 build/C/man3/pthread_detach.3:52
393 #: build/C/man3/pthread_equal.3:42 build/C/man3/pthread_exit.3:70
394 #: build/C/man3/pthread_getattr_np.3:73
395 #: build/C/man3/pthread_getcpuclockid.3:46 build/C/man3/pthread_join.3:73
396 #: build/C/man3/pthread_kill.3:55 build/C/man3/pthread_self.3:45
397 #: build/C/man3/pthread_setaffinity_np.3:77
398 #: build/C/man3/pthread_setcancelstate.3:92
399 #: build/C/man3/pthread_setconcurrency.3:65
400 #: build/C/man3/pthread_setschedparam.3:109
401 #: build/C/man3/pthread_setschedprio.3:58 build/C/man3/pthread_sigmask.3:52
402 #: build/C/man3/pthread_sigqueue.3:68 build/C/man3/pthread_testcancel.3:51
403 #: build/C/man3/pthread_tryjoin_np.3:87 build/C/man3/pthread_yield.3:46
409 #: build/C/man2/getcontext.2:124
410 msgid "None defined."
414 #: build/C/man2/getcontext.2:124 build/C/man3/makecontext.3:102
415 #: build/C/man3/pthread_attr_init.3:76
416 #: build/C/man3/pthread_attr_setaffinity_np.3:105
417 #: build/C/man3/pthread_attr_setdetachstate.3:84
418 #: build/C/man3/pthread_attr_setguardsize.3:103
419 #: build/C/man3/pthread_attr_setinheritsched.3:98
420 #: build/C/man3/pthread_attr_setschedparam.3:86
421 #: build/C/man3/pthread_attr_setschedpolicy.3:86
422 #: build/C/man3/pthread_attr_setscope.3:104
423 #: build/C/man3/pthread_attr_setstack.3:110
424 #: build/C/man3/pthread_attr_setstackaddr.3:80
425 #: build/C/man3/pthread_attr_setstacksize.3:80
426 #: build/C/man3/pthread_cancel.3:119 build/C/man3/pthread_cleanup_push.3:122
427 #: build/C/man3/pthread_cleanup_push_defer_np.3:98
428 #: build/C/man3/pthread_create.3:144 build/C/man3/pthread_detach.3:62
429 #: build/C/man3/pthread_equal.3:44 build/C/man3/pthread_exit.3:72
430 #: build/C/man3/pthread_getattr_np.3:95
431 #: build/C/man3/pthread_getcpuclockid.3:62 build/C/man3/pthread_join.3:96
432 #: build/C/man3/pthread_kill.3:64
433 #: build/C/man3/pthread_kill_other_threads_np.3:45
434 #: build/C/man3/pthread_self.3:47 build/C/man3/pthread_setaffinity_np.3:118
435 #: build/C/man3/pthread_setcancelstate.3:110
436 #: build/C/man3/pthread_setconcurrency.3:80
437 #: build/C/man3/pthread_setschedparam.3:138
438 #: build/C/man3/pthread_setschedprio.3:80 build/C/man3/pthread_sigmask.3:55
439 #: build/C/man3/pthread_sigqueue.3:91 build/C/man3/pthread_testcancel.3:55
440 #: build/C/man3/pthread_tryjoin_np.3:110 build/C/man3/pthread_yield.3:50
442 msgid "CONFORMING TO"
446 #: build/C/man2/getcontext.2:130
448 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specification of B<getcontext>"
449 "(), citing portability issues, and recommending that applications be "
450 "rewritten to use POSIX threads instead."
452 "SUSv2, POSIX.1-2001. POSIX.1-2008 では、移植性の問題から B<getcontext>() の"
453 "仕様が削除された。 代わりに、アプリケーションを POSIX スレッドを使って書き直"
457 #: build/C/man2/getcontext.2:130 build/C/man3/makecontext.3:110
458 #: build/C/man3/pthread_attr_init.3:78
459 #: build/C/man3/pthread_attr_setaffinity_np.3:108
460 #: build/C/man3/pthread_attr_setdetachstate.3:86
461 #: build/C/man3/pthread_attr_setguardsize.3:105
462 #: build/C/man3/pthread_attr_setschedparam.3:91
463 #: build/C/man3/pthread_attr_setscope.3:106
464 #: build/C/man3/pthread_attr_setstack.3:112
465 #: build/C/man3/pthread_attr_setstackaddr.3:83
466 #: build/C/man3/pthread_attr_setstacksize.3:85
467 #: build/C/man3/pthread_cancel.3:121 build/C/man3/pthread_cleanup_push.3:124
468 #: build/C/man3/pthread_create.3:146 build/C/man3/pthread_detach.3:64
469 #: build/C/man3/pthread_equal.3:46 build/C/man3/pthread_exit.3:74
470 #: build/C/man3/pthread_getcpuclockid.3:64 build/C/man3/pthread_join.3:98
471 #: build/C/man3/pthread_kill.3:66
472 #: build/C/man3/pthread_kill_other_threads_np.3:48
473 #: build/C/man3/pthread_self.3:49 build/C/man3/pthread_setaffinity_np.3:121
474 #: build/C/man3/pthread_setcancelstate.3:112
475 #: build/C/man3/pthread_setconcurrency.3:82
476 #: build/C/man3/pthread_setschedparam.3:140
477 #: build/C/man3/pthread_setschedprio.3:82 build/C/man3/pthread_sigmask.3:57
478 #: build/C/man3/pthread_yield.3:56
484 #: build/C/man2/getcontext.2:147
486 "The earliest incarnation of this mechanism was the B<setjmp>(3)/B<longjmp>"
487 "(3) mechanism. Since that does not define the handling of the signal "
488 "context, the next stage was the B<sigsetjmp>(3)/B<siglongjmp>(3) pair. The "
489 "present mechanism gives much more control. On the other hand, there is no "
490 "easy way to detect whether a return from B<getcontext>() is from the first "
491 "call, or via a B<setcontext>() call. The user has to invent her own "
492 "bookkeeping device, and a register variable won't do since registers are "
495 "このメカニズムの最古の実装は、 B<setjmp>(3)/B<longjmp>(3) 機構であった。 こ"
496 "れらにはシグナルコンテキストの取り扱いが定義されていなかったので、 次の段階で"
497 "は B<sigsetjmp>(3)/B<siglongjmp>(3) のペアが現われた。 現在の機構ではずっと"
498 "細かな制御ができる。 一方 B<getcontext>() から返ったとき、 これが最初の呼び"
499 "出しであったか、 それとも B<setcontext>() 呼び出しからのものであるかを 区別"
500 "する容易な方法がなくなってしまった。 ユーザは「しおり」機構を自分で作らなけれ"
501 "ばならない。 レジスタ変数は (レジスタはリストアされてしまうので) これをやって"
505 #: build/C/man2/getcontext.2:158
507 "When a signal occurs, the current user context is saved and a new context is "
508 "created by the kernel for the signal handler. Do not leave the handler "
509 "using B<longjmp>(3): it is undefined what would happen with contexts. Use "
510 "B<siglongjmp>(3) or B<setcontext>() instead."
512 "シグナルが発生すると、 現在のユーザコンテキストは保存され、 シグナルハンドラ"
513 "用のコンテキストがカーネルによって生成される。 今後はハンドラに B<longjmp>"
514 "(3) を使わせないこと: この関数のコンテキスト下での動作は定義されていない。 "
515 "代わりに B<siglongjmp>(3) か B<setcontext>() を使うこと。"
518 #: build/C/man2/getcontext.2:158 build/C/man3/makecontext.3:217
519 #: build/C/man3/pthread_attr_init.3:294
520 #: build/C/man3/pthread_attr_setaffinity_np.3:115
521 #: build/C/man3/pthread_attr_setdetachstate.3:108
522 #: build/C/man3/pthread_attr_setguardsize.3:155
523 #: build/C/man3/pthread_attr_setinheritsched.3:119
524 #: build/C/man3/pthread_attr_setschedparam.3:95
525 #: build/C/man3/pthread_attr_setschedpolicy.3:91
526 #: build/C/man3/pthread_attr_setscope.3:117
527 #: build/C/man3/pthread_attr_setstack.3:154
528 #: build/C/man3/pthread_attr_setstackaddr.3:107
529 #: build/C/man3/pthread_attr_setstacksize.3:108
530 #: build/C/man3/pthread_cancel.3:220 build/C/man3/pthread_cleanup_push.3:308
531 #: build/C/man3/pthread_cleanup_push_defer_np.3:101
532 #: build/C/man3/pthread_create.3:367 build/C/man3/pthread_detach.3:95
533 #: build/C/man3/pthread_equal.3:53 build/C/man3/pthread_exit.3:102
534 #: build/C/man3/pthread_getattr_np.3:342
535 #: build/C/man3/pthread_getcpuclockid.3:166 build/C/man3/pthread_join.3:125
536 #: build/C/man3/pthread_kill.3:73
537 #: build/C/man3/pthread_kill_other_threads_np.3:64
538 #: build/C/man3/pthread_self.3:73 build/C/man3/pthread_setaffinity_np.3:203
539 #: build/C/man3/pthread_setcancelstate.3:174
540 #: build/C/man3/pthread_setconcurrency.3:97
541 #: build/C/man3/pthread_setschedparam.3:428
542 #: build/C/man3/pthread_setschedprio.3:88 build/C/man3/pthread_sigmask.3:133
543 #: build/C/man3/pthread_sigqueue.3:93 build/C/man3/pthread_testcancel.3:60
544 #: build/C/man3/pthread_tryjoin_np.3:133 build/C/man3/pthread_yield.3:59
545 #: build/C/man7/pthreads.7:893
551 #: build/C/man2/getcontext.2:165
553 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<longjmp>(3), "
554 "B<makecontext>(3), B<sigsetjmp>(3)"
556 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<longjmp>(3), "
557 "B<makecontext>(3), B<sigsetjmp>(3)"
560 #: build/C/man2/getcontext.2:165 build/C/man3/makecontext.3:223
561 #: build/C/man3/pthread_attr_init.3:308
562 #: build/C/man3/pthread_attr_setaffinity_np.3:121
563 #: build/C/man3/pthread_attr_setdetachstate.3:114
564 #: build/C/man3/pthread_attr_setguardsize.3:163
565 #: build/C/man3/pthread_attr_setinheritsched.3:128
566 #: build/C/man3/pthread_attr_setschedparam.3:105
567 #: build/C/man3/pthread_attr_setschedpolicy.3:100
568 #: build/C/man3/pthread_attr_setscope.3:125
569 #: build/C/man3/pthread_attr_setstack.3:164
570 #: build/C/man3/pthread_attr_setstackaddr.3:113
571 #: build/C/man3/pthread_attr_setstacksize.3:115
572 #: build/C/man3/pthread_cancel.3:230 build/C/man3/pthread_cleanup_push.3:314
573 #: build/C/man3/pthread_cleanup_push_defer_np.3:107
574 #: build/C/man3/pthread_create.3:378 build/C/man3/pthread_detach.3:102
575 #: build/C/man3/pthread_equal.3:57 build/C/man3/pthread_exit.3:106
576 #: build/C/man3/pthread_getattr_np.3:356
577 #: build/C/man3/pthread_getcpuclockid.3:174 build/C/man3/pthread_join.3:132
578 #: build/C/man3/pthread_kill.3:82
579 #: build/C/man3/pthread_kill_other_threads_np.3:70
580 #: build/C/man3/pthread_self.3:77 build/C/man3/pthread_setaffinity_np.3:211
581 #: build/C/man3/pthread_setcancelstate.3:179
582 #: build/C/man3/pthread_setconcurrency.3:100
583 #: build/C/man3/pthread_setschedparam.3:440
584 #: build/C/man3/pthread_setschedprio.3:100 build/C/man3/pthread_sigmask.3:142
585 #: build/C/man3/pthread_sigqueue.3:101 build/C/man3/pthread_testcancel.3:65
586 #: build/C/man3/pthread_tryjoin_np.3:138 build/C/man3/pthread_yield.3:63
587 #: build/C/man7/pthreads.7:927
593 #: build/C/man2/getcontext.2:172 build/C/man3/makecontext.3:230
594 #: build/C/man3/pthread_attr_init.3:315
595 #: build/C/man3/pthread_attr_setaffinity_np.3:128
596 #: build/C/man3/pthread_attr_setdetachstate.3:121
597 #: build/C/man3/pthread_attr_setguardsize.3:170
598 #: build/C/man3/pthread_attr_setinheritsched.3:135
599 #: build/C/man3/pthread_attr_setschedparam.3:112
600 #: build/C/man3/pthread_attr_setschedpolicy.3:107
601 #: build/C/man3/pthread_attr_setscope.3:132
602 #: build/C/man3/pthread_attr_setstack.3:171
603 #: build/C/man3/pthread_attr_setstackaddr.3:120
604 #: build/C/man3/pthread_attr_setstacksize.3:122
605 #: build/C/man3/pthread_cancel.3:237 build/C/man3/pthread_cleanup_push.3:321
606 #: build/C/man3/pthread_cleanup_push_defer_np.3:114
607 #: build/C/man3/pthread_create.3:385 build/C/man3/pthread_detach.3:109
608 #: build/C/man3/pthread_equal.3:64 build/C/man3/pthread_exit.3:113
609 #: build/C/man3/pthread_getattr_np.3:363
610 #: build/C/man3/pthread_getcpuclockid.3:181 build/C/man3/pthread_join.3:139
611 #: build/C/man3/pthread_kill.3:89
612 #: build/C/man3/pthread_kill_other_threads_np.3:77
613 #: build/C/man3/pthread_self.3:84 build/C/man3/pthread_setaffinity_np.3:218
614 #: build/C/man3/pthread_setcancelstate.3:186
615 #: build/C/man3/pthread_setconcurrency.3:107
616 #: build/C/man3/pthread_setschedparam.3:447
617 #: build/C/man3/pthread_setschedprio.3:107 build/C/man3/pthread_sigmask.3:149
618 #: build/C/man3/pthread_sigqueue.3:108 build/C/man3/pthread_testcancel.3:72
619 #: build/C/man3/pthread_tryjoin_np.3:145 build/C/man3/pthread_yield.3:70
620 #: build/C/man7/pthreads.7:934
622 "This page is part of release 3.37 of the Linux I<man-pages> project. A "
623 "description of the project, and information about reporting bugs, can be "
624 "found at http://www.kernel.org/doc/man-pages/."
628 #: build/C/man3/makecontext.3:25
634 #: build/C/man3/makecontext.3:25
640 #: build/C/man3/makecontext.3:25
646 #: build/C/man3/makecontext.3:28
647 msgid "makecontext, swapcontext - manipulate user context"
648 msgstr "makecontext, swapcontext - ユーザコンテキストを操作する"
651 #: build/C/man3/makecontext.3:33
653 "B<void makecontext(ucontext_t *>I<ucp>B<, void (*>I<func>B<)(),> B<int "
656 "B<void makecontext(ucontext_t *>I<ucp>B<, void (*>I<func>B<)(),> B<int "
660 #: build/C/man3/makecontext.3:35
661 msgid "B<int swapcontext(ucontext_t *>I<oucp>B<, ucontext_t *>I<ucp>B<);>"
662 msgstr "B<int swapcontext(ucontext_t *>I<oucp>B<, ucontext_t *>I<ucp>B<);>"
665 #: build/C/man3/makecontext.3:46
667 "In a System V-like environment, one has the type I<ucontext_t> defined in "
668 "I<E<lt>ucontext.hE<gt>> and the four functions B<getcontext>(2), "
669 "B<setcontext>(2), B<makecontext>() and B<swapcontext>() that allow user-"
670 "level context switching between multiple threads of control within a process."
672 "System V 的な環境では、 B<mcontext_t> および B<ucontext_t> という 2 つの型"
673 "と、 B<getcontext>(2), B<setcontext>(2), B<makecontext>(), B<swapcontext>() "
674 "という 4 つの関数が I<E<lt>ucontext.hE<gt>> で定義されており、あるプロセス内"
675 "部で制御下にある複数のスレッド間で、 ユーザレベルのコンテキスト切替えができる"
679 #: build/C/man3/makecontext.3:49
680 msgid "For the type and the first two functions, see B<getcontext>(2)."
682 "これらの型と、最初の 2 つの関数については、 B<getcontext>(2) を参照のこと。"
685 #: build/C/man3/makecontext.3:61
687 "The B<makecontext>() function modifies the context pointed to by I<ucp> "
688 "(which was obtained from a call to B<getcontext>(2)). Before invoking "
689 "B<makecontext>(), the caller must allocate a new stack for this context and "
690 "assign its address to I<ucp-E<gt>uc_stack>, and define a successor context "
691 "and assign its address to I<ucp-E<gt>uc_link>."
693 "B<makecontext>() 関数は、ポインタ I<ucp> が指すコンテキストを変更する "
694 "(I<ucp> は以前の B<getcontext>(2) 呼び出しで得られたものである)。 "
695 "B<makecontext>() を起動する前には、呼び出し者は、このコンテキスト用に 新しい"
696 "スタックを確保し、そのアドレスを I<ucp-E<gt>uc_stack> に代入し、 さらに後継の"
697 "コンテキストを定義し、そのアドレスを I<ucp-E<gt>uc_link> に 代入しなければな"
701 #: build/C/man3/makecontext.3:75
703 "When this context is later activated (using B<setcontext>(2) or "
704 "B<swapcontext>()) the function I<func> is called, and passed the series of "
705 "integer (I<int>) arguments that follow I<argc>; the caller must specify the "
706 "number of these arguments in I<argc>. When this function returns, the "
707 "successor context is activated. If the successor context pointer is NULL, "
710 "このコンテキストが将来 (B<setcontext>(2) または B<swapcontext>() によっ"
711 "て) 有効にされると、関数 I<func> が呼ばれ、 引き数として I<argc> 以降の整数 "
712 "(I<int>) 引き数の列が渡される。 呼び出し者は I<argc> にこれらの引き数の個数"
713 "を指定しなければならない。 この関数が戻ると、後継のコンテキストが有効にな"
714 "る。 後継コンテキストのポインタが NULL の場合、そのスレッドが終了する。"
717 #: build/C/man3/makecontext.3:81
719 "The B<swapcontext>() function saves the current context in the structure "
720 "pointed to by I<oucp>, and then activates the context pointed to by I<ucp>."
722 "B<swapcontext>() 関数は現在のコンテキストを ポインタ I<oucp> が指す構造体に"
723 "保存し、 ポインタ I<ucp> が指すコンテキストを有効にする。"
726 #: build/C/man3/makecontext.3:93
728 "When successful, B<swapcontext>() does not return. (But we may return "
729 "later, in case I<oucp> is activated, in which case it looks like "
730 "B<swapcontext>() returns 0.) On error, B<swapcontext>() returns -1 and "
731 "sets I<errno> appropriately."
733 "成功すると、 B<swapcontext>() は返らない (しかし後に I<oucp> が有効になった"
734 "場合には返ることがある。 このときには B<swapcontext>() は 0 を返すように見え"
735 "る。) 失敗すると、 B<swapcontext>() は -1 を返し、 I<errno> をエラーに応じ"
739 #: build/C/man3/makecontext.3:94 build/C/man3/pthread_attr_setaffinity_np.3:99
740 #: build/C/man3/pthread_getattr_np.3:74
746 #: build/C/man3/makecontext.3:97
747 msgid "Insufficient stack space left."
748 msgstr "スタックに割り当てる空間が残っていない。"
751 #: build/C/man3/makecontext.3:97
752 #: build/C/man3/pthread_attr_setaffinity_np.3:103
753 #: build/C/man3/pthread_attr_setguardsize.3:101
754 #: build/C/man3/pthread_attr_setstack.3:108
755 #: build/C/man3/pthread_attr_setstackaddr.3:78
756 #: build/C/man3/pthread_attr_setstacksize.3:78
757 #: build/C/man3/pthread_getattr_np.3:93
758 #: build/C/man3/pthread_getcpuclockid.3:60
759 #: build/C/man3/pthread_setaffinity_np.3:116
760 #: build/C/man3/pthread_setconcurrency.3:78
761 #: build/C/man3/pthread_setschedprio.3:78 build/C/man3/pthread_sigqueue.3:87
762 #: build/C/man3/pthread_tryjoin_np.3:108
768 #: build/C/man3/makecontext.3:102
770 "B<makecontext>() and B<swapcontext>() are provided in glibc since version "
773 "B<makecontext>() と B<swapcontext>() は、バージョン 2.1 以降の glibc で提供"
777 #: build/C/man3/makecontext.3:110
779 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specifications of "
780 "B<makecontext>() and B<swapcontext>(), citing portability issues, and "
781 "recommending that applications be rewritten to use POSIX threads instead."
783 "SUSv2, POSIX.1-2001. POSIX.1-2008 では、移植性の問題から B<makecontext>() "
784 "と B<swapcontext>() の仕様が削除されている。 代わりに、アプリケーションを "
785 "POSIX スレッドを使って書き直すことが 推奨されている。"
788 #: build/C/man3/makecontext.3:118
790 "The interpretation of I<ucp-E<gt>uc_stack> is just as in B<sigaltstack>(2), "
791 "namely, this struct contains the start and length of a memory area to be "
792 "used as the stack, regardless of the direction of growth of the stack. "
793 "Thus, it is not necessary for the user program to worry about this direction."
795 "I<ucp-E<gt>uc_stack> の解釈は B<sigaltstack>(2) の場合と同じである。 すなわ"
796 "ちこの構造体には、 スタックとして用いられるメモリ領域の開始アドレスと長さが含"
797 "まれ、 これはスタックが伸びる方向がどちらであるかには関係しない。 したがっ"
798 "て、ユーザプログラムはこの件については心配しなくてよい。"
801 #: build/C/man3/makecontext.3:134
803 "On architectures where I<int> and pointer types are the same size (e.g., "
804 "x86-32, where both types are 32 bits), you may be able to get away with "
805 "passing pointers as arguments to B<makecontext>() following I<argc>. "
806 "However, doing this is not guaranteed to be portable, is undefined according "
807 "to the standards, and won't work on architectures where pointers are larger "
808 "than I<int>s. Nevertheless, starting with version 2.8, glibc makes some "
809 "changes to B<makecontext>(), to permit this on some 64-bit architectures (e."
812 "I<int> とポインタ型が同じ大きさであるアーキテクチャでは (x86-32 はその例であ"
813 "り、両方の型とも 32 ビットである)、 B<makecontext>() の I<argc> 以降の引き数"
814 "としてポインタを渡してもうまく動くかもしれない。 しかしながら、このようにする"
815 "と、移植性は保証されず、 標準に従えば動作は未定義であり、ポインタが I<int> よ"
816 "りも大きいアーキテクチャでは正しく動作しないことだろう。 それにも関わらず、"
817 "バージョン 2.8 以降の glibc では、 B<makecontext>() に変更が行われ、(x86-64 "
818 "などの) いくつかの 64 ビットアーキテクチャで 引き数としてポインタを渡すことが"
822 #: build/C/man3/makecontext.3:134 build/C/man3/pthread_attr_init.3:84
823 #: build/C/man3/pthread_attr_setdetachstate.3:105
824 #: build/C/man3/pthread_attr_setguardsize.3:152
825 #: build/C/man3/pthread_attr_setinheritsched.3:100
826 #: build/C/man3/pthread_attr_setschedparam.3:88
827 #: build/C/man3/pthread_attr_setschedpolicy.3:88
828 #: build/C/man3/pthread_attr_setstack.3:151
829 #: build/C/man3/pthread_attr_setstacksize.3:82
830 #: build/C/man3/pthread_cancel.3:129 build/C/man3/pthread_cleanup_push.3:148
831 #: build/C/man3/pthread_create.3:194 build/C/man3/pthread_detach.3:91
832 #: build/C/man3/pthread_getattr_np.3:98
833 #: build/C/man3/pthread_getcpuclockid.3:75 build/C/man3/pthread_join.3:122
834 #: build/C/man3/pthread_setaffinity_np.3:151
835 #: build/C/man3/pthread_setcancelstate.3:171
836 #: build/C/man3/pthread_setschedparam.3:146 build/C/man3/pthread_sigmask.3:59
837 #: build/C/man3/pthread_testcancel.3:57 build/C/man3/pthread_tryjoin_np.3:113
843 #: build/C/man3/makecontext.3:142
845 "The example program below demonstrates the use of B<getcontext>(2), "
846 "B<makecontext>(), and B<swapcontext>(). Running the program produces the "
849 "以下のサンプル・プログラムは、 B<getcontext>(2), B<makecontext>(), "
850 "B<swapcontext>() の使用方法の例を示すものである。 このプログラムを実行する"
854 #: build/C/man3/makecontext.3:154
858 "main: swapcontext(&uctx_main, &uctx_func2)\n"
860 "func2: swapcontext(&uctx_func2, &uctx_func1)\n"
862 "func1: swapcontext(&uctx_func1, &uctx_func2)\n"
868 "main: swapcontext(&uctx_main, &uctx_func2)\n"
870 "func2: swapcontext(&uctx_func2, &uctx_func1)\n"
872 "func1: swapcontext(&uctx_func1, &uctx_func2)\n"
878 #: build/C/man3/makecontext.3:156 build/C/man3/pthread_attr_init.3:145
879 #: build/C/man3/pthread_cancel.3:145 build/C/man3/pthread_cleanup_push.3:224
880 #: build/C/man3/pthread_create.3:233 build/C/man3/pthread_getattr_np.3:176
881 #: build/C/man3/pthread_getcpuclockid.3:92
882 #: build/C/man3/pthread_setschedparam.3:221 build/C/man3/pthread_sigmask.3:77
884 msgid "Program source"
888 #: build/C/man3/makecontext.3:162
891 "#include E<lt>ucontext.hE<gt>\n"
892 "#include E<lt>stdio.hE<gt>\n"
893 "#include E<lt>stdlib.hE<gt>\n"
895 "#include E<lt>ucontext.hE<gt>\n"
896 "#include E<lt>stdio.hE<gt>\n"
897 "#include E<lt>stdlib.hE<gt>\n"
900 #: build/C/man3/makecontext.3:164
902 msgid "static ucontext_t uctx_main, uctx_func1, uctx_func2;\n"
903 msgstr "static ucontext_t uctx_main, uctx_func1, uctx_func2;\n"
906 #: build/C/man3/makecontext.3:167
909 "#define handle_error(msg) \\e\n"
910 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
912 "#define handle_error(msg) \\e\n"
913 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
916 #: build/C/man3/makecontext.3:177
922 " printf(\"func1: started\\en\");\n"
923 " printf(\"func1: swapcontext(&uctx_func1, &uctx_func2)\\en\");\n"
924 " if (swapcontext(&uctx_func1, &uctx_func2) == -1)\n"
925 " handle_error(\"swapcontext\");\n"
926 " printf(\"func1: returning\\en\");\n"
932 " printf(\"func1: started\\en\");\n"
933 " printf(\"func1: swapcontext(&uctx_func1, &uctx_func2)\\en\");\n"
934 " if (swapcontext(&uctx_func1, &uctx_func2) == -1)\n"
935 " handle_error(\"swapcontext\");\n"
936 " printf(\"func1: returning\\en\");\n"
940 #: build/C/man3/makecontext.3:187
946 " printf(\"func2: started\\en\");\n"
947 " printf(\"func2: swapcontext(&uctx_func2, &uctx_func1)\\en\");\n"
948 " if (swapcontext(&uctx_func2, &uctx_func1) == -1)\n"
949 " handle_error(\"swapcontext\");\n"
950 " printf(\"func2: returning\\en\");\n"
956 " printf(\"func2: started\\en\");\n"
957 " printf(\"func2: swapcontext(&uctx_func2, &uctx_func1)\\en\");\n"
958 " if (swapcontext(&uctx_func2, &uctx_func1) == -1)\n"
959 " handle_error(\"swapcontext\");\n"
960 " printf(\"func2: returning\\en\");\n"
964 #: build/C/man3/makecontext.3:193
968 "main(int argc, char *argv[])\n"
970 " char func1_stack[16384];\n"
971 " char func2_stack[16384];\n"
974 "main(int argc, char *argv[])\n"
976 " char func1_stack[16384];\n"
977 " char func2_stack[16384];\n"
980 #: build/C/man3/makecontext.3:200
983 " if (getcontext(&uctx_func1) == -1)\n"
984 " handle_error(\"getcontext\");\n"
985 " uctx_func1.uc_stack.ss_sp = func1_stack;\n"
986 " uctx_func1.uc_stack.ss_size = sizeof(func1_stack);\n"
987 " uctx_func1.uc_link = &uctx_main;\n"
988 " makecontext(&uctx_func1, func1, 0);\n"
990 " if (getcontext(&uctx_func1) == -1)\n"
991 " handle_error(\"getcontext\");\n"
992 " uctx_func1.uc_stack.ss_sp = func1_stack;\n"
993 " uctx_func1.uc_stack.ss_size = sizeof(func1_stack);\n"
994 " uctx_func1.uc_link = &uctx_main;\n"
995 " makecontext(&uctx_func1, func1, 0);\n"
998 #: build/C/man3/makecontext.3:208
1001 " if (getcontext(&uctx_func2) == -1)\n"
1002 " handle_error(\"getcontext\");\n"
1003 " uctx_func2.uc_stack.ss_sp = func2_stack;\n"
1004 " uctx_func2.uc_stack.ss_size = sizeof(func2_stack);\n"
1005 " /* Successor context is f1(), unless argc E<gt> 1 */\n"
1006 " uctx_func2.uc_link = (argc E<gt> 1) ? NULL : &uctx_func1;\n"
1007 " makecontext(&uctx_func2, func2, 0);\n"
1009 " if (getcontext(&uctx_func2) == -1)\n"
1010 " handle_error(\"getcontext\");\n"
1011 " uctx_func2.uc_stack.ss_sp = func2_stack;\n"
1012 " uctx_func2.uc_stack.ss_size = sizeof(func2_stack);\n"
1013 " /* Successor context is f1(), unless argc E<gt> 1 */\n"
1014 " uctx_func2.uc_link = (argc E<gt> 1) ? NULL : &uctx_func1;\n"
1015 " makecontext(&uctx_func2, func2, 0);\n"
1018 #: build/C/man3/makecontext.3:212
1021 " printf(\"main: swapcontext(&uctx_main, &uctx_func2)\\en\");\n"
1022 " if (swapcontext(&uctx_main, &uctx_func2) == -1)\n"
1023 " handle_error(\"swapcontext\");\n"
1025 " printf(\"main: swapcontext(&uctx_main, &uctx_func2)\\en\");\n"
1026 " if (swapcontext(&uctx_main, &uctx_func2) == -1)\n"
1027 " handle_error(\"swapcontext\");\n"
1030 #: build/C/man3/makecontext.3:216
1033 " printf(\"main: exiting\\en\");\n"
1034 " exit(EXIT_SUCCESS);\n"
1037 " printf(\"main: exiting\\en\");\n"
1038 " exit(EXIT_SUCCESS);\n"
1042 #: build/C/man3/makecontext.3:223
1044 "B<getcontext>(2), B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), "
1047 "B<getcontext>(2), B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), "
1051 #: build/C/man3/pthread_attr_init.3:24
1053 msgid "PTHREAD_ATTR_INIT"
1054 msgstr "PTHREAD_ATTR_INIT"
1057 #: build/C/man3/pthread_attr_init.3:24 build/C/man3/pthread_create.3:24
1063 #: build/C/man3/pthread_attr_init.3:28
1065 "pthread_attr_init, pthread_attr_destroy - initialize and destroy thread "
1070 #: build/C/man3/pthread_attr_init.3:31
1071 #: build/C/man3/pthread_attr_setdetachstate.3:31
1072 #: build/C/man3/pthread_attr_setguardsize.3:31
1073 #: build/C/man3/pthread_attr_setinheritsched.3:31
1074 #: build/C/man3/pthread_attr_setschedparam.3:31
1075 #: build/C/man3/pthread_attr_setschedpolicy.3:31
1076 #: build/C/man3/pthread_attr_setscope.3:31
1077 #: build/C/man3/pthread_attr_setstack.3:31
1078 #: build/C/man3/pthread_attr_setstackaddr.3:31
1079 #: build/C/man3/pthread_attr_setstacksize.3:31
1080 #: build/C/man3/pthread_cancel.3:30 build/C/man3/pthread_cleanup_push.3:31
1081 #: build/C/man3/pthread_cleanup_push_defer_np.3:31
1082 #: build/C/man3/pthread_create.3:30 build/C/man3/pthread_detach.3:30
1083 #: build/C/man3/pthread_equal.3:30 build/C/man3/pthread_exit.3:30
1084 #: build/C/man3/pthread_join.3:30
1085 #: build/C/man3/pthread_kill_other_threads_np.3:30
1086 #: build/C/man3/pthread_self.3:30 build/C/man3/pthread_setcancelstate.3:31
1087 #: build/C/man3/pthread_setconcurrency.3:30
1088 #: build/C/man3/pthread_setschedparam.3:31
1089 #: build/C/man3/pthread_setschedprio.3:30 build/C/man3/pthread_sigqueue.3:29
1090 #: build/C/man3/pthread_testcancel.3:30 build/C/man3/pthread_yield.3:29
1092 msgid "B<#include E<lt>pthread.hE<gt>>\n"
1093 msgstr "B<#include E<lt>pthread.hE<gt>>\n"
1096 #: build/C/man3/pthread_attr_init.3:34
1099 "B<int pthread_attr_init(pthread_attr_t *>I<attr>B<);>\n"
1100 "B<int pthread_attr_destroy(pthread_attr_t *>I<attr>B<);>\n"
1102 "B<int pthread_attr_init(pthread_attr_t *>I<attr>B<);>\n"
1103 "B<int pthread_attr_destroy(pthread_attr_t *>I<attr>B<);>\n"
1106 #: build/C/man3/pthread_attr_init.3:36
1107 #: build/C/man3/pthread_attr_setaffinity_np.3:39
1108 #: build/C/man3/pthread_attr_setdetachstate.3:38
1109 #: build/C/man3/pthread_attr_setguardsize.3:38
1110 #: build/C/man3/pthread_attr_setinheritsched.3:38
1111 #: build/C/man3/pthread_attr_setschedparam.3:38
1112 #: build/C/man3/pthread_attr_setschedpolicy.3:38
1113 #: build/C/man3/pthread_attr_setscope.3:38
1114 #: build/C/man3/pthread_attr_setstack.3:38
1115 #: build/C/man3/pthread_attr_setstackaddr.3:38
1116 #: build/C/man3/pthread_attr_setstacksize.3:38
1117 #: build/C/man3/pthread_cancel.3:34 build/C/man3/pthread_cleanup_push.3:37
1118 #: build/C/man3/pthread_cleanup_push_defer_np.3:37
1119 #: build/C/man3/pthread_equal.3:34 build/C/man3/pthread_exit.3:34
1120 #: build/C/man3/pthread_getattr_np.3:35
1121 #: build/C/man3/pthread_getcpuclockid.3:35 build/C/man3/pthread_self.3:34
1122 #: build/C/man3/pthread_setaffinity_np.3:39
1123 #: build/C/man3/pthread_setcancelstate.3:36
1124 #: build/C/man3/pthread_setconcurrency.3:35
1125 #: build/C/man3/pthread_setschedparam.3:38
1126 #: build/C/man3/pthread_setschedprio.3:34 build/C/man3/pthread_testcancel.3:34
1128 msgid "Compile and link with I<-pthread>.\n"
1132 #: build/C/man3/pthread_attr_init.3:47
1134 "The B<pthread_attr_init>() function initializes the thread attributes "
1135 "object pointed to by I<attr> with default attribute values. After this "
1136 "call, individual attributes of the object can be set using various related "
1137 "functions (listed under SEE ALSO), and then the object can be used in one or "
1138 "more B<pthread_create>(3) calls that create threads."
1142 #: build/C/man3/pthread_attr_init.3:52
1144 "Calling B<pthread_attr_init>() on a thread attributes object that has "
1145 "already been initialized results in undefined behavior."
1149 #: build/C/man3/pthread_attr_init.3:59
1151 "When a thread attributes object is no longer required, it should be "
1152 "destroyed using the B<pthread_attr_destroy>() function. Destroying a "
1153 "thread attributes object has no effect on threads that were created using "
1158 #: build/C/man3/pthread_attr_init.3:65
1160 "Once a thread attributes object has been destroyed, it can be reinitialized "
1161 "using B<pthread_attr_init>(). Any other use of a destroyed thread "
1162 "attributes object has undefined results."
1166 #: build/C/man3/pthread_attr_init.3:68
1167 #: build/C/man3/pthread_attr_setaffinity_np.3:76
1168 #: build/C/man3/pthread_attr_setdetachstate.3:77
1169 #: build/C/man3/pthread_attr_setguardsize.3:90
1170 #: build/C/man3/pthread_attr_setinheritsched.3:84
1171 #: build/C/man3/pthread_attr_setschedparam.3:74
1172 #: build/C/man3/pthread_attr_setschedpolicy.3:72
1173 #: build/C/man3/pthread_attr_setscope.3:91
1174 #: build/C/man3/pthread_attr_setstack.3:86
1175 #: build/C/man3/pthread_attr_setstackaddr.3:74
1176 #: build/C/man3/pthread_attr_setstacksize.3:61
1177 #: build/C/man3/pthread_setaffinity_np.3:77
1178 #: build/C/man3/pthread_setcancelstate.3:92
1180 "On success, these functions return 0; on error, they return a nonzero error "
1185 #: build/C/man3/pthread_attr_init.3:76
1187 "POSIX.1-2001 documents an B<ENOMEM> error for B<pthread_attr_init>(); on "
1188 "Linux these functions always succeed (but portable and future-proof "
1189 "applications should nevertheless handle a possible error return)."
1193 #: build/C/man3/pthread_attr_init.3:78
1194 #: build/C/man3/pthread_attr_setdetachstate.3:86
1195 #: build/C/man3/pthread_attr_setguardsize.3:105
1196 #: build/C/man3/pthread_attr_setinheritsched.3:100
1197 #: build/C/man3/pthread_attr_setschedparam.3:88
1198 #: build/C/man3/pthread_attr_setschedpolicy.3:88
1199 #: build/C/man3/pthread_attr_setscope.3:106
1200 #: build/C/man3/pthread_attr_setstack.3:112
1201 #: build/C/man3/pthread_attr_setstacksize.3:82
1202 #: build/C/man3/pthread_cancel.3:121 build/C/man3/pthread_cleanup_push.3:124
1203 #: build/C/man3/pthread_create.3:146 build/C/man3/pthread_detach.3:64
1204 #: build/C/man3/pthread_equal.3:46 build/C/man3/pthread_exit.3:74
1205 #: build/C/man3/pthread_getcpuclockid.3:64 build/C/man3/pthread_join.3:98
1206 #: build/C/man3/pthread_kill.3:66 build/C/man3/pthread_self.3:49
1207 #: build/C/man3/pthread_setcancelstate.3:112
1208 #: build/C/man3/pthread_setconcurrency.3:82
1209 #: build/C/man3/pthread_setschedparam.3:140
1210 #: build/C/man3/pthread_setschedprio.3:82 build/C/man3/pthread_sigmask.3:57
1211 #: build/C/man3/pthread_testcancel.3:57
1212 msgid "POSIX.1-2001."
1216 #: build/C/man3/pthread_attr_init.3:84
1218 "The I<pthread_attr_t> type should be treated as opaque: any access to the "
1219 "object other than via pthreads functions is nonportable and produces "
1220 "undefined results."
1224 #: build/C/man3/pthread_attr_init.3:93
1226 "The program below optionally makes use of B<pthread_attr_init>() and "
1227 "various related functions to initialize a thread attributes object that is "
1228 "used to create a single thread. Once created, the thread uses the "
1229 "B<pthread_getattr_np>(3) function (a nonstandard GNU extension) to retrieve "
1230 "the thread's attributes, and then displays those attributes."
1234 #: build/C/man3/pthread_attr_init.3:102
1236 "If the program is run with no command-line argument, then it passes NULL as "
1237 "the I<attr> argument of B<pthread_create>(3), so that the thread is created "
1238 "with default attributes. Running the program on Linux/x86-32 with the NPTL "
1239 "threading implementation, we see the following:"
1242 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
1244 #: build/C/man3/pthread_attr_init.3:118
1247 "$B< ulimit -s> # No stack imit ==E<gt> default stack size is 2MB\n"
1250 "Thread attributes:\n"
1251 " Detach state = PTHREAD_CREATE_JOINABLE\n"
1252 " Scope = PTHREAD_SCOPE_SYSTEM\n"
1253 " Inherit scheduler = PTHREAD_INHERIT_SCHED\n"
1254 " Scheduling policy = SCHED_OTHER\n"
1255 " Scheduling priority = 0\n"
1256 " Guard size = 4096 bytes\n"
1257 " Stack address = 0x40196000\n"
1258 " Stack size = 0x201000 bytes\n"
1262 #: build/C/man3/pthread_attr_init.3:128
1264 "When we supply a stack size as a command-line argument, the program "
1265 "initializes a thread attributes object, sets various attributes in that "
1266 "object, and passes a pointer to the object in the call to B<pthread_create>"
1267 "(3). Running the program on Linux/x86-32 with the NPTL threading "
1268 "implementation, we see the following:"
1271 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
1273 #: build/C/man3/pthread_attr_init.3:143
1276 "$B< ./a.out 0x3000000>\n"
1277 "posix_memalign() allocated at 0x40197000\n"
1278 "Thread attributes:\n"
1279 " Detach state = PTHREAD_CREATE_DETACHED\n"
1280 " Scope = PTHREAD_SCOPE_SYSTEM\n"
1281 " Inherit scheduler = PTHREAD_EXPLICIT_SCHED\n"
1282 " Scheduling policy = SCHED_OTHER\n"
1283 " Scheduling priority = 0\n"
1284 " Guard size = 0 bytes\n"
1285 " Stack address = 0x40197000\n"
1286 " Stack size = 0x3000000 bytes\n"
1290 #: build/C/man3/pthread_attr_init.3:154 build/C/man3/pthread_getattr_np.3:185
1293 "#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n"
1294 "#include E<lt>pthread.hE<gt>\n"
1295 "#include E<lt>stdio.hE<gt>\n"
1296 "#include E<lt>stdlib.hE<gt>\n"
1297 "#include E<lt>unistd.hE<gt>\n"
1298 "#include E<lt>errno.hE<gt>\n"
1302 #: build/C/man3/pthread_attr_init.3:157 build/C/man3/pthread_cancel.3:156
1303 #: build/C/man3/pthread_cleanup_push.3:236 build/C/man3/pthread_create.3:246
1304 #: build/C/man3/pthread_getattr_np.3:188
1305 #: build/C/man3/pthread_getcpuclockid.3:110
1306 #: build/C/man3/pthread_setaffinity_np.3:169
1307 #: build/C/man3/pthread_setschedparam.3:234 build/C/man3/pthread_sigmask.3:91
1310 "#define handle_error_en(en, msg) \\e\n"
1311 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
1315 #: build/C/man3/pthread_attr_init.3:165
1319 "display_pthread_attr(pthread_attr_t *attr, char *prefix)\n"
1324 " struct sched_param sp;\n"
1328 #: build/C/man3/pthread_attr_init.3:173
1331 " s = pthread_attr_getdetachstate(attr, &i);\n"
1333 " handle_error_en(s, \"pthread_attr_getdetachstate\");\n"
1334 " printf(\"%sDetach state = %s\\en\", prefix,\n"
1335 " (i == PTHREAD_CREATE_DETACHED) ? \"PTHREAD_CREATE_DETACHED\" :\n"
1336 " (i == PTHREAD_CREATE_JOINABLE) ? \"PTHREAD_CREATE_JOINABLE\" :\n"
1341 #: build/C/man3/pthread_attr_init.3:181
1344 " s = pthread_attr_getscope(attr, &i);\n"
1346 " handle_error_en(s, \"pthread_attr_getscope\");\n"
1347 " printf(\"%sScope = %s\\en\", prefix,\n"
1348 " (i == PTHREAD_SCOPE_SYSTEM) ? \"PTHREAD_SCOPE_SYSTEM\" :\n"
1349 " (i == PTHREAD_SCOPE_PROCESS) ? \"PTHREAD_SCOPE_PROCESS\" :\n"
1354 #: build/C/man3/pthread_attr_init.3:189
1357 " s = pthread_attr_getinheritsched(attr, &i);\n"
1359 " handle_error_en(s, \"pthread_attr_getinheritsched\");\n"
1360 " printf(\"%sInherit scheduler = %s\\en\", prefix,\n"
1361 " (i == PTHREAD_INHERIT_SCHED) ? \"PTHREAD_INHERIT_SCHED\" :\n"
1362 " (i == PTHREAD_EXPLICIT_SCHED) ? \"PTHREAD_EXPLICIT_SCHED\" :\n"
1367 #: build/C/man3/pthread_attr_init.3:198
1370 " s = pthread_attr_getschedpolicy(attr, &i);\n"
1372 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
1373 " printf(\"%sScheduling policy = %s\\en\", prefix,\n"
1374 " (i == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
1375 " (i == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
1376 " (i == SCHED_RR) ? \"SCHED_RR\" :\n"
1381 #: build/C/man3/pthread_attr_init.3:203
1384 " s = pthread_attr_getschedparam(attr, &sp);\n"
1386 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
1387 " printf(\"%sScheduling priority = %d\\en\", prefix, sp.sched_priority);\n"
1391 #: build/C/man3/pthread_attr_init.3:208
1394 " s = pthread_attr_getguardsize(attr, &v);\n"
1396 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
1397 " printf(\"%sGuard size = %d bytes\\en\", prefix, v);\n"
1401 #: build/C/man3/pthread_attr_init.3:215
1404 " s = pthread_attr_getstack(attr, &stkaddr, &v);\n"
1406 " handle_error_en(s, \"pthread_attr_getstack\");\n"
1407 " printf(\"%sStack address = %p\\en\", prefix, stkaddr);\n"
1408 " printf(\"%sStack size = 0x%x bytes\\en\", prefix, v);\n"
1413 #: build/C/man3/pthread_attr_init.3:221
1417 "thread_start(void *arg)\n"
1420 " pthread_attr_t gattr;\n"
1424 #: build/C/man3/pthread_attr_init.3:225
1427 " /* pthread_getattr_np() is a non-standard GNU extension that\n"
1428 " retrieves the attributes of the thread specified in its\n"
1429 " first argument */\n"
1433 #: build/C/man3/pthread_attr_init.3:229
1436 " s = pthread_getattr_np(pthread_self(), &gattr);\n"
1438 " handle_error_en(s, \"pthread_getattr_np\");\n"
1442 #: build/C/man3/pthread_attr_init.3:232
1445 " printf(\"Thread attributes:\\en\");\n"
1446 " display_pthread_attr(&gattr, \"\\et\");\n"
1450 #: build/C/man3/pthread_attr_init.3:235 build/C/man3/pthread_getattr_np.3:237
1453 " exit(EXIT_SUCCESS); /* Terminate all threads */\n"
1458 #: build/C/man3/pthread_attr_init.3:243
1462 "main(int argc, char *argv[])\n"
1465 " pthread_attr_t attr;\n"
1466 " pthread_attr_t *attrp; /* NULL or &attr */\n"
1471 #: build/C/man3/pthread_attr_init.3:245
1472 #: build/C/man3/pthread_setschedparam.3:352
1474 msgid " attrp = NULL;\n"
1478 #: build/C/man3/pthread_attr_init.3:249
1481 " /* If a command-line argument was supplied, use it to set the\n"
1482 " stack-size attribute and set a few other thread attributes,\n"
1483 " and set attrp pointing to thread attributes object */\n"
1487 #: build/C/man3/pthread_attr_init.3:253
1490 " if (argc E<gt> 1) {\n"
1491 " int stack_size;\n"
1496 #: build/C/man3/pthread_attr_init.3:255
1498 msgid " attrp = &attr;\n"
1502 #: build/C/man3/pthread_attr_init.3:259
1505 " s = pthread_attr_init(&attr);\n"
1507 " handle_error_en(s, \"pthread_attr_init\");\n"
1511 #: build/C/man3/pthread_attr_init.3:263
1514 " s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n"
1516 " handle_error_en(s, \"pthread_attr_setdetachstate\");\n"
1520 #: build/C/man3/pthread_attr_init.3:267
1523 " s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n"
1525 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
1529 #: build/C/man3/pthread_attr_init.3:269
1531 msgid " stack_size = strtoul(argv[1], NULL, 0);\n"
1535 #: build/C/man3/pthread_attr_init.3:273
1538 " s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);\n"
1540 " handle_error_en(s, \"posix_memalign\");\n"
1544 #: build/C/man3/pthread_attr_init.3:275
1546 msgid " printf(\"posix_memalign() allocated at %p\\en\", sp);\n"
1550 #: build/C/man3/pthread_attr_init.3:280
1553 " s = pthread_attr_setstack(&attr, sp, stack_size);\n"
1555 " handle_error_en(s, \"pthread_attr_setstack\");\n"
1560 #: build/C/man3/pthread_attr_init.3:284 build/C/man3/pthread_getattr_np.3:332
1563 " s = pthread_create(&thr, attrp, &thread_start, NULL);\n"
1565 " handle_error_en(s, \"pthread_create\");\n"
1569 #: build/C/man3/pthread_attr_init.3:290 build/C/man3/pthread_getattr_np.3:338
1572 " if (attrp != NULL) {\n"
1573 " s = pthread_attr_destroy(attrp);\n"
1575 " handle_error_en(s, \"pthread_attr_destroy\");\n"
1580 #: build/C/man3/pthread_attr_init.3:293 build/C/man3/pthread_getattr_np.3:341
1583 " pause(); /* Terminates when other thread calls exit() */\n"
1588 #: build/C/man3/pthread_attr_init.3:308
1590 "B<pthread_attr_setaffinity_np>(3), B<pthread_attr_setdetachstate>(3), "
1591 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setinheritsched>(3), "
1592 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
1593 "B<pthread_attr_setscope>(3), B<pthread_attr_setstack>(3), "
1594 "B<pthread_attr_setstackaddr>(3), B<pthread_attr_setstacksize>(3), "
1595 "B<pthread_create>(3), B<pthread_getattr_np>(3), B<pthreads>(7)"
1599 #: build/C/man3/pthread_attr_setaffinity_np.3:24
1601 msgid "PTHREAD_ATTR_SETAFFINITY_NP"
1605 #: build/C/man3/pthread_attr_setaffinity_np.3:24
1606 #: build/C/man3/pthread_getattr_np.3:24
1607 #: build/C/man3/pthread_setaffinity_np.3:24
1608 #: build/C/man3/pthread_tryjoin_np.3:24
1614 #: build/C/man3/pthread_attr_setaffinity_np.3:28
1616 "pthread_attr_setaffinity_np, pthread_attr_getaffinity_np - set/get CPU "
1617 "affinity attribute in thread attributes object"
1621 #: build/C/man3/pthread_attr_setaffinity_np.3:32
1622 #: build/C/man3/pthread_getattr_np.3:31
1623 #: build/C/man3/pthread_setaffinity_np.3:32
1624 #: build/C/man3/pthread_tryjoin_np.3:32
1627 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
1628 "B<#include E<lt>pthread.hE<gt>>\n"
1632 #: build/C/man3/pthread_attr_setaffinity_np.3:37
1635 "B<int pthread_attr_setaffinity_np(pthread_attr_t *>I<attr>B<,>\n"
1636 "B< size_t >I<cpusetsize>B<, const cpu_set_t *>I<cpuset>B<);>\n"
1637 "B<int pthread_attr_getaffinity_np(pthread_attr_t *>I<attr>B<,>\n"
1638 "B< size_t >I<cpusetsize>B<, cpu_set_t *>I<cpuset>B<);>\n"
1642 #: build/C/man3/pthread_attr_setaffinity_np.3:51
1644 "The B<pthread_attr_setaffinity_np>() function sets the CPU affinity mask "
1645 "attribute of the thread attributes object referred to by I<attr> to the "
1646 "value specified in I<cpuset>. This attribute determines the CPU affinity "
1647 "mask of a thread created using the thread attributes object I<attr>."
1651 #: build/C/man3/pthread_attr_setaffinity_np.3:60
1653 "The B<pthread_attr_getaffinity_np>() function returns the CPU affinity mask "
1654 "attribute of the thread attributes object referred to by I<attr> in the "
1655 "buffer pointed to by I<cpuset>."
1659 #: build/C/man3/pthread_attr_setaffinity_np.3:67
1661 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
1662 "by I<cpuset>. Typically, this argument would be specified as I<sizeof"
1667 #: build/C/man3/pthread_attr_setaffinity_np.3:73
1668 #: build/C/man3/pthread_setaffinity_np.3:64
1670 "For more details on CPU affinity masks, see B<sched_setaffinity>(2). For a "
1671 "description of a set of macros that can be used to manipulate and inspect "
1672 "CPU sets, see B<CPU_SET>(3)."
1676 #: build/C/man3/pthread_attr_setaffinity_np.3:77
1677 #: build/C/man3/pthread_attr_setaffinity_np.3:89
1678 #: build/C/man3/pthread_attr_setdetachstate.3:80
1679 #: build/C/man3/pthread_attr_setinheritsched.3:87
1680 #: build/C/man3/pthread_attr_setschedpolicy.3:75
1681 #: build/C/man3/pthread_attr_setscope.3:94
1682 #: build/C/man3/pthread_attr_setstack.3:89
1683 #: build/C/man3/pthread_attr_setstacksize.3:64
1684 #: build/C/man3/pthread_create.3:135 build/C/man3/pthread_detach.3:53
1685 #: build/C/man3/pthread_join.3:83 build/C/man3/pthread_join.3:87
1686 #: build/C/man3/pthread_kill.3:56 build/C/man3/pthread_setaffinity_np.3:81
1687 #: build/C/man3/pthread_setaffinity_np.3:90
1688 #: build/C/man3/pthread_setaffinity_np.3:106
1689 #: build/C/man3/pthread_setcancelstate.3:96
1690 #: build/C/man3/pthread_setcancelstate.3:104
1691 #: build/C/man3/pthread_setconcurrency.3:68
1692 #: build/C/man3/pthread_setschedparam.3:119
1693 #: build/C/man3/pthread_setschedprio.3:59 build/C/man3/pthread_sigqueue.3:75
1699 #. The raw sched_getaffinity() system call returns the size (in bytes)
1700 #. of the cpumask_t type.
1702 #: build/C/man3/pthread_attr_setaffinity_np.3:89
1704 "(B<pthread_attr_setaffinity_np>()) I<cpuset> specified a CPU that was "
1705 "outside the set supported by the kernel. (The kernel configuration option "
1706 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
1707 "type used to represent CPU sets.)"
1711 #: build/C/man3/pthread_attr_setaffinity_np.3:99
1713 "(B<pthread_attr_getaffinity_np>()) A CPU in the affinity mask of the thread "
1714 "attributes object referred to by I<attr> lies outside the range specified by "
1715 "I<cpusetsize> (i.e., I<cpuset>/I<cpusetsize> is too small)."
1719 #: build/C/man3/pthread_attr_setaffinity_np.3:103
1720 msgid "(B<pthread_attr_setaffinity_np>()) Could not allocate memory."
1724 #: build/C/man3/pthread_attr_setaffinity_np.3:105
1725 #: build/C/man3/pthread_setaffinity_np.3:118
1726 msgid "These functions are provided by glibc since version 2.3.4."
1730 #: build/C/man3/pthread_attr_setaffinity_np.3:108
1731 #: build/C/man3/pthread_cleanup_push_defer_np.3:101
1732 #: build/C/man3/pthread_setaffinity_np.3:121
1733 #: build/C/man3/pthread_tryjoin_np.3:113
1735 "These functions are nonstandard GNU extensions; hence the suffix \"_np"
1736 "\" (nonportable) in the names."
1740 #: build/C/man3/pthread_attr_setaffinity_np.3:115
1741 #: build/C/man3/pthread_setaffinity_np.3:147
1743 "In glibc 2.3.3 only, versions of these functions were provided that did not "
1744 "have a I<cpusetsize> argument. Instead the CPU set size given to the "
1745 "underlying system calls was always I<sizeof(cpu_set_t)>."
1749 #: build/C/man3/pthread_attr_setaffinity_np.3:121
1751 "B<sched_setaffinity>(2), B<pthread_attr_init>(3), B<pthread_setaffinity_np>"
1752 "(3), B<cpuset>(7), B<pthreads>(7)"
1756 #: build/C/man3/pthread_attr_setdetachstate.3:24
1758 msgid "PTHREAD_ATTR_SETDETACHSTATE"
1762 #: build/C/man3/pthread_attr_setdetachstate.3:24
1763 #: build/C/man3/pthread_attr_setschedparam.3:24
1764 #: build/C/man3/pthread_attr_setschedpolicy.3:24
1770 #: build/C/man3/pthread_attr_setdetachstate.3:28
1772 "pthread_attr_setdetachstate, pthread_attr_getdetachstate - set/get detach "
1773 "state attribute in thread attributes object"
1777 #: build/C/man3/pthread_attr_setdetachstate.3:36
1780 "B<int pthread_attr_setdetachstate(pthread_attr_t *>I<attr>B<, int >I<detachstate>B<);>\n"
1781 "B<int pthread_attr_getdetachstate(pthread_attr_t *>I<attr>B<, int *>I<detachstate>B<);>\n"
1785 #: build/C/man3/pthread_attr_setdetachstate.3:50
1787 "The B<pthread_attr_setdetachstate>() function sets the detach state "
1788 "attribute of the thread attributes object referred to by I<attr> to the "
1789 "value specified in I<detachstate>. The detach state attribute determines "
1790 "whether a thread created using the thread attributes object I<attr> will be "
1791 "created in a joinable or a detached state."
1795 #: build/C/man3/pthread_attr_setdetachstate.3:53
1796 msgid "The following values may be specified in I<detachstate>:"
1800 #: build/C/man3/pthread_attr_setdetachstate.3:53
1802 msgid "B<PTHREAD_CREATE_DETACHED>"
1806 #: build/C/man3/pthread_attr_setdetachstate.3:58
1808 "Threads that are created using I<attr> will be created in a detached state."
1812 #: build/C/man3/pthread_attr_setdetachstate.3:58
1814 msgid "B<PTHREAD_CREATE_JOINABLE>"
1818 #: build/C/man3/pthread_attr_setdetachstate.3:63
1820 "Threads that are created using I<attr> will be created in a joinable state."
1824 #: build/C/man3/pthread_attr_setdetachstate.3:67
1826 "The default setting of the detach state attribute in a newly initialized "
1827 "thread attributes object is B<PTHREAD_CREATE_JOINABLE>."
1831 #: build/C/man3/pthread_attr_setdetachstate.3:74
1833 "The B<pthread_attr_getdetachstate>() returns the detach state attribute of "
1834 "the thread attributes object I<attr> in the buffer pointed to by "
1839 #: build/C/man3/pthread_attr_setdetachstate.3:80
1840 msgid "B<pthread_attr_setdetachstate>() can fail with the following error:"
1844 #: build/C/man3/pthread_attr_setdetachstate.3:84
1845 msgid "An invalid value was specified in I<detachstate>."
1849 #: build/C/man3/pthread_attr_setdetachstate.3:90
1851 "See B<pthread_create>(3) for more details on detached and joinable threads."
1855 #: build/C/man3/pthread_attr_setdetachstate.3:98
1857 "A thread that is created in a joinable state should eventually either be "
1858 "joined using B<pthread_join>(3) or detached using B<pthread_detach>(3); see "
1859 "B<pthread_create>(3)."
1863 #: build/C/man3/pthread_attr_setdetachstate.3:105
1865 "It is an error to specify the thread ID of a thread that was created in a "
1866 "detached state in a later call to B<pthread_detach>(3) or B<pthread_join>"
1871 #: build/C/man3/pthread_attr_setdetachstate.3:108
1872 #: build/C/man3/pthread_attr_setstack.3:154
1873 msgid "See B<pthread_attr_init>(3)."
1877 #: build/C/man3/pthread_attr_setdetachstate.3:114
1879 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthread_detach>(3), "
1880 "B<pthread_join>(3), B<pthreads>(7)"
1884 #: build/C/man3/pthread_attr_setguardsize.3:24
1886 msgid "PTHREAD_ATTR_SETGUARDSIZE"
1890 #: build/C/man3/pthread_attr_setguardsize.3:24
1891 #: build/C/man3/pthread_attr_setscope.3:24
1892 #: build/C/man3/pthread_attr_setstack.3:24
1893 #: build/C/man3/pthread_attr_setstackaddr.3:24 build/C/man3/pthread_self.3:24
1899 #: build/C/man3/pthread_attr_setguardsize.3:28
1901 "pthread_attr_setguardsize, pthread_attr_getguardsize - set/get guard size "
1902 "attribute in thread attributes object"
1906 #: build/C/man3/pthread_attr_setguardsize.3:36
1909 "B<int pthread_attr_setguardsize(pthread_attr_t *>I<attr>B<, size_t >I<guardsize>B<);>\n"
1910 "B<int pthread_attr_getguardsize(pthread_attr_t *>I<attr>B<, size_t *>I<guardsize>B<);>\n"
1914 #: build/C/man3/pthread_attr_setguardsize.3:46
1916 "The B<pthread_attr_setguardsize>() function sets the guard size attribute "
1917 "of the thread attributes object referred to by I<attr> to the value "
1918 "specified in I<guardsize>."
1922 #: build/C/man3/pthread_attr_setguardsize.3:56
1924 "If I<guardsize> is greater than 0, then for each new thread created using "
1925 "I<attr> the system allocates an additional region of at least I<guardsize> "
1926 "bytes at the end of the thread's stack to act as the guard area for the "
1927 "stack (but see BUGS)."
1931 #: build/C/man3/pthread_attr_setguardsize.3:62
1933 "If I<guardsize> is 0, then new threads created with I<attr> will not have a "
1938 #: build/C/man3/pthread_attr_setguardsize.3:64
1939 msgid "The default guard size is the same as the system page size."
1943 #: build/C/man3/pthread_attr_setguardsize.3:79
1945 "If the stack address attribute has been set in I<attr> (using "
1946 "B<pthread_attr_setstack>(3) or B<pthread_attr_setstackaddr>(3)), meaning "
1947 "that the caller is allocating the thread's stack, then the guard size "
1948 "attribute is ignored (i.e., no guard area is created by the system): it is "
1949 "the application's responsibility to handle stack overflow (perhaps by using "
1950 "B<mprotect>(2) to manually define a guard area at the end of the stack that "
1951 "it has allocated)."
1955 #: build/C/man3/pthread_attr_setguardsize.3:87
1957 "The B<pthread_attr_getguardsize>() function returns the guard size "
1958 "attribute of the thread attributes object referred to by I<attr> in the "
1959 "buffer pointed to by I<guardsize>."
1963 #: build/C/man3/pthread_attr_setguardsize.3:101
1965 "POSIX.1-2001 documents an B<EINVAL> error if I<attr> or I<guardsize> is "
1966 "invalid. On Linux these functions always succeed (but portable and future-"
1967 "proof applications should nevertheless handle a possible error return)."
1971 #: build/C/man3/pthread_attr_setguardsize.3:103
1972 #: build/C/man3/pthread_attr_setstackaddr.3:80
1973 #: build/C/man3/pthread_attr_setstacksize.3:80
1974 msgid "These functions are provided by glibc since version 2.1."
1978 #: build/C/man3/pthread_attr_setguardsize.3:119
1980 "A guard area consists of virtual memory pages that are protected to prevent "
1981 "read and write access. If a thread overflows its stack into the guard area, "
1982 "then, on most hard architectures, it receives a B<SIGSEGV> signal, thus "
1983 "notifying it of the overflow. Guard areas start on page boundaries, and the "
1984 "guard size is internally rounded up to the system page size when creating a "
1985 "thread. (Nevertheless, B<pthread_attr_getguardsize>() returns the guard "
1986 "size that was set by B<pthread_attr_setguardsize>().)"
1990 #: build/C/man3/pthread_attr_setguardsize.3:123
1992 "Setting a guard size of 0 may be useful to save memory in an application "
1993 "that creates many threads and knows that stack overflow can never occur."
1997 #: build/C/man3/pthread_attr_setguardsize.3:127
1999 "Choosing a guard size larger than the default size may be necessary for "
2000 "detecting stack overflows if a thread allocates large data structures on the "
2005 #: build/C/man3/pthread_attr_setguardsize.3:127
2006 #: build/C/man3/pthread_attr_setinheritsched.3:103
2007 #: build/C/man3/pthread_attr_setstacksize.3:96
2008 #: build/C/man3/pthread_create.3:361 build/C/man3/pthread_exit.3:90
2014 #: build/C/man3/pthread_attr_setguardsize.3:138
2016 "As at glibc 2.8, the NPTL threading implementation includes the guard area "
2017 "within the stack size allocation, rather than allocating extra space at the "
2018 "end of the stack, as POSIX.1 requires. (This can result in an B<EINVAL> "
2019 "error from B<pthread_create>(3) if the guard size value is too large, "
2020 "leaving no space for the actual stack.)"
2023 #. glibc includes the guardsize within the allocated stack size,
2024 #. which looks pretty clearly to be in violation of POSIX.
2025 #. Filed bug, 22 Oct 2008:
2026 #. http://sources.redhat.com/bugzilla/show_bug.cgi?id=6973
2028 #. https//bugzilla.redhat.com/show_bug.cgi?id=435337
2029 #. Reportedly, LinuxThreads did the right thing, allocating
2030 #. extra space at the end of the stack:
2031 #. http://sourceware.org/ml/libc-alpha/2008-05/msg00086.html
2033 #: build/C/man3/pthread_attr_setguardsize.3:152
2035 "The obsolete LinuxThreads implementation did the right thing, allocating "
2036 "extra space at the end of the stack for the guard area."
2040 #: build/C/man3/pthread_attr_setguardsize.3:155
2041 msgid "See B<pthread_getattr_np>(3)."
2045 #: build/C/man3/pthread_attr_setguardsize.3:163
2047 "B<mmap>(2), B<mprotect>(2), B<pthread_attr_init>(3), B<pthread_attr_setstack>"
2048 "(3), B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2052 #: build/C/man3/pthread_attr_setinheritsched.3:24
2054 msgid "PTHREAD_ATTR_SETINHERITSCHED"
2058 #: build/C/man3/pthread_attr_setinheritsched.3:24
2064 #: build/C/man3/pthread_attr_setinheritsched.3:28
2066 "pthread_attr_setinheritsched, pthread_attr_getinheritsched - set/get inherit "
2067 "scheduler attribute in thread attributes object"
2071 #: build/C/man3/pthread_attr_setinheritsched.3:36
2074 "B<int pthread_attr_setinheritsched(pthread_attr_t *>I<attr>B<,>\n"
2075 "B< int >I<inheritsched>B<);>\n"
2076 "B<int pthread_attr_getinheritsched(pthread_attr_t *>I<attr>B<,>\n"
2077 "B< int *>I<inheritsched>B<);>\n"
2081 #: build/C/man3/pthread_attr_setinheritsched.3:52
2083 "The B<pthread_attr_setinheritsched>() function sets the inherit scheduler "
2084 "attribute of the thread attributes object referred to by I<attr> to the "
2085 "value specified in I<inheritsched>. The inherit scheduler attribute "
2086 "determines whether a thread created using the thread attributes object "
2087 "I<attr> will inherit its scheduling attributes from the calling thread or "
2088 "whether it will take them from I<attr>."
2092 #: build/C/man3/pthread_attr_setinheritsched.3:55
2093 msgid "The following values may be specified in I<inheritsched>:"
2097 #: build/C/man3/pthread_attr_setinheritsched.3:55
2099 msgid "B<PTHREAD_INHERIT_SCHED>"
2103 #: build/C/man3/pthread_attr_setinheritsched.3:63
2105 "Threads that are created using I<attr> inherit scheduling attributes from "
2106 "the creating thread; the scheduling attributes in I<attr> are ignored."
2110 #: build/C/man3/pthread_attr_setinheritsched.3:63
2112 msgid "B<PTHREAD_EXPLICIT_SCHED>"
2115 #. FIXME what are the defaults for scheduler settings?
2117 #: build/C/man3/pthread_attr_setinheritsched.3:70
2119 "Threads that are created using I<attr> take their scheduling attributes from "
2120 "the values specified by the attributes object."
2124 #: build/C/man3/pthread_attr_setinheritsched.3:74
2126 "The default setting of the inherit scheduler attribute in a newly "
2127 "initialized thread attributes object is B<PTHREAD_INHERIT_SCHED>."
2131 #: build/C/man3/pthread_attr_setinheritsched.3:81
2133 "The B<pthread_attr_getinheritsched>() returns the inherit scheduler "
2134 "attribute of the thread attributes object I<attr> in the buffer pointed to "
2135 "by I<inheritsched>."
2139 #: build/C/man3/pthread_attr_setinheritsched.3:87
2140 msgid "B<pthread_attr_setinheritsched>() can fail with the following error:"
2144 #: build/C/man3/pthread_attr_setinheritsched.3:91
2145 msgid "Invalid value in I<inheritsched>."
2149 #. Available since glibc 2.0.
2151 #: build/C/man3/pthread_attr_setinheritsched.3:98
2153 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
2154 "to set the attribute to an unsupported value\") for "
2155 "B<pthread_attr_setinheritsched>()."
2159 #: build/C/man3/pthread_attr_setinheritsched.3:103
2160 #: build/C/man3/pthread_attr_setschedparam.3:91
2161 #: build/C/man3/pthread_attr_setschedpolicy.3:91
2162 msgid "See B<pthread_setschedparam>(3)."
2165 #. FIXME . Track status of the following bug:
2166 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7007
2168 #: build/C/man3/pthread_attr_setinheritsched.3:119
2170 "As at glibc 2.8, if a thread attributes object is initialized using "
2171 "B<pthread_attr_init>(3), then the scheduling policy of the attributes object "
2172 "is set to B<SCHED_OTHER> and the scheduling priority is set to 0. However, "
2173 "if the inherit scheduler attribute is then set to B<PTHREAD_EXPLICIT_SCHED>, "
2174 "then a thread created using the attribute object wrongly inherits its "
2175 "scheduling attributes from the creating thread. This bug does not occur if "
2176 "either the scheduling policy or scheduling priority attribute is explicitly "
2177 "set in the thread attributes object before calling B<pthread_create>(3)."
2181 #: build/C/man3/pthread_attr_setinheritsched.3:128
2183 "B<sched_setscheduler>(2), B<pthread_attr_init>(3), "
2184 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
2185 "B<pthread_create>(3), B<pthread_setschedparam>(3), B<pthread_setschedprio>"
2186 "(3), B<pthreads>(7)"
2190 #: build/C/man3/pthread_attr_setschedparam.3:24
2192 msgid "PTHREAD_ATTR_SETSCHEDPARAM"
2196 #: build/C/man3/pthread_attr_setschedparam.3:28
2198 "pthread_attr_setschedparam, pthread_attr_getschedparam - set/get scheduling "
2199 "parameter attributes in thread attributes object"
2203 #: build/C/man3/pthread_attr_setschedparam.3:36
2206 "B<int pthread_attr_setschedparam(pthread_attr_t *>I<attr>B<,>\n"
2207 "B< const struct sched_param *>I<param>B<);>\n"
2208 "B<int pthread_attr_getschedparam(pthread_attr_t *>I<attr>B<,>\n"
2209 "B< struct sched_param *>I<param>B<);>\n"
2213 #: build/C/man3/pthread_attr_setschedparam.3:49
2215 "The B<pthread_attr_setschedparam>() function sets the scheduling parameter "
2216 "attributes of the thread attributes object referred to by I<attr> to the "
2217 "values specified in the buffer pointed to by I<param>. These attributes "
2218 "determine the scheduling parameters of a thread created using the thread "
2219 "attributes object I<attr>."
2223 #: build/C/man3/pthread_attr_setschedparam.3:56
2225 "The B<pthread_attr_getschedparam>() returns the scheduling parameter "
2226 "attributes of the thread attributes object I<attr> in the buffer pointed to "
2231 #: build/C/man3/pthread_attr_setschedparam.3:58
2232 msgid "Scheduling parameters are maintained in the following structure:"
2236 #: build/C/man3/pthread_attr_setschedparam.3:64
2237 #: build/C/man3/pthread_setschedparam.3:66
2240 "struct sched_param {\n"
2241 " int sched_priority; /* Scheduling priority */\n"
2246 #: build/C/man3/pthread_attr_setschedparam.3:71
2247 #: build/C/man3/pthread_setschedparam.3:73
2249 "As can be seen, only one scheduling parameter is supported. For details of "
2250 "the permitted ranges for scheduling priorities in each scheduling policy, "
2251 "see B<sched_setscheduler>(2)."
2255 #. Available since glibc 2.0.
2257 #: build/C/man3/pthread_attr_setschedparam.3:86
2259 "POSIX.1 documents B<EINVAL> and B<ENOTSUP> errors for "
2260 "B<pthread_attr_setschedparam>(). On Linux these functions always succeed "
2261 "(but portable and future-proof applications should nevertheless handle a "
2262 "possible error return)."
2266 #: build/C/man3/pthread_attr_setschedparam.3:95
2268 "See B<pthread_attr_setschedpolicy>(3) for a list of the thread scheduling "
2269 "policies supported on Linux."
2273 #: build/C/man3/pthread_attr_setschedparam.3:105
2275 "B<sched_get_priority_min>(2), B<sched_setscheduler>(2), B<pthread_attr_init>"
2276 "(3), B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedpolicy>(3), "
2277 "B<pthread_create>(3), B<pthread_setschedparam>(3), B<pthread_setschedprio>"
2278 "(3), B<pthreads>(7)"
2282 #: build/C/man3/pthread_attr_setschedpolicy.3:24
2284 msgid "PTHREAD_ATTR_SETSCHEDPOLICY"
2288 #: build/C/man3/pthread_attr_setschedpolicy.3:28
2290 "pthread_attr_setschedpolicy, pthread_attr_getschedpolicy - set/get "
2291 "scheduling policy attribute in thread attributes object"
2295 #: build/C/man3/pthread_attr_setschedpolicy.3:36
2298 "B<int pthread_attr_setschedpolicy(pthread_attr_t *>I<attr>B<, int >I<policy>B<);>\n"
2299 "B<int pthread_attr_getschedpolicy(pthread_attr_t *>I<attr>B<, int >I<*policy>B<);>\n"
2303 #: build/C/man3/pthread_attr_setschedpolicy.3:49
2305 "The B<pthread_attr_setschedpolicy>() function sets the scheduling policy "
2306 "attribute of the thread attributes object referred to by I<attr> to the "
2307 "value specified in I<policy>. This attribute determines the scheduling "
2308 "policy of a thread created using the thread attributes object I<attr>."
2311 #. FIXME . pthread_setschedparam() places no restriction on the policy,
2312 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
2313 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
2315 #: build/C/man3/pthread_attr_setschedpolicy.3:62
2317 "The supported values for I<policy> are B<SCHED_FIFO>, B<SCHED_RR>, and "
2318 "B<SCHED_OTHER>, with the semantics described in B<sched_setscheduler>(2)."
2322 #: build/C/man3/pthread_attr_setschedpolicy.3:69
2324 "The B<pthread_attr_getschedpolicy>() returns the scheduling policy "
2325 "attribute of the thread attributes object I<attr> in the buffer pointed to "
2330 #: build/C/man3/pthread_attr_setschedpolicy.3:75
2331 msgid "B<pthread_attr_setschedpolicy>() can fail with the following error:"
2335 #: build/C/man3/pthread_attr_setschedpolicy.3:79
2336 msgid "Invalid value in I<policy>."
2340 #. Available since glibc 2.0.
2342 #: build/C/man3/pthread_attr_setschedpolicy.3:86
2344 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
2345 "to set the attribute to an unsupported value\") for "
2346 "B<pthread_attr_setschedpolicy>()."
2350 #: build/C/man3/pthread_attr_setschedpolicy.3:100
2352 "B<sched_setscheduler>(2), B<pthread_attr_init>(3), "
2353 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
2354 "B<pthread_create>(3), B<pthread_setschedparam>(3), B<pthread_setschedprio>"
2355 "(3), B<pthreads>(7)"
2359 #: build/C/man3/pthread_attr_setscope.3:24
2361 msgid "PTHREAD_ATTR_SETSCOPE"
2365 #: build/C/man3/pthread_attr_setscope.3:28
2367 "pthread_attr_setscope, pthread_attr_getscope - set/get contention scope "
2368 "attribute in thread attributes object"
2372 #: build/C/man3/pthread_attr_setscope.3:36
2375 "B<int pthread_attr_setscope(pthread_attr_t *>I<attr>B<, int >I<scope>B<);>\n"
2376 "B<int pthread_attr_getscope(pthread_attr_t *>I<attr>B<, int *>I<scope>B<);>\n"
2380 #: build/C/man3/pthread_attr_setscope.3:50
2382 "The B<pthread_attr_setscope>() function sets the contention scope attribute "
2383 "of the thread attributes object referred to by I<attr> to the value "
2384 "specified in I<scope>. The contention scope attribute defines the set of "
2385 "threads against which a thread competes for resources such as the CPU. "
2386 "POSIX.1-2001 specifies two possible values for I<scope>:"
2390 #: build/C/man3/pthread_attr_setscope.3:50
2392 msgid "B<PTHREAD_SCOPE_SYSTEM>"
2396 #: build/C/man3/pthread_attr_setscope.3:58
2398 "The thread competes for resources with all other threads in all processes on "
2399 "the system that are in the same scheduling allocation domain (a group of one "
2400 "or more processors). B<PTHREAD_SCOPE_SYSTEM> threads are scheduled relative "
2401 "to one another according to their scheduling policy and priority."
2405 #: build/C/man3/pthread_attr_setscope.3:58
2407 msgid "B<PTHREAD_SCOPE_PROCESS>"
2411 #: build/C/man3/pthread_attr_setscope.3:73
2413 "The thread competes for resources with all other threads in the same process "
2414 "that were also created with the B<PTHREAD_SCOPE_PROCESS> contention scope. "
2415 "B<PTHREAD_SCOPE_PROCESS> threads are scheduled relative to other threads in "
2416 "the process according to their scheduling policy and priority. POSIX.1-2001 "
2417 "leaves it unspecified how these threads contend with other threads in other "
2418 "process on the system or with other threads in the same process that were "
2419 "created with the B<PTHREAD_SCOPE_SYSTEM> contention scope."
2423 #: build/C/man3/pthread_attr_setscope.3:80
2425 "POSIX.1-2001 only requires that an implementation support one of these "
2426 "contention scopes, but permits both to be supported. Linux supports "
2427 "B<PTHREAD_SCOPE_SYSTEM>, but not B<PTHREAD_SCOPE_PROCESS>."
2431 #: build/C/man3/pthread_attr_setscope.3:88
2433 "The B<pthread_attr_getscope>() function returns the contention scope "
2434 "attribute of the thread attributes object referred to by I<attr> in the "
2435 "buffer pointed to by I<scope>."
2439 #: build/C/man3/pthread_attr_setscope.3:94
2440 msgid "B<pthread_attr_setscope>() can fail with the following errors:"
2444 #: build/C/man3/pthread_attr_setscope.3:98
2445 msgid "An invalid value was specified in I<scope>."
2449 #: build/C/man3/pthread_attr_setscope.3:98
2455 #: build/C/man3/pthread_attr_setscope.3:104
2457 "I<scope> specified the value B<PTHREAD_SCOPE_PROCESS>, which is not "
2458 "supported on Linux."
2462 #: build/C/man3/pthread_attr_setscope.3:114
2464 "The B<PTHREAD_SCOPE_SYSTEM> contention scope typically indicates that a "
2465 "userspace thread is bound directly to a single kernel-scheduling entity. "
2466 "This is the case on Linux for the obsolete LinuxThreads implementation and "
2467 "the modern NPTL implementation, which are both 1:1 threading implementations."
2471 #: build/C/man3/pthread_attr_setscope.3:117
2473 "POSIX.1-2001 specifies that the default contention scope is implementation-"
2478 #: build/C/man3/pthread_attr_setscope.3:125
2480 "B<pthread_attr_init>(3), B<pthread_attr_setaffinity_np>(3), "
2481 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
2482 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), B<pthreads>(7)"
2486 #: build/C/man3/pthread_attr_setstack.3:24
2488 msgid "PTHREAD_ATTR_SETSTACK"
2492 #: build/C/man3/pthread_attr_setstack.3:28
2494 "pthread_attr_setstack, pthread_attr_getstack - set/get stack attributes in "
2495 "thread attributes object"
2499 #: build/C/man3/pthread_attr_setstack.3:36
2502 "B<int pthread_attr_setstack(pthread_attr_t *>I<attr>B<,>\n"
2503 "B< void *>I<stackaddr>B<, size_t >I<stacksize>B<);>\n"
2504 "B<int pthread_attr_getstack(pthread_attr_t *>I<attr>B<,>\n"
2505 "B< void **>I<stackaddr>B<, size_t *>I<stacksize>B<);>\n"
2509 #: build/C/man3/pthread_attr_setstack.3:43 build/C/man3/pthread_sigqueue.3:39
2511 "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
2515 #: build/C/man3/pthread_attr_setstack.3:48
2516 msgid "B<pthread_attr_getstack>(), B<pthread_attr_setstack>():"
2520 #: build/C/man3/pthread_attr_setstack.3:50
2521 msgid "_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600"
2525 #: build/C/man3/pthread_attr_setstack.3:66
2527 "The B<pthread_attr_setstack>() function sets the stack address and stack "
2528 "size attributes of the thread attributes object referred to by I<attr> to "
2529 "the values specified in I<stackaddr> and I<stacksize>, respectively. These "
2530 "attributes specify the location and size of the stack that should be used by "
2531 "a thread that is created using the thread attributes object I<attr>."
2535 #: build/C/man3/pthread_attr_setstack.3:72
2537 "I<stackaddr> should point to the lowest addressable byte of a buffer of "
2538 "I<stacksize> bytes that was allocated by the caller. The pages of the "
2539 "allocated buffer should be both readable and writable."
2543 #: build/C/man3/pthread_attr_setstack.3:83
2545 "The B<pthread_attr_getstack>() function returns the stack address and stack "
2546 "size attributes of the thread attributes object referred to by I<attr> in "
2547 "the buffers pointed to by I<stackaddr> and I<stacksize>, respectively."
2551 #: build/C/man3/pthread_attr_setstack.3:89
2552 msgid "B<pthread_attr_setstack>() can fail with the following error:"
2556 #: build/C/man3/pthread_attr_setstack.3:100
2558 "I<stacksize> is less than B<PTHREAD_STACK_MIN> (16384) bytes. On some "
2559 "systems, this error may also occur if I<stackaddr> or I<stackaddr\\ +\\ "
2560 "stacksize> is not suitably aligned."
2564 #: build/C/man3/pthread_attr_setstack.3:108
2566 "POSIX.1-2001 also documents an B<EACCES> error if the stack area described "
2567 "by I<stackaddr> and I<stacksize> is not both readable and writable by the "
2572 #: build/C/man3/pthread_attr_setstack.3:110
2573 msgid "These functions are provided by glibc since version 2.2."
2577 #: build/C/man3/pthread_attr_setstack.3:120
2579 "These functions are provided for applications that must ensure that a "
2580 "thread's stack is placed in a particular location. For most applications, "
2581 "this is not necessary, and the use of these functions should be avoided. "
2582 "(Use B<pthread_attr_setstacksize>(3) if an application simply requires a "
2583 "stack size other than the default.)"
2587 #: build/C/man3/pthread_attr_setstack.3:131
2589 "When an application employs B<pthread_attr_setstack>(), it takes over the "
2590 "responsibility of allocating the stack. Any guard size value that was set "
2591 "using B<pthread_attr_setguardsize>(3) is ignored. If deemed necessary, it "
2592 "is the application's responsibility to allocate a guard area (one or more "
2593 "pages protected against reading and writing) to handle the possibility of "
2598 #: build/C/man3/pthread_attr_setstack.3:142
2600 "The address specified in I<stackaddr> should be suitably aligned: for full "
2601 "portability, align it on a page boundary (I<sysconf(_SC_PAGESIZE)>). "
2602 "B<posix_memalign>(3) may be useful for allocation. Probably, I<stacksize> "
2603 "should also be a multiple of the system page size."
2607 #: build/C/man3/pthread_attr_setstack.3:151
2609 "If I<attr> is used to create multiple threads, then the caller must change "
2610 "the stack address attribute between calls to B<pthread_create>(3); "
2611 "otherwise, the threads will attempt to use the same memory area for their "
2612 "stacks, and chaos will ensue."
2616 #: build/C/man3/pthread_attr_setstack.3:164
2618 "B<mmap>(2), B<mprotect>(2), B<posix_memalign>(3), B<pthread_attr_init>(3), "
2619 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setstackaddr>(3), "
2620 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2624 #: build/C/man3/pthread_attr_setstackaddr.3:24
2626 msgid "PTHREAD_ATTR_SETSTACKADDR"
2630 #: build/C/man3/pthread_attr_setstackaddr.3:28
2632 "pthread_attr_setstackaddr, pthread_attr_getstackaddr - set/get stack address "
2633 "attribute in thread attributes object"
2637 #: build/C/man3/pthread_attr_setstackaddr.3:36
2640 "B<int pthread_attr_setstackaddr(pthread_attr_t *>I<attr>B<, void *>I<stackaddr>B<);>\n"
2641 "B<int pthread_attr_getstackaddr(pthread_attr_t *>I<attr>B<, void **>I<stackaddr>B<);>\n"
2645 #: build/C/man3/pthread_attr_setstackaddr.3:46
2647 "These functions are obsolete: B<do not use them.> Use "
2648 "B<pthread_attr_setstack>(3) and B<pthread_attr_getstack>(3) instead."
2652 #: build/C/man3/pthread_attr_setstackaddr.3:57
2654 "The B<pthread_attr_setstackaddr>() function sets the stack address "
2655 "attribute of the thread attributes object referred to by I<attr> to the "
2656 "value specified in I<stackaddr>. This attribute specifies the location of "
2657 "the stack that should be used by a thread that is created using the thread "
2658 "attributes object I<attr>."
2662 #: build/C/man3/pthread_attr_setstackaddr.3:63
2664 "I<stackaddr> should point to a buffer of at least B<PTHREAD_STACK_MIN> bytes "
2665 "that was allocated by the caller. The pages of the allocated buffer should "
2666 "be both readable and writable."
2670 #: build/C/man3/pthread_attr_setstackaddr.3:71
2672 "The B<pthread_attr_getstackaddr>() function returns the stack address "
2673 "attribute of the thread attributes object referred to by I<attr> in the "
2674 "buffer pointed to by I<stackaddr>."
2678 #: build/C/man3/pthread_attr_setstackaddr.3:78
2680 "No errors are defined (but applications should nevertheless handle a "
2681 "possible error return)."
2685 #: build/C/man3/pthread_attr_setstackaddr.3:83
2687 "POSIX.1-2001 specifies these functions but marks them as obsolete. "
2688 "POSIX.1-2008 removes the specification of these functions."
2692 #: build/C/man3/pthread_attr_setstackaddr.3:107
2694 "I<Do not use these functions!> They cannot be portably used, since they "
2695 "provide no way of specifying the direction of growth or the range of the "
2696 "stack. For example, on architectures with a stack that grows downward, "
2697 "I<stackaddr> specifies the next address past the I<highest> address of the "
2698 "allocated stack area. However, on architectures with a stack that grows "
2699 "upward, I<stackaddr> specifies the I<lowest> address in the allocated stack "
2700 "area. By contrast, the I<stackaddr> used by B<pthread_attr_setstack>(3) "
2701 "and B<pthread_attr_getstack>(3), is always a pointer to the lowest address "
2702 "in the allocated stack area (and the I<stacksize> argument specifies the "
2703 "range of the stack)."
2707 #: build/C/man3/pthread_attr_setstackaddr.3:113
2709 "B<pthread_attr_init>(3), B<pthread_attr_setstack>(3), "
2710 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2714 #: build/C/man3/pthread_attr_setstacksize.3:24
2716 msgid "PTHREAD_ATTR_SETSTACKSIZE"
2720 #: build/C/man3/pthread_attr_setstacksize.3:24
2726 #: build/C/man3/pthread_attr_setstacksize.3:28
2728 "pthread_attr_setstacksize, pthread_attr_getstacksize - set/get stack size "
2729 "attribute in thread attributes object"
2733 #: build/C/man3/pthread_attr_setstacksize.3:36
2736 "B<int pthread_attr_setstacksize(pthread_attr_t *>I<attr>B<, size_t >I<stacksize>B<);>\n"
2737 "B<int pthread_attr_getstacksize(pthread_attr_t *>I<attr>B<, size_t *>I<stacksize>B<);>\n"
2741 #: build/C/man3/pthread_attr_setstacksize.3:46
2743 "The B<pthread_attr_setstacksize>() function sets the stack size attribute "
2744 "of the thread attributes object referred to by I<attr> to the value "
2745 "specified in I<stacksize>."
2749 #: build/C/man3/pthread_attr_setstacksize.3:50
2751 "The stack size attribute determines the minimum size (in bytes) that will be "
2752 "allocated for threads created using the thread attributes object I<attr>."
2756 #: build/C/man3/pthread_attr_setstacksize.3:58
2758 "The B<pthread_attr_getstacksize>() function returns the stack size "
2759 "attribute of the thread attributes object referred to by I<attr> in the "
2760 "buffer pointed to by I<stacksize>."
2764 #: build/C/man3/pthread_attr_setstacksize.3:64
2765 msgid "B<pthread_attr_setstacksize>() can fail with the following error:"
2769 #: build/C/man3/pthread_attr_setstacksize.3:69
2770 msgid "The stack size is less than B<PTHREAD_STACK_MIN> (16384) bytes."
2775 #: build/C/man3/pthread_attr_setstacksize.3:78
2777 "On some systems, B<pthread_attr_setstacksize>() can fail with the error "
2778 "B<EINVAL> if I<stacksize> is not a multiple of the system page size."
2782 #: build/C/man3/pthread_attr_setstacksize.3:85 build/C/man3/pthread_join.3:125
2783 msgid "See B<pthread_create>(3)."
2787 #: build/C/man3/pthread_attr_setstacksize.3:88
2789 "For details on the default stack size of new threads, see B<pthread_create>"
2794 #: build/C/man3/pthread_attr_setstacksize.3:91
2796 "A thread's stack size is fixed at the time of thread creation. Only the "
2797 "main thread can dynamically grow its stack."
2801 #: build/C/man3/pthread_attr_setstacksize.3:96
2803 "The B<pthread_attr_setstack>(3) function allows an application to set both "
2804 "the size and location of a caller-allocated stack that is to be used by a "
2809 #: build/C/man3/pthread_attr_setstacksize.3:108
2811 "As at glibc 2.8, if the specified I<stacksize> is not a multiple of "
2812 "B<STACK_ALIGN> (16 bytes on most architectures), it may be rounded "
2813 "I<downward>, in violation of POSIX.1-2001, which says that the allocated "
2814 "stack will be at least I<stacksize> bytes."
2818 #: build/C/man3/pthread_attr_setstacksize.3:115
2820 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_attr_setguardsize>(3), "
2821 "B<pthread_attr_setstack>(3), B<pthread_create>(3), B<pthreads>(7)"
2825 #: build/C/man3/pthread_cancel.3:24
2827 msgid "PTHREAD_CANCEL"
2831 #: build/C/man3/pthread_cancel.3:24 build/C/man3/pthread_setschedparam.3:24
2832 #: build/C/man3/pthread_testcancel.3:24
2838 #: build/C/man3/pthread_cancel.3:27
2839 msgid "pthread_cancel - send a cancellation request to a thread"
2843 #: build/C/man3/pthread_cancel.3:32
2845 msgid "B<int pthread_cancel(pthread_t >I<thread>B<);>\n"
2849 #: build/C/man3/pthread_cancel.3:43
2851 "The B<pthread_cancel>() function sends a cancellation request to the thread "
2852 "I<thread>. Whether and when the target thread reacts to the cancellation "
2853 "request depends on two attributes that are under the control of that thread: "
2854 "its cancelability I<state> and I<type>."
2858 #: build/C/man3/pthread_cancel.3:55
2860 "A thread's cancelability state, determined by B<pthread_setcancelstate>(3), "
2861 "can be I<enabled> (the default for new threads) or I<disabled>. If a thread "
2862 "has disabled cancellation, then a cancellation request remains queued until "
2863 "the thread enables cancellation. If a thread has enabled cancellation, then "
2864 "its cancelability type determines when cancellation occurs."
2868 #: build/C/man3/pthread_cancel.3:71
2870 "A thread's cancellation type, determined by B<pthread_setcanceltype>(3), may "
2871 "be either I<asynchronous> or I<deferred> (the default for new threads). "
2872 "Asynchronous cancelability means that the thread can be canceled at any time "
2873 "(usually immediately, but the system does not guarantee this). Deferred "
2874 "cancelability means that cancellation will be delayed until the thread next "
2875 "calls a function that is a I<cancellation point>. A list of functions that "
2876 "are or may be cancellation points is provided in I<pthreads>(7)."
2880 #: build/C/man3/pthread_cancel.3:75
2882 "When a cancellation requested is acted on, the following steps occur for "
2883 "I<thread> (in this order):"
2887 #: build/C/man3/pthread_cancel.3:75 build/C/man3/pthread_cleanup_push.3:66
2893 #: build/C/man3/pthread_cancel.3:80
2895 "Cancellation clean-up handlers are popped (in the reverse of the order in "
2896 "which they were pushed) and called. (See B<pthread_cleanup_push>(3).)"
2900 #: build/C/man3/pthread_cancel.3:80 build/C/man3/pthread_cleanup_push.3:70
2906 #: build/C/man3/pthread_cancel.3:85
2908 "Thread-specific data destructors are called, in an unspecified order. (See "
2909 "B<pthread_key_create>(3).)"
2913 #: build/C/man3/pthread_cancel.3:85 build/C/man3/pthread_cleanup_push.3:78
2919 #: build/C/man3/pthread_cancel.3:89
2920 msgid "The thread is terminated. (See B<pthread_exit>(3).)"
2924 #: build/C/man3/pthread_cancel.3:97
2926 "The above steps happen asynchronously with respect to the B<pthread_cancel>"
2927 "() call; the return status of B<pthread_cancel>() merely informs the "
2928 "caller whether the cancellation request was successfully queued."
2932 #: build/C/man3/pthread_cancel.3:106
2934 "After a canceled thread has terminated, a join with that thread using "
2935 "B<pthread_join>(3) obtains B<PTHREAD_CANCELED> as the thread's exit "
2936 "status. (Joining with a thread is the only way to know that cancellation "
2941 #: build/C/man3/pthread_cancel.3:111
2943 "On success, B<pthread_cancel>() returns 0; on error, it returns a nonzero "
2948 #: build/C/man3/pthread_cancel.3:112 build/C/man3/pthread_detach.3:57
2949 #: build/C/man3/pthread_getcpuclockid.3:55 build/C/man3/pthread_join.3:91
2950 #: build/C/man3/pthread_kill.3:59 build/C/man3/pthread_setaffinity_np.3:111
2951 #: build/C/man3/pthread_setschedparam.3:111
2952 #: build/C/man3/pthread_setschedprio.3:67 build/C/man3/pthread_sigqueue.3:83
2958 #: build/C/man3/pthread_cancel.3:119 build/C/man3/pthread_detach.3:62
2959 #: build/C/man3/pthread_getcpuclockid.3:60 build/C/man3/pthread_join.3:96
2960 #: build/C/man3/pthread_kill.3:64 build/C/man3/pthread_setaffinity_np.3:116
2961 #: build/C/man3/pthread_setschedparam.3:116
2962 #: build/C/man3/pthread_setschedprio.3:72
2963 msgid "No thread with the ID I<thread> could be found."
2967 #: build/C/man3/pthread_cancel.3:129
2969 "On Linux, cancellation is implemented using signals. Under the NPTL "
2970 "threading implementation, the first real-time signal (i.e., signal 32) is "
2971 "used for this purpose. On LinuxThreads, the second real-time signal is "
2972 "used, if real-time signals are available, otherwise B<SIGUSR2> is used."
2976 #: build/C/man3/pthread_cancel.3:135
2978 "The program below creates a thread and then cancels it. The main thread "
2979 "joins with the canceled thread to check that its exit status was "
2980 "B<PTHREAD_CANCELED>. The following shell session shows what happens when we "
2985 #: build/C/man3/pthread_cancel.3:143
2989 "thread_func(): started; cancellation disabled\n"
2990 "main(): sending cancellation request\n"
2991 "thread_func(): about to enable cancellation\n"
2992 "main(): thread was canceled\n"
2996 #: build/C/man3/pthread_cancel.3:153
2999 "#include E<lt>pthread.hE<gt>\n"
3000 "#include E<lt>stdio.hE<gt>\n"
3001 "#include E<lt>errno.hE<gt>\n"
3002 "#include E<lt>stdlib.hE<gt>\n"
3003 "#include E<lt>unistd.hE<gt>\n"
3007 #: build/C/man3/pthread_cancel.3:161
3011 "thread_func(void *ignored_argument)\n"
3017 #: build/C/man3/pthread_cancel.3:164
3020 " /* Disable cancellation for a while, so that we don\\(aqt\n"
3021 " immediately react to a cancellation request */\n"
3025 #: build/C/man3/pthread_cancel.3:168
3028 " s = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);\n"
3030 " handle_error_en(s, \"pthread_setcancelstate\");\n"
3034 #: build/C/man3/pthread_cancel.3:172
3037 " printf(\"thread_func(): started; cancellation disabled\\en\");\n"
3039 " printf(\"thread_func(): about to enable cancellation\\en\");\n"
3043 #: build/C/man3/pthread_cancel.3:176
3046 " s = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);\n"
3048 " handle_error_en(s, \"pthread_setcancelstate\");\n"
3052 #: build/C/man3/pthread_cancel.3:178
3054 msgid " /* sleep() is a cancellation point */\n"
3058 #: build/C/man3/pthread_cancel.3:180
3060 msgid " sleep(1000); /* Should get canceled while we sleep */\n"
3064 #: build/C/man3/pthread_cancel.3:182
3066 msgid " /* Should never get here */\n"
3070 #: build/C/man3/pthread_cancel.3:186
3073 " printf(\"thread_func(): not canceled!\\en\");\n"
3079 #: build/C/man3/pthread_cancel.3:193
3091 #: build/C/man3/pthread_cancel.3:195
3093 msgid " /* Start a thread and then send it a cancellation request */\n"
3097 #: build/C/man3/pthread_cancel.3:199
3100 " s = pthread_create(&thr, NULL, &thread_func, NULL);\n"
3102 " handle_error_en(s, \"pthread_create\");\n"
3106 #: build/C/man3/pthread_cancel.3:201
3108 msgid " sleep(2); /* Give thread a chance to get started */\n"
3112 #: build/C/man3/pthread_cancel.3:206
3115 " printf(\"main(): sending cancellation request\\en\");\n"
3116 " s = pthread_cancel(thr);\n"
3118 " handle_error_en(s, \"pthread_cancel\");\n"
3122 #: build/C/man3/pthread_cancel.3:208
3124 msgid " /* Join with thread to see what its exit status was */\n"
3128 #: build/C/man3/pthread_cancel.3:212 build/C/man3/pthread_cleanup_push.3:300
3131 " s = pthread_join(thr, &res);\n"
3133 " handle_error_en(s, \"pthread_join\");\n"
3137 #: build/C/man3/pthread_cancel.3:219
3140 " if (res == PTHREAD_CANCELED)\n"
3141 " printf(\"main(): thread was canceled\\en\");\n"
3143 " printf(\"main(): thread wasn\\(aqt canceled (shouldn\\(aqt happen!)\\en\");\n"
3144 " exit(EXIT_SUCCESS);\n"
3149 #: build/C/man3/pthread_cancel.3:230
3151 "B<pthread_cleanup_push>(3), B<pthread_create>(3), B<pthread_exit>(3), "
3152 "B<pthread_join>(3), B<pthread_key_create>(3), B<pthread_setcancelstate>(3), "
3153 "B<pthread_setcanceltype>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3157 #: build/C/man3/pthread_cleanup_push.3:24
3159 msgid "PTHREAD_CLEANUP_PUSH"
3163 #: build/C/man3/pthread_cleanup_push.3:24
3164 #: build/C/man3/pthread_setcancelstate.3:24
3170 #: build/C/man3/pthread_cleanup_push.3:28
3172 "pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancellation "
3177 #: build/C/man3/pthread_cleanup_push.3:35
3180 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *),>\n"
3181 "B< void *>I<arg>B<);>\n"
3182 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
3186 #: build/C/man3/pthread_cleanup_push.3:45
3188 "These functions manipulate the calling thread's stack of thread-cancellation "
3189 "clean-up handlers. A clean-up handler is a function that is automatically "
3190 "executed when a thread is canceled (or in various other circumstances "
3191 "described below); it might, for example, unlock a mutex so that it becomes "
3192 "available to other threads in the process."
3196 #: build/C/man3/pthread_cleanup_push.3:56
3198 "The B<pthread_cleanup_push>() function pushes I<routine> onto the top of "
3199 "the stack of clean-up handlers. When I<routine> is later invoked, it will "
3200 "be given I<arg> as its argument."
3204 #: build/C/man3/pthread_cleanup_push.3:63
3206 "The B<pthread_cleanup_pop>() function removes the routine at the top of the "
3207 "stack of clean-up handlers, and optionally executes it if I<execute> is "
3212 #: build/C/man3/pthread_cleanup_push.3:66
3214 "A cancellation clean-up handler is popped from the stack and executed in the "
3215 "following circumstances:"
3219 #: build/C/man3/pthread_cleanup_push.3:70
3221 "When a thread is canceled, all of the stacked clean-up handlers are popped "
3222 "and executed in the reverse of the order in which they were pushed onto the "
3227 #: build/C/man3/pthread_cleanup_push.3:78
3229 "When a thread terminates by calling B<pthread_exit>(3), all clean-up "
3230 "handlers are executed as described in the preceding point. (Clean-up "
3231 "handlers are I<not> called if the thread terminates by performing a "
3232 "I<return> from the thread start function.)"
3236 #: build/C/man3/pthread_cleanup_push.3:84
3238 "When a thread calls B<pthread_cleanup_pop>() with a nonzero I<execute> "
3239 "argument, the top-most clean-up handler is popped and executed."
3243 #: build/C/man3/pthread_cleanup_push.3:96
3245 "POSIX.1 permits B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() to "
3246 "be implemented as macros that expand to text containing \\(aqB<{>\\(aq and "
3247 "\\(aqB<}>\\(aq, respectively. For this reason, the caller must ensure that "
3248 "calls to these functions are paired within the same function, and at the "
3249 "same lexical nesting level. (In other words, a clean-up handler is only "
3250 "established during the execution of a specified section of code.)"
3254 #: build/C/man3/pthread_cleanup_push.3:116
3256 "Calling B<longjmp>(3) (B<siglongjmp>(3)) produces undefined results if any "
3257 "call has been made to B<pthread_cleanup_push>() or B<pthread_cleanup_pop>"
3258 "() without the matching call of the pair since the jump buffer was filled "
3259 "by B<setjmp>(3) (B<sigsetjmp>(3)). Likewise, calling B<longjmp>(3) "
3260 "(B<siglongjmp>(3)) from inside a clean-up handler produces undefined "
3261 "results unless the jump buffer was also filled by B<setjmp>(3) (B<sigsetjmp>"
3262 "(3)) inside the handler."
3266 #: build/C/man3/pthread_cleanup_push.3:118
3267 msgid "These functions do not return a value."
3271 #. Available since glibc 2.0
3273 #: build/C/man3/pthread_cleanup_push.3:122
3274 msgid "There are no errors."
3278 #: build/C/man3/pthread_cleanup_push.3:133
3280 "On Linux, the B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() "
3281 "functions I<are> implemented as macros that expand to text containing \\(aqB<"
3282 "{>\\(aq and \\(aqB<}>\\(aq, respectively. This means that variables "
3283 "declared within the scope of paired calls to these functions will only be "
3284 "visible within that scope."
3287 #. The text was actually added in the 2004 TC2
3289 #: build/C/man3/pthread_cleanup_push.3:148
3291 "POSIX.1 says that the effect of using I<return>, I<break>, I<continue>, or "
3292 "I<goto> to prematurely leave a block bracketed B<pthread_cleanup_push>() "
3293 "and B<pthread_cleanup_pop>() is undefined. Portable applications should "
3298 #: build/C/man3/pthread_cleanup_push.3:163
3300 "The program below provides a simple example of the use of the functions "
3301 "described in this page. The program creates a thread that executes a loop "
3302 "bracketed by B<pthread_cleanup_push>() and B<pthread_cleanup_pop>(). This "
3303 "loop increments a global variable, I<cnt>, once each second. Depending on "
3304 "what command-line arguments are supplied, the main thread sends the other "
3305 "thread a cancellation request, or sets a global variable that causes the "
3306 "other thread to exit its loop and terminate normally (by doing a I<return>)."
3310 #: build/C/man3/pthread_cleanup_push.3:166
3312 "In the following shell session, the main thread sends a cancellation request "
3313 "to the other thread:"
3317 #: build/C/man3/pthread_cleanup_push.3:176
3321 "New thread started\n"
3324 "Canceling thread\n"
3325 "Called clean-up handler\n"
3326 "Thread was canceled; cnt = 0\n"
3330 #: build/C/man3/pthread_cleanup_push.3:184
3332 "From the above, we see that the thread was canceled, and that the "
3333 "cancellation clean-up handler was called and it reset the value of the "
3334 "global variable I<cnt> to 0."
3338 #: build/C/man3/pthread_cleanup_push.3:187
3340 "In the next run, the main program sets a global variable that causes other "
3341 "thread to terminate normally:"
3345 #: build/C/man3/pthread_cleanup_push.3:195
3349 "New thread started\n"
3352 "Thread terminated normally; cnt = 2\n"
3356 #: build/C/man3/pthread_cleanup_push.3:203
3358 "From the above, we see that the clean-up handler was not executed (because "
3359 "I<cleanup_pop_arg> was 0), and therefore the value of I<cnt> was not reset."
3363 #: build/C/man3/pthread_cleanup_push.3:208
3365 "In the next run, the main program sets a global variable that causes the "
3366 "other thread to terminate normally, and supplies a nonzero value for "
3367 "I<cleanup_pop_arg>:"
3371 #: build/C/man3/pthread_cleanup_push.3:217
3374 "$ B<./a.out x 1>\n"
3375 "New thread started\n"
3378 "Called clean-up handler\n"
3379 "Thread terminated normally; cnt = 0\n"
3383 #: build/C/man3/pthread_cleanup_push.3:224
3385 "In the above, we see that although the thread was not canceled, the clean-up "
3386 "handler was executed, because the argument given to B<pthread_cleanup_pop>"
3391 #: build/C/man3/pthread_cleanup_push.3:233
3394 "#include E<lt>pthread.hE<gt>\n"
3395 "#include E<lt>sys/types.hE<gt>\n"
3396 "#include E<lt>stdio.hE<gt>\n"
3397 "#include E<lt>stdlib.hE<gt>\n"
3398 "#include E<lt>unistd.hE<gt>\n"
3399 "#include E<lt>errno.hE<gt>\n"
3403 #: build/C/man3/pthread_cleanup_push.3:240
3406 "static int done = 0;\n"
3407 "static int cleanup_pop_arg = 0;\n"
3408 "static int cnt = 0;\n"
3412 #: build/C/man3/pthread_cleanup_push.3:247
3416 "cleanup_handler(void *arg)\n"
3418 " printf(\"Called clean-up handler\\en\");\n"
3424 #: build/C/man3/pthread_cleanup_push.3:252
3428 "thread_start(void *arg)\n"
3430 " time_t start, curr;\n"
3434 #: build/C/man3/pthread_cleanup_push.3:254
3436 msgid " printf(\"New thread started\\en\");\n"
3440 #: build/C/man3/pthread_cleanup_push.3:256
3442 msgid " pthread_cleanup_push(cleanup_handler, NULL);\n"
3446 #: build/C/man3/pthread_cleanup_push.3:258
3448 msgid " curr = start = time(NULL);\n"
3452 #: build/C/man3/pthread_cleanup_push.3:267
3455 " while (!done) {\n"
3456 " pthread_testcancel(); /* A cancellation point */\n"
3457 " if (curr E<lt> time(NULL)) {\n"
3458 " curr = time(NULL);\n"
3459 " printf(\"cnt = %d\\en\", cnt); /* A cancellation point */\n"
3466 #: build/C/man3/pthread_cleanup_push.3:271
3469 " pthread_cleanup_pop(cleanup_pop_arg);\n"
3475 #: build/C/man3/pthread_cleanup_push.3:278
3479 "main(int argc, char *argv[])\n"
3487 #: build/C/man3/pthread_cleanup_push.3:282
3490 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
3492 " handle_error_en(s, \"pthread_create\");\n"
3496 #: build/C/man3/pthread_cleanup_push.3:284
3498 msgid " sleep(2); /* Allow new thread to run a while */\n"
3502 #: build/C/man3/pthread_cleanup_push.3:289
3505 " if (argc E<gt> 1) {\n"
3506 " if (argc E<gt> 2)\n"
3507 " cleanup_pop_arg = atoi(argv[2]);\n"
3512 #: build/C/man3/pthread_cleanup_push.3:296
3516 " printf(\"Canceling thread\\en\");\n"
3517 " s = pthread_cancel(thr);\n"
3519 " handle_error_en(s, \"pthread_cancel\");\n"
3524 #: build/C/man3/pthread_cleanup_push.3:307
3527 " if (res == PTHREAD_CANCELED)\n"
3528 " printf(\"Thread was canceled; cnt = %d\\en\", cnt);\n"
3530 " printf(\"Thread terminated normally; cnt = %d\\en\", cnt);\n"
3531 " exit(EXIT_SUCCESS);\n"
3536 #: build/C/man3/pthread_cleanup_push.3:314
3538 "B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), "
3539 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3543 #: build/C/man3/pthread_cleanup_push_defer_np.3:24
3545 msgid "PTHREAD_CLEANUP_PUSH_DEFER_NP"
3549 #: build/C/man3/pthread_cleanup_push_defer_np.3:24
3555 #: build/C/man3/pthread_cleanup_push_defer_np.3:28
3557 "pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np - push and pop "
3558 "thread cancellation clean-up handlers while saving cancelability type"
3562 #: build/C/man3/pthread_cleanup_push_defer_np.3:35
3565 "B<void pthread_cleanup_push_defer_np(void (*>I<routine>B<)(void *),>\n"
3566 "B< void *>I<arg>B<);>\n"
3567 "B<void pthread_cleanup_pop_restore_np(int >I<execute>B<);>\n"
3571 #: build/C/man3/pthread_cleanup_push_defer_np.3:43
3573 "These functions are the same as B<pthread_cleanup_push>(3) and "
3574 "B<pthread_cleanup_pop>(3), except for the differences noted on this page."
3578 #: build/C/man3/pthread_cleanup_push_defer_np.3:56
3580 "Like B<pthread_cleanup_push>(3), B<pthread_cleanup_push_defer_np>() pushes "
3581 "I<routine> onto the thread's stack of cancellation clean-up handlers. In "
3582 "addition, it also saves the thread's current cancelability type, and sets "
3583 "the cancelability type to \"deferred\" (see B<pthread_setcanceltype>(3)); "
3584 "this ensures that cancellation clean-up will occur even if the thread's "
3585 "cancelability type was \"asynchronous\" before the the call."
3589 #: build/C/man3/pthread_cleanup_push_defer_np.3:65
3591 "Like B<pthread_cleanup_pop>(3), B<pthread_cleanup_pop_restore_np>() pops "
3592 "the top-most clean-up handler from the thread's stack of cancellation clean-"
3593 "up handlers. In addition, it restores the thread's cancelability type to "
3594 "its value at the time of the matching B<pthread_cleanup_push_defer_np>()."
3598 #: build/C/man3/pthread_cleanup_push_defer_np.3:71
3600 "The caller must ensure that calls to these functions are paired within the "
3601 "same function, and at the same lexical nesting level. Other restrictions "
3602 "apply, as described in B<pthread_cleanup_push>(3)."
3606 #: build/C/man3/pthread_cleanup_push_defer_np.3:73
3607 msgid "This sequence of calls:"
3611 #: build/C/man3/pthread_cleanup_push_defer_np.3:78
3614 "pthread_cleanup_push_defer_np(routine, arg);\n"
3615 "pthread_cleanup_pop_restore_np(execute);\n"
3619 #: build/C/man3/pthread_cleanup_push_defer_np.3:82
3620 msgid "is equivalent to (but shorter and more efficient than):"
3624 #: build/C/man3/pthread_cleanup_push_defer_np.3:88
3626 msgid "int oldtype;\n"
3630 #: build/C/man3/pthread_cleanup_push_defer_np.3:94
3633 "pthread_cleanup_push(routine, arg);\n"
3634 "pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);\n"
3636 "pthread_setcanceltype(oldtype, NULL);\n"
3637 "pthread_cleanup_pop(execute);\n"
3641 #: build/C/man3/pthread_cleanup_push_defer_np.3:107
3643 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), B<pthread_setcancelstate>"
3644 "(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3648 #: build/C/man3/pthread_create.3:24
3650 msgid "PTHREAD_CREATE"
3654 #: build/C/man3/pthread_create.3:27
3655 msgid "pthread_create - create a new thread"
3659 #: build/C/man3/pthread_create.3:33
3662 "B<int pthread_create(pthread_t *>I<thread>B<, const pthread_attr_t *>I<attr>B<,>\n"
3663 "B< void *(*>I<start_routine>B<) (void *), void *>I<arg>B<);>\n"
3667 #: build/C/man3/pthread_create.3:36 build/C/man3/pthread_detach.3:35
3668 #: build/C/man3/pthread_join.3:35 build/C/man3/pthread_kill.3:35
3669 #: build/C/man3/pthread_sigmask.3:36 build/C/man3/pthread_sigqueue.3:35
3670 #: build/C/man3/pthread_tryjoin_np.3:40 build/C/man3/pthread_yield.3:34
3671 msgid "Compile and link with I<-pthread>."
3675 #: build/C/man3/pthread_create.3:45
3677 "The B<pthread_create>() function starts a new thread in the calling "
3678 "process. The new thread starts execution by invoking I<start_routine>(); "
3679 "I<arg> is passed as the sole argument of I<start_routine>()."
3683 #: build/C/man3/pthread_create.3:47
3684 msgid "The new thread terminates in one of the following ways:"
3688 #: build/C/man3/pthread_create.3:47 build/C/man3/pthread_create.3:53
3689 #: build/C/man3/pthread_create.3:61 build/C/man3/pthread_create.3:64
3690 #: build/C/man3/pthread_getattr_np.3:49 build/C/man3/pthread_getattr_np.3:52
3691 #: build/C/man3/pthread_getattr_np.3:55
3697 #: build/C/man3/pthread_create.3:53
3699 "It calls B<pthread_exit>(3), specifying an exit status value that is "
3700 "available to another thread in the same process that calls B<pthread_join>"
3705 #: build/C/man3/pthread_create.3:61
3707 "It returns from I<start_routine>(). This is equivalent to calling "
3708 "B<pthread_exit>(3) with the value supplied in the I<return> statement."
3712 #: build/C/man3/pthread_create.3:64
3713 msgid "It is canceled (see B<pthread_cancel>(3))."
3717 #: build/C/man3/pthread_create.3:70
3719 "Any of the threads in the process calls B<exit>(3), or the main thread "
3720 "performs a return from I<main>(). This causes the termination of all "
3721 "threads in the process."
3725 #: build/C/man3/pthread_create.3:84
3727 "The I<attr> argument points to a I<pthread_attr_t> structure whose contents "
3728 "are used at thread creation time to determine attributes for the new thread; "
3729 "this structure is initialized using B<pthread_attr_init>(3) and related "
3730 "functions. If I<attr> is NULL, then the thread is created with default "
3735 #: build/C/man3/pthread_create.3:91
3737 "Before returning, a successful call to B<pthread_create>() stores the ID of "
3738 "the new thread in the buffer pointed to by I<thread>; this identifier is "
3739 "used to refer to the thread in subsequent calls to other pthreads functions."
3743 #: build/C/man3/pthread_create.3:99
3745 "The new thread inherits a copy of the creating thread's signal mask "
3746 "(B<pthread_sigmask>(3)). The set of pending signals for the new thread is "
3747 "empty (B<sigpending>(2)). The new thread does not inherit the creating "
3748 "thread's alternate signal stack (B<sigaltstack>(2))."
3752 #: build/C/man3/pthread_create.3:102
3754 "The new thread inherits the calling thread's floating-point environment "
3758 #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
3760 #: build/C/man3/pthread_create.3:107
3762 "The initial value of the new thread's CPU-time clock is 0 (see "
3763 "B<pthread_getcpuclockid>(3))."
3767 #: build/C/man3/pthread_create.3:107
3769 msgid "Linux-specific details"
3773 #: build/C/man3/pthread_create.3:113
3775 "The new thread inherits copies of the calling thread's capability sets (see "
3776 "B<capabilities>(7)) and CPU affinity mask (see B<sched_setaffinity>(2))."
3780 #: build/C/man3/pthread_create.3:120
3782 "On success, B<pthread_create>() returns 0; on error, it returns an error "
3783 "number, and the contents of I<*thread> are undefined."
3787 #: build/C/man3/pthread_create.3:121 build/C/man3/pthread_sigqueue.3:69
3793 #: build/C/man3/pthread_create.3:135
3795 "Insufficient resources to create another thread, or a system-imposed limit "
3796 "on the number of threads was encountered. The latter case may occur in two "
3797 "ways: the B<RLIMIT_NPROC> soft resource limit (set via B<setrlimit>(2)), "
3798 "which limits the number of process for a real user ID, was reached; or the "
3799 "kernel's system-wide limit on the number of threads, I</proc/sys/kernel/"
3800 "threads-max>, was reached."
3804 #: build/C/man3/pthread_create.3:139
3805 msgid "Invalid settings in I<attr>."
3809 #: build/C/man3/pthread_create.3:139 build/C/man3/pthread_setschedparam.3:126
3810 #: build/C/man3/pthread_setschedprio.3:63
3816 #: build/C/man3/pthread_create.3:144
3818 "No permission to set the scheduling policy and parameters specified in "
3823 #: build/C/man3/pthread_create.3:158
3825 "See B<pthread_self>(3) for further information on the thread ID returned in "
3826 "I<*thread> by B<pthread_create>(). Unless real-time scheduling policies are "
3827 "being employed, after a call to B<pthread_create>(), it is indeterminate "
3828 "which thread\\(emthe caller or the new thread\\(emwill next execute."
3832 #: build/C/man3/pthread_create.3:178
3834 "A thread may either be I<joinable> or I<detached>. If a thread is joinable, "
3835 "then another thread can call B<pthread_join>(3) to wait for the thread to "
3836 "terminate and fetch its exit status. Only when a terminated joinable thread "
3837 "has been joined are the last of its resources released back to the system. "
3838 "When a detached thread terminates, its resources are automatically released "
3839 "back to the system: it is not possible to join with the thread in order to "
3840 "obtain its exit status. Making a thread detached is useful for some types "
3841 "of daemon threads whose exit status the application does not need to care "
3842 "about. By default, a new thread is created in a joinable state, unless "
3843 "I<attr> was set to create the thread in a detached state (using "
3844 "B<pthread_attr_setdetachstate>(3))."
3847 #. FIXME . Perhaps some of the following detail should be in
3848 #. a future pthread_attr_setstacksize(3) page.
3850 #: build/C/man3/pthread_create.3:194
3852 "On Linux/x86-32, the default stack size for a new thread is 2 megabytes. "
3853 "Under the NPTL threading implementation, if the B<RLIMIT_STACK> soft "
3854 "resource limit I<at the time the program started> has any value other than "
3855 "\"unlimited\", then it determines the default stack size of new threads. "
3856 "Using B<pthread_attr_setstacksize>(3), the stack size attribute can be "
3857 "explicitly set in the I<attr> argument used to create a thread, in order to "
3858 "obtain a stack size other than the default."
3862 #: build/C/man3/pthread_create.3:198
3864 "The program below demonstrates the use of B<pthread_create>(), as well as a "
3865 "number of other functions in the pthreads API."
3869 #: build/C/man3/pthread_create.3:203
3871 "In the following run, on a system providing the NPTL threading "
3872 "implementation, the stack size defaults to the value given by the \"stack "
3873 "size\" resource limit:"
3877 #: build/C/man3/pthread_create.3:215
3881 "8192 # The stack size limit is 8 MB (0x80000 bytes)\n"
3882 "$B< ./a.out hola salut servus>\n"
3883 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
3884 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
3885 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
3886 "Joined with thread 1; returned value was HOLA\n"
3887 "Joined with thread 2; returned value was SALUT\n"
3888 "Joined with thread 3; returned value was SERVUS\n"
3892 #: build/C/man3/pthread_create.3:221
3894 "In the next run, the program explicitly sets a stack size of 1MB (using "
3895 "B<pthread_attr_setstacksize>(3)) for the created threads:"
3899 #: build/C/man3/pthread_create.3:231
3902 "$B< ./a.out -s 0x100000 hola salut servus>\n"
3903 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
3904 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
3905 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
3906 "Joined with thread 1; returned value was HOLA\n"
3907 "Joined with thread 2; returned value was SALUT\n"
3908 "Joined with thread 3; returned value was SERVUS\n"
3912 #: build/C/man3/pthread_create.3:243
3915 "#include E<lt>pthread.hE<gt>\n"
3916 "#include E<lt>string.hE<gt>\n"
3917 "#include E<lt>stdio.hE<gt>\n"
3918 "#include E<lt>stdlib.hE<gt>\n"
3919 "#include E<lt>unistd.hE<gt>\n"
3920 "#include E<lt>errno.hE<gt>\n"
3921 "#include E<lt>ctype.hE<gt>\n"
3925 #: build/C/man3/pthread_create.3:249 build/C/man3/pthread_getcpuclockid.3:107
3928 "#define handle_error(msg) \\e\n"
3929 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
3933 #: build/C/man3/pthread_create.3:255
3936 "struct thread_info { /* Used as argument to thread_start() */\n"
3937 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
3938 " int thread_num; /* Application-defined thread # */\n"
3939 " char *argv_string; /* From command-line argument */\n"
3944 #: build/C/man3/pthread_create.3:258
3947 "/* Thread start function: display address near top of our stack,\n"
3948 " and return upper-cased copy of argv_string */\n"
3952 #: build/C/man3/pthread_create.3:264
3956 "thread_start(void *arg)\n"
3958 " struct thread_info *tinfo = (struct thread_info *) arg;\n"
3959 " char *uargv, *p;\n"
3963 #: build/C/man3/pthread_create.3:267
3966 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n"
3967 " tinfo-E<gt>thread_num, &p, tinfo-E<gt>argv_string);\n"
3971 #: build/C/man3/pthread_create.3:271
3974 " uargv = strdup(tinfo-E<gt>argv_string);\n"
3975 " if (uargv == NULL)\n"
3976 " handle_error(\"strdup\");\n"
3980 #: build/C/man3/pthread_create.3:274
3983 " for (p = uargv; *p != \\(aq\\e0\\(aq; p++)\n"
3984 " *p = toupper(*p);\n"
3988 #: build/C/man3/pthread_create.3:277
3996 #: build/C/man3/pthread_create.3:286
4000 "main(int argc, char *argv[])\n"
4002 " int s, tnum, opt, num_threads;\n"
4003 " struct thread_info *tinfo;\n"
4004 " pthread_attr_t attr;\n"
4005 " int stack_size;\n"
4010 #: build/C/man3/pthread_create.3:288
4012 msgid " /* The \"-s\" option specifies a stack size for our threads */\n"
4016 #: build/C/man3/pthread_create.3:295
4019 " stack_size = -1;\n"
4020 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
4022 " case \\(aqs\\(aq:\n"
4023 " stack_size = strtoul(optarg, NULL, 0);\n"
4028 #: build/C/man3/pthread_create.3:302
4032 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n"
4034 " exit(EXIT_FAILURE);\n"
4040 #: build/C/man3/pthread_create.3:304
4042 msgid " num_threads = argc - optind;\n"
4046 #: build/C/man3/pthread_create.3:306
4048 msgid " /* Initialize thread creation attributes */\n"
4052 #: build/C/man3/pthread_create.3:310
4055 " s = pthread_attr_init(&attr);\n"
4057 " handle_error_en(s, \"pthread_attr_init\");\n"
4061 #: build/C/man3/pthread_create.3:316
4064 " if (stack_size E<gt> 0) {\n"
4065 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
4067 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4072 #: build/C/man3/pthread_create.3:318
4074 msgid " /* Allocate memory for pthread_create() arguments */\n"
4078 #: build/C/man3/pthread_create.3:322
4081 " tinfo = calloc(num_threads, sizeof(struct thread_info));\n"
4082 " if (tinfo == NULL)\n"
4083 " handle_error(\"calloc\");\n"
4087 #: build/C/man3/pthread_create.3:324
4089 msgid " /* Create one thread for each command-line argument */\n"
4093 #: build/C/man3/pthread_create.3:328
4096 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
4097 " tinfo[tnum].thread_num = tnum + 1;\n"
4098 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
4102 #: build/C/man3/pthread_create.3:331
4105 " /* The pthread_create() call stores the thread ID into\n"
4106 " corresponding element of tinfo[] */\n"
4110 #: build/C/man3/pthread_create.3:337
4113 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
4114 " &thread_start, &tinfo[tnum]);\n"
4116 " handle_error_en(s, \"pthread_create\");\n"
4121 #: build/C/man3/pthread_create.3:340
4124 " /* Destroy the thread attributes object, since it is no\n"
4125 " longer needed */\n"
4129 #: build/C/man3/pthread_create.3:344 build/C/man3/pthread_setschedparam.3:420
4132 " s = pthread_attr_destroy(&attr);\n"
4134 " handle_error_en(s, \"pthread_attr_destroy\");\n"
4138 #: build/C/man3/pthread_create.3:346
4140 msgid " /* Now join with each thread, and display its returned value */\n"
4144 #: build/C/man3/pthread_create.3:351
4147 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
4148 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
4150 " handle_error_en(s, \"pthread_join\");\n"
4154 #: build/C/man3/pthread_create.3:356
4157 " printf(\"Joined with thread %d; returned value was %s\\en\",\n"
4158 " tinfo[tnum].thread_num, (char *) res);\n"
4159 " free(res); /* Free memory allocated by thread */\n"
4164 #: build/C/man3/pthread_create.3:360
4168 " exit(EXIT_SUCCESS);\n"
4173 #: build/C/man3/pthread_create.3:367
4175 "In the obsolete LinuxThreads implementation, each of the threads in a "
4176 "process has a different process ID. This is in violation of the POSIX "
4177 "threads specification, and is the source of many other nonconformances to "
4178 "the standard; see B<pthreads>(7)."
4182 #: build/C/man3/pthread_create.3:378
4184 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
4185 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
4186 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), B<pthreads>"
4191 #: build/C/man3/pthread_detach.3:24
4193 msgid "PTHREAD_DETACH"
4197 #: build/C/man3/pthread_detach.3:24 build/C/man3/pthread_join.3:24
4203 #: build/C/man3/pthread_detach.3:27
4204 msgid "pthread_detach - detach a thread"
4208 #: build/C/man3/pthread_detach.3:32
4210 msgid "B<int pthread_detach(pthread_t >I<thread>B<);>\n"
4214 #: build/C/man3/pthread_detach.3:44
4216 "The B<pthread_detach>() function marks the thread identified by I<thread> "
4217 "as detached. When a detached thread terminates, its resources are "
4218 "automatically released back to the system without the need for another "
4219 "thread to join with the terminated thread."
4223 #: build/C/man3/pthread_detach.3:47
4225 "Attempting to detach an already detached thread results in unspecified "
4230 #: build/C/man3/pthread_detach.3:52
4232 "On success, B<pthread_detach>() returns 0; on error, it returns an error "
4237 #: build/C/man3/pthread_detach.3:57 build/C/man3/pthread_join.3:87
4238 msgid "I<thread> is not a joinable thread."
4242 #: build/C/man3/pthread_detach.3:68
4244 "Once a thread has been detached, it can't be joined with B<pthread_join>(3) "
4245 "or be made joinable again."
4249 #: build/C/man3/pthread_detach.3:75
4251 "A new thread can be created in a detached state using "
4252 "B<pthread_attr_setdetachstate>(3) to set the detached attribute of the "
4253 "I<attr> argument of B<pthread_create>(3)."
4257 #: build/C/man3/pthread_detach.3:82
4259 "The detached attribute merely determines the behavior of the system when the "
4260 "thread terminates; it does not prevent the thread from being terminated if "
4261 "the process terminates using B<exit>(3) (or equivalently, if the main "
4266 #: build/C/man3/pthread_detach.3:91
4268 "Either B<pthread_join>(3) or B<pthread_detach>() should be called for each "
4269 "thread that an application creates, so that system resources for the thread "
4270 "can be released. (But note that the resources of all threads are freed when "
4271 "the process terminates.)"
4275 #: build/C/man3/pthread_detach.3:93
4276 msgid "The following statement detaches the calling thread:"
4280 #: build/C/man3/pthread_detach.3:95
4282 msgid " pthread_detach(pthread_self());\n"
4286 #: build/C/man3/pthread_detach.3:102
4288 "B<pthread_attr_setdetachstate>(3), B<pthread_cancel>(3), B<pthread_create>"
4289 "(3), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
4293 #: build/C/man3/pthread_equal.3:24
4295 msgid "PTHREAD_EQUAL"
4299 #: build/C/man3/pthread_equal.3:24 build/C/man3/pthread_exit.3:24
4305 #: build/C/man3/pthread_equal.3:27
4306 msgid "pthread_equal - compare thread IDs"
4310 #: build/C/man3/pthread_equal.3:32
4312 msgid "B<int pthread_equal(pthread_t >I<t1>B<, pthread_t >I<t2>B<);>\n"
4316 #: build/C/man3/pthread_equal.3:38
4317 msgid "The B<pthread_equal>() function compares two thread identifiers."
4321 #: build/C/man3/pthread_equal.3:42
4323 "If the two thread IDs are equal, B<pthread_equal>() returns a nonzero "
4324 "value; otherwise, it returns 0."
4328 #. Available since glibc 2.0
4330 #: build/C/man3/pthread_equal.3:44 build/C/man3/pthread_exit.3:72
4331 #: build/C/man3/pthread_self.3:47 build/C/man3/pthread_testcancel.3:55
4332 msgid "This function always succeeds."
4336 #: build/C/man3/pthread_equal.3:53
4338 "The B<pthread_equal>() function is necessary because thread IDs should be "
4339 "considered opaque: there is no portable way for applications to directly "
4340 "compare two I<pthread_t> values."
4344 #: build/C/man3/pthread_equal.3:57
4345 msgid "B<pthread_create>(3), B<pthread_self>(3), B<pthreads>(7)"
4349 #: build/C/man3/pthread_exit.3:24
4351 msgid "PTHREAD_EXIT"
4355 #: build/C/man3/pthread_exit.3:27
4356 msgid "pthread_exit - terminate calling thread"
4360 #: build/C/man3/pthread_exit.3:32
4362 msgid "B<void pthread_exit(void *>I<retval>B<);>\n"
4366 #: build/C/man3/pthread_exit.3:42
4368 "The B<pthread_exit>() function terminates the calling thread and returns a "
4369 "value via I<retval> that (if the thread is joinable) is available to "
4370 "another thread in the same process that calls B<pthread_join>(3)."
4374 #: build/C/man3/pthread_exit.3:52
4376 "Any clean-up handlers established by B<pthread_cleanup_push>(3) that have "
4377 "not yet been popped, are popped (in the reverse of the order in which they "
4378 "were pushed) and executed. If the thread has any thread-specific data, "
4379 "then, after the clean-up handlers have been executed, the corresponding "
4380 "destructor functions are called, in an unspecified order."
4384 #: build/C/man3/pthread_exit.3:59
4386 "When a thread terminates, process-shared resources (e.g., mutexes, condition "
4387 "variables, semaphores, and file descriptors) are not released, and functions "
4388 "registered using B<atexit>(3) are not called."
4392 #: build/C/man3/pthread_exit.3:68
4394 "After the last thread in a process terminates, the process terminates as by "
4395 "calling B<exit>(3) with an exit status of zero; thus, process-shared "
4396 "resources are released and functions registered using B<atexit>(3) are "
4401 #: build/C/man3/pthread_exit.3:70
4402 msgid "This function does not return to the caller."
4406 #: build/C/man3/pthread_exit.3:79
4408 "Performing a return from the start function of any thread other than the "
4409 "main thread results in an implicit call to B<pthread_exit>(), using the "
4410 "function's return value as the thread's exit status."
4414 #: build/C/man3/pthread_exit.3:85
4416 "To allow other threads to continue execution, the main thread should "
4417 "terminate by calling B<pthread_exit>() rather than B<exit>(3)."
4421 #: build/C/man3/pthread_exit.3:90
4423 "The value pointed to by I<retval> should not be located on the calling "
4424 "thread's stack, since the contents of that stack are undefined after the "
4425 "thread terminates."
4429 #. FIXME . review a later kernel to see if this gets fixed
4430 #. http://thread.gmane.org/gmane.linux.kernel/611611
4431 #. http://marc.info/?l=linux-kernel&m=122525468300823&w=2
4433 #: build/C/man3/pthread_exit.3:102
4435 "Currently, there are limitations in the kernel implementation logic for "
4436 "B<wait>(2)ing on a stopped thread group with a dead thread group leader. "
4437 "This can manifest in problems such as a locked terminal if a stop signal is "
4438 "sent to a foreground process whose thread group leader has already called "
4439 "B<pthread_exit>()."
4443 #: build/C/man3/pthread_exit.3:106
4444 msgid "B<pthread_create>(3), B<pthread_join>(3), B<pthreads>(7)"
4448 #: build/C/man3/pthread_getattr_np.3:24
4450 msgid "PTHREAD_GETATTR_NP"
4454 #: build/C/man3/pthread_getattr_np.3:27
4455 msgid "pthread_getattr_np - get attributes of created thread"
4459 #: build/C/man3/pthread_getattr_np.3:33
4461 msgid "B<int pthread_getattr_np(pthread_t >I<thread>B<, pthread_attr_t *>I<attr>B<);>\n"
4465 #: build/C/man3/pthread_getattr_np.3:42
4467 "The B<pthread_getattr_np>() function initializes the thread attributes "
4468 "object referred to by I<attr> so that it contains actual attribute values "
4469 "describing the running thread I<thread>."
4473 #: build/C/man3/pthread_getattr_np.3:49
4475 "The returned attribute values may differ from the corresponding attribute "
4476 "values passed in the I<attr> object that was used to create the thread using "
4477 "B<pthread_create>(3). In particular, the following attributes may differ:"
4481 #: build/C/man3/pthread_getattr_np.3:52
4483 "the detach state, since a joinable thread may have detached itself after "
4488 #: build/C/man3/pthread_getattr_np.3:55
4490 "the stack size, which the implementation may align to a suitable boundary."
4494 #: build/C/man3/pthread_getattr_np.3:60
4496 "and the guard size, which the implementation may round upward to a multiple "
4497 "of the page size, or ignore (i.e., treat as 0), if the application is "
4498 "allocating its own stack."
4502 #: build/C/man3/pthread_getattr_np.3:65
4504 "Furthermore, if the stack address attribute was not set in the thread "
4505 "attributes object used to create the thread, then the returned thread "
4506 "attributes object will report the actual stack address that the "
4507 "implementation selected for the thread."
4511 #: build/C/man3/pthread_getattr_np.3:70
4513 "When the thread attributes object returned by B<pthread_getattr_np>() is no "
4514 "longer required, it should be destroyed using B<pthread_attr_destroy>(3)."
4518 #: build/C/man3/pthread_getattr_np.3:73
4519 #: build/C/man3/pthread_getcpuclockid.3:46
4521 "On success, this function returns 0; on error, it returns a nonzero error "
4525 #. Can happen (but unlikely) while trying to allocate memory for cpuset
4527 #: build/C/man3/pthread_getattr_np.3:78
4528 msgid "Insufficient memory."
4532 #: build/C/man3/pthread_getattr_np.3:93
4534 "In addition, if I<thread> refers to the main thread, then "
4535 "B<pthread_getattr_np>() can fail because of errors from various underlying "
4536 "calls: B<fopen>(3), if I</proc/self/maps> can't be opened; and B<getrlimit>"
4537 "(2), if the B<RLIMIT_STACK> resource limit is not supported."
4541 #: build/C/man3/pthread_getattr_np.3:95
4542 msgid "This function is available in glibc since version 2.2.3."
4546 #: build/C/man3/pthread_getattr_np.3:98
4547 #: build/C/man3/pthread_kill_other_threads_np.3:48
4549 "This function is a nonstandard GNU extension; hence the suffix \"_np"
4550 "\" (nonportable) in the name."
4554 #: build/C/man3/pthread_getattr_np.3:108
4556 "The program below demonstrates the use of B<pthread_getattr_np>(). The "
4557 "program creates a thread that then uses B<pthread_getattr_np>() to retrieve "
4558 "and display its guard size, stack address, and stack size attributes. "
4559 "Command-line arguments can be used to set these attributes to values other "
4560 "than the default when creating the thread. The shell sessions below "
4561 "demonstrate the use of the program."
4565 #: build/C/man3/pthread_getattr_np.3:111
4567 "In the first run, on an x86-32 system, a thread is created using default "
4572 #: build/C/man3/pthread_getattr_np.3:121
4575 "$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2MB\n"
4578 "Attributes of created thread:\n"
4579 " Guard size = 4096 bytes\n"
4580 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
4581 " Stack size = 0x201000 (2101248) bytes\n"
4585 #: build/C/man3/pthread_getattr_np.3:127
4587 "In the following run, we see that if a guard size is specified, it is "
4588 "rounded up to the next multiple of the system page size (4096 bytes on "
4593 #: build/C/man3/pthread_getattr_np.3:135
4596 "$B< ./a.out -g 4097>\n"
4597 "Thread attributes object after initializations:\n"
4598 " Guard size = 4097 bytes\n"
4599 " Stack address = (nil)\n"
4600 " Stack size = 0x0 (0) bytes\n"
4604 #: build/C/man3/pthread_getattr_np.3:140
4607 "Attributes of created thread:\n"
4608 " Guard size = 8192 bytes\n"
4609 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
4610 " Stack size = 0x201000 (2101248) bytes\n"
4615 #. $ ./a.out \-s 0x8000
4616 #. Thread attributes object after initializations:
4617 #. Guard size = 4096 bytes
4618 #. Stack address = 0xffff8000 (EOS = (nil))
4619 #. Stack size = 0x8000 (32768) bytes
4620 #. Attributes of created thread:
4621 #. Guard size = 4096 bytes
4622 #. Stack address = 0x4001e000 (EOS = 0x40026000)
4623 #. Stack size = 0x8000 (32768) bytes
4627 #: build/C/man3/pthread_getattr_np.3:159
4629 "In the last run, the program manually allocates a stack for the thread. In "
4630 "this case, the guard size attribute is ignored."
4634 #: build/C/man3/pthread_getattr_np.3:164
4637 "$B< ./a.out -g 4096 -s 0x8000 -a>\n"
4638 "Allocated thread stack at 0x804d000\n"
4642 #: build/C/man3/pthread_getattr_np.3:169
4645 "Thread attributes object after initializations:\n"
4646 " Guard size = 4096 bytes\n"
4647 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4648 " Stack size = 0x8000 (32768) bytes\n"
4652 #: build/C/man3/pthread_getattr_np.3:174
4655 "Attributes of created thread:\n"
4656 " Guard size = 0 bytes\n"
4657 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4658 " Stack size = 0x8000 (32768) bytes\n"
4662 #: build/C/man3/pthread_getattr_np.3:195
4666 "display_stack_related_attributes(pthread_attr_t *attr, char *prefix)\n"
4669 " size_t stack_size, guard_size;\n"
4670 " void *stack_addr;\n"
4674 #: build/C/man3/pthread_getattr_np.3:200
4677 " s = pthread_attr_getguardsize(attr, &guard_size);\n"
4679 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
4680 " printf(\"%sGuard size = %d bytes\\en\", prefix, guard_size);\n"
4684 #: build/C/man3/pthread_getattr_np.3:211
4687 " s = pthread_attr_getstack(attr, &stack_addr, &stack_size);\n"
4689 " handle_error_en(s, \"pthread_attr_getstack\");\n"
4690 " printf(\"%sStack address = %p\", prefix, stack_addr);\n"
4691 " if (stack_size E<gt> 0)\n"
4692 " printf(\" (EOS = %p)\", (char *) stack_addr + stack_size);\n"
4693 " printf(\"\\en\");\n"
4694 " printf(\"%sStack size = 0x%x (%d) bytes\\en\",\n"
4695 " prefix, stack_size, stack_size);\n"
4700 #: build/C/man3/pthread_getattr_np.3:217
4704 "display_thread_attributes(pthread_t thread, char *prefix)\n"
4707 " pthread_attr_t attr;\n"
4711 #: build/C/man3/pthread_getattr_np.3:221
4714 " s = pthread_getattr_np(thread, &attr);\n"
4716 " handle_error_en(s, \"pthread_getattr_np\");\n"
4720 #: build/C/man3/pthread_getattr_np.3:223
4722 msgid " display_stack_related_attributes(&attr, prefix);\n"
4726 #: build/C/man3/pthread_getattr_np.3:228
4729 " s = pthread_attr_destroy(&attr);\n"
4731 " handle_error_en(s, \"pthread_attr_destroy\");\n"
4736 #: build/C/man3/pthread_getattr_np.3:234
4739 "static void * /* Start function for thread we create */\n"
4740 "thread_start(void *arg)\n"
4742 " printf(\"Attributes of created thread:\\en\");\n"
4743 " display_thread_attributes(pthread_self(), \"\\et\");\n"
4747 #: build/C/man3/pthread_getattr_np.3:248
4751 "usage(char *pname, char *msg)\n"
4753 " if (msg != NULL)\n"
4754 " fputs(msg, stderr);\n"
4755 " fprintf(stderr, \"Usage: %s [-s stack-size [-a]]\"\n"
4756 " \" [-g guard-size]\\en\", pname);\n"
4757 " fprintf(stderr, \"\\et\\et-a means program should allocate stack\\en\");\n"
4758 " exit(EXIT_FAILURE);\n"
4763 #: build/C/man3/pthread_getattr_np.3:261
4766 "static pthread_attr_t * /* Get thread attributes from command line */\n"
4767 "get_thread_attributes_from_cl(int argc, char *argv[],\n"
4768 " pthread_attr_t *attrp)\n"
4770 " int s, opt, allocate_stack;\n"
4771 " long stack_size, guard_size;\n"
4772 " void *stack_addr;\n"
4773 " pthread_attr_t *ret_attrp = NULL; /* Set to attrp if we initialize\n"
4774 " a thread attributes object */\n"
4775 " allocate_stack = 0;\n"
4776 " stack_size = -1;\n"
4777 " guard_size = -1;\n"
4781 #: build/C/man3/pthread_getattr_np.3:270
4784 " while ((opt = getopt(argc, argv, \"ag:s:\")) != -1) {\n"
4786 " case \\(aqa\\(aq: allocate_stack = 1; break;\n"
4787 " case \\(aqg\\(aq: guard_size = strtoul(optarg, NULL, 0); break;\n"
4788 " case \\(aqs\\(aq: stack_size = strtoul(optarg, NULL, 0); break;\n"
4789 " default: usage(argv[0], NULL);\n"
4795 #: build/C/man3/pthread_getattr_np.3:273
4798 " if (allocate_stack && stack_size == -1)\n"
4799 " usage(argv[0], \"Specifying -a without -s makes no sense\\en\");\n"
4803 #: build/C/man3/pthread_getattr_np.3:276
4806 " if (argc E<gt> optind)\n"
4807 " usage(argv[0], \"Extraneous command-line arguments\\en\");\n"
4811 #: build/C/man3/pthread_getattr_np.3:279
4814 " if (stack_size E<gt>= 0 || guard_size E<gt> 0) {\n"
4815 " ret_attrp = attrp;\n"
4819 #: build/C/man3/pthread_getattr_np.3:284
4822 " s = pthread_attr_init(attrp);\n"
4824 " handle_error_en(s, \"pthread_attr_init\");\n"
4829 #: build/C/man3/pthread_getattr_np.3:296
4832 " if (stack_size E<gt>= 0) {\n"
4833 " if (!allocate_stack) {\n"
4834 " s = pthread_attr_setstacksize(attrp, stack_size);\n"
4836 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4838 " s = posix_memalign(&stack_addr, sysconf(_SC_PAGESIZE),\n"
4841 " handle_error_en(s, \"posix_memalign\");\n"
4842 " printf(\"Allocated thread stack at %p\\en\\en\", stack_addr);\n"
4846 #: build/C/man3/pthread_getattr_np.3:302
4849 " s = pthread_attr_setstack(attrp, stack_addr, stack_size);\n"
4851 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4857 #: build/C/man3/pthread_getattr_np.3:308
4860 " if (guard_size E<gt>= 0) {\n"
4861 " s = pthread_attr_setguardsize(attrp, guard_size);\n"
4863 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4868 #: build/C/man3/pthread_getattr_np.3:311
4871 " return ret_attrp;\n"
4876 #: build/C/man3/pthread_getattr_np.3:320
4880 "main(int argc, char *argv[])\n"
4884 " pthread_attr_t attr;\n"
4885 " pthread_attr_t *attrp = NULL; /* Set to &attr if we initialize\n"
4886 " a thread attributes object */\n"
4890 #: build/C/man3/pthread_getattr_np.3:322
4892 msgid " attrp = get_thread_attributes_from_cl(argc, argv, &attr);\n"
4896 #: build/C/man3/pthread_getattr_np.3:328
4899 " if (attrp != NULL) {\n"
4900 " printf(\"Thread attributes object after initializations:\\en\");\n"
4901 " display_stack_related_attributes(attrp, \"\\et\");\n"
4902 " printf(\"\\en\");\n"
4907 #: build/C/man3/pthread_getattr_np.3:356
4909 "B<pthread_attr_getaffinity_np>(3), B<pthread_attr_getdetachstate>(3), "
4910 "B<pthread_attr_getguardsize>(3), B<pthread_attr_getinheritsched>(3), "
4911 "B<pthread_attr_getschedparam>(3), B<pthread_attr_getschedpolicy>(3), "
4912 "B<pthread_attr_getscope>(3), B<pthread_attr_getstack>(3), "
4913 "B<pthread_attr_getstackaddr>(3), B<pthread_attr_getstacksize>(3), "
4914 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthreads>(7)"
4918 #: build/C/man3/pthread_getcpuclockid.3:24
4920 msgid "PTHREAD_GETCPUCLOCKID"
4924 #: build/C/man3/pthread_getcpuclockid.3:24
4930 #: build/C/man3/pthread_getcpuclockid.3:27
4931 msgid "pthread_getcpuclockid - retrieve ID of a thread's CPU time clock"
4935 #: build/C/man3/pthread_getcpuclockid.3:31
4938 "B<#include E<lt>pthread.hE<gt>>\n"
4939 "B<#include E<lt>time.hE<gt>>\n"
4943 #: build/C/man3/pthread_getcpuclockid.3:33
4945 msgid "B<int pthread_getcpuclockid(pthread_t >I<thread>B<, clockid_t *>I<clock_id);>\n"
4948 #. The clockid is constructed as follows:
4949 #. *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE)
4950 #. where CLOCK_IDFIELD_SIZE is 3.
4952 #: build/C/man3/pthread_getcpuclockid.3:43
4954 "The B<pthread_getcpuclockid>() function returns the clock ID for the CPU "
4955 "time clock of the thread I<thread>."
4959 #: build/C/man3/pthread_getcpuclockid.3:47
4964 #. CLOCK_THREAD_CPUTIME_ID not defined
4965 #. Looking at nptl/pthread_getcpuclockid.c an ERANGE error would
4966 #. be possible if kernel thread IDs took more than 29 bits (which
4967 #. they currently cannot).
4969 #: build/C/man3/pthread_getcpuclockid.3:55
4970 msgid "Per-thread CPU time clocks are not supported by the system."
4974 #: build/C/man3/pthread_getcpuclockid.3:62
4975 msgid "This function is available in glibc since version 2.2."
4979 #: build/C/man3/pthread_getcpuclockid.3:75
4981 "When I<thread> refers to the calling thread, this function returns an "
4982 "identifier that refers to the same clock manipulated by B<clock_gettime>(2) "
4983 "and B<clock_settime>(2) when given the clock ID B<CLOCK_THREAD_CPUTIME_ID>."
4987 #: build/C/man3/pthread_getcpuclockid.3:81
4989 "The program below creates a thread and then uses B<clock_gettime>(2) to "
4990 "retrieve the total process CPU time, and the per-thread CPU time consumed by "
4991 "the two threads. The following shell session shows an example run:"
4995 #: build/C/man3/pthread_getcpuclockid.3:90
4999 "Main thread sleeping\n"
5000 "Subthread starting infinite loop\n"
5001 "Main thread consuming some CPU time...\n"
5002 "Process total CPU time: 1.368\n"
5003 "Main thread CPU time: 0.376\n"
5004 "Subthread CPU time: 0.992\n"
5008 #: build/C/man3/pthread_getcpuclockid.3:96
5010 msgid "/* Link with \"-lrt\" */\n"
5014 #: build/C/man3/pthread_getcpuclockid.3:104
5017 "#include E<lt>time.hE<gt>\n"
5018 "#include E<lt>stdio.hE<gt>\n"
5019 "#include E<lt>stdlib.hE<gt>\n"
5020 "#include E<lt>unistd.hE<gt>\n"
5021 "#include E<lt>pthread.hE<gt>\n"
5022 "#include E<lt>string.hE<gt>\n"
5023 "#include E<lt>errno.hE<gt>\n"
5027 #: build/C/man3/pthread_getcpuclockid.3:118
5031 "thread_start(void *arg)\n"
5033 " printf(\"Subthread starting infinite loop\\en\");\n"
5040 #: build/C/man3/pthread_getcpuclockid.3:123
5044 "pclock(char *msg, clockid_t cid)\n"
5046 " struct timespec ts;\n"
5050 #: build/C/man3/pthread_getcpuclockid.3:129
5053 " printf(\"%s\", msg);\n"
5054 " if (clock_gettime(cid, &ts) == -1)\n"
5055 " handle_error(\"clock_gettime\");\n"
5056 " printf(\"%4ld.%03ld\\en\", ts.tv_sec, ts.tv_nsec / 1000000);\n"
5061 #: build/C/man3/pthread_getcpuclockid.3:136
5065 "main(int argc, char *argv[])\n"
5067 " pthread_t thread;\n"
5073 #: build/C/man3/pthread_getcpuclockid.3:140
5076 " s = pthread_create(&thread, NULL, thread_start, NULL);\n"
5078 " handle_error_en(s, \"pthread_create\");\n"
5082 #: build/C/man3/pthread_getcpuclockid.3:143
5085 " printf(\"Main thread sleeping\\en\");\n"
5090 #: build/C/man3/pthread_getcpuclockid.3:147
5093 " printf(\"Main thread consuming some CPU time...\\en\");\n"
5094 " for (j = 0; j E<lt> 2000000; j++)\n"
5099 #: build/C/man3/pthread_getcpuclockid.3:149
5101 msgid " pclock(\"Process total CPU time: \", CLOCK_PROCESS_CPUTIME_ID);\n"
5105 #: build/C/man3/pthread_getcpuclockid.3:154
5108 " s = pthread_getcpuclockid(pthread_self(), &cid);\n"
5110 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
5111 " pclock(\"Main thread CPU time: \", cid);\n"
5115 #: build/C/man3/pthread_getcpuclockid.3:157
5118 " /* The preceding 4 lines of code could have been replaced by:\n"
5119 " pclock(\"Main thread CPU time: \", CLOCK_THREAD_CPUTIME_ID); */\n"
5123 #: build/C/man3/pthread_getcpuclockid.3:162
5126 " s = pthread_getcpuclockid(thread, &cid);\n"
5128 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
5129 " pclock(\"Subthread CPU time: 1 \", cid);\n"
5133 #: build/C/man3/pthread_getcpuclockid.3:165
5136 " exit(EXIT_SUCCESS); /* Terminates both threads */\n"
5141 #: build/C/man3/pthread_getcpuclockid.3:174
5143 "B<clock_gettime>(2), B<clock_settime>(2), B<timer_create>(2), "
5144 "B<clock_getcpuclockid>(3), B<pthread_self>(3), B<pthreads>(7), B<time>(7)"
5148 #: build/C/man3/pthread_join.3:24
5150 msgid "PTHREAD_JOIN"
5154 #: build/C/man3/pthread_join.3:27
5155 msgid "pthread_join - join with a terminated thread"
5159 #: build/C/man3/pthread_join.3:32
5161 msgid "B<int pthread_join(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
5165 #: build/C/man3/pthread_join.3:47
5167 "The B<pthread_join>() function waits for the thread specified by I<thread> "
5168 "to terminate. If that thread has already terminated, then B<pthread_join>"
5169 "() returns immediately. The thread specified by I<thread> must be joinable."
5173 #: build/C/man3/pthread_join.3:61
5175 "If I<retval> is not NULL, then B<pthread_join>() copies the exit status of "
5176 "the target thread (i.e., the value that the target thread supplied to "
5177 "B<pthread_exit>(3)) into the location pointed to by I<*retval>. If the "
5178 "target thread was canceled, then B<PTHREAD_CANCELED> is placed in I<*retval>."
5182 #: build/C/man3/pthread_join.3:68
5184 "If multiple threads simultaneously try to join with the same thread, the "
5185 "results are undefined. If the thread calling B<pthread_join>() is "
5186 "canceled, then the target thread will remain joinable (i.e., it will not be "
5191 #: build/C/man3/pthread_join.3:73
5193 "On success, B<pthread_join>() returns 0; on error, it returns an error "
5198 #: build/C/man3/pthread_join.3:74
5203 #. The following verified by testing on glibc 2.8/NPTL:
5204 #. The following verified by testing on glibc 2.8/NPTL:
5206 #: build/C/man3/pthread_join.3:83
5208 "A deadlock was detected (e.g., two threads tried to join with each other); "
5209 "or I<thread> specifies the calling thread."
5212 #. POSIX.1-2001 does not specify this error case.
5214 #: build/C/man3/pthread_join.3:91
5215 msgid "Another thread is already waiting to join with this thread."
5219 #: build/C/man3/pthread_join.3:102
5221 "After a successful call to B<pthread_join>(), the caller is guaranteed that "
5222 "the target thread has terminated."
5226 #: build/C/man3/pthread_join.3:105
5228 "Joining with a thread that has previously been joined results in undefined "
5233 #: build/C/man3/pthread_join.3:113
5235 "Failure to join with a thread that is joinable (i.e., one that is not "
5236 "detached), produces a \"zombie thread\". Avoid doing this, since each "
5237 "zombie thread consumes some system resources, and when enough zombie threads "
5238 "have accumulated, it will no longer be possible to create new threads (or "
5243 #: build/C/man3/pthread_join.3:119
5245 "There is no pthreads analog of I<waitpid(-1,\\ &status,\\ 0)>, that is, "
5246 "\"join with any terminated thread\". If you believe you need this "
5247 "functionality, you probably need to rethink your application design."
5251 #: build/C/man3/pthread_join.3:122
5253 "All of the threads in a process are peers: any thread can join with any "
5254 "other thread in the process."
5258 #: build/C/man3/pthread_join.3:132
5260 "B<pthread_cancel>(3), B<pthread_create>(3), B<pthread_detach>(3), "
5261 "B<pthread_exit>(3), B<pthread_tryjoin_np>(3), B<pthreads>(7)"
5265 #: build/C/man3/pthread_kill.3:24
5267 msgid "PTHREAD_KILL"
5271 #: build/C/man3/pthread_kill.3:24
5277 #: build/C/man3/pthread_kill.3:27
5278 msgid "pthread_kill - send a signal to a thread"
5282 #: build/C/man3/pthread_kill.3:30 build/C/man3/pthread_sigmask.3:30
5284 msgid "B<#include E<lt>signal.hE<gt>>\n"
5288 #: build/C/man3/pthread_kill.3:32
5290 msgid "B<int pthread_kill(pthread_t >I<thread>B<, int >I<sig>B<);>\n"
5294 #: build/C/man3/pthread_kill.3:45
5296 "The B<pthread_kill>() function sends the signal I<sig> to I<thread>, "
5297 "another thread in the same process as the caller. The signal is "
5298 "asynchronously directed to I<thread>."
5302 #: build/C/man3/pthread_kill.3:50
5304 "If I<sig> is 0, then no signal is sent, but error checking is still "
5305 "performed; this can be used to check for the existence of a thread ID."
5309 #: build/C/man3/pthread_kill.3:55
5311 "On success, B<pthread_kill>() returns 0; on error, it returns an error "
5312 "number, and no signal is sent."
5316 #: build/C/man3/pthread_kill.3:59
5317 msgid "An invalid signal was specified."
5321 #: build/C/man3/pthread_kill.3:73
5323 "Signal dispositions are process-wide: if a signal handler is installed, the "
5324 "handler will be invoked in the thread I<thread>, but if the disposition of "
5325 "the signal is \"stop\", \"continue\", or \"terminate\", this action will "
5326 "affect the whole process."
5330 #: build/C/man3/pthread_kill.3:82
5332 "B<kill>(2) B<sigaction>(2), B<sigpending>(2), B<pthread_self>(3), "
5333 "B<pthread_sigmask>(3), B<raise>(3), B<pthreads>(7), B<signal>(7)"
5337 #: build/C/man3/pthread_kill_other_threads_np.3:24
5339 msgid "PTHREAD_KILL_OTHER_THREADS_NP"
5343 #: build/C/man3/pthread_kill_other_threads_np.3:24
5349 #: build/C/man3/pthread_kill_other_threads_np.3:27
5350 msgid "pthread_kill_other_threads_np - terminate all other threads in process"
5354 #: build/C/man3/pthread_kill_other_threads_np.3:32
5356 msgid "B<void pthread_kill_other_threads_np(void);>\n"
5360 #. Available since glibc 2.0
5362 #: build/C/man3/pthread_kill_other_threads_np.3:45
5364 "B<pthread_kill_other_threads_np>() only has an effect in the LinuxThreads "
5365 "threading implementation. On that implementation, calling this function "
5366 "causes the immediate termination of all threads in the application, except "
5367 "the calling thread. The cancellation state and cancellation type of the to-"
5368 "be-terminated threads are ignored, and the cleanup handlers are not called "
5373 #: build/C/man3/pthread_kill_other_threads_np.3:57
5375 "B<pthread_kill_other_threads_np>() is intended to be called just before a "
5376 "thread calls B<execve>(2) or a similar function. This function is designed "
5377 "to address a limitation in the obsolete LinuxThreads implementation whereby "
5378 "the other threads of an application are not automatically terminated (as "
5379 "POSIX.1-2001 requires) during B<execve>(2)."
5383 #: build/C/man3/pthread_kill_other_threads_np.3:64
5385 "In the NPTL threading implementation, B<pthread_kill_other_threads_np>() "
5386 "exists, but does nothing. (Nothing needs to be done, because the "
5387 "implementation does the right thing during an B<execve>(2).)"
5391 #: build/C/man3/pthread_kill_other_threads_np.3:70
5393 "B<execve>(2), B<pthread_cancel>(3), B<pthread_setcancelstate>(3), "
5394 "B<pthread_setcanceltype>(3), B<pthreads>(7)"
5398 #: build/C/man3/pthread_self.3:24
5400 msgid "PTHREAD_SELF"
5404 #: build/C/man3/pthread_self.3:27
5405 msgid "pthread_self - obtain ID of the calling thread"
5409 #: build/C/man3/pthread_self.3:32
5411 msgid "B<pthread_t pthread_self(void);>\n"
5415 #: build/C/man3/pthread_self.3:43
5417 "The B<pthread_self>() function returns the ID of the calling thread. This "
5418 "is the same value that is returned in I<*thread> in the B<pthread_create>"
5419 "(3) call that created this thread."
5423 #: build/C/man3/pthread_self.3:45
5424 msgid "This function always succeeds, returning the calling thread's ID."
5428 #: build/C/man3/pthread_self.3:60
5430 "POSIX.1 allows an implementation wide freedom in choosing the type used to "
5431 "represent a thread ID; for example, representation using either an "
5432 "arithmetic type or a structure is permitted. Therefore, variables of type "
5433 "I<pthread_t> can't portably be compared using the C equality operator "
5434 "(B<==>); use B<pthread_equal>(3) instead."
5438 #: build/C/man3/pthread_self.3:64
5440 "Thread identifiers should be considered opaque: any attempt to use a thread "
5441 "ID other than in pthreads calls is nonportable and can lead to unspecified "
5446 #: build/C/man3/pthread_self.3:68
5448 "Thread IDs are only guaranteed to be unique within a process. A thread ID "
5449 "may be reused after a terminated thread has been joined, or a detached "
5450 "thread has terminated."
5454 #: build/C/man3/pthread_self.3:73
5456 "The thread ID returned by B<pthread_self>() is not the same thing as the "
5457 "kernel thread ID returned by a call to B<gettid>(2)."
5461 #: build/C/man3/pthread_self.3:77
5462 msgid "B<pthread_create>(3), B<pthread_equal>(3), B<pthreads>(7)"
5466 #: build/C/man3/pthread_setaffinity_np.3:24
5468 msgid "PTHREAD_SETAFFINITY_NP"
5472 #: build/C/man3/pthread_setaffinity_np.3:28
5474 "pthread_setaffinity_np, pthread_getaffinity_np - set/get CPU affinity of a "
5479 #: build/C/man3/pthread_setaffinity_np.3:37
5482 "B<int pthread_setaffinity_np(pthread_t >I<thread>B<, size_t >I<cpusetsize>B<,>\n"
5483 "B< const cpu_set_t *>I<cpuset>B<);>\n"
5484 "B<int pthread_getaffinity_np(pthread_t >I<thread>B<, size_t >I<cpusetsize>B<,>\n"
5485 "B< cpu_set_t *>I<cpuset>B<);>\n"
5489 #: build/C/man3/pthread_setaffinity_np.3:51
5491 "The B<pthread_setaffinity_np>() function sets the CPU affinity mask of the "
5492 "thread I<thread> to the CPU set pointed to by I<cpuset>. If the call is "
5493 "successful, and the thread is not currently running on one of the CPUs in "
5494 "I<cpuset>, then it is migrated to one of those CPUs."
5498 #: build/C/man3/pthread_setaffinity_np.3:58
5500 "The B<pthread_getaffinity_np>() function returns the CPU affinity mask of "
5501 "the thread I<thread> in the buffer pointed to by I<cpuset>."
5505 #: build/C/man3/pthread_setaffinity_np.3:74
5507 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
5508 "by I<cpuset>. Typically, this argument would be specified as I<sizeof"
5509 "(cpu_set_t)>. (It may be some other value, if using the macros described in "
5510 "B<CPU_SET>(3) for dynamically allocating a CPU set.)"
5514 #: build/C/man3/pthread_setaffinity_np.3:78
5520 #: build/C/man3/pthread_setaffinity_np.3:81
5521 msgid "A supplied memory address was invalid."
5525 #: build/C/man3/pthread_setaffinity_np.3:90
5527 "(B<pthread_setaffinity_np>()) The affinity bit mask I<mask> contains no "
5528 "processors that are currently physically on the system and permitted to the "
5529 "thread according to any restrictions that may be imposed by the \"cpuset\" "
5530 "mechanism described in B<cpuset>(7)."
5534 #. Loic Domaigne commented: it seems that in the future the
5535 #. kernel developers want to make cpumask_t dynamic, so
5536 #. CONFIG_NR_CPUS might become obsolete in the future.
5538 #. The raw sched_getaffinity() system call returns the size (in bytes)
5539 #. of the cpumask_t type.
5541 #: build/C/man3/pthread_setaffinity_np.3:106
5543 "(B<pthread_setaffinity_np>()) I<cpuset> specified a CPU that was outside "
5544 "the set supported by the kernel. (The kernel configuration option "
5545 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
5546 "type used to represent CPU sets.)"
5550 #: build/C/man3/pthread_setaffinity_np.3:111
5552 "(B<pthread_getaffinity_np>()) I<cpusetsize> is smaller than the size of the "
5553 "affinity mask used by the kernel."
5557 #: build/C/man3/pthread_setaffinity_np.3:134
5559 "After a call to B<pthread_setaffinity_np>(), the set of CPUs on which the "
5560 "thread will actually run is the intersection of the set specified in the "
5561 "I<cpuset> argument and the set of CPUs actually present on the system. The "
5562 "system may further restrict the set of CPUs on which the thread runs if the "
5563 "\"cpuset\" mechanism described in B<cpuset>(7) is being used. These "
5564 "restrictions on the actual set of CPUs on which the thread will run are "
5565 "silently imposed by the kernel."
5569 #: build/C/man3/pthread_setaffinity_np.3:140
5571 "These functions are implemented on top of the B<sched_setaffinity>(2) and "
5572 "B<sched_getaffinity>(2) system calls."
5576 #: build/C/man3/pthread_setaffinity_np.3:151
5578 "A new thread created by B<pthread_create>(3) inherits a copy of its "
5579 "creator's CPU affinity mask."
5583 #: build/C/man3/pthread_setaffinity_np.3:159
5585 "In the following program, the main thread uses B<pthread_setaffinity_np>() "
5586 "to set its CPU affinity mask to include CPUs 0 to 7 (which may not all be "
5587 "available on the system), and then calls B<pthread_getaffinity_np>() to "
5588 "check the resulting CPU affinity mask of the thread."
5592 #: build/C/man3/pthread_setaffinity_np.3:166
5595 "#define _GNU_SOURCE\n"
5596 "#include E<lt>pthread.hE<gt>\n"
5597 "#include E<lt>stdio.hE<gt>\n"
5598 "#include E<lt>stdlib.hE<gt>\n"
5599 "#include E<lt>errno.hE<gt>\n"
5603 #: build/C/man3/pthread_setaffinity_np.3:176
5607 "main(int argc, char *argv[])\n"
5610 " cpu_set_t cpuset;\n"
5611 " pthread_t thread;\n"
5615 #: build/C/man3/pthread_setaffinity_np.3:178
5617 msgid " thread = pthread_self();\n"
5621 #: build/C/man3/pthread_setaffinity_np.3:180
5623 msgid " /* Set affinity mask to include CPUs 0 to 7 */\n"
5627 #: build/C/man3/pthread_setaffinity_np.3:184
5630 " CPU_ZERO(&cpuset);\n"
5631 " for (j = 0; j E<lt> 8; j++)\n"
5632 " CPU_SET(j, &cpuset);\n"
5636 #: build/C/man3/pthread_setaffinity_np.3:188
5639 " s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5641 " handle_error_en(s, \"pthread_setaffinity_np\");\n"
5645 #: build/C/man3/pthread_setaffinity_np.3:190
5647 msgid " /* Check the actual affinity mask assigned to the thread */\n"
5651 #: build/C/man3/pthread_setaffinity_np.3:194
5654 " s = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5656 " handle_error_en(s, \"pthread_getaffinity_np\");\n"
5660 #: build/C/man3/pthread_setaffinity_np.3:199
5663 " printf(\"Set returned by pthread_getaffinity_np() contained:\\en\");\n"
5664 " for (j = 0; j E<lt> CPU_SETSIZE; j++)\n"
5665 " if (CPU_ISSET(j, &cpuset))\n"
5666 " printf(\" CPU %d\\en\", j);\n"
5670 #: build/C/man3/pthread_setaffinity_np.3:202
5671 #: build/C/man3/pthread_setschedparam.3:427
5674 " exit(EXIT_SUCCESS);\n"
5679 #: build/C/man3/pthread_setaffinity_np.3:211
5681 "B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
5682 "B<pthread_attr_setaffinity_np>(3), B<pthread_self>(3), B<sched_getcpu>(3), "
5683 "B<cpuset>(7), B<pthreads>(7)"
5687 #: build/C/man3/pthread_setcancelstate.3:24
5689 msgid "PTHREAD_SETCANCELSTATE"
5693 #: build/C/man3/pthread_setcancelstate.3:28
5695 "pthread_setcancelstate, pthread_setcanceltype - set cancelability state and "
5700 #: build/C/man3/pthread_setcancelstate.3:34
5703 "B<int pthread_setcancelstate(int >I<state>B<, int *>I<oldstate>B<);>\n"
5704 "B<int pthread_setcanceltype(int >I<type>B<, int *>I<oldtype>B<);>\n"
5708 #: build/C/man3/pthread_setcancelstate.3:48
5710 "The B<pthread_setcancelstate>() sets the cancelability state of the calling "
5711 "thread to the value given in I<state>. The previous cancelability state of "
5712 "the thread is returned in the buffer pointed to by I<oldstate>. The "
5713 "I<state> argument must have one of the following values:"
5717 #: build/C/man3/pthread_setcancelstate.3:48
5719 msgid "B<PTHREAD_CANCEL_ENABLE>"
5723 #: build/C/man3/pthread_setcancelstate.3:55
5725 "The thread is cancelable. This is the default cancelability state in all "
5726 "new threads, including the initial thread. The thread's cancelability type "
5727 "determines when a cancelable thread will respond to a cancellation request."
5731 #: build/C/man3/pthread_setcancelstate.3:55
5733 msgid "B<PTHREAD_CANCEL_DISABLE>"
5737 #: build/C/man3/pthread_setcancelstate.3:60
5739 "The thread is not cancelable. If a cancellation request is received, it is "
5740 "blocked until cancelability is enabled."
5744 #: build/C/man3/pthread_setcancelstate.3:72
5746 "The B<pthread_setcanceltype>() sets the cancelability type of the calling "
5747 "thread to the value given in I<type>. The previous cancelability type of "
5748 "the thread is returned in the buffer pointed to by I<oldtype>. The I<type> "
5749 "argument must have one of the following values:"
5753 #: build/C/man3/pthread_setcancelstate.3:72
5755 msgid "B<PTHREAD_CANCEL_DEFERRED>"
5759 #: build/C/man3/pthread_setcancelstate.3:79
5761 "A cancellation request is deferred until the thread next calls a function "
5762 "that is a cancellation point (see B<pthreads>(7)). This is the default "
5763 "cancelability type in all new threads, including the initial thread."
5767 #: build/C/man3/pthread_setcancelstate.3:79
5769 msgid "B<PTHREAD_CANCEL_ASYNCHRONOUS>"
5773 #: build/C/man3/pthread_setcancelstate.3:85
5775 "The thread can be canceled at any time. (Typically, it will be canceled "
5776 "immediately upon receiving a cancellation request, but the system doesn't "
5781 #: build/C/man3/pthread_setcancelstate.3:89
5783 "The set-and-get operation performed by each of these functions is atomic "
5784 "with respect to other threads in the process calling the same function."
5788 #: build/C/man3/pthread_setcancelstate.3:96
5789 msgid "The B<pthread_setcancelstate>() can fail with the following error:"
5793 #: build/C/man3/pthread_setcancelstate.3:100
5794 msgid "Invalid value for I<state>."
5798 #: build/C/man3/pthread_setcancelstate.3:104
5799 msgid "The B<pthread_setcanceltype>() can fail with the following error:"
5803 #. Available since glibc 2.0
5805 #: build/C/man3/pthread_setcancelstate.3:110
5806 msgid "Invalid value for I<type>."
5810 #: build/C/man3/pthread_setcancelstate.3:115
5812 "For details of what happens when a thread is canceled, see B<pthread_cancel>"
5817 #: build/C/man3/pthread_setcancelstate.3:122
5819 "Briefly disabling cancelability is useful if a thread performs some critical "
5820 "action that must not be interrupted by a cancellation request. Beware of "
5821 "disabling cancelability for long periods, or around operations that may "
5822 "block for long periods, since that will render the thread unresponsive to "
5823 "cancellation requests."
5827 #: build/C/man3/pthread_setcancelstate.3:153
5829 "Setting the cancelability type to B<PTHREAD_CANCEL_ASYNCHRONOUS> is rarely "
5830 "useful. Since the thread could be canceled at I<any> time, it cannot safely "
5831 "reserve resources (e.g., allocating memory with B<malloc>(3)), acquire "
5832 "mutexes, semaphores, or locks, and so on. Reserving resources is unsafe "
5833 "because the application has no way of knowing what the state of these "
5834 "resources is when the thread is canceled; that is, did cancellation occur "
5835 "before the resources were reserved, while they were reserved, or after they "
5836 "were released? Furthermore, some internal data structures (e.g., the linked "
5837 "list of free blocks managed by the B<malloc>(3) family of functions) may be "
5838 "left in an inconsistent state if cancellation occurs in the middle of the "
5839 "function call. Consequently, clean-up handlers cease to be useful. "
5840 "Functions that can be safely asynchronously canceled are called I<async-"
5841 "cancel-safe functions>. POSIX.1-2001 only requires that B<pthread_cancel>"
5842 "(3), B<pthread_setcancelstate>(), and B<pthread_setcanceltype>() be async-"
5843 "cancel-safe. In general, other library functions can't be safely called "
5844 "from an asynchronously cancelable thread. One of the few circumstances in "
5845 "which asynchronous cancelability is useful is for cancellation of a thread "
5846 "that is in a pure compute-bound loop."
5849 #. It looks like at least Solaris, FreeBSD and Tru64 support this.
5851 #: build/C/man3/pthread_setcancelstate.3:171
5853 "The Linux threading implementations permit the I<oldstate> argument of "
5854 "B<pthread_setcancelstate>() to be NULL, in which case the information about "
5855 "the previous cancelability state is not returned to the caller. Many other "
5856 "implementations also permit a NULL I<oldstat> argument, but POSIX.1-2001 "
5857 "does not specify this point, so portable applications should always specify "
5858 "a non-NULL value in I<oldstate>. A precisely analogous set of statements "
5859 "applies for the I<oldtype> argument of B<pthread_setcanceltype>()."
5863 #: build/C/man3/pthread_setcancelstate.3:174
5864 msgid "See B<pthread_cancel>(3)."
5868 #: build/C/man3/pthread_setcancelstate.3:179
5870 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), B<pthread_testcancel>(3), "
5875 #: build/C/man3/pthread_setconcurrency.3:23
5877 msgid "PTHREAD_SETCONCURRENCY"
5881 #: build/C/man3/pthread_setconcurrency.3:23 build/C/man3/pthread_yield.3:23
5887 #: build/C/man3/pthread_setconcurrency.3:27
5889 "pthread_setconcurrency, pthread_getconcurrency - set/get the concurrency "
5894 #: build/C/man3/pthread_setconcurrency.3:33
5897 "B<int pthread_setconcurrency(int >I<new_level>B<);>\n"
5898 "B<int pthread_getconcurrency(void);>\n"
5902 #: build/C/man3/pthread_setconcurrency.3:45
5904 "The B<pthread_setconcurrency>() function informs the implementation of the "
5905 "application's desired concurrency level, specified in I<new_level>. The "
5906 "implementation only takes this as a hint: POSIX.1 does not specify the level "
5907 "of concurrency that should be provided as a result of calling "
5908 "B<pthread_setconcurrency>()."
5912 #: build/C/man3/pthread_setconcurrency.3:50
5914 "Specifying I<new_level> as 0 instructs the implementation to manage the "
5915 "concurrency level as it deems appropriate."
5919 #: build/C/man3/pthread_setconcurrency.3:53
5921 "B<pthread_getconcurrency>() returns the current value of the concurrency "
5922 "level for this process."
5926 #: build/C/man3/pthread_setconcurrency.3:58
5928 "On success, B<pthread_setconcurrency>() returns 0; on error, it returns a "
5929 "nonzero error number."
5933 #: build/C/man3/pthread_setconcurrency.3:65
5935 "B<pthread_getconcurrency>() always succeeds, returning the concurrency "
5936 "level set by a previous call to B<pthread_setconcurrency>(), or 0, if "
5937 "B<pthread_setconcurrency>() has not previously been called."
5941 #: build/C/man3/pthread_setconcurrency.3:68
5942 msgid "B<pthread_setconcurrency>() can fail with the following error:"
5946 #: build/C/man3/pthread_setconcurrency.3:72
5947 msgid "I<new_level> is negative."
5951 #: build/C/man3/pthread_setconcurrency.3:78
5953 "POSIX.1-2001 also documents an B<EAGAIN> error (\"the value specified by "
5954 "I<new_level> would cause a system resource to be exceeded\")."
5958 #: build/C/man3/pthread_setconcurrency.3:80
5959 msgid "These functions are available in glibc since version 2.1."
5963 #: build/C/man3/pthread_setconcurrency.3:84
5964 msgid "The default concurrency level is 0."
5968 #: build/C/man3/pthread_setconcurrency.3:91
5970 "Concurrency levels are only meaningful for M:N threading implementations, "
5971 "where at any moment a subset of a process's set of user-level threads may be "
5972 "bound to a smaller number of kernel-scheduling entities. Setting the "
5973 "concurrency level allows the application to give the system a hint as to the "
5974 "number of kernel-scheduling entities that should be provided for efficient "
5975 "execution of the application."
5979 #: build/C/man3/pthread_setconcurrency.3:97
5981 "Both LinuxThreads and NPTL are 1:1 threading implementations, so setting the "
5982 "concurrency level has no meaning. In other words, on Linux these functions "
5983 "merely exist for compatibility with other systems, and they have no effect "
5984 "on the execution of a program."
5988 #: build/C/man3/pthread_setconcurrency.3:100
5989 msgid "B<pthread_attr_setscope>(3), B<pthreads>(7)"
5993 #: build/C/man3/pthread_setschedparam.3:24
5995 msgid "PTHREAD_SETSCHEDPARAM"
5999 #: build/C/man3/pthread_setschedparam.3:28
6001 "pthread_setschedparam, pthread_getschedparam - set/get scheduling policy and "
6002 "parameters of a thread"
6006 #: build/C/man3/pthread_setschedparam.3:36
6009 "B<pthread_setschedparam(pthread_t >I<thread>B<, int >I<policy>B<,>\n"
6010 "B< const struct sched_param *>I<param>B<);>\n"
6011 "B<pthread_getschedparam(pthread_t >I<thread>B<, int *>I<policy>B<,>\n"
6012 "B< struct sched_param *>I<param>B<);>\n"
6016 #: build/C/man3/pthread_setschedparam.3:43
6018 "The B<pthread_setschedparam>() function sets the scheduling policy and "
6019 "parameters of the thread I<thread>."
6022 #. FIXME . pthread_setschedparam() places no restriction on the policy,
6023 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
6024 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
6026 #: build/C/man3/pthread_setschedparam.3:54
6028 "I<policy> specifies the new scheduling policy for I<thread>. The supported "
6029 "values for I<policy>, and their semantics, are described in "
6030 "B<sched_setscheduler>(2)."
6034 #: build/C/man3/pthread_setschedparam.3:60
6036 "The structure pointed to by I<param> specifies the new scheduling parameters "
6037 "for I<thread>. Scheduling parameters are maintained in the following "
6041 #. FIXME . nptl/pthread_setschedparam.c has the following
6042 #. /* If the thread should have higher priority because of some
6043 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
6044 #. Eventually (perhaps after writing the mutexattr pages), we
6045 #. may want to add something on the topic to this page.
6047 #: build/C/man3/pthread_setschedparam.3:101
6049 "The B<pthread_getschedparam>() function returns the scheduling policy and "
6050 "parameters of the thread I<thread>, in the buffers pointed to by I<policy> "
6051 "and I<param>, respectively. The returned priority value is that set by the "
6052 "most recent B<pthread_setschedparam>(), B<pthread_setschedprio>(3), or "
6053 "B<pthread_create>(3) call that affected I<thread>. The returned priority "
6054 "does not reflect any temporary priority adjustments as a result of calls to "
6055 "any priority inheritance or priority ceiling functions (see, for example, "
6056 "B<pthread_mutexattr_setprioceiling>(3) and B<pthread_mutexattr_setprotocol>"
6061 #: build/C/man3/pthread_setschedparam.3:109
6063 "On success, these functions return 0; on error, they return a nonzero error "
6064 "number. If B<pthread_setschedparam>() fails, the scheduling policy and "
6065 "parameters of I<thread> are not changed."
6069 #: build/C/man3/pthread_setschedparam.3:111
6070 msgid "Both of these functions can fail with the following error:"
6074 #: build/C/man3/pthread_setschedparam.3:119
6076 "B<pthread_setschedparam>() may additionally fail with the following errors:"
6080 #: build/C/man3/pthread_setschedparam.3:126
6082 "I<policy> is not a recognized policy, or I<param> does not make sense for "
6087 #: build/C/man3/pthread_setschedparam.3:130
6089 "The caller does not have appropriate privileges to set the specified "
6090 "scheduling policy and parameters."
6094 #. Available since glibc 2.0
6096 #: build/C/man3/pthread_setschedparam.3:138
6098 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
6099 "policy or scheduling parameters to an unsupported value\") error for "
6100 "B<pthread_setschedparam>()."
6104 #: build/C/man3/pthread_setschedparam.3:146
6106 "For a description of the permissions required to, and the effect of, "
6107 "changing a thread's scheduling policy and priority, and details of the "
6108 "permitted ranges for priorities in each scheduling policy, see "
6109 "B<sched_setscheduler>(2)."
6113 #: build/C/man3/pthread_setschedparam.3:153
6115 "The program below demonstrates the use of B<pthread_setschedparam>() and "
6116 "B<pthread_getschedparam>(), as well as the use of a number of other "
6117 "scheduling-related pthreads functions."
6121 #: build/C/man3/pthread_setschedparam.3:169
6123 "In the following run, the main thread sets its scheduling policy to "
6124 "B<SCHED_FIFO> with a priority of 10, and initializes a thread attributes "
6125 "object with a scheduling policy attribute of B<SCHED_RR> and a scheduling "
6126 "priority attribute of 20. The program then sets (using "
6127 "B<pthread_attr_setinheritsched>(3)) the inherit scheduler attribute of the "
6128 "thread attributes object to B<PTHREAD_EXPLICIT_SCHED>, meaning that threads "
6129 "created using this attributes object should take their scheduling attributes "
6130 "from the thread attributes object. The program then creates a thread using "
6131 "the thread attributes object, and that thread displays its scheduling policy "
6136 #: build/C/man3/pthread_setschedparam.3:177
6139 "$ B<su> # Need privilege to set real-time scheduling policies\n"
6141 "# B<./a.out -mf10 -ar20 -i e>\n"
6142 "Scheduler settings of main thread\n"
6143 " policy=SCHED_FIFO, priority=10\n"
6147 #: build/C/man3/pthread_setschedparam.3:181
6150 "Scheduler settings in \\(aqattr\\(aq\n"
6151 " policy=SCHED_RR, priority=20\n"
6152 " inheritsched is EXPLICIT\n"
6156 #: build/C/man3/pthread_setschedparam.3:184
6159 "Scheduler attributes of new thread\n"
6160 " policy=SCHED_RR, priority=20\n"
6164 #: build/C/man3/pthread_setschedparam.3:189
6166 "In the above output, one can see that the scheduling policy and priority "
6167 "were taken from the values specified in the thread attributes object."
6171 #: build/C/man3/pthread_setschedparam.3:196
6173 "The next run is the same as the previous, except that the inherit scheduler "
6174 "attribute is set to B<PTHREAD_INHERIT_SCHED>, meaning that threads created "
6175 "using the thread attributes object should ignore the scheduling attributes "
6176 "specified in the attributes object and instead take their scheduling "
6177 "attributes from the creating thread."
6181 #: build/C/man3/pthread_setschedparam.3:202
6184 "# B<./a.out -mf10 -ar20 -i i>\n"
6185 "Scheduler settings of main thread\n"
6186 " policy=SCHED_FIFO, priority=10\n"
6190 #: build/C/man3/pthread_setschedparam.3:206
6193 "Scheduler settings in \\(aqattr\\(aq\n"
6194 " policy=SCHED_RR, priority=20\n"
6195 " inheritsched is INHERIT\n"
6199 #: build/C/man3/pthread_setschedparam.3:209
6202 "Scheduler attributes of new thread\n"
6203 " policy=SCHED_FIFO, priority=10\n"
6207 #: build/C/man3/pthread_setschedparam.3:215
6209 "In the above output, one can see that the scheduling policy and priority "
6210 "were taken from the creating thread, rather than the thread attributes "
6215 #: build/C/man3/pthread_setschedparam.3:221
6217 "Note that if we had omitted the I<-i\\ i> option, the output would have been "
6218 "the same, since B<PTHREAD_INHERIT_SCHED> is the default for the inherit "
6219 "scheduler attribute."
6223 #: build/C/man3/pthread_setschedparam.3:225
6225 msgid "/* pthreads_sched_test.c */\n"
6229 #: build/C/man3/pthread_setschedparam.3:231
6232 "#include E<lt>pthread.hE<gt>\n"
6233 "#include E<lt>stdio.hE<gt>\n"
6234 "#include E<lt>stdlib.hE<gt>\n"
6235 "#include E<lt>unistd.hE<gt>\n"
6236 "#include E<lt>errno.hE<gt>\n"
6240 #: build/C/man3/pthread_setschedparam.3:240
6244 "usage(char *prog_name, char *msg)\n"
6246 " if (msg != NULL)\n"
6247 " fputs(msg, stderr);\n"
6251 #: build/C/man3/pthread_setschedparam.3:257
6254 " fprintf(stderr, \"Usage: %s [options]\\en\", prog_name);\n"
6255 " fprintf(stderr, \"Options are:\\en\");\n"
6256 "#define fpe(msg) fprintf(stderr, \"\\et%s\", msg); /* Shorter */\n"
6257 " fpe(\"-aE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and priority in\\en\");\n"
6258 " fpe(\" thread attributes object\\en\");\n"
6259 " fpe(\" E<lt>policyE<gt> can be\\en\");\n"
6260 " fpe(\" f SCHED_FIFO\\en\");\n"
6261 " fpe(\" r SCHED_RR\\en\");\n"
6262 " fpe(\" o SCHED_OTHER\\en\");\n"
6263 " fpe(\"-A Use default thread attributes object\\en\");\n"
6264 " fpe(\"-i {e|s} Set inherit scheduler attribute to\\en\");\n"
6265 " fpe(\" \\(aqexplicit\\(aq or \\(aqinherit\\(aq\\en\");\n"
6266 " fpe(\"-mE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and priority on\\en\");\n"
6267 " fpe(\" main thread before pthread_create() call\\en\");\n"
6268 " exit(EXIT_FAILURE);\n"
6273 #: build/C/man3/pthread_setschedparam.3:268
6277 "get_policy(char p, int *policy)\n"
6280 " case \\(aqf\\(aq: *policy = SCHED_FIFO; return 1;\n"
6281 " case \\(aqr\\(aq: *policy = SCHED_RR; return 1;\n"
6282 " case \\(aqo\\(aq: *policy = SCHED_OTHER; return 1;\n"
6283 " default: return 0;\n"
6289 #: build/C/man3/pthread_setschedparam.3:279
6293 "display_sched_attr(int policy, struct sched_param *param)\n"
6295 " printf(\" policy=%s, priority=%d\\en\",\n"
6296 " (policy == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
6297 " (policy == SCHED_RR) ? \"SCHED_RR\" :\n"
6298 " (policy == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
6300 " param-E<gt>sched_priority);\n"
6305 #: build/C/man3/pthread_setschedparam.3:285
6309 "display_thread_sched_attr(char *msg)\n"
6312 " struct sched_param param;\n"
6316 #: build/C/man3/pthread_setschedparam.3:289
6319 " s = pthread_getschedparam(pthread_self(), &policy, ¶m);\n"
6321 " handle_error_en(s, \"pthread_getschedparam\");\n"
6325 #: build/C/man3/pthread_setschedparam.3:293
6328 " printf(\"%s\\en\", msg);\n"
6329 " display_sched_attr(policy, ¶m);\n"
6334 #: build/C/man3/pthread_setschedparam.3:298
6338 "thread_start(void *arg)\n"
6340 " display_thread_sched_attr(\"Scheduler attributes of new thread\");\n"
6344 #: build/C/man3/pthread_setschedparam.3:301
6352 #: build/C/man3/pthread_setschedparam.3:311
6356 "main(int argc, char *argv[])\n"
6358 " int s, opt, inheritsched, use_null_attrib, policy;\n"
6359 " pthread_t thread;\n"
6360 " pthread_attr_t attr;\n"
6361 " pthread_attr_t *attrp;\n"
6362 " char *attr_sched_str, *main_sched_str, *inheritsched_str;\n"
6363 " struct sched_param param;\n"
6367 #: build/C/man3/pthread_setschedparam.3:313
6369 msgid " /* Process command-line options */\n"
6373 #: build/C/man3/pthread_setschedparam.3:318
6376 " use_null_attrib = 0;\n"
6377 " attr_sched_str = NULL;\n"
6378 " main_sched_str = NULL;\n"
6379 " inheritsched_str = NULL;\n"
6383 #: build/C/man3/pthread_setschedparam.3:328
6386 " while ((opt = getopt(argc, argv, \"a:Ai:m:\")) != -1) {\n"
6388 " case \\(aqa\\(aq: attr_sched_str = optarg; break;\n"
6389 " case \\(aqA\\(aq: use_null_attrib = 1; break;\n"
6390 " case \\(aqi\\(aq: inheritsched_str = optarg; break;\n"
6391 " case \\(aqm\\(aq: main_sched_str = optarg; break;\n"
6392 " default: usage(argv[0], \"Unrecognized option\\en\");\n"
6398 #: build/C/man3/pthread_setschedparam.3:332
6401 " if (use_null_attrib &&\n"
6402 " (inheritsched_str != NULL || attr_sched_str != NULL))\n"
6403 " usage(argv[0], \"Can\\(aqt specify -A with -i or -a\\en\");\n"
6407 #: build/C/man3/pthread_setschedparam.3:335
6410 " /* Optionally set scheduling attributes of main thread,\n"
6411 " and display the attributes */\n"
6415 #: build/C/man3/pthread_setschedparam.3:340
6418 " if (main_sched_str != NULL) {\n"
6419 " if (!get_policy(main_sched_str[0], &policy))\n"
6420 " usage(argv[0], \"Bad policy for main thread (-s)\\en\");\n"
6421 " param.sched_priority = strtol(&main_sched_str[1], NULL, 0);\n"
6425 #: build/C/man3/pthread_setschedparam.3:345
6428 " s = pthread_setschedparam(pthread_self(), policy, ¶m);\n"
6430 " handle_error_en(s, \"pthread_setschedparam\");\n"
6435 #: build/C/man3/pthread_setschedparam.3:348
6438 " display_thread_sched_attr(\"Scheduler settings of main thread\");\n"
6439 " printf(\"\\en\");\n"
6443 #: build/C/man3/pthread_setschedparam.3:350
6445 msgid " /* Initialize thread attributes object according to options */\n"
6449 #: build/C/man3/pthread_setschedparam.3:359
6452 " if (!use_null_attrib) {\n"
6453 " s = pthread_attr_init(&attr);\n"
6455 " handle_error_en(s, \"pthread_attr_init\");\n"
6461 #: build/C/man3/pthread_setschedparam.3:367
6464 " if (inheritsched_str != NULL) {\n"
6465 " if (inheritsched_str[0] == \\(aqe\\(aq)\n"
6466 " inheritsched = PTHREAD_EXPLICIT_SCHED;\n"
6467 " else if (inheritsched_str[0] == \\(aqi\\(aq)\n"
6468 " inheritsched = PTHREAD_INHERIT_SCHED;\n"
6470 " usage(argv[0], \"Value for -i must be \\(aqe\\(aq or \\(aqi\\(aq\\en\");\n"
6474 #: build/C/man3/pthread_setschedparam.3:372
6477 " s = pthread_attr_setinheritsched(&attr, inheritsched);\n"
6479 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
6484 #: build/C/man3/pthread_setschedparam.3:378
6487 " if (attr_sched_str != NULL) {\n"
6488 " if (!get_policy(attr_sched_str[0], &policy))\n"
6490 " \"Bad policy for \\(aqattr\\(aq (-a)\\en\");\n"
6491 " param.sched_priority = strtol(&attr_sched_str[1], NULL, 0);\n"
6495 #: build/C/man3/pthread_setschedparam.3:386
6498 " s = pthread_attr_setschedpolicy(&attr, policy);\n"
6500 " handle_error_en(s, \"pthread_attr_setschedpolicy\");\n"
6501 " s = pthread_attr_setschedparam(&attr, ¶m);\n"
6503 " handle_error_en(s, \"pthread_attr_setschedparam\");\n"
6508 #: build/C/man3/pthread_setschedparam.3:389
6511 " /* If we initialized a thread attributes object, display\n"
6512 " the scheduling attributes that were set in the object */\n"
6516 #: build/C/man3/pthread_setschedparam.3:397
6519 " if (attrp != NULL) {\n"
6520 " s = pthread_attr_getschedparam(&attr, ¶m);\n"
6522 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
6523 " s = pthread_attr_getschedpolicy(&attr, &policy);\n"
6525 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
6529 #: build/C/man3/pthread_setschedparam.3:400
6532 " printf(\"Scheduler settings in \\(aqattr\\(aq\\en\");\n"
6533 " display_sched_attr(policy, ¶m);\n"
6537 #: build/C/man3/pthread_setschedparam.3:408
6540 " s = pthread_attr_getinheritsched(&attr, &inheritsched);\n"
6541 " printf(\" inheritsched is %s\\en\",\n"
6542 " (inheritsched == PTHREAD_INHERIT_SCHED) ? \"INHERIT\" :\n"
6543 " (inheritsched == PTHREAD_EXPLICIT_SCHED) ? \"EXPLICIT\" :\n"
6545 " printf(\"\\en\");\n"
6550 #: build/C/man3/pthread_setschedparam.3:410
6552 msgid " /* Create a thread that will display its scheduling attributes */\n"
6556 #: build/C/man3/pthread_setschedparam.3:414
6559 " s = pthread_create(&thread, attrp, &thread_start, NULL);\n"
6561 " handle_error_en(s, \"pthread_create\");\n"
6565 #: build/C/man3/pthread_setschedparam.3:416
6567 msgid " /* Destroy unneeded thread attributes object */\n"
6571 #: build/C/man3/pthread_setschedparam.3:424
6574 " s = pthread_join(thread, NULL);\n"
6576 " handle_error_en(s, \"pthread_join\");\n"
6580 #: build/C/man3/pthread_setschedparam.3:440
6582 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<sched_setscheduler>(2), "
6583 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
6584 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
6585 "B<pthread_create>(3), B<pthread_self>(3), B<pthread_setschedprio>(3), "
6590 #: build/C/man3/pthread_setschedprio.3:24
6592 msgid "PTHREAD_SETSCHEDPRIO"
6596 #: build/C/man3/pthread_setschedprio.3:24
6602 #: build/C/man3/pthread_setschedprio.3:27
6603 msgid "pthread_setschedprio - set scheduling priority of a thread"
6607 #: build/C/man3/pthread_setschedprio.3:32
6609 msgid "B<pthread_setschedprio(pthread_t >I<thread>B<, int >I<prio>B<);>\n"
6612 #. FIXME . nptl/pthread_setschedprio.c has the following
6613 #. /* If the thread should have higher priority because of some
6614 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
6615 #. Eventually (perhaps after writing the mutexattr pages), we
6616 #. may want to add something on the topic to this page.
6617 #. nptl/pthread_setschedparam.c has a similar case.
6619 #: build/C/man3/pthread_setschedprio.3:50
6621 "The B<pthread_setschedprio>() function sets the scheduling priority of the "
6622 "thread I<thread> to the value specified in I<prio>. (By contrast "
6623 "B<pthread_setschedparam>(3) changes both the scheduling policy and priority "
6628 #: build/C/man3/pthread_setschedprio.3:58
6630 "On success, this function returns 0; on error, it returns a nonzero error "
6631 "number. If B<pthread_setschedprio>() fails, the scheduling priority of "
6632 "I<thread> is not changed."
6636 #: build/C/man3/pthread_setschedprio.3:63
6637 msgid "I<prio> is not valid for the scheduling policy of the specified thread."
6641 #: build/C/man3/pthread_setschedprio.3:67
6643 "The caller does not have appropriate privileges to set the specified "
6648 #: build/C/man3/pthread_setschedprio.3:78
6650 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
6651 "priority to an unsupported value\") error for B<pthread_setschedparam>(3)."
6655 #: build/C/man3/pthread_setschedprio.3:80
6656 msgid "This function is available in glibc since version 2.3.4."
6660 #: build/C/man3/pthread_setschedprio.3:88
6662 "For a description of the permissions required to, and the effect of, "
6663 "changing a thread's scheduling priority, and details of the permitted ranges "
6664 "for priorities in each scheduling policy, see B<sched_setscheduler>(2)."
6668 #: build/C/man3/pthread_setschedprio.3:100
6670 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<sched_setscheduler>(2), "
6671 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
6672 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
6673 "B<pthread_create>(3), B<pthread_self>(3), B<pthread_setschedparam>(3), "
6678 #: build/C/man3/pthread_sigmask.3:24
6680 msgid "PTHREAD_SIGMASK"
6684 #: build/C/man3/pthread_sigmask.3:24
6686 #| msgid "2008-11-11"
6691 #: build/C/man3/pthread_sigmask.3:27
6692 msgid "pthread_sigmask - examine and change mask of blocked signals"
6696 #: build/C/man3/pthread_sigmask.3:33
6698 msgid "B<int pthread_sigmask(int >I<how>B<, const sigset_t *>I<set>B<, sigset_t *>I<oldset>B<);>\n"
6702 #: build/C/man3/pthread_sigmask.3:44
6704 "The B<pthread_sigmask>() function is just like B<sigprocmask>(2), with the "
6705 "difference that its use in multithreaded programs is explicitly specified by "
6706 "POSIX.1-2001. Other differences are noted in this page."
6710 #: build/C/man3/pthread_sigmask.3:47
6712 "For a description of the arguments and operation of this function, see "
6713 "B<sigprocmask>(2)."
6717 #: build/C/man3/pthread_sigmask.3:52
6719 "On success, B<pthread_sigmask>() returns 0; on error, it returns an error "
6724 #: build/C/man3/pthread_sigmask.3:55
6725 msgid "See B<sigprocmask>(2)."
6729 #: build/C/man3/pthread_sigmask.3:59
6730 msgid "A new thread inherits a copy of its creator's signal mask."
6734 #: build/C/man3/pthread_sigmask.3:64
6736 "The program below blocks some signals in the main thread, and then creates a "
6737 "dedicated thread to fetch those signals via B<sigwait>(3). The following "
6738 "shell session demonstrates its use:"
6742 #: build/C/man3/pthread_sigmask.3:75
6747 "$B< kill -QUIT %1>\n"
6748 "Signal handling thread got signal 3\n"
6749 "$B< kill -USR1 %1>\n"
6750 "Signal handling thread got signal 10\n"
6751 "$B< kill -TERM %1>\n"
6752 "[1]+ Terminated ./a.out\n"
6756 #: build/C/man3/pthread_sigmask.3:86
6759 "#include E<lt>pthread.hE<gt>\n"
6760 "#include E<lt>stdio.hE<gt>\n"
6761 "#include E<lt>stdlib.hE<gt>\n"
6762 "#include E<lt>unistd.hE<gt>\n"
6763 "#include E<lt>signal.hE<gt>\n"
6764 "#include E<lt>errno.hE<gt>\n"
6768 #: build/C/man3/pthread_sigmask.3:88
6770 msgid "/* Simple error handling functions */\n"
6774 #: build/C/man3/pthread_sigmask.3:97
6778 "sig_thread(void *arg)\n"
6780 " sigset_t *set = (sigset_t *) arg;\n"
6785 #: build/C/man3/pthread_sigmask.3:105
6789 " s = sigwait(set, &sig);\n"
6791 " handle_error_en(s, \"sigwait\");\n"
6792 " printf(\"Signal handling thread got signal %d\\en\", sig);\n"
6798 #: build/C/man3/pthread_sigmask.3:112
6802 "main(int argc, char *argv[])\n"
6804 " pthread_t thread;\n"
6810 #: build/C/man3/pthread_sigmask.3:115
6813 " /* Block SIGQUIT and SIGUSR1; other threads created by main()\n"
6814 " will inherit a copy of the signal mask. */\n"
6818 #: build/C/man3/pthread_sigmask.3:122
6821 " sigemptyset(&set);\n"
6822 " sigaddset(&set, SIGQUIT);\n"
6823 " sigaddset(&set, SIGUSR1);\n"
6824 " s = pthread_sigmask(SIG_BLOCK, &set, NULL);\n"
6826 " handle_error_en(s, \"pthread_sigmask\");\n"
6830 #: build/C/man3/pthread_sigmask.3:126
6833 " s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);\n"
6835 " handle_error_en(s, \"pthread_create\");\n"
6839 #: build/C/man3/pthread_sigmask.3:129
6842 " /* Main thread carries on to create other threads and/or do\n"
6847 #: build/C/man3/pthread_sigmask.3:132
6850 " pause(); /* Dummy pause so we can test program */\n"
6855 #: build/C/man3/pthread_sigmask.3:142
6857 "B<sigaction>(2), B<sigpending>(2), B<sigprocmask>(2) B<pthread_create>(3), "
6858 "B<pthread_kill>(3), B<sigsetops>(3), B<pthreads>(7), B<signal>(7)"
6862 #: build/C/man3/pthread_sigqueue.3:23
6864 msgid "PTHREAD_SIGQUEUE"
6868 #: build/C/man3/pthread_sigqueue.3:23
6874 #: build/C/man3/pthread_sigqueue.3:26
6875 msgid "pthread_sigqueue - queue a signal and data to a thread"
6879 #: build/C/man3/pthread_sigqueue.3:32
6882 "B<int pthread_sigqueue(pthread_t *>I<thread>B<, int >I<sig>B<,>\n"
6883 "B< const union sigval >I<value>B<);>\n"
6887 #: build/C/man3/pthread_sigqueue.3:43
6888 msgid "B<pthread_sigqueue>(): _GNU_SOURCE"
6892 #: build/C/man3/pthread_sigqueue.3:51
6894 "The B<pthread_sigqueue>() function performs a similar task to B<sigqueue>"
6895 "(3), but, rather than sending a signal to another process, it sends a signal "
6896 "to another thread in the same process as the calling thread."
6900 #: build/C/man3/pthread_sigqueue.3:63
6902 "The I<thread> argument is the ID of another thread in the same process as "
6903 "the caller. The I<sig> argument specifies the signal to be sent. The "
6904 "I<value> argument specifies data to accompany the signal; see B<sigqueue>"
6909 #: build/C/man3/pthread_sigqueue.3:68
6911 "On success, B<pthread_sigqueue>() returns 0; on error, it returns an error "
6916 #: build/C/man3/pthread_sigqueue.3:75
6918 "The limit of signals which may be queued has been reached. (See B<signal>"
6919 "(7) for further information.)"
6923 #: build/C/man3/pthread_sigqueue.3:79
6924 msgid "I<sig> was invalid."
6928 #: build/C/man3/pthread_sigqueue.3:79
6934 #: build/C/man3/pthread_sigqueue.3:83
6935 msgid "B<pthread_sigqueue>() is not supported on this system."
6939 #: build/C/man3/pthread_sigqueue.3:87
6940 msgid "I<thread> is not valid."
6944 #: build/C/man3/pthread_sigqueue.3:91
6945 msgid "The B<pthread_sigqueue>() function first appeared in glibc 2.11."
6949 #: build/C/man3/pthread_sigqueue.3:93
6950 msgid "This function is a GNU extension."
6954 #: build/C/man3/pthread_sigqueue.3:101
6956 "B<rt_tgsigqueueinfo>(2), B<sigaction>(2), B<sigqueue>(3), B<sigwait>(3), "
6957 "B<pthread_sigmask>(3), B<pthreads>(7), B<signal>(7)"
6961 #: build/C/man3/pthread_testcancel.3:24
6963 msgid "PTHREAD_TESTCANCEL"
6967 #: build/C/man3/pthread_testcancel.3:27
6969 "pthread_testcancel - request delivery of any pending cancellation request"
6973 #: build/C/man3/pthread_testcancel.3:32
6975 msgid "B<void pthread_testcancel(void);>\n"
6979 #: build/C/man3/pthread_testcancel.3:40
6981 "Calling B<pthread_testcancel>() creates a cancellation point within the "
6982 "calling thread, so that a thread that is otherwise executing code that "
6983 "contains no cancellation points will respond to a cancellation request."
6987 #: build/C/man3/pthread_testcancel.3:47
6989 "If cancelability is disabled (using B<pthread_setcancelstate>(3)), or no "
6990 "cancellation request is pending, then a call to B<pthread_cancel>(3) has no "
6995 #: build/C/man3/pthread_testcancel.3:51
6997 "This function does not return a value. If the calling thread is canceled as "
6998 "a consequence of a call to this function, then the function does not return."
7002 #: build/C/man3/pthread_testcancel.3:60
7003 msgid "See B<pthread_cleanup_push>(3)."
7007 #: build/C/man3/pthread_testcancel.3:65
7009 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), B<pthread_setcancelstate>"
7010 "(3), B<pthreads>(7)"
7014 #: build/C/man3/pthread_tryjoin_np.3:24
7016 msgid "PTHREAD_TRYJOIN_NP"
7020 #: build/C/man3/pthread_tryjoin_np.3:28
7022 "pthread_tryjoin_np, pthread_timedjoin_np - try to join with a terminated "
7027 #: build/C/man3/pthread_tryjoin_np.3:34
7029 msgid "B<int pthread_tryjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
7033 #: build/C/man3/pthread_tryjoin_np.3:37
7036 "B<int pthread_timedjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<,>\n"
7037 "B< const struct timespec *>I<abstime>B<);>\n"
7041 #: build/C/man3/pthread_tryjoin_np.3:44
7043 "These functions operate in the same way as B<pthread_join>(3), except for "
7044 "the differences described on this page."
7048 #: build/C/man3/pthread_tryjoin_np.3:56
7050 "The B<pthread_tryjoin_np>() function performs a nonblocking join with the "
7051 "thread I<thread>, returning the exit status of the thread in I<*retval>. If "
7052 "I<thread> has not yet terminated, then instead of blocking, as is done by "
7053 "B<pthread_join>(3), the call returns an error."
7057 #: build/C/man3/pthread_tryjoin_np.3:74
7059 "The B<pthread_timedjoin_np>() function performs a join-with-timeout. If "
7060 "I<thread> has not yet terminated, then the call blocks until a maximum time, "
7061 "specified in I<abstime>. If the timeout expires before I<thread> "
7062 "terminates, the call returns an error. The I<abstime> argument is a "
7063 "structure of the following form, specifying an absolute time measured since "
7064 "the Epoch (see B<time>(2)):"
7068 #: build/C/man3/pthread_tryjoin_np.3:81
7071 "struct timespec {\n"
7072 " time_t tv_sec; /* seconds */\n"
7073 " long tv_nsec; /* nanoseconds */\n"
7078 #: build/C/man3/pthread_tryjoin_np.3:87
7080 "On success, these functions return 0; on error, they return an error number."
7084 #: build/C/man3/pthread_tryjoin_np.3:92
7086 "These functions can fail with the same errors as B<pthread_join>(3). "
7087 "B<pthread_tryjoin_np>() can in addition fail with the following error:"
7091 #: build/C/man3/pthread_tryjoin_np.3:92
7097 #: build/C/man3/pthread_tryjoin_np.3:96
7098 msgid "I<thread> had not yet terminated at the time of the call."
7102 #: build/C/man3/pthread_tryjoin_np.3:99
7104 "B<pthread_timedjoin_np>() can in addition fail with the following error:"
7108 #: build/C/man3/pthread_tryjoin_np.3:99
7110 msgid "B<ETIMEDOUT>"
7114 #: build/C/man3/pthread_tryjoin_np.3:104
7115 msgid "The call timed out before I<thread> terminated."
7119 #: build/C/man3/pthread_tryjoin_np.3:108
7120 msgid "B<pthread_timedjoin_np>() never returns the error B<EINTR>."
7124 #: build/C/man3/pthread_tryjoin_np.3:110
7125 msgid "These functions first appeared in glibc in version 2.3.3."
7129 #: build/C/man3/pthread_tryjoin_np.3:115
7130 msgid "The following code waits to join for up to 5 seconds:"
7134 #: build/C/man3/pthread_tryjoin_np.3:119
7137 " struct timespec ts;\n"
7142 #: build/C/man3/pthread_tryjoin_np.3:121
7148 #: build/C/man3/pthread_tryjoin_np.3:125
7151 " if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {\n"
7152 "\t/* Handle error */\n"
7157 #: build/C/man3/pthread_tryjoin_np.3:127
7159 msgid " ts.tv_sec += 5;\n"
7163 #: build/C/man3/pthread_tryjoin_np.3:132
7166 " s = pthread_timedjoin_np(thread, NULL, &ts);\n"
7168 " /* Handle error */\n"
7173 #: build/C/man3/pthread_tryjoin_np.3:138
7175 "B<clock_gettime>(2), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
7179 #: build/C/man3/pthread_yield.3:23
7181 msgid "PTHREAD_YIELD"
7185 #: build/C/man3/pthread_yield.3:26
7186 msgid "pthread_yield - yield the processor"
7190 #: build/C/man3/pthread_yield.3:31
7192 msgid "B<int pthread_yield(void);>\n"
7196 #: build/C/man3/pthread_yield.3:41
7198 "B<pthread_yield>() causes the calling thread to relinquish the CPU. The "
7199 "thread is placed at the end of the run queue for its static priority and "
7200 "another thread is scheduled to run. For further details, see B<sched_yield>"
7205 #: build/C/man3/pthread_yield.3:46
7207 "On success, B<pthread_yield>() returns 0; on error, it returns an error "
7212 #: build/C/man3/pthread_yield.3:50
7214 "On Linux, this call always succeeds (but portable and future-proof "
7215 "applications should nevertheless handle a possible error return)."
7218 #. e.g., the BSDs, Tru64, AIX, and Irix.
7220 #: build/C/man3/pthread_yield.3:56
7222 "This call is nonstandard, but present on several other systems. Use the "
7223 "standardized B<sched_yield>(2) instead."
7227 #: build/C/man3/pthread_yield.3:59
7228 msgid "On Linux, this function is implemented as a call to B<sched_yield>(2)."
7232 #: build/C/man3/pthread_yield.3:63
7233 msgid "B<sched_setscheduler>(2), B<sched_yield>(2) B<pthreads>(7)"
7234 msgstr "B<sched_setscheduler>(2), B<sched_yield>(2) B<pthreads>(7)"
7237 #: build/C/man7/pthreads.7:24
7243 #: build/C/man7/pthreads.7:24
7245 #| msgid "2008-11-11"
7250 #: build/C/man7/pthreads.7:27
7251 msgid "pthreads - POSIX threads"
7252 msgstr "pthreads - POSIX スレッド"
7255 #: build/C/man7/pthreads.7:34
7257 "POSIX.1 specifies a set of interfaces (functions, header files) for threaded "
7258 "programming commonly known as POSIX threads, or Pthreads. A single process "
7259 "can contain multiple threads, all of which are executing the same program. "
7260 "These threads share the same global memory (data and heap segments), but "
7261 "each thread has its own stack (automatic variables)."
7263 "POSIX.1 は、一般に POSIX スレッドや Pthreads として知られる スレッド・プログ"
7264 "ラミングのインタフェース群 (関数、ヘッダファイル) を規定している。一つのプロ"
7265 "セスは複数のスレッドを持つことができ、 全てのスレッドは同じプログラムを実行す"
7266 "る。 これらのスレッドは同じ大域メモリ (データとヒープ領域) を共有するが、 各"
7267 "スレッドは自分専用のスタック (自動変数) を持つ。"
7270 #: build/C/man7/pthreads.7:37
7272 "POSIX.1 also requires that threads share a range of other attributes (i.e., "
7273 "these attributes are process-wide rather than per-thread):"
7275 "POSIX.1 はスレッド間でどのような属性を共有するかについても定めている (つま"
7276 "り、これらの属性はスレッド単位ではなくプロセス全体で共通である):"
7279 #: build/C/man7/pthreads.7:37 build/C/man7/pthreads.7:39
7280 #: build/C/man7/pthreads.7:41 build/C/man7/pthreads.7:43
7281 #: build/C/man7/pthreads.7:45 build/C/man7/pthreads.7:47
7282 #: build/C/man7/pthreads.7:49 build/C/man7/pthreads.7:52
7283 #: build/C/man7/pthreads.7:54 build/C/man7/pthreads.7:57
7284 #: build/C/man7/pthreads.7:63 build/C/man7/pthreads.7:68
7285 #: build/C/man7/pthreads.7:71 build/C/man7/pthreads.7:74
7286 #: build/C/man7/pthreads.7:82 build/C/man7/pthreads.7:86
7287 #: build/C/man7/pthreads.7:89 build/C/man7/pthreads.7:93
7288 #: build/C/man7/pthreads.7:96 build/C/man7/pthreads.7:103
7289 #: build/C/man7/pthreads.7:106 build/C/man7/pthreads.7:683
7290 #: build/C/man7/pthreads.7:690 build/C/man7/pthreads.7:702
7291 #: build/C/man7/pthreads.7:712 build/C/man7/pthreads.7:716
7292 #: build/C/man7/pthreads.7:725 build/C/man7/pthreads.7:735
7293 #: build/C/man7/pthreads.7:742 build/C/man7/pthreads.7:749
7294 #: build/C/man7/pthreads.7:751 build/C/man7/pthreads.7:754
7295 #: build/C/man7/pthreads.7:760 build/C/man7/pthreads.7:763
7296 #: build/C/man7/pthreads.7:765 build/C/man7/pthreads.7:767
7297 #: build/C/man7/pthreads.7:777 build/C/man7/pthreads.7:797
7298 #: build/C/man7/pthreads.7:806 build/C/man7/pthreads.7:812
7299 #: build/C/man7/pthreads.7:814 build/C/man7/pthreads.7:816
7300 #: build/C/man7/pthreads.7:820 build/C/man7/pthreads.7:825
7301 #: build/C/man7/pthreads.7:833
7307 #: build/C/man7/pthreads.7:39
7312 #: build/C/man7/pthreads.7:41
7313 msgid "parent process ID"
7317 #: build/C/man7/pthreads.7:43
7318 msgid "process group ID and session ID"
7319 msgstr "プロセスグループ ID とセッション ID"
7322 #: build/C/man7/pthreads.7:45
7323 msgid "controlling terminal"
7327 #: build/C/man7/pthreads.7:47
7328 msgid "user and group IDs"
7329 msgstr "ユーザ ID とグループ ID"
7332 #: build/C/man7/pthreads.7:49
7333 msgid "open file descriptors"
7334 msgstr "オープンするファイルディスクリプタ"
7337 #: build/C/man7/pthreads.7:52
7338 msgid "record locks (see B<fcntl>(2))"
7339 msgstr "レコードのロック (B<fcntl>(3) 参照)"
7342 #: build/C/man7/pthreads.7:54
7343 msgid "signal dispositions"
7347 #: build/C/man7/pthreads.7:57
7348 msgid "file mode creation mask (B<umask>(2))"
7349 msgstr "ファイルモード作成マスク (B<umask>(2))"
7352 #: build/C/man7/pthreads.7:63
7353 msgid "current directory (B<chdir>(2)) and root directory (B<chroot>(2))"
7355 "カレント・ディレクトリ (B<chdir>(2)) とルート・ディレクトリ (B<chroot>(2))"
7358 #: build/C/man7/pthreads.7:68
7360 "interval timers (B<setitimer>(2)) and POSIX timers (B<timer_create>(2))"
7362 "インターバル・タイマ (B<setitimer>(2)) と POSIX タイマ (B<timer_create>(2))"
7365 #: build/C/man7/pthreads.7:71
7366 msgid "nice value (B<setpriority>(2))"
7367 msgstr "nice 値 (B<setpriority>(2))"
7370 #: build/C/man7/pthreads.7:74
7371 msgid "resource limits (B<setrlimit>(2))"
7372 msgstr "リソース制限 (B<setrlimit>(2))"
7375 #: build/C/man7/pthreads.7:79
7377 "measurements of the consumption of CPU time (B<times>(2)) and resources "
7379 msgstr "CPU 時間 (B<times>(2)) とリソース (B<getrusage>(2)) の消費状況の計測"
7382 #: build/C/man7/pthreads.7:82
7384 "As well as the stack, POSIX.1 specifies that various other attributes are "
7385 "distinct for each thread, including:"
7387 "スタックについても、POSIX.1 はどのような属性が 個々のスレッドで独立に管理され"
7391 #: build/C/man7/pthreads.7:86
7392 msgid "thread ID (the I<pthread_t> data type)"
7393 msgstr "スレッド ID (B<pthread_t> データ型)"
7396 #: build/C/man7/pthreads.7:89
7397 msgid "signal mask (B<pthread_sigmask>(3))"
7398 msgstr "シグナルマスク (B<pthread_sigmask>(3))"
7401 #: build/C/man7/pthreads.7:93
7402 msgid "the I<errno> variable"
7403 msgstr "I<errno> 変数"
7406 #: build/C/man7/pthreads.7:96
7407 msgid "alternate signal stack (B<sigaltstack>(2))"
7408 msgstr "代替シグナルスタック (B<sigaltstack>(2))"
7411 #: build/C/man7/pthreads.7:101
7413 "real-time scheduling policy and priority (B<sched_setscheduler>(2) and "
7414 "B<sched_setparam>(2))"
7416 "リアルタイム・スケジューリングのポリシーと優先度 (B<sched_setscheduler>(2) "
7417 "と B<sched_setparam>(2))"
7420 #: build/C/man7/pthreads.7:103
7421 msgid "The following Linux-specific features are also per-thread:"
7422 msgstr "以下の Linux 特有の機能もスレッド単位である:"
7425 #: build/C/man7/pthreads.7:106
7426 msgid "capabilities (see B<capabilities>(7))"
7427 msgstr "ケーパビリティ (B<capabilities>(7) 参照)"
7430 #: build/C/man7/pthreads.7:109
7431 msgid "CPU affinity (B<sched_setaffinity>(2))"
7432 msgstr "CPU affinity (親和度) (B<sched_setaffinity>(2))"
7435 #: build/C/man7/pthreads.7:109
7437 msgid "Pthreads function return values"
7438 msgstr "pthreads 関数の返り値"
7441 #: build/C/man7/pthreads.7:116
7443 "Most pthreads functions return 0 on success, and an error number of "
7444 "failure. Note that the pthreads functions do not set I<errno>. For each of "
7445 "the pthreads functions that can return an error, POSIX.1-2001 specifies that "
7446 "the function can never fail with the error B<EINTR>."
7448 "ほとんどの pthreads 関数は成功すると 0 を返し、 失敗した場合エラー番号を返"
7449 "す。 pthreads 関数は I<errno> をセットしない点に注意すること。 POSIX.1-2001 "
7450 "では、 エラーを返す可能性のある pthreads 関数がエラー B<EINTR> で失敗すること"
7454 #: build/C/man7/pthreads.7:116
7460 #: build/C/man7/pthreads.7:130
7462 "Each of the threads in a process has a unique thread identifier (stored in "
7463 "the type I<pthread_t>). This identifier is returned to the caller of "
7464 "B<pthread_create>(3), and a thread can obtain its own thread identifier "
7465 "using B<pthread_self>(3). Thread IDs are only guaranteed to be unique "
7466 "within a process. A thread ID may be reused after a terminated thread has "
7467 "been joined, or a detached thread has terminated. In all pthreads functions "
7468 "that accept a thread ID as an argument, that ID by definition refers to a "
7469 "thread in the same process as the caller."
7471 "あるプロセス内の各スレッドは (I<pthread_t> 型の) 一意なスレッド識別子を持"
7472 "つ。 この識別子は、 B<pthread_create>(3) の呼び出し元に返される。また、ス"
7473 "レッドは自身のスレッド識別子を B<pthread_self>(3) を使って取得できる。 ス"
7474 "レッド ID の一意性が保証されるのは、一つのプロセス内においてのみである。 終了"
7475 "したスレッドが join された後では、スレッド ID は再利用される可能性がある。 ス"
7476 "レッド ID を引き数に取る全てのスレッド関数において、 その ID は呼び出し元と同"
7477 "じプロセス内の一つのスレッドを参照する。"
7480 #: build/C/man7/pthreads.7:130
7482 msgid "Thread-safe functions"
7486 #: build/C/man7/pthreads.7:134
7488 "A thread-safe function is one that can be safely (i.e., it will deliver the "
7489 "same results regardless of whether it is) called from multiple threads at "
7492 "スレッドセーフな関数は、複数のスレッドから同時に呼び出しても安全な (すなわ"
7493 "ち、同時に呼び出されたかに関わらず、同じ結果を返す) 関数のことである。"
7496 #: build/C/man7/pthreads.7:138
7498 "POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the "
7499 "standard shall be thread-safe, except for the following functions:"
7501 "POSIX.1-2001 と POSIX.1-2008では、一部の例外を除き、 標準で規定されている全て"
7502 "の関数がスレッドセーフであることを要求している。 以下の関数が例外である。"
7505 #: build/C/man7/pthreads.7:232
7512 "ctermid() if passed a non-NULL argument\n"
7526 "ecvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7531 "fcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7533 "gcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7535 "getchar_unlocked()\n"
7541 "gethostbyaddr() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7542 "gethostbyname() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7549 "getprotobyname()\n"
7550 "getprotobynumber()\n"
7578 "putchar_unlocked()\n"
7589 "strsignal() [Added in POSIX.1-2008]\n"
7591 "system() [Added in POSIX.1-2008]\n"
7592 "tmpnam() if passed a non-NULL argument\n"
7595 "wcrtomb() if its final argument is NULL\n"
7596 "wcsrtombs() if its final argument is NULL\n"
7604 "ctermid() (NULL でない引き数を渡された場合)\n"
7618 "ecvt() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7623 "fcvt() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7625 "gcvt() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7627 "getchar_unlocked()\n"
7633 "gethostbyaddr() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7634 "gethostbyname() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7641 "getprotobyname()\n"
7642 "getprotobynumber()\n"
7670 "putchar_unlocked()\n"
7681 "strsignal() [POSIX.1-2008 で追加された]\n"
7683 "system() [POSIX.1-2008 で追加された]\n"
7684 "tmpnam() (NULL でない引き数を渡された場合)\n"
7687 "wcrtomb() (最後の引き数が NULL の場合)\n"
7688 "wcsrtombs() (最後の引き数が NULL の場合)\n"
7693 #: build/C/man7/pthreads.7:234
7695 #| msgid "Thread-safe functions"
7696 msgid "Async-cancel-safe functions"
7700 #: build/C/man7/pthreads.7:238
7702 "An async-cancel-safe function is one that can be safely called in an "
7703 "application where asynchronous cancelability is enabled (see "
7704 "B<pthread_setcancelstate>(3))."
7708 #: build/C/man7/pthreads.7:241
7711 #| "The following functions are required to be cancellation points by "
7712 #| "POSIX.1-2001 and/or POSIX.1-2008:"
7714 "Only the following functions are required to be async-cancel-safe by "
7715 "POSIX.1-2001 and POSIX.1-2008:"
7717 "POSIX.1-2001 と POSIX.1-2008 の両方、もしくはいずれか一方では、 以下の関数"
7718 "は、取り消しポイント (cancellation points) で あることが必須となっている。"
7721 #: build/C/man7/pthreads.7:247
7724 "pthread_cancel()\n"
7725 "pthread_setcancelstate()\n"
7726 "pthread_setcanceltype()\n"
7730 #: build/C/man7/pthreads.7:249
7732 msgid "Cancellation Points"
7733 msgstr "取り消しポイント (cancellation points)"
7736 #: build/C/man7/pthreads.7:256
7738 "POSIX.1 specifies that certain functions must, and certain other functions "
7739 "may, be cancellation points. If a thread is cancelable, its cancelability "
7740 "type is deferred, and a cancellation request is pending for the thread, then "
7741 "the thread is canceled when it calls a function that is a cancellation point."
7743 "POSIX.1 の規定では、特定の関数は取り消しポイントでなければならず、 他の特定の"
7744 "関数は取り消しポイントであってもよいとされている。 あるスレッドが取り消し可能"
7745 "で、その取り消し種別 (cancelability type) が延期 (deferred) で、そのスレッド"
7746 "に対する取り消し要求が処理待ちの場合、 取り消しポイントである関数を呼び出した"
7747 "時点で、そのスレッドのキャンセルが 行われる。"
7750 #: build/C/man7/pthreads.7:259
7752 "The following functions are required to be cancellation points by "
7753 "POSIX.1-2001 and/or POSIX.1-2008:"
7755 "POSIX.1-2001 と POSIX.1-2008 の両方、もしくはいずれか一方では、 以下の関数"
7756 "は、取り消しポイント (cancellation points) で あることが必須となっている。"
7759 #: build/C/man7/pthreads.7:322
7764 "clock_nanosleep()\n"
7768 "fcntl() F_SETLKW\n"
7776 "mq_timedreceive()\n"
7783 "openat() [Added in POSIX.1-2008]\n"
7788 "pthread_cond_timedwait()\n"
7789 "pthread_cond_wait()\n"
7791 "pthread_testcancel()\n"
7806 "sigpause() [POSIX.1-2001 only (moves to \"may\" list in POSIX.1-2008)]\n"
7814 "usleep() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7823 "clock_nanosleep()\n"
7827 "fcntl() F_SETLKW\n"
7835 "mq_timedreceive()\n"
7842 "openat() [POSIX.1-2008 で追加された]\n"
7847 "pthread_cond_timedwait()\n"
7848 "pthread_cond_wait()\n"
7850 "pthread_testcancel()\n"
7865 "sigpause() [POSIX.1-2001 only (moves to \"may\" list in POSIX.1-2008)]\n"
7873 "usleep() [POSIX.1-2001 のみ (POSIX.1-2008 で削除された)]\n"
7881 #: build/C/man7/pthreads.7:327
7883 "The following functions may be cancellation points according to POSIX.1-2001 "
7884 "and/or POSIX.1-2008:"
7886 "POSIX.1-2001 と POSIX.1-2008 の両方、もしくはいずれか一方では、 以下の関数"
7887 "は、取り消しポイント (cancellation points) で あってもよいことになっている。"
7890 #: build/C/man7/pthreads.7:555
7899 "chmod() [Added in POSIX.1-2008]\n"
7900 "chown() [Added in POSIX.1-2008]\n"
7914 "dprintf() [Added in POSIX.1-2008]\n"
7922 "faccessat() [Added in POSIX.1-2008]\n"
7923 "fchmod() [Added in POSIX.1-2008]\n"
7924 "fchmodat() [Added in POSIX.1-2008]\n"
7925 "fchown() [Added in POSIX.1-2008]\n"
7926 "fchownat() [Added in POSIX.1-2008]\n"
7928 "fcntl() (for any value of cmd argument)\n"
7950 "fstatat() [Added in POSIX.1-2008]\n"
7954 "futimens() [Added in POSIX.1-2008]\n"
7962 "getchar_unlocked()\n"
7965 "getdelim() [Added in POSIX.1-2008]\n"
7971 "gethostbyaddr() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7972 "gethostbyname() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7976 "getline() [Added in POSIX.1-2008]\n"
7983 "getopt() (if opterr is nonzero)\n"
7984 "getprotobyname()\n"
7985 "getprotobynumber()\n"
8001 "getwd() [SUSv3 only (function removed in POSIX.1-2008)]\n"
8007 "linkat() [Added in POSIX.1-2008]\n"
8008 "lio_listio() [Added in POSIX.1-2008]\n"
8011 "lockf() [Added in POSIX.1-2008]\n"
8014 "mkdir() [Added in POSIX.1-2008]\n"
8015 "mkdirat() [Added in POSIX.1-2008]\n"
8016 "mkdtemp() [Added in POSIX.1-2008]\n"
8017 "mkfifo() [Added in POSIX.1-2008]\n"
8018 "mkfifoat() [Added in POSIX.1-2008]\n"
8019 "mknod() [Added in POSIX.1-2008]\n"
8020 "mknodat() [Added in POSIX.1-2008]\n"
8031 "posix_fallocate()\n"
8036 "posix_trace_clear()\n"
8037 "posix_trace_close()\n"
8038 "posix_trace_create()\n"
8039 "posix_trace_create_withlog()\n"
8040 "posix_trace_eventtypelist_getnext_id()\n"
8041 "posix_trace_eventtypelist_rewind()\n"
8042 "posix_trace_flush()\n"
8043 "posix_trace_get_attr()\n"
8044 "posix_trace_get_filter()\n"
8045 "posix_trace_get_status()\n"
8046 "posix_trace_getnext_event()\n"
8047 "posix_trace_open()\n"
8048 "posix_trace_rewind()\n"
8049 "posix_trace_set_filter()\n"
8050 "posix_trace_shutdown()\n"
8051 "posix_trace_timedgetnext_event()\n"
8052 "posix_typed_mem_open()\n"
8054 "psiginfo() [Added in POSIX.1-2008]\n"
8055 "psignal() [Added in POSIX.1-2008]\n"
8056 "pthread_rwlock_rdlock()\n"
8057 "pthread_rwlock_timedrdlock()\n"
8058 "pthread_rwlock_timedwrlock()\n"
8059 "pthread_rwlock_wrlock()\n"
8063 "putchar_unlocked()\n"
8070 "readlink() [Added in POSIX.1-2008]\n"
8071 "readlinkat() [Added in POSIX.1-2008]\n"
8074 "renameat() [Added in POSIX.1-2008]\n"
8077 "scandir() [Added in POSIX.1-2008]\n"
8088 "sigpause() [Added in POSIX.1-2008]\n"
8094 "symlinkat() [Added in POSIX.1-2008]\n"
8105 "unlinkat() [Added in POSIX.1-2008]\n"
8106 "utime() [Added in POSIX.1-2008]\n"
8107 "utimensat() [Added in POSIX.1-2008]\n"
8108 "utimes() [Added in POSIX.1-2008]\n"
8109 "vdprintf() [Added in POSIX.1-2008]\n"
8125 "chmod() [POSIX.1-2008 で追加された]\n"
8126 "chown() [POSIX.1-2008 で追加された]\n"
8140 "dprintf() [POSIX.1-2008 で追加された]\n"
8148 "faccessat() [POSIX.1-2008 で追加された]\n"
8149 "fchmod() [POSIX.1-2008 で追加された]\n"
8150 "fchmodat() [POSIX.1-2008 で追加された]\n"
8151 "fchown() [POSIX.1-2008 で追加された]\n"
8152 "fchownat() [POSIX.1-2008 で追加された]\n"
8154 "fcntl() (cmd 引き数が何であっても)\n"
8176 "fstatat() [POSIX.1-2008 で追加された]\n"
8180 "futimens() [POSIX.1-2008 で追加された]\n"
8188 "getchar_unlocked()\n"
8191 "getdelim() [POSIX.1-2008 で追加された]\n"
8197 "gethostbyaddr() [SUSv3 のみ (この関数は POSIX.1-2008 で削除されている)]\n"
8198 "gethostbyname() [SUSv3 のみ (この関数は POSIX.1-2008 で削除されている)]\n"
8202 "getline() [POSIX.1-2008 で追加された]\n"
8209 "getopt() (opterr が 0 以外の場合)\n"
8210 "getprotobyname()\n"
8211 "getprotobynumber()\n"
8227 "getwd() [SUSv3 のみ (この関数は POSIX.1-2008 で削除されている)]\n"
8233 "linkat() [POSIX.1-2008 で追加された]\n"
8234 "lio_listio() [POSIX.1-2008 で追加された]\n"
8237 "lockf() [POSIX.1-2008 で追加された]\n"
8240 "mkdir() [POSIX.1-2008 で追加された]\n"
8241 "mkdirat() [POSIX.1-2008 で追加された]\n"
8242 "mkdtemp() [POSIX.1-2008 で追加された]\n"
8243 "mkfifo() [POSIX.1-2008 で追加された]\n"
8244 "mkfifoat() [POSIX.1-2008 で追加された]\n"
8245 "mknod() [POSIX.1-2008 で追加された]\n"
8246 "mknodat() [POSIX.1-2008 で追加された]\n"
8257 "posix_fallocate()\n"
8262 "posix_trace_clear()\n"
8263 "posix_trace_close()\n"
8264 "posix_trace_create()\n"
8265 "posix_trace_create_withlog()\n"
8266 "posix_trace_eventtypelist_getnext_id()\n"
8267 "posix_trace_eventtypelist_rewind()\n"
8268 "posix_trace_flush()\n"
8269 "posix_trace_get_attr()\n"
8270 "posix_trace_get_filter()\n"
8271 "posix_trace_get_status()\n"
8272 "posix_trace_getnext_event()\n"
8273 "posix_trace_open()\n"
8274 "posix_trace_rewind()\n"
8275 "posix_trace_set_filter()\n"
8276 "posix_trace_shutdown()\n"
8277 "posix_trace_timedgetnext_event()\n"
8278 "posix_typed_mem_open()\n"
8280 "psiginfo() [POSIX.1-2008 で追加された]\n"
8281 "psignal() [POSIX.1-2008 で追加された]\n"
8282 "pthread_rwlock_rdlock()\n"
8283 "pthread_rwlock_timedrdlock()\n"
8284 "pthread_rwlock_timedwrlock()\n"
8285 "pthread_rwlock_wrlock()\n"
8289 "putchar_unlocked()\n"
8296 "readlink() [POSIX.1-2008 で追加された]\n"
8297 "readlinkat() [POSIX.1-2008 で追加された]\n"
8300 "renameat() [POSIX.1-2008 で追加された]\n"
8303 "scandir() [POSIX.1-2008 で追加された]\n"
8314 "sigpause() [POSIX.1-2008 で追加された]\n"
8320 "symlinkat() [POSIX.1-2008 で追加された]\n"
8331 "unlinkat() [POSIX.1-2008 で追加された]\n"
8332 "utime() [POSIX.1-2008 で追加された]\n"
8333 "utimensat() [POSIX.1-2008 で追加された]\n"
8334 "utimes() [POSIX.1-2008 で追加された]\n"
8335 "vdprintf() [POSIX.1-2008 で追加された]\n"
8345 #. So, scanning "cancellation point" comments in the glibc 2.8 header
8346 #. files, it looks as though at least the following nonstandard
8347 #. functions are cancellation points:
8387 #. getprotobynumber_r
8402 #. getwchar_unlocked
8409 #. pthread_timedjoin_np
8415 #. putwchar_unlocked
8436 #: build/C/man7/pthreads.7:653
8438 "An implementation may also mark other functions not specified in the "
8439 "standard as cancellation points. In particular, an implementation is likely "
8440 "to mark any nonstandard function that may block as a cancellation point. "
8441 "(This includes most functions that can touch files.)"
8443 "実装時に、標準規格で規定されていないその他の関数を取り消しポイント とすること"
8444 "も認められている。 特に、停止 (block) する可能性がある非標準の関数を取り消し"
8445 "ポイントと する実装はあり得ることだろう (ファイルを扱う可能性のあるほとんどの"
8449 #: build/C/man7/pthreads.7:653
8451 msgid "Compiling on Linux"
8452 msgstr "Linux でのコンパイル"
8455 #: build/C/man7/pthreads.7:656
8457 "On Linux, programs that use the Pthreads API should be compiled using I<cc -"
8460 "Linux では、Pthreads API を用いたプログラムは I<cc -pthread> でコンパイルすべ"
8464 #: build/C/man7/pthreads.7:656
8466 msgid "Linux Implementations of POSIX Threads"
8467 msgstr "POSIX スレッドの Linux での実装"
8470 #: build/C/man7/pthreads.7:659
8472 "Over time, two threading implementations have been provided by the GNU C "
8475 "これまで、2つのスレッドの実装が Linux の GNU C ライブラリにより 提供されてき"
8479 #: build/C/man7/pthreads.7:659
8481 msgid "B<LinuxThreads>"
8482 msgstr "B<LinuxThreads>"
8485 #: build/C/man7/pthreads.7:663
8487 "This is the original Pthreads implementation. Since glibc 2.4, this "
8488 "implementation is no longer supported."
8490 "最初の Pthreads の実装。 glibc 2.4 以降は、この実装はもはやサポートされていな"
8494 #: build/C/man7/pthreads.7:663
8496 msgid "B<NPTL> (Native POSIX Threads Library)"
8497 msgstr "B<NPTL> (Native POSIX Threads Library)"
8500 #: build/C/man7/pthreads.7:671
8502 "This is the modern Pthreads implementation. By comparison with "
8503 "LinuxThreads, NPTL provides closer conformance to the requirements of the "
8504 "POSIX.1 specification and better performance when creating large numbers of "
8505 "threads. NPTL is available since glibc 2.3.2, and requires features that "
8506 "are present in the Linux 2.6 kernel."
8508 "新しい Pthreads の実装。LinuxThreads と比べると、 NPTL は POSIX.1 の要求仕様"
8509 "への準拠の度合いが高く、 多数のスレッドを作成した際の性能も高い。 NPTL は "
8510 "glibc 2.3.2 以降で利用可能である。 NPTL を利用するには Linux 2.6 カーネルに実"
8514 #: build/C/man7/pthreads.7:681
8516 "Both of these are so-called 1:1 implementations, meaning that each thread "
8517 "maps to a kernel scheduling entity. Both threading implementations employ "
8518 "the Linux B<clone>(2) system call. In NPTL, thread synchronization "
8519 "primitives (mutexes, thread joining, etc.) are implemented using the Linux "
8520 "B<futex>(2) system call."
8522 "どちらの実装もいわゆる 1:1 実装、すなわち個々のスレッドが カーネルのスケ"
8523 "ジューリング実体にマッピングされる。 どちらのスレッドの実装も Linux の "
8524 "B<clone>(2) システムコールを利用している。 NPTL では、スレッド同期の基本機"
8525 "構 (mutex や スレッドの join 等) は Linux の B<futex>(2) システムコールを"
8529 #: build/C/man7/pthreads.7:681
8531 msgid "LinuxThreads"
8532 msgstr "LinuxThreads"
8535 #: build/C/man7/pthreads.7:683
8536 msgid "The notable features of this implementation are the following:"
8537 msgstr "この実装の大きな特徴は以下の通りである:"
8540 #: build/C/man7/pthreads.7:690
8542 "In addition to the main (initial) thread, and the threads that the program "
8543 "creates using B<pthread_create>(3), the implementation creates a \"manager\" "
8544 "thread. This thread handles thread creation and termination. (Problems can "
8545 "result if this thread is inadvertently killed.)"
8547 "メインスレッド (最初のスレッド) とプログラムが B<pthread_create>(3) を使って"
8548 "作成したスレッドに加え、 この実装では「管理 (manager)」スレッドが作成され"
8549 "る。 管理スレッドはスレッドの作成と終了を取り扱う (このスレッドがうっかり "
8550 "kill されると、問題が起こることがある)。"
8553 #: build/C/man7/pthreads.7:702
8555 "Signals are used internally by the implementation. On Linux 2.2 and later, "
8556 "the first three real-time signals are used (see also B<signal>(7)). On "
8557 "older Linux kernels, B<SIGUSR1> and B<SIGUSR2> are used. Applications must "
8558 "avoid the use of whichever set of signals is employed by the implementation."
8560 "この実装では内部でシグナルを使用している。 Linux 2.2 以降では、リアルタイムシ"
8561 "グナルのうち最初の 3つが使われる (B<signal>(7) 参照)。 それ以前のカーネルで"
8562 "は B<SIGUSR1> と B<SIGUSR2> が使われる。 アプリケーションは、スレッド実装で利"
8563 "用されているシグナルを どれも使わないようにしなければならない。"
8566 #: build/C/man7/pthreads.7:709
8568 "Threads do not share process IDs. (In effect, LinuxThreads threads are "
8569 "implemented as processes which share more information than usual, but which "
8570 "do not share a common process ID.) LinuxThreads threads (including the "
8571 "manager thread) are visible as separate processes using B<ps>(1)."
8573 "スレッド間でプロセス ID を共有しない (実際には LinuxThreads のスレッドは通常"
8574 "よりは情報を共有するプロセスとして 実装されているが、一つの共通のプロセス ID "
8575 "を共有してはいない)。 (管理スレッドを含む) LinuxThreads スレッドは B<ps>(1) "
8576 "を使うと別のプロセスのように見える。"
8579 #: build/C/man7/pthreads.7:712
8581 "The LinuxThreads implementation deviates from the POSIX.1 specification in a "
8582 "number of ways, including the following:"
8584 "LinuxThreads の実装では POSIX.1 仕様から逸脱している点が いくつかある。以下に"
8588 #: build/C/man7/pthreads.7:716
8589 msgid "Calls to B<getpid>(2) return a different value in each thread."
8590 msgstr "B<getpid>(2) を呼び出したときに、スレッド毎に異なる値が返される。"
8593 #: build/C/man7/pthreads.7:725
8595 "Calls to B<getppid>(2) in threads other than the main thread return the "
8596 "process ID of the manager thread; instead B<getppid>(2) in these threads "
8597 "should return the same value as B<getppid>(2) in the main thread."
8599 "メインスレッド以外のスレッドで B<getppid>(2) を呼び出すと、管理スレッドのプ"
8600 "ロセス ID が返される。 本当は、これらのスレッドで B<getppid>(2) を呼んだ場合"
8601 "にはメインスレッドでの B<getppid>(2) と同じ値が返るべきである。"
8604 #: build/C/man7/pthreads.7:735
8606 "When one thread creates a new child process using B<fork>(2), any thread "
8607 "should be able to B<wait>(2) on the child. However, the implementation "
8608 "only allows the thread that created the child to B<wait>(2) on it."
8610 "あるスレッドが B<fork>(2) を使って新しい子プロセスを作成した場合、 どのス"
8611 "レッドでもこの子プロセスを B<wait>(2) できるべきである。しかしながら、この実"
8612 "装では子プロセスを作成した スレッドだけがこの子プロセスを B<wait>(2) でき"
8616 #: build/C/man7/pthreads.7:742
8618 "When a thread calls B<execve>(2), all other threads are terminated (as "
8619 "required by POSIX.1). However, the resulting process has the same PID as "
8620 "the thread that called B<execve>(2): it should have the same PID as the main "
8623 "あるスレッドが B<execve>(2) を呼び出した場合、他のスレッドは全て終了される "
8624 "(POSIX.1 の仕様通り)。 しかしながら、新しいプロセスは B<execve>(2) を呼んだ"
8625 "スレッドと同じ PID を持つ。正しくは メインスレッドと同じ PID を持つべきであ"
8629 #: build/C/man7/pthreads.7:749
8631 "Threads do not share user and group IDs. This can cause complications with "
8632 "set-user-ID programs and can cause failures in Pthreads functions if an "
8633 "application changes its credentials using B<seteuid>(2) or similar."
8635 "スレッド間でユーザ ID とグループ ID が共有されない このことは、set-user-ID プ"
8636 "ログラムで面倒な事態を招いたり、 アプリケーションが B<seteuid>(2) などを使っ"
8637 "て信用情報 (credentials) を変更した場合に Pthreads 関数が失敗する原因となる。"
8640 #: build/C/man7/pthreads.7:751
8641 msgid "Threads do not share a common session ID and process group ID."
8642 msgstr "スレッド間で共通のセッション ID やプロセスグループ ID を共有しない。"
8645 #: build/C/man7/pthreads.7:754
8646 msgid "Threads do not share record locks created using B<fcntl>(2)."
8648 "スレッド間で B<fcntl>(2) を使って作成されるレコード・ロックを共有しない。"
8651 #: build/C/man7/pthreads.7:760
8653 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
8654 "rather than process-wide."
8656 "B<times>(2) と B<getrusage>(2) が返す情報がプロセス全体の情報でなくスレッド"
8660 #: build/C/man7/pthreads.7:763
8661 msgid "Threads do not share semaphore undo values (see B<semop>(2))."
8662 msgstr "スレッド間でセマフォのアンドゥ値 (B<semop>(2) 参照) を共有しない。"
8665 #: build/C/man7/pthreads.7:765
8666 msgid "Threads do not share interval timers."
8667 msgstr "スレッド間でインターバル・タイマを共有しない。"
8669 #. FIXME . bug report filed for NPTL nice nonconformance
8670 #. http://bugzilla.kernel.org/show_bug.cgi?id=6258
8671 #. Sep 08: there is a patch by Denys Vlasenko to address this
8672 #. "make setpriority POSIX compliant; introduce PRIO_THREAD extension"
8673 #. Monitor this to see if it makes it into mainline.
8675 #: build/C/man7/pthreads.7:767 build/C/man7/pthreads.7:804
8676 msgid "Threads do not share a common nice value."
8677 msgstr "スレッドは共通の nice 値を共有しない。"
8680 #: build/C/man7/pthreads.7:777
8682 "POSIX.1 distinguishes the notions of signals that are directed to the "
8683 "process as a whole and signals that are directed to individual threads. "
8684 "According to POSIX.1, a process-directed signal (sent using B<kill>(2), for "
8685 "example) should be handled by a single, arbitrarily selected thread within "
8686 "the process. LinuxThreads does not support the notion of process-directed "
8687 "signals: signals may only be sent to specific threads."
8689 "POSXI.1 では、全体としてのプロセスに送られるシグナルと、 個別のスレッドに送ら"
8690 "れるシグナルを区別して考えている。 POSIX.1 によると、プロセスに送られたシグナ"
8691 "ル (例えば B<kill>(2) を使って送る) は、そのプロセスに属すスレッドのうち 勝"
8692 "手に (arbitrarily) に選択された一つのスレッドにより処理される ことになってい"
8693 "る。LinuxThreads はプロセスに送られるシグナルの 概念に対応しておらず、シグナ"
8694 "ルは特定のスレッドにだけ送ることができる。"
8697 #: build/C/man7/pthreads.7:786
8699 "Threads have distinct alternate signal stack settings. However, a new "
8700 "thread's alternate signal stack settings are copied from the thread that "
8701 "created it, so that the threads initially share an alternate signal stack. "
8702 "(A new thread should start with no alternate signal stack defined. If two "
8703 "threads handle signals on their shared alternate signal stack at the same "
8704 "time, unpredictable program failures are likely to occur.)"
8706 "スレッドはそれぞれの独自の代替シグナルスタックの設定を持つ。 しかし、新しいス"
8707 "レッドの代替シグナルスタックの設定は そのスレッドを作成したスレッドからコピー"
8708 "され、そのため スレッドは最初は一つの代替シグナルスタックを共有する。 (仕様で"
8709 "は、新しいスレッドは代替シグナルスタックが定義されていない状態 で開始されるべ"
8710 "きとされている。 2つのスレッドが共有されている代替シグナルスタック上で同時に "
8711 "シグナルの処理を行った場合、予測不可能なプログラムのエラーが 起こり得る。)"
8714 #: build/C/man7/pthreads.7:786
8720 #: build/C/man7/pthreads.7:795
8722 "With NPTL, all of the threads in a process are placed in the same thread "
8723 "group; all members of a thread group share the same PID. NPTL does not "
8724 "employ a manager thread. NPTL makes internal use of the first two real-time "
8725 "signals (see also B<signal>(7)); these signals cannot be used in "
8728 "NPTL では、一つのプロセスの全てのスレッドは同じスレッド・グループ に属する; "
8729 "スレッド・グループの全メンバーは同じ PID を共有する。 NPTL は管理スレッド "
8730 "(manager thread) を利用しない。 NPTL は内部でリアルタイムシグナルのうち最初"
8731 "の 2つの番号を使用しており (B<signal>(7) 参照)、これらのシグナルはアプリケー"
8735 #: build/C/man7/pthreads.7:797
8736 msgid "NPTL still has at least one nonconformance with POSIX.1:"
8737 msgstr "NPTL にも POSIX.1 に準拠していない点が少なくとも一つある:"
8740 #: build/C/man7/pthreads.7:806
8741 msgid "Some NPTL nonconformances only occur with older kernels:"
8742 msgstr "NPTL の標準非準拠な点のうちいくつかは以前のカーネルでのみ発生する:"
8745 #: build/C/man7/pthreads.7:812
8747 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
8748 "rather than process-wide (fixed in kernel 2.6.9)."
8750 "B<times>(2) と B<getrusage>(2) が返す情報がプロセス全体の情報でなくスレッド"
8751 "単位の情報である (カーネル 2.6.9 で修正された)。"
8754 #: build/C/man7/pthreads.7:814
8755 msgid "Threads do not share resource limits (fixed in kernel 2.6.10)."
8756 msgstr "スレッド間でリソース制限を共有しない (カーネル 2.6.10 で修正された)。"
8759 #: build/C/man7/pthreads.7:816
8760 msgid "Threads do not share interval timers (fixed in kernel 2.6.12)."
8762 "スレッド間でインターバル・タイマを共有しない (カーネル 2.6.12 で修正された)。"
8765 #: build/C/man7/pthreads.7:820
8767 "Only the main thread is permitted to start a new session using B<setsid>(2) "
8768 "(fixed in kernel 2.6.16)."
8770 "メインスレッドだけが B<setsid>(2) を使って新しいセッションを開始することがで"
8771 "きる (カーネル 2.6.16 で修正された)。"
8774 #: build/C/man7/pthreads.7:825
8776 "Only the main thread is permitted to make the process into a process group "
8777 "leader using B<setpgid>(2) (fixed in kernel 2.6.16)."
8779 "メインスレッドだけが B<setpgid>(2) を使ってそのプロセスをプロセス・グルー"
8780 "プ・リーダーにすることができる (カーネル 2.6.16 で修正された)。"
8783 #: build/C/man7/pthreads.7:831
8785 "Threads have distinct alternate signal stack settings. However, a new "
8786 "thread's alternate signal stack settings are copied from the thread that "
8787 "created it, so that the threads initially share an alternate signal stack "
8788 "(fixed in kernel 2.6.16)."
8790 "スレッドはそれぞれの独自の代替シグナルスタックの設定を持つ。 しかし、新しいス"
8791 "レッドの代替シグナルスタックの設定は そのスレッドを作成したスレッドからコピー"
8792 "され、そのため スレッドは最初は一つの代替シグナルスタックを共有する (カーネ"
8796 #: build/C/man7/pthreads.7:833
8797 msgid "Note the following further points about the NPTL implementation:"
8798 msgstr "NPTL の実装では以下の点についても注意すること:"
8801 #: build/C/man7/pthreads.7:847
8803 "If the stack size soft resource limit (see the description of "
8804 "B<RLIMIT_STACK> in B<setrlimit>(2)) is set to a value other than "
8805 "I<unlimited>, then this value defines the default stack size for new "
8806 "threads. To be effective, this limit must be set before the program is "
8807 "executed, perhaps using the I<ulimit -s> shell built-in command (I<limit "
8808 "stacksize> in the C shell)."
8810 "スタックサイズのリソースのソフト・リミット (B<setrlimit>(2) の "
8811 "B<RLIMIT_STACK> の説明を参照) が I<unlimited> 以外の値に設定されている場合、"
8812 "ソフト・リミットの値が 新しいスレッドのデフォルトのスタックサイズとなる。 設"
8813 "定を有効にするためには、プログラムを実行する前にリミット値を 設定しておかなけ"
8814 "ればならない。たいていは、シェルの組み込みコマンドの I<ulimit -s> (C シェルで"
8815 "は I<limit stacksize>) を使って設定する。"
8818 #: build/C/man7/pthreads.7:847
8820 msgid "Determining the Threading Implementation"
8824 #: build/C/man7/pthreads.7:852
8826 "Since glibc 2.3.2, the B<getconf>(1) command can be used to determine the "
8827 "system's threading implementation, for example:"
8829 "glibc 2.3.2 以降では、 B<getconf>(1) コマンドを使って、 システムのスレッド実"
8830 "装を判定することができる。 以下に例を示す:"
8833 #: build/C/man7/pthreads.7:857
8836 "bash$ getconf GNU_LIBPTHREAD_VERSION\n"
8839 "bash$ getconf GNU_LIBPTHREAD_VERSION\n"
8843 #: build/C/man7/pthreads.7:862
8845 "With older glibc versions, a command such as the following should be "
8846 "sufficient to determine the default threading implementation:"
8848 "ぞれ以前の glibc のバージョンでは、以下のようなコマンドで デフォルトのスレッ"
8852 #: build/C/man7/pthreads.7:868
8855 "bash$ $( ldd /bin/ls | grep libc.so | awk \\(aq{print $3}\\(aq ) | \\e\n"
8856 " egrep -i \\(aqthreads|nptl\\(aq\n"
8857 " Native POSIX Threads Library by Ulrich Drepper et al\n"
8859 "bash$ $( ldd /bin/ls | grep libc.so | awk \\(aq{print $3}\\(aq ) | \\e\n"
8860 " egrep -i \\(aqthreads|ntpl\\(aq\n"
8861 " Native POSIX Threads Library by Ulrich Drepper et al\n"
8864 #: build/C/man7/pthreads.7:870
8866 msgid "Selecting the Threading Implementation: LD_ASSUME_KERNEL"
8867 msgstr "スレッドの実装の選択: LD_ASSUME_KERNEL"
8870 #: build/C/man7/pthreads.7:885
8872 "On systems with a glibc that supports both LinuxThreads and NPTL (i.e., "
8873 "glibc 2.3.I<x>), the B<LD_ASSUME_KERNEL> environment variable can be used to "
8874 "override the dynamic linker's default choice of threading implementation. "
8875 "This variable tells the dynamic linker to assume that it is running on top "
8876 "of a particular kernel version. By specifying a kernel version that does "
8877 "not provide the support required by NPTL, we can force the use of "
8878 "LinuxThreads. (The most likely reason for doing this is to run a (broken) "
8879 "application that depends on some nonconformant behavior in LinuxThreads.) "
8882 "LinuxThreads と NPTL の両方をサポートしている glibc (glibc 2.3.I<x>) があるシ"
8883 "ステムでは、 B<LD_ASSUME_KERNEL> 環境変数を使うことで、動的リンカがデフォルト"
8884 "で 選択するスレッド実装を上書きすることができる。 この変数により、動的リンカ"
8885 "が特定のバージョンのカーネル上で 動作していると仮定するように指定する。 NPTL "
8886 "が必要とするサポート機能を提供していないカーネルバージョンを 指定することで、"
8887 "強制的に LinuxThreads を使うことができる (このようなことをする最もありそうな"
8888 "場面は、 LinuxThreads の標準非準拠な振舞いに依存する (壊れた) アプリケーショ"
8889 "ン を動作させる場合だろう)。 以下に例を示す:"
8892 #: build/C/man7/pthreads.7:891
8895 "bash$ $( LD_ASSUME_KERNEL=2.2.5 ldd /bin/ls | grep libc.so | \\e\n"
8896 " awk \\(aq{print $3}\\(aq ) | egrep -i \\(aqthreads|ntpl\\(aq\n"
8897 " linuxthreads-0.10 by Xavier Leroy\n"
8899 "bash$ $( LD_ASSUME_KERNEL=2.2.5 ldd /bin/ls | grep libc.so | \\e\n"
8900 " awk \\(aq{print $3}\\(aq ) | egrep -i \\(aqthreads|ntpl\\(aq\n"
8901 " linuxthreads-0.10 by Xavier Leroy\n"
8904 #: build/C/man7/pthreads.7:903
8906 "B<clone>(2), B<futex>(2), B<gettid>(2), B<proc>(5), B<futex>(7), B<sigevent>"
8907 "(7), B<signal>(7),"
8909 "B<clone>(2), B<futex>(2), B<gettid>(2), B<futex>(7), B<sigevent>(7), "
8913 #: build/C/man7/pthreads.7:927
8916 #| "and various Pthreads manual pages, for example: B<pthread_attr_init>(3), "
8917 #| "B<pthread_atfork>(3), B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
8918 #| "B<pthread_cond_signal>(3), B<pthread_cond_wait>(3), B<pthread_create>(3), "
8919 #| "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
8920 #| "B<pthread_key_create>(3), B<pthread_kill>(3), B<pthread_mutex_lock>(3), "
8921 #| "B<pthread_mutex_unlock>(3), B<pthread_once>(3), B<pthread_setcancelstate>"
8922 #| "(3), B<pthread_setcanceltype>(3), B<pthread_setspecific>(3), "
8923 #| "B<pthread_sigmask>(3), and B<pthread_testcancel>(3)"
8925 "and various Pthreads manual pages, for example: B<pthread_attr_init>(3), "
8926 "B<pthread_atfork>(3), B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
8927 "B<pthread_cond_signal>(3), B<pthread_cond_wait>(3), B<pthread_create>(3), "
8928 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
8929 "B<pthread_key_create>(3), B<pthread_kill>(3), B<pthread_mutex_lock>(3), "
8930 "B<pthread_mutex_unlock>(3), B<pthread_once>(3), B<pthread_setcancelstate>"
8931 "(3), B<pthread_setcanceltype>(3), B<pthread_setspecific>(3), "
8932 "B<pthread_sigmask>(3), B<pthread_sigqueue>(3), and B<pthread_testcancel>(3)"
8934 "および Pthreads の各種マニュアルページ、例えば: B<pthread_attr_init>(3), "
8935 "B<pthread_atfork>(3), B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
8936 "B<pthread_cond_signal>(3), B<pthread_cond_wait>(3), B<pthread_create>(3), "
8937 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
8938 "B<pthread_key_create>(3), B<pthread_kill>(3), B<pthread_mutex_lock>(3), "
8939 "B<pthread_mutex_unlock>(3), B<pthread_once>(3), B<pthread_setcancelstate>"
8940 "(3), B<pthread_setcanceltype>(3), B<pthread_setspecific>(3), "
8941 "B<pthread_sigmask>(3), B<pthread_testcancel>(3)"
8943 #~ msgid "2008-11-18"
8944 #~ msgstr "2008-11-18"