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.
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2013-03-26 16:48+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=CHARSET\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: build/C/man3/getcontext.3:25
26 #: build/C/man3/getcontext.3:25
32 #: build/C/man3/getcontext.3:25 build/C/man3/pthread_attr_init.3:26 build/C/man3/pthread_attr_setaffinity_np.3:26 build/C/man3/pthread_attr_setdetachstate.3:26 build/C/man3/pthread_attr_setguardsize.3:26 build/C/man3/pthread_attr_setinheritsched.3:26 build/C/man3/pthread_attr_setschedparam.3:26 build/C/man3/pthread_attr_setschedpolicy.3:26 build/C/man3/pthread_attr_setscope.3:26 build/C/man3/pthread_attr_setstack.3:26 build/C/man3/pthread_attr_setstackaddr.3:26 build/C/man3/pthread_attr_setstacksize.3:26 build/C/man3/pthread_cancel.3:26 build/C/man3/pthread_cleanup_push.3:26 build/C/man3/pthread_cleanup_push_defer_np.3:26 build/C/man3/pthread_create.3:26 build/C/man3/pthread_detach.3:26 build/C/man3/pthread_equal.3:26 build/C/man3/pthread_exit.3:26 build/C/man3/pthread_getattr_np.3:26 build/C/man3/pthread_getcpuclockid.3:26 build/C/man3/pthread_join.3:26 build/C/man3/pthread_kill.3:26 build/C/man3/pthread_kill_other_threads_np.3:26 build/C/man3/pthread_self.3:26 build/C/man3/pthread_setaffinity_np.3:26 build/C/man3/pthread_setcancelstate.3:26 build/C/man3/pthread_setconcurrency.3:25 build/C/man3/pthread_setname_np.3:26 build/C/man3/pthread_setschedparam.3:26 build/C/man3/pthread_setschedprio.3:26 build/C/man3/pthread_sigmask.3:26 build/C/man3/pthread_sigqueue.3:25 build/C/man3/pthread_testcancel.3:26 build/C/man3/pthread_tryjoin_np.3:26 build/C/man3/pthread_yield.3:25 build/C/man7/pthreads.7:26
38 #: build/C/man3/getcontext.3:25 build/C/man3/makecontext.3:28 build/C/man3/pthread_attr_init.3:26 build/C/man3/pthread_attr_setaffinity_np.3:26 build/C/man3/pthread_attr_setdetachstate.3:26 build/C/man3/pthread_attr_setguardsize.3:26 build/C/man3/pthread_attr_setinheritsched.3:26 build/C/man3/pthread_attr_setschedparam.3:26 build/C/man3/pthread_attr_setschedpolicy.3:26 build/C/man3/pthread_attr_setscope.3:26 build/C/man3/pthread_attr_setstack.3:26 build/C/man3/pthread_attr_setstackaddr.3:26 build/C/man3/pthread_attr_setstacksize.3:26 build/C/man3/pthread_cancel.3:26 build/C/man3/pthread_cleanup_push.3:26 build/C/man3/pthread_cleanup_push_defer_np.3:26 build/C/man3/pthread_create.3:26 build/C/man3/pthread_detach.3:26 build/C/man3/pthread_equal.3:26 build/C/man3/pthread_exit.3:26 build/C/man3/pthread_getattr_np.3:26 build/C/man3/pthread_getcpuclockid.3:26 build/C/man3/pthread_join.3:26 build/C/man3/pthread_kill.3:26 build/C/man3/pthread_kill_other_threads_np.3:26 build/C/man3/pthread_self.3:26 build/C/man3/pthread_setaffinity_np.3:26 build/C/man3/pthread_setcancelstate.3:26 build/C/man3/pthread_setconcurrency.3:25 build/C/man3/pthread_setname_np.3:26 build/C/man3/pthread_setschedparam.3:26 build/C/man3/pthread_setschedprio.3:26 build/C/man3/pthread_sigmask.3:26 build/C/man3/pthread_sigqueue.3:25 build/C/man3/pthread_testcancel.3:26 build/C/man3/pthread_tryjoin_np.3:26 build/C/man3/pthread_yield.3:25 build/C/man7/pthreads.7:26
40 msgid "Linux Programmer's Manual"
44 #: build/C/man3/getcontext.3:26 build/C/man3/makecontext.3:29 build/C/man3/pthread_attr_init.3:27 build/C/man3/pthread_attr_setaffinity_np.3:27 build/C/man3/pthread_attr_setdetachstate.3:27 build/C/man3/pthread_attr_setguardsize.3:27 build/C/man3/pthread_attr_setinheritsched.3:27 build/C/man3/pthread_attr_setschedparam.3:27 build/C/man3/pthread_attr_setschedpolicy.3:27 build/C/man3/pthread_attr_setscope.3:27 build/C/man3/pthread_attr_setstack.3:27 build/C/man3/pthread_attr_setstackaddr.3:27 build/C/man3/pthread_attr_setstacksize.3:27 build/C/man3/pthread_cancel.3:27 build/C/man3/pthread_cleanup_push.3:27 build/C/man3/pthread_cleanup_push_defer_np.3:27 build/C/man3/pthread_create.3:27 build/C/man3/pthread_detach.3:27 build/C/man3/pthread_equal.3:27 build/C/man3/pthread_exit.3:27 build/C/man3/pthread_getattr_np.3:27 build/C/man3/pthread_getcpuclockid.3:27 build/C/man3/pthread_join.3:27 build/C/man3/pthread_kill.3:27 build/C/man3/pthread_kill_other_threads_np.3:27 build/C/man3/pthread_self.3:27 build/C/man3/pthread_setaffinity_np.3:27 build/C/man3/pthread_setcancelstate.3:27 build/C/man3/pthread_setconcurrency.3:26 build/C/man3/pthread_setname_np.3:27 build/C/man3/pthread_setschedparam.3:27 build/C/man3/pthread_setschedprio.3:27 build/C/man3/pthread_sigmask.3:27 build/C/man3/pthread_sigqueue.3:26 build/C/man3/pthread_testcancel.3:27 build/C/man3/pthread_tryjoin_np.3:27 build/C/man3/pthread_yield.3:26 build/C/man7/pthreads.7:27
50 #: build/C/man3/getcontext.3:28
51 msgid "getcontext, setcontext - get or set the user context"
55 #: build/C/man3/getcontext.3:28 build/C/man3/makecontext.3:31 build/C/man3/pthread_attr_init.3:30 build/C/man3/pthread_attr_setaffinity_np.3:30 build/C/man3/pthread_attr_setdetachstate.3:30 build/C/man3/pthread_attr_setguardsize.3:30 build/C/man3/pthread_attr_setinheritsched.3:30 build/C/man3/pthread_attr_setschedparam.3:30 build/C/man3/pthread_attr_setschedpolicy.3:30 build/C/man3/pthread_attr_setscope.3:30 build/C/man3/pthread_attr_setstack.3:30 build/C/man3/pthread_attr_setstackaddr.3:30 build/C/man3/pthread_attr_setstacksize.3:30 build/C/man3/pthread_cancel.3:29 build/C/man3/pthread_cleanup_push.3:30 build/C/man3/pthread_cleanup_push_defer_np.3:30 build/C/man3/pthread_create.3:29 build/C/man3/pthread_detach.3:29 build/C/man3/pthread_equal.3:29 build/C/man3/pthread_exit.3:29 build/C/man3/pthread_getattr_np.3:29 build/C/man3/pthread_getcpuclockid.3:29 build/C/man3/pthread_join.3:29 build/C/man3/pthread_kill.3:29 build/C/man3/pthread_kill_other_threads_np.3:29 build/C/man3/pthread_self.3:29 build/C/man3/pthread_setaffinity_np.3:30 build/C/man3/pthread_setcancelstate.3:30 build/C/man3/pthread_setconcurrency.3:29 build/C/man3/pthread_setname_np.3:29 build/C/man3/pthread_setschedparam.3:30 build/C/man3/pthread_setschedprio.3:29 build/C/man3/pthread_sigmask.3:29 build/C/man3/pthread_sigqueue.3:28 build/C/man3/pthread_testcancel.3:29 build/C/man3/pthread_tryjoin_np.3:30 build/C/man3/pthread_yield.3:28
61 #: build/C/man3/getcontext.3:30 build/C/man3/makecontext.3:33
62 msgid "B<#include E<lt>ucontext.hE<gt>>"
66 #: build/C/man3/getcontext.3:32
67 msgid "B<int getcontext(ucontext_t *>I<ucp>B<);>"
71 #: build/C/man3/getcontext.3:34
72 msgid "B<int setcontext(const ucontext_t *>I<ucp>B<);>"
76 #: build/C/man3/getcontext.3:34 build/C/man3/makecontext.3:38 build/C/man3/pthread_attr_init.3:39 build/C/man3/pthread_attr_setaffinity_np.3:42 build/C/man3/pthread_attr_setdetachstate.3:41 build/C/man3/pthread_attr_setguardsize.3:41 build/C/man3/pthread_attr_setinheritsched.3:41 build/C/man3/pthread_attr_setschedparam.3:41 build/C/man3/pthread_attr_setschedpolicy.3:41 build/C/man3/pthread_attr_setscope.3:41 build/C/man3/pthread_attr_setstack.3:54 build/C/man3/pthread_attr_setstackaddr.3:41 build/C/man3/pthread_attr_setstacksize.3:41 build/C/man3/pthread_cancel.3:37 build/C/man3/pthread_cleanup_push.3:40 build/C/man3/pthread_cleanup_push_defer_np.3:40 build/C/man3/pthread_create.3:38 build/C/man3/pthread_detach.3:37 build/C/man3/pthread_equal.3:37 build/C/man3/pthread_exit.3:37 build/C/man3/pthread_getattr_np.3:38 build/C/man3/pthread_getcpuclockid.3:38 build/C/man3/pthread_join.3:37 build/C/man3/pthread_kill.3:37 build/C/man3/pthread_kill_other_threads_np.3:35 build/C/man3/pthread_self.3:37 build/C/man3/pthread_setaffinity_np.3:42 build/C/man3/pthread_setcancelstate.3:39 build/C/man3/pthread_setconcurrency.3:38 build/C/man3/pthread_setname_np.3:39 build/C/man3/pthread_setschedparam.3:41 build/C/man3/pthread_setschedprio.3:37 build/C/man3/pthread_sigmask.3:38 build/C/man3/pthread_sigqueue.3:45 build/C/man3/pthread_testcancel.3:37 build/C/man3/pthread_tryjoin_np.3:42 build/C/man3/pthread_yield.3:37 build/C/man7/pthreads.7:29
82 #: build/C/man3/getcontext.3:46
84 "In a System V-like environment, one has the two types I<mcontext_t> and "
85 "I<ucontext_t> defined in I<E<lt>ucontext.hE<gt>> and the four functions "
86 "B<getcontext>(), B<setcontext>(), B<makecontext>(3) and B<swapcontext>(3) "
87 "that allow user-level context switching between multiple threads of control "
92 #: build/C/man3/getcontext.3:50
94 "The I<mcontext_t> type is machine-dependent and opaque. The I<ucontext_t> "
95 "type is a structure that has at least the following fields:"
99 #: build/C/man3/getcontext.3:60
102 "typedef struct ucontext {\n"
103 " struct ucontext *uc_link;\n"
104 " sigset_t uc_sigmask;\n"
105 " stack_t uc_stack;\n"
106 " mcontext_t uc_mcontext;\n"
112 #: build/C/man3/getcontext.3:77
114 "with I<sigset_t> and I<stack_t> defined in I<E<lt>signal.hE<gt>>. Here "
115 "I<uc_link> points to the context that will be resumed when the current "
116 "context terminates (in case the current context was created using "
117 "B<makecontext>(3)), I<uc_sigmask> is the set of signals blocked in this "
118 "context (see B<sigprocmask>(2)), I<uc_stack> is the stack used by this "
119 "context (see B<sigaltstack>(2)), and I<uc_mcontext> is the machine-specific "
120 "representation of the saved context, that includes the calling thread's "
125 #: build/C/man3/getcontext.3:82
127 "The function B<getcontext>() initializes the structure pointed at by I<ucp> "
128 "to the currently active context."
132 #: build/C/man3/getcontext.3:94
134 "The function B<setcontext>() restores the user context pointed at by "
135 "I<ucp>. A successful call does not return. The context should have been "
136 "obtained by a call of B<getcontext>(), or B<makecontext>(3), or passed as "
137 "third argument to a signal handler."
141 #: build/C/man3/getcontext.3:98
143 "If the context was obtained by a call of B<getcontext>(), program execution "
144 "continues as if this call just returned."
148 #: build/C/man3/getcontext.3:109
150 "If the context was obtained by a call of B<makecontext>(3), program "
151 "execution continues by a call to the function I<func> specified as the "
152 "second argument of that call to B<makecontext>(3). When the function "
153 "I<func> returns, we continue with the I<uc_link> member of the structure "
154 "I<ucp> specified as the first argument of that call to B<makecontext>(3). "
155 "When this member is NULL, the thread exits."
159 #: build/C/man3/getcontext.3:116
161 "If the context was obtained by a call to a signal handler, then old standard "
162 "text says that \"program execution continues with the program instruction "
163 "following the instruction interrupted by the signal\". However, this "
164 "sentence was removed in SUSv2, and the present verdict is \"the result is "
169 #: build/C/man3/getcontext.3:116 build/C/man3/makecontext.3:84 build/C/man3/pthread_attr_init.3:68 build/C/man3/pthread_attr_setaffinity_np.3:76 build/C/man3/pthread_attr_setdetachstate.3:77 build/C/man3/pthread_attr_setguardsize.3:90 build/C/man3/pthread_attr_setinheritsched.3:84 build/C/man3/pthread_attr_setschedparam.3:74 build/C/man3/pthread_attr_setschedpolicy.3:72 build/C/man3/pthread_attr_setscope.3:91 build/C/man3/pthread_attr_setstack.3:85 build/C/man3/pthread_attr_setstackaddr.3:74 build/C/man3/pthread_attr_setstacksize.3:61 build/C/man3/pthread_cancel.3:109 build/C/man3/pthread_cleanup_push.3:119 build/C/man3/pthread_create.3:115 build/C/man3/pthread_detach.3:49 build/C/man3/pthread_equal.3:41 build/C/man3/pthread_exit.3:71 build/C/man3/pthread_getattr_np.3:73 build/C/man3/pthread_getcpuclockid.3:46 build/C/man3/pthread_join.3:70 build/C/man3/pthread_kill.3:52 build/C/man3/pthread_self.3:46 build/C/man3/pthread_setaffinity_np.3:77 build/C/man3/pthread_setcancelstate.3:92 build/C/man3/pthread_setconcurrency.3:56 build/C/man3/pthread_setname_np.3:72 build/C/man3/pthread_setschedparam.3:104 build/C/man3/pthread_setschedprio.3:53 build/C/man3/pthread_sigmask.3:49 build/C/man3/pthread_sigqueue.3:65 build/C/man3/pthread_testcancel.3:50 build/C/man3/pthread_tryjoin_np.3:85 build/C/man3/pthread_yield.3:44
175 #: build/C/man3/getcontext.3:124
177 "When successful, B<getcontext>() returns 0 and B<setcontext>() does not "
178 "return. On error, both return -1 and set I<errno> appropriately."
182 #: build/C/man3/getcontext.3:124 build/C/man3/makecontext.3:96 build/C/man3/pthread_attr_init.3:71 build/C/man3/pthread_attr_setaffinity_np.3:79 build/C/man3/pthread_attr_setdetachstate.3:80 build/C/man3/pthread_attr_setguardsize.3:93 build/C/man3/pthread_attr_setinheritsched.3:87 build/C/man3/pthread_attr_setschedparam.3:77 build/C/man3/pthread_attr_setschedpolicy.3:75 build/C/man3/pthread_attr_setscope.3:94 build/C/man3/pthread_attr_setstack.3:88 build/C/man3/pthread_attr_setstackaddr.3:77 build/C/man3/pthread_attr_setstacksize.3:64 build/C/man3/pthread_cancel.3:114 build/C/man3/pthread_cleanup_push.3:121 build/C/man3/pthread_create.3:122 build/C/man3/pthread_detach.3:54 build/C/man3/pthread_equal.3:45 build/C/man3/pthread_exit.3:73 build/C/man3/pthread_getattr_np.3:76 build/C/man3/pthread_getcpuclockid.3:49 build/C/man3/pthread_join.3:75 build/C/man3/pthread_kill.3:57 build/C/man3/pthread_self.3:48 build/C/man3/pthread_setaffinity_np.3:80 build/C/man3/pthread_setcancelstate.3:95 build/C/man3/pthread_setconcurrency.3:68 build/C/man3/pthread_setname_np.3:75 build/C/man3/pthread_setschedparam.3:112 build/C/man3/pthread_setschedprio.3:61 build/C/man3/pthread_sigmask.3:54 build/C/man3/pthread_sigqueue.3:70 build/C/man3/pthread_testcancel.3:54 build/C/man3/pthread_tryjoin_np.3:89 build/C/man3/pthread_yield.3:49
188 #: build/C/man3/getcontext.3:126
189 msgid "None defined."
193 #: build/C/man3/getcontext.3:126 build/C/man3/makecontext.3:105 build/C/man3/pthread_attr_init.3:79 build/C/man3/pthread_attr_setaffinity_np.3:108 build/C/man3/pthread_attr_setdetachstate.3:87 build/C/man3/pthread_attr_setguardsize.3:106 build/C/man3/pthread_attr_setinheritsched.3:101 build/C/man3/pthread_attr_setschedparam.3:89 build/C/man3/pthread_attr_setschedpolicy.3:89 build/C/man3/pthread_attr_setscope.3:107 build/C/man3/pthread_attr_setstack.3:112 build/C/man3/pthread_attr_setstackaddr.3:83 build/C/man3/pthread_attr_setstacksize.3:83 build/C/man3/pthread_cancel.3:122 build/C/man3/pthread_cleanup_push.3:125 build/C/man3/pthread_cleanup_push_defer_np.3:101 build/C/man3/pthread_create.3:146 build/C/man3/pthread_detach.3:64 build/C/man3/pthread_equal.3:47 build/C/man3/pthread_exit.3:75 build/C/man3/pthread_getattr_np.3:98 build/C/man3/pthread_getcpuclockid.3:65 build/C/man3/pthread_join.3:98 build/C/man3/pthread_kill.3:66 build/C/man3/pthread_kill_other_threads_np.3:47 build/C/man3/pthread_self.3:50 build/C/man3/pthread_setaffinity_np.3:121 build/C/man3/pthread_setcancelstate.3:113 build/C/man3/pthread_setconcurrency.3:83 build/C/man3/pthread_setname_np.3:102 build/C/man3/pthread_setschedparam.3:141 build/C/man3/pthread_setschedprio.3:83 build/C/man3/pthread_sigmask.3:57 build/C/man3/pthread_sigqueue.3:93 build/C/man3/pthread_testcancel.3:58 build/C/man3/pthread_tryjoin_np.3:112 build/C/man3/pthread_yield.3:53
195 msgid "CONFORMING TO"
199 #: build/C/man3/getcontext.3:132
201 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specification of "
202 "B<getcontext>(), citing portability issues, and recommending that "
203 "applications be rewritten to use POSIX threads instead."
207 #: build/C/man3/getcontext.3:132 build/C/man3/makecontext.3:113 build/C/man3/pthread_attr_init.3:81 build/C/man3/pthread_attr_setaffinity_np.3:111 build/C/man3/pthread_attr_setdetachstate.3:89 build/C/man3/pthread_attr_setguardsize.3:108 build/C/man3/pthread_attr_setschedparam.3:91 build/C/man3/pthread_attr_setscope.3:109 build/C/man3/pthread_attr_setstack.3:114 build/C/man3/pthread_attr_setstackaddr.3:86 build/C/man3/pthread_attr_setstacksize.3:85 build/C/man3/pthread_cancel.3:124 build/C/man3/pthread_cleanup_push.3:127 build/C/man3/pthread_create.3:148 build/C/man3/pthread_detach.3:66 build/C/man3/pthread_equal.3:49 build/C/man3/pthread_exit.3:77 build/C/man3/pthread_getcpuclockid.3:67 build/C/man3/pthread_join.3:100 build/C/man3/pthread_kill.3:68 build/C/man3/pthread_kill_other_threads_np.3:50 build/C/man3/pthread_self.3:52 build/C/man3/pthread_setaffinity_np.3:124 build/C/man3/pthread_setcancelstate.3:115 build/C/man3/pthread_setconcurrency.3:85 build/C/man3/pthread_setname_np.3:104 build/C/man3/pthread_setschedparam.3:143 build/C/man3/pthread_setschedprio.3:85 build/C/man3/pthread_sigmask.3:59 build/C/man3/pthread_yield.3:59
213 #: build/C/man3/getcontext.3:149
215 "The earliest incarnation of this mechanism was the "
216 "B<setjmp>(3)/B<longjmp>(3) mechanism. Since that does not define the "
217 "handling of the signal context, the next stage was the "
218 "B<sigsetjmp>(3)/B<siglongjmp>(3) pair. The present mechanism gives much "
219 "more control. On the other hand, there is no easy way to detect whether a "
220 "return from B<getcontext>() is from the first call, or via a "
221 "B<setcontext>() call. The user has to invent her own bookkeeping device, "
222 "and a register variable won't do since registers are restored."
226 #: build/C/man3/getcontext.3:160
228 "When a signal occurs, the current user context is saved and a new context is "
229 "created by the kernel for the signal handler. Do not leave the handler "
230 "using B<longjmp>(3): it is undefined what would happen with contexts. Use "
231 "B<siglongjmp>(3) or B<setcontext>() instead."
235 #: build/C/man3/getcontext.3:160 build/C/man3/makecontext.3:220 build/C/man3/pthread_attr_init.3:297 build/C/man3/pthread_attr_setaffinity_np.3:118 build/C/man3/pthread_attr_setdetachstate.3:111 build/C/man3/pthread_attr_setguardsize.3:158 build/C/man3/pthread_attr_setinheritsched.3:122 build/C/man3/pthread_attr_setschedparam.3:98 build/C/man3/pthread_attr_setschedpolicy.3:94 build/C/man3/pthread_attr_setscope.3:120 build/C/man3/pthread_attr_setstack.3:156 build/C/man3/pthread_attr_setstackaddr.3:110 build/C/man3/pthread_attr_setstacksize.3:111 build/C/man3/pthread_cancel.3:223 build/C/man3/pthread_cleanup_push.3:311 build/C/man3/pthread_cleanup_push_defer_np.3:104 build/C/man3/pthread_create.3:369 build/C/man3/pthread_detach.3:97 build/C/man3/pthread_equal.3:56 build/C/man3/pthread_exit.3:105 build/C/man3/pthread_getattr_np.3:345 build/C/man3/pthread_getcpuclockid.3:169 build/C/man3/pthread_join.3:127 build/C/man3/pthread_kill.3:75 build/C/man3/pthread_kill_other_threads_np.3:66 build/C/man3/pthread_self.3:76 build/C/man3/pthread_setaffinity_np.3:206 build/C/man3/pthread_setcancelstate.3:177 build/C/man3/pthread_setconcurrency.3:100 build/C/man3/pthread_setname_np.3:198 build/C/man3/pthread_setschedparam.3:431 build/C/man3/pthread_setschedprio.3:91 build/C/man3/pthread_sigmask.3:135 build/C/man3/pthread_sigqueue.3:95 build/C/man3/pthread_testcancel.3:63 build/C/man3/pthread_tryjoin_np.3:135 build/C/man3/pthread_yield.3:62 build/C/man7/pthreads.7:895
241 #: build/C/man3/getcontext.3:167
243 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<longjmp>(3), "
244 "B<makecontext>(3), B<sigsetjmp>(3)"
248 #: build/C/man3/getcontext.3:167 build/C/man3/makecontext.3:226 build/C/man3/pthread_attr_init.3:313 build/C/man3/pthread_attr_setaffinity_np.3:124 build/C/man3/pthread_attr_setdetachstate.3:117 build/C/man3/pthread_attr_setguardsize.3:166 build/C/man3/pthread_attr_setinheritsched.3:133 build/C/man3/pthread_attr_setschedparam.3:110 build/C/man3/pthread_attr_setschedpolicy.3:105 build/C/man3/pthread_attr_setscope.3:130 build/C/man3/pthread_attr_setstack.3:168 build/C/man3/pthread_attr_setstackaddr.3:116 build/C/man3/pthread_attr_setstacksize.3:118 build/C/man3/pthread_cancel.3:235 build/C/man3/pthread_cleanup_push.3:317 build/C/man3/pthread_cleanup_push_defer_np.3:110 build/C/man3/pthread_create.3:382 build/C/man3/pthread_detach.3:104 build/C/man3/pthread_equal.3:60 build/C/man3/pthread_exit.3:109 build/C/man3/pthread_getattr_np.3:361 build/C/man3/pthread_getcpuclockid.3:177 build/C/man3/pthread_join.3:134 build/C/man3/pthread_kill.3:84 build/C/man3/pthread_kill_other_threads_np.3:72 build/C/man3/pthread_self.3:80 build/C/man3/pthread_setaffinity_np.3:214 build/C/man3/pthread_setcancelstate.3:182 build/C/man3/pthread_setconcurrency.3:103 build/C/man3/pthread_setname_np.3:204 build/C/man3/pthread_setschedparam.3:445 build/C/man3/pthread_setschedprio.3:105 build/C/man3/pthread_sigmask.3:144 build/C/man3/pthread_sigqueue.3:103 build/C/man3/pthread_testcancel.3:68 build/C/man3/pthread_tryjoin_np.3:140 build/C/man3/pthread_yield.3:66 build/C/man7/pthreads.7:929
254 #: build/C/man3/getcontext.3:174 build/C/man3/makecontext.3:233 build/C/man3/pthread_attr_init.3:320 build/C/man3/pthread_attr_setaffinity_np.3:131 build/C/man3/pthread_attr_setdetachstate.3:124 build/C/man3/pthread_attr_setguardsize.3:173 build/C/man3/pthread_attr_setinheritsched.3:140 build/C/man3/pthread_attr_setschedparam.3:117 build/C/man3/pthread_attr_setschedpolicy.3:112 build/C/man3/pthread_attr_setscope.3:137 build/C/man3/pthread_attr_setstack.3:175 build/C/man3/pthread_attr_setstackaddr.3:123 build/C/man3/pthread_attr_setstacksize.3:125 build/C/man3/pthread_cancel.3:242 build/C/man3/pthread_cleanup_push.3:324 build/C/man3/pthread_cleanup_push_defer_np.3:117 build/C/man3/pthread_create.3:389 build/C/man3/pthread_detach.3:111 build/C/man3/pthread_equal.3:67 build/C/man3/pthread_exit.3:116 build/C/man3/pthread_getattr_np.3:368 build/C/man3/pthread_getcpuclockid.3:184 build/C/man3/pthread_join.3:141 build/C/man3/pthread_kill.3:91 build/C/man3/pthread_kill_other_threads_np.3:79 build/C/man3/pthread_self.3:87 build/C/man3/pthread_setaffinity_np.3:221 build/C/man3/pthread_setcancelstate.3:189 build/C/man3/pthread_setconcurrency.3:110 build/C/man3/pthread_setname_np.3:211 build/C/man3/pthread_setschedparam.3:452 build/C/man3/pthread_setschedprio.3:112 build/C/man3/pthread_sigmask.3:151 build/C/man3/pthread_sigqueue.3:110 build/C/man3/pthread_testcancel.3:75 build/C/man3/pthread_tryjoin_np.3:147 build/C/man3/pthread_yield.3:73 build/C/man7/pthreads.7:936
256 "This page is part of release 3.50 of the Linux I<man-pages> project. A "
257 "description of the project, and information about reporting bugs, can be "
258 "found at http://www.kernel.org/doc/man-pages/."
262 #: build/C/man3/makecontext.3:28
268 #: build/C/man3/makecontext.3:28
274 #: build/C/man3/makecontext.3:28
280 #: build/C/man3/makecontext.3:31
281 msgid "makecontext, swapcontext - manipulate user context"
285 #: build/C/man3/makecontext.3:36
287 "B<void makecontext(ucontext_t *>I<ucp>B<, void (*>I<func>B<)(),> B<int "
292 #: build/C/man3/makecontext.3:38
293 msgid "B<int swapcontext(ucontext_t *>I<oucp>B<, ucontext_t *>I<ucp>B<);>"
297 #: build/C/man3/makecontext.3:49
299 "In a System V-like environment, one has the type I<ucontext_t> defined in "
300 "I<E<lt>ucontext.hE<gt>> and the four functions B<getcontext>(3), "
301 "B<setcontext>(3), B<makecontext>() and B<swapcontext>() that allow "
302 "user-level context switching between multiple threads of control within a "
307 #: build/C/man3/makecontext.3:52
308 msgid "For the type and the first two functions, see B<getcontext>(3)."
312 #: build/C/man3/makecontext.3:64
314 "The B<makecontext>() function modifies the context pointed to by I<ucp> "
315 "(which was obtained from a call to B<getcontext>(3)). Before invoking "
316 "B<makecontext>(), the caller must allocate a new stack for this context and "
317 "assign its address to I<ucp-E<gt>uc_stack>, and define a successor context "
318 "and assign its address to I<ucp-E<gt>uc_link>."
322 #: build/C/man3/makecontext.3:78
324 "When this context is later activated (using B<setcontext>(3) or "
325 "B<swapcontext>()) the function I<func> is called, and passed the series of "
326 "integer (I<int>) arguments that follow I<argc>; the caller must specify the "
327 "number of these arguments in I<argc>. When this function returns, the "
328 "successor context is activated. If the successor context pointer is NULL, "
333 #: build/C/man3/makecontext.3:84
335 "The B<swapcontext>() function saves the current context in the structure "
336 "pointed to by I<oucp>, and then activates the context pointed to by I<ucp>."
340 #: build/C/man3/makecontext.3:96
342 "When successful, B<swapcontext>() does not return. (But we may return "
343 "later, in case I<oucp> is activated, in which case it looks like "
344 "B<swapcontext>() returns 0.) On error, B<swapcontext>() returns -1 and "
345 "sets I<errno> appropriately."
349 #: build/C/man3/makecontext.3:97 build/C/man3/pthread_attr_setaffinity_np.3:102 build/C/man3/pthread_getattr_np.3:77
355 #: build/C/man3/makecontext.3:100
356 msgid "Insufficient stack space left."
360 #: build/C/man3/makecontext.3:100 build/C/man3/pthread_attr_setaffinity_np.3:106 build/C/man3/pthread_attr_setguardsize.3:104 build/C/man3/pthread_attr_setstack.3:110 build/C/man3/pthread_attr_setstackaddr.3:81 build/C/man3/pthread_attr_setstacksize.3:81 build/C/man3/pthread_getattr_np.3:96 build/C/man3/pthread_getcpuclockid.3:63 build/C/man3/pthread_setaffinity_np.3:119 build/C/man3/pthread_setconcurrency.3:81 build/C/man3/pthread_setname_np.3:100 build/C/man3/pthread_setschedprio.3:81 build/C/man3/pthread_sigqueue.3:89 build/C/man3/pthread_tryjoin_np.3:110
366 #: build/C/man3/makecontext.3:105
368 "B<makecontext>() and B<swapcontext>() are provided in glibc since version "
373 #: build/C/man3/makecontext.3:113
375 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specifications of "
376 "B<makecontext>() and B<swapcontext>(), citing portability issues, and "
377 "recommending that applications be rewritten to use POSIX threads instead."
381 #: build/C/man3/makecontext.3:121
383 "The interpretation of I<ucp-E<gt>uc_stack> is just as in B<sigaltstack>(2), "
384 "namely, this struct contains the start and length of a memory area to be "
385 "used as the stack, regardless of the direction of growth of the stack. "
386 "Thus, it is not necessary for the user program to worry about this "
391 #: build/C/man3/makecontext.3:137
393 "On architectures where I<int> and pointer types are the same size (e.g., "
394 "x86-32, where both types are 32 bits), you may be able to get away with "
395 "passing pointers as arguments to B<makecontext>() following I<argc>. "
396 "However, doing this is not guaranteed to be portable, is undefined according "
397 "to the standards, and won't work on architectures where pointers are larger "
398 "than I<int>s. Nevertheless, starting with version 2.8, glibc makes some "
399 "changes to B<makecontext>(), to permit this on some 64-bit architectures "
404 #: build/C/man3/makecontext.3:137 build/C/man3/pthread_attr_init.3:87 build/C/man3/pthread_attr_setdetachstate.3:108 build/C/man3/pthread_attr_setguardsize.3:155 build/C/man3/pthread_attr_setinheritsched.3:119 build/C/man3/pthread_attr_setschedparam.3:95 build/C/man3/pthread_attr_setschedpolicy.3:91 build/C/man3/pthread_attr_setstack.3:153 build/C/man3/pthread_attr_setstacksize.3:108 build/C/man3/pthread_cancel.3:132 build/C/man3/pthread_cleanup_push.3:151 build/C/man3/pthread_create.3:202 build/C/man3/pthread_detach.3:93 build/C/man3/pthread_getattr_np.3:101 build/C/man3/pthread_getcpuclockid.3:78 build/C/man3/pthread_join.3:124 build/C/man3/pthread_setaffinity_np.3:154 build/C/man3/pthread_setcancelstate.3:174 build/C/man3/pthread_setname_np.3:112 build/C/man3/pthread_setschedparam.3:149 build/C/man3/pthread_sigmask.3:61 build/C/man3/pthread_testcancel.3:60 build/C/man3/pthread_tryjoin_np.3:115
410 #: build/C/man3/makecontext.3:145
412 "The example program below demonstrates the use of B<getcontext>(3), "
413 "B<makecontext>(), and B<swapcontext>(). Running the program produces the "
418 #: build/C/man3/makecontext.3:157
422 "main: swapcontext(&uctx_main, &uctx_func2)\n"
424 "func2: swapcontext(&uctx_func2, &uctx_func1)\n"
426 "func1: swapcontext(&uctx_func1, &uctx_func2)\n"
433 #: build/C/man3/makecontext.3:159 build/C/man3/pthread_attr_init.3:148 build/C/man3/pthread_cancel.3:148 build/C/man3/pthread_cleanup_push.3:227 build/C/man3/pthread_create.3:241 build/C/man3/pthread_getattr_np.3:179 build/C/man3/pthread_getcpuclockid.3:95 build/C/man3/pthread_setname_np.3:138 build/C/man3/pthread_setschedparam.3:224 build/C/man3/pthread_sigmask.3:79
435 msgid "Program source"
439 #: build/C/man3/makecontext.3:165
442 "#include E<lt>ucontext.hE<gt>\n"
443 "#include E<lt>stdio.hE<gt>\n"
444 "#include E<lt>stdlib.hE<gt>\n"
448 #: build/C/man3/makecontext.3:167
450 msgid "static ucontext_t uctx_main, uctx_func1, uctx_func2;\n"
454 #: build/C/man3/makecontext.3:170
457 "#define handle_error(msg) \\e\n"
458 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
462 #: build/C/man3/makecontext.3:180
468 " printf(\"func1: started\\en\");\n"
469 " printf(\"func1: swapcontext(&uctx_func1, &uctx_func2)\\en\");\n"
470 " if (swapcontext(&uctx_func1, &uctx_func2) == -1)\n"
471 " handle_error(\"swapcontext\");\n"
472 " printf(\"func1: returning\\en\");\n"
477 #: build/C/man3/makecontext.3:190
483 " printf(\"func2: started\\en\");\n"
484 " printf(\"func2: swapcontext(&uctx_func2, &uctx_func1)\\en\");\n"
485 " if (swapcontext(&uctx_func2, &uctx_func1) == -1)\n"
486 " handle_error(\"swapcontext\");\n"
487 " printf(\"func2: returning\\en\");\n"
492 #: build/C/man3/makecontext.3:196
496 "main(int argc, char *argv[])\n"
498 " char func1_stack[16384];\n"
499 " char func2_stack[16384];\n"
503 #: build/C/man3/makecontext.3:203
506 " if (getcontext(&uctx_func1) == -1)\n"
507 " handle_error(\"getcontext\");\n"
508 " uctx_func1.uc_stack.ss_sp = func1_stack;\n"
509 " uctx_func1.uc_stack.ss_size = sizeof(func1_stack);\n"
510 " uctx_func1.uc_link = &uctx_main;\n"
511 " makecontext(&uctx_func1, func1, 0);\n"
515 #: build/C/man3/makecontext.3:211
518 " if (getcontext(&uctx_func2) == -1)\n"
519 " handle_error(\"getcontext\");\n"
520 " uctx_func2.uc_stack.ss_sp = func2_stack;\n"
521 " uctx_func2.uc_stack.ss_size = sizeof(func2_stack);\n"
522 " /* Successor context is f1(), unless argc E<gt> 1 */\n"
523 " uctx_func2.uc_link = (argc E<gt> 1) ? NULL : &uctx_func1;\n"
524 " makecontext(&uctx_func2, func2, 0);\n"
528 #: build/C/man3/makecontext.3:215
531 " printf(\"main: swapcontext(&uctx_main, &uctx_func2)\\en\");\n"
532 " if (swapcontext(&uctx_main, &uctx_func2) == -1)\n"
533 " handle_error(\"swapcontext\");\n"
537 #: build/C/man3/makecontext.3:219
540 " printf(\"main: exiting\\en\");\n"
541 " exit(EXIT_SUCCESS);\n"
546 #: build/C/man3/makecontext.3:226
548 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<getcontext>(3), "
553 #: build/C/man3/pthread_attr_init.3:26
555 msgid "PTHREAD_ATTR_INIT"
559 #: build/C/man3/pthread_attr_init.3:26
565 #: build/C/man3/pthread_attr_init.3:30
567 "pthread_attr_init, pthread_attr_destroy - initialize and destroy thread "
572 #: build/C/man3/pthread_attr_init.3:33 build/C/man3/pthread_attr_setdetachstate.3:33 build/C/man3/pthread_attr_setguardsize.3:33 build/C/man3/pthread_attr_setinheritsched.3:33 build/C/man3/pthread_attr_setschedparam.3:33 build/C/man3/pthread_attr_setschedpolicy.3:33 build/C/man3/pthread_attr_setscope.3:33 build/C/man3/pthread_attr_setstack.3:33 build/C/man3/pthread_attr_setstackaddr.3:33 build/C/man3/pthread_attr_setstacksize.3:33 build/C/man3/pthread_cancel.3:32 build/C/man3/pthread_cleanup_push.3:33 build/C/man3/pthread_cleanup_push_defer_np.3:33 build/C/man3/pthread_create.3:32 build/C/man3/pthread_detach.3:32 build/C/man3/pthread_equal.3:32 build/C/man3/pthread_exit.3:32 build/C/man3/pthread_join.3:32 build/C/man3/pthread_kill_other_threads_np.3:32 build/C/man3/pthread_self.3:32 build/C/man3/pthread_setcancelstate.3:33 build/C/man3/pthread_setconcurrency.3:32 build/C/man3/pthread_setschedparam.3:33 build/C/man3/pthread_setschedprio.3:32 build/C/man3/pthread_sigqueue.3:31 build/C/man3/pthread_testcancel.3:32
574 msgid "B<#include E<lt>pthread.hE<gt>>\n"
578 #: build/C/man3/pthread_attr_init.3:36
581 "B<int pthread_attr_init(pthread_attr_t *>I<attr>B<);>\n"
582 "B<int pthread_attr_destroy(pthread_attr_t *>I<attr>B<);>\n"
586 #: build/C/man3/pthread_attr_init.3:38 build/C/man3/pthread_attr_setaffinity_np.3:41 build/C/man3/pthread_attr_setdetachstate.3:40 build/C/man3/pthread_attr_setguardsize.3:40 build/C/man3/pthread_attr_setinheritsched.3:40 build/C/man3/pthread_attr_setschedparam.3:40 build/C/man3/pthread_attr_setschedpolicy.3:40 build/C/man3/pthread_attr_setscope.3:40 build/C/man3/pthread_attr_setstack.3:40 build/C/man3/pthread_attr_setstackaddr.3:40 build/C/man3/pthread_attr_setstacksize.3:40 build/C/man3/pthread_cancel.3:36 build/C/man3/pthread_cleanup_push.3:39 build/C/man3/pthread_equal.3:36 build/C/man3/pthread_exit.3:36 build/C/man3/pthread_getattr_np.3:37 build/C/man3/pthread_getcpuclockid.3:37 build/C/man3/pthread_self.3:36 build/C/man3/pthread_setaffinity_np.3:41 build/C/man3/pthread_setcancelstate.3:38 build/C/man3/pthread_setconcurrency.3:37 build/C/man3/pthread_setschedparam.3:40 build/C/man3/pthread_setschedprio.3:36 build/C/man3/pthread_testcancel.3:36
588 msgid "Compile and link with I<-pthread>.\n"
592 #: build/C/man3/pthread_attr_init.3:50
594 "The B<pthread_attr_init>() function initializes the thread attributes "
595 "object pointed to by I<attr> with default attribute values. After this "
596 "call, individual attributes of the object can be set using various related "
597 "functions (listed under SEE ALSO), and then the object can be used in one or "
598 "more B<pthread_create>(3) calls that create threads."
602 #: build/C/man3/pthread_attr_init.3:55
604 "Calling B<pthread_attr_init>() on a thread attributes object that has "
605 "already been initialized results in undefined behavior."
609 #: build/C/man3/pthread_attr_init.3:62
611 "When a thread attributes object is no longer required, it should be "
612 "destroyed using the B<pthread_attr_destroy>() function. Destroying a "
613 "thread attributes object has no effect on threads that were created using "
618 #: build/C/man3/pthread_attr_init.3:68
620 "Once a thread attributes object has been destroyed, it can be reinitialized "
621 "using B<pthread_attr_init>(). Any other use of a destroyed thread "
622 "attributes object has undefined results."
626 #: build/C/man3/pthread_attr_init.3:71 build/C/man3/pthread_attr_setaffinity_np.3:79 build/C/man3/pthread_attr_setdetachstate.3:80 build/C/man3/pthread_attr_setguardsize.3:93 build/C/man3/pthread_attr_setinheritsched.3:87 build/C/man3/pthread_attr_setschedparam.3:77 build/C/man3/pthread_attr_setschedpolicy.3:75 build/C/man3/pthread_attr_setscope.3:94 build/C/man3/pthread_attr_setstack.3:88 build/C/man3/pthread_attr_setstackaddr.3:77 build/C/man3/pthread_attr_setstacksize.3:64 build/C/man3/pthread_setaffinity_np.3:80 build/C/man3/pthread_setcancelstate.3:95 build/C/man3/pthread_setname_np.3:75
628 "On success, these functions return 0; on error, they return a nonzero error "
633 #: build/C/man3/pthread_attr_init.3:79
635 "POSIX.1-2001 documents an B<ENOMEM> error for B<pthread_attr_init>(); on "
636 "Linux these functions always succeed (but portable and future-proof "
637 "applications should nevertheless handle a possible error return)."
641 #: build/C/man3/pthread_attr_init.3:81 build/C/man3/pthread_attr_setdetachstate.3:89 build/C/man3/pthread_attr_setguardsize.3:108 build/C/man3/pthread_attr_setinheritsched.3:103 build/C/man3/pthread_attr_setschedparam.3:91 build/C/man3/pthread_attr_setschedpolicy.3:91 build/C/man3/pthread_attr_setscope.3:109 build/C/man3/pthread_attr_setstack.3:114 build/C/man3/pthread_attr_setstacksize.3:85 build/C/man3/pthread_cancel.3:124 build/C/man3/pthread_cleanup_push.3:127 build/C/man3/pthread_create.3:148 build/C/man3/pthread_detach.3:66 build/C/man3/pthread_equal.3:49 build/C/man3/pthread_exit.3:77 build/C/man3/pthread_getcpuclockid.3:67 build/C/man3/pthread_join.3:100 build/C/man3/pthread_kill.3:68 build/C/man3/pthread_self.3:52 build/C/man3/pthread_setcancelstate.3:115 build/C/man3/pthread_setconcurrency.3:85 build/C/man3/pthread_setschedparam.3:143 build/C/man3/pthread_setschedprio.3:85 build/C/man3/pthread_sigmask.3:59 build/C/man3/pthread_testcancel.3:60
642 msgid "POSIX.1-2001."
646 #: build/C/man3/pthread_attr_init.3:87
648 "The I<pthread_attr_t> type should be treated as opaque: any access to the "
649 "object other than via pthreads functions is nonportable and produces "
654 #: build/C/man3/pthread_attr_init.3:96
656 "The program below optionally makes use of B<pthread_attr_init>() and "
657 "various related functions to initialize a thread attributes object that is "
658 "used to create a single thread. Once created, the thread uses the "
659 "B<pthread_getattr_np>(3) function (a nonstandard GNU extension) to retrieve "
660 "the thread's attributes, and then displays those attributes."
664 #: build/C/man3/pthread_attr_init.3:105
666 "If the program is run with no command-line argument, then it passes NULL as "
667 "the I<attr> argument of B<pthread_create>(3), so that the thread is created "
668 "with default attributes. Running the program on Linux/x86-32 with the NPTL "
669 "threading implementation, we see the following:"
672 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
674 #: build/C/man3/pthread_attr_init.3:121
677 "$B< ulimit -s> # No stack imit ==E<gt> default stack size is 2MB\n"
680 "Thread attributes:\n"
681 " Detach state = PTHREAD_CREATE_JOINABLE\n"
682 " Scope = PTHREAD_SCOPE_SYSTEM\n"
683 " Inherit scheduler = PTHREAD_INHERIT_SCHED\n"
684 " Scheduling policy = SCHED_OTHER\n"
685 " Scheduling priority = 0\n"
686 " Guard size = 4096 bytes\n"
687 " Stack address = 0x40196000\n"
688 " Stack size = 0x201000 bytes\n"
692 #: build/C/man3/pthread_attr_init.3:131
694 "When we supply a stack size as a command-line argument, the program "
695 "initializes a thread attributes object, sets various attributes in that "
696 "object, and passes a pointer to the object in the call to "
697 "B<pthread_create>(3). Running the program on Linux/x86-32 with the NPTL "
698 "threading implementation, we see the following:"
701 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
703 #: build/C/man3/pthread_attr_init.3:146
706 "$B< ./a.out 0x3000000>\n"
707 "posix_memalign() allocated at 0x40197000\n"
708 "Thread attributes:\n"
709 " Detach state = PTHREAD_CREATE_DETACHED\n"
710 " Scope = PTHREAD_SCOPE_SYSTEM\n"
711 " Inherit scheduler = PTHREAD_EXPLICIT_SCHED\n"
712 " Scheduling policy = SCHED_OTHER\n"
713 " Scheduling priority = 0\n"
714 " Guard size = 0 bytes\n"
715 " Stack address = 0x40197000\n"
716 " Stack size = 0x3000000 bytes\n"
720 #: build/C/man3/pthread_attr_init.3:157 build/C/man3/pthread_getattr_np.3:188
723 "#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n"
724 "#include E<lt>pthread.hE<gt>\n"
725 "#include E<lt>stdio.hE<gt>\n"
726 "#include E<lt>stdlib.hE<gt>\n"
727 "#include E<lt>unistd.hE<gt>\n"
728 "#include E<lt>errno.hE<gt>\n"
732 #: build/C/man3/pthread_attr_init.3:160 build/C/man3/pthread_cancel.3:159 build/C/man3/pthread_cleanup_push.3:239 build/C/man3/pthread_create.3:254 build/C/man3/pthread_getattr_np.3:191 build/C/man3/pthread_getcpuclockid.3:113 build/C/man3/pthread_setaffinity_np.3:172 build/C/man3/pthread_setschedparam.3:237 build/C/man3/pthread_sigmask.3:93
735 "#define handle_error_en(en, msg) \\e\n"
736 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
740 #: build/C/man3/pthread_attr_init.3:168
744 "display_pthread_attr(pthread_attr_t *attr, char *prefix)\n"
749 " struct sched_param sp;\n"
753 #: build/C/man3/pthread_attr_init.3:176
756 " s = pthread_attr_getdetachstate(attr, &i);\n"
758 " handle_error_en(s, \"pthread_attr_getdetachstate\");\n"
759 " printf(\"%sDetach state = %s\\en\", prefix,\n"
760 " (i == PTHREAD_CREATE_DETACHED) ? \"PTHREAD_CREATE_DETACHED\" :\n"
761 " (i == PTHREAD_CREATE_JOINABLE) ? \"PTHREAD_CREATE_JOINABLE\" :\n"
766 #: build/C/man3/pthread_attr_init.3:184
769 " s = pthread_attr_getscope(attr, &i);\n"
771 " handle_error_en(s, \"pthread_attr_getscope\");\n"
772 " printf(\"%sScope = %s\\en\", prefix,\n"
773 " (i == PTHREAD_SCOPE_SYSTEM) ? \"PTHREAD_SCOPE_SYSTEM\" :\n"
774 " (i == PTHREAD_SCOPE_PROCESS) ? \"PTHREAD_SCOPE_PROCESS\" :\n"
779 #: build/C/man3/pthread_attr_init.3:192
782 " s = pthread_attr_getinheritsched(attr, &i);\n"
784 " handle_error_en(s, \"pthread_attr_getinheritsched\");\n"
785 " printf(\"%sInherit scheduler = %s\\en\", prefix,\n"
786 " (i == PTHREAD_INHERIT_SCHED) ? \"PTHREAD_INHERIT_SCHED\" :\n"
787 " (i == PTHREAD_EXPLICIT_SCHED) ? \"PTHREAD_EXPLICIT_SCHED\" :\n"
792 #: build/C/man3/pthread_attr_init.3:201
795 " s = pthread_attr_getschedpolicy(attr, &i);\n"
797 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
798 " printf(\"%sScheduling policy = %s\\en\", prefix,\n"
799 " (i == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
800 " (i == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
801 " (i == SCHED_RR) ? \"SCHED_RR\" :\n"
806 #: build/C/man3/pthread_attr_init.3:206
809 " s = pthread_attr_getschedparam(attr, &sp);\n"
811 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
812 " printf(\"%sScheduling priority = %d\\en\", prefix, sp.sched_priority);\n"
816 #: build/C/man3/pthread_attr_init.3:211
819 " s = pthread_attr_getguardsize(attr, &v);\n"
821 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
822 " printf(\"%sGuard size = %d bytes\\en\", prefix, v);\n"
826 #: build/C/man3/pthread_attr_init.3:218
829 " s = pthread_attr_getstack(attr, &stkaddr, &v);\n"
831 " handle_error_en(s, \"pthread_attr_getstack\");\n"
832 " printf(\"%sStack address = %p\\en\", prefix, stkaddr);\n"
833 " printf(\"%sStack size = 0x%x bytes\\en\", prefix, v);\n"
838 #: build/C/man3/pthread_attr_init.3:224
842 "thread_start(void *arg)\n"
845 " pthread_attr_t gattr;\n"
849 #: build/C/man3/pthread_attr_init.3:228
852 " /* pthread_getattr_np() is a non-standard GNU extension that\n"
853 " retrieves the attributes of the thread specified in its\n"
854 " first argument */\n"
858 #: build/C/man3/pthread_attr_init.3:232
861 " s = pthread_getattr_np(pthread_self(), &gattr);\n"
863 " handle_error_en(s, \"pthread_getattr_np\");\n"
867 #: build/C/man3/pthread_attr_init.3:235
870 " printf(\"Thread attributes:\\en\");\n"
871 " display_pthread_attr(&gattr, \"\\et\");\n"
875 #: build/C/man3/pthread_attr_init.3:238 build/C/man3/pthread_getattr_np.3:240
878 " exit(EXIT_SUCCESS); /* Terminate all threads */\n"
883 #: build/C/man3/pthread_attr_init.3:246
887 "main(int argc, char *argv[])\n"
890 " pthread_attr_t attr;\n"
891 " pthread_attr_t *attrp; /* NULL or &attr */\n"
896 #: build/C/man3/pthread_attr_init.3:248 build/C/man3/pthread_setschedparam.3:355
898 msgid " attrp = NULL;\n"
902 #: build/C/man3/pthread_attr_init.3:252
905 " /* If a command-line argument was supplied, use it to set the\n"
906 " stack-size attribute and set a few other thread attributes,\n"
907 " and set attrp pointing to thread attributes object */\n"
911 #: build/C/man3/pthread_attr_init.3:256
914 " if (argc E<gt> 1) {\n"
920 #: build/C/man3/pthread_attr_init.3:258
922 msgid " attrp = &attr;\n"
926 #: build/C/man3/pthread_attr_init.3:262
929 " s = pthread_attr_init(&attr);\n"
931 " handle_error_en(s, \"pthread_attr_init\");\n"
935 #: build/C/man3/pthread_attr_init.3:266
938 " s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n"
940 " handle_error_en(s, \"pthread_attr_setdetachstate\");\n"
944 #: build/C/man3/pthread_attr_init.3:270
947 " s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n"
949 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
953 #: build/C/man3/pthread_attr_init.3:272
955 msgid " stack_size = strtoul(argv[1], NULL, 0);\n"
959 #: build/C/man3/pthread_attr_init.3:276
962 " s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);\n"
964 " handle_error_en(s, \"posix_memalign\");\n"
968 #: build/C/man3/pthread_attr_init.3:278
970 msgid " printf(\"posix_memalign() allocated at %p\\en\", sp);\n"
974 #: build/C/man3/pthread_attr_init.3:283
977 " s = pthread_attr_setstack(&attr, sp, stack_size);\n"
979 " handle_error_en(s, \"pthread_attr_setstack\");\n"
984 #: build/C/man3/pthread_attr_init.3:287 build/C/man3/pthread_getattr_np.3:335
987 " s = pthread_create(&thr, attrp, &thread_start, NULL);\n"
989 " handle_error_en(s, \"pthread_create\");\n"
993 #: build/C/man3/pthread_attr_init.3:293 build/C/man3/pthread_getattr_np.3:341
996 " if (attrp != NULL) {\n"
997 " s = pthread_attr_destroy(attrp);\n"
999 " handle_error_en(s, \"pthread_attr_destroy\");\n"
1004 #: build/C/man3/pthread_attr_init.3:296 build/C/man3/pthread_getattr_np.3:344
1007 " pause(); /* Terminates when other thread calls exit() */\n"
1012 #: build/C/man3/pthread_attr_init.3:313
1014 "B<pthread_attr_setaffinity_np>(3), B<pthread_attr_setdetachstate>(3), "
1015 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setinheritsched>(3), "
1016 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
1017 "B<pthread_attr_setscope>(3), B<pthread_attr_setstack>(3), "
1018 "B<pthread_attr_setstackaddr>(3), B<pthread_attr_setstacksize>(3), "
1019 "B<pthread_create>(3), B<pthread_getattr_np>(3), B<pthreads>(7)"
1023 #: build/C/man3/pthread_attr_setaffinity_np.3:26
1025 msgid "PTHREAD_ATTR_SETAFFINITY_NP"
1029 #: build/C/man3/pthread_attr_setaffinity_np.3:26 build/C/man3/pthread_getattr_np.3:26 build/C/man3/pthread_setaffinity_np.3:26 build/C/man3/pthread_tryjoin_np.3:26
1035 #: build/C/man3/pthread_attr_setaffinity_np.3:30
1037 "pthread_attr_setaffinity_np, pthread_attr_getaffinity_np - set/get CPU "
1038 "affinity attribute in thread attributes object"
1042 #: build/C/man3/pthread_attr_setaffinity_np.3:34 build/C/man3/pthread_getattr_np.3:33 build/C/man3/pthread_setaffinity_np.3:34 build/C/man3/pthread_tryjoin_np.3:34 build/C/man3/pthread_yield.3:32
1045 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
1046 "B<#include E<lt>pthread.hE<gt>>\n"
1050 #: build/C/man3/pthread_attr_setaffinity_np.3:39
1053 "B<int pthread_attr_setaffinity_np(pthread_attr_t *>I<attr>B<,>\n"
1054 "B< size_t >I<cpusetsize>B<, const cpu_set_t "
1055 "*>I<cpuset>B<);>\n"
1056 "B<int pthread_attr_getaffinity_np(pthread_attr_t *>I<attr>B<,>\n"
1057 "B< size_t >I<cpusetsize>B<, cpu_set_t *>I<cpuset>B<);>\n"
1061 #: build/C/man3/pthread_attr_setaffinity_np.3:54
1063 "The B<pthread_attr_setaffinity_np>() function sets the CPU affinity mask "
1064 "attribute of the thread attributes object referred to by I<attr> to the "
1065 "value specified in I<cpuset>. This attribute determines the CPU affinity "
1066 "mask of a thread created using the thread attributes object I<attr>."
1070 #: build/C/man3/pthread_attr_setaffinity_np.3:63
1072 "The B<pthread_attr_getaffinity_np>() function returns the CPU affinity mask "
1073 "attribute of the thread attributes object referred to by I<attr> in the "
1074 "buffer pointed to by I<cpuset>."
1078 #: build/C/man3/pthread_attr_setaffinity_np.3:70
1080 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
1081 "by I<cpuset>. Typically, this argument would be specified as "
1082 "I<sizeof(cpu_set_t)>."
1086 #: build/C/man3/pthread_attr_setaffinity_np.3:76 build/C/man3/pthread_setaffinity_np.3:67
1088 "For more details on CPU affinity masks, see B<sched_setaffinity>(2). For a "
1089 "description of a set of macros that can be used to manipulate and inspect "
1090 "CPU sets, see B<CPU_SET>(3)."
1094 #: build/C/man3/pthread_attr_setaffinity_np.3:80 build/C/man3/pthread_attr_setaffinity_np.3:92 build/C/man3/pthread_attr_setdetachstate.3:83 build/C/man3/pthread_attr_setinheritsched.3:90 build/C/man3/pthread_attr_setschedpolicy.3:78 build/C/man3/pthread_attr_setscope.3:97 build/C/man3/pthread_attr_setstack.3:91 build/C/man3/pthread_attr_setstacksize.3:67 build/C/man3/pthread_create.3:137 build/C/man3/pthread_detach.3:55 build/C/man3/pthread_join.3:85 build/C/man3/pthread_join.3:89 build/C/man3/pthread_kill.3:58 build/C/man3/pthread_setaffinity_np.3:84 build/C/man3/pthread_setaffinity_np.3:93 build/C/man3/pthread_setaffinity_np.3:109 build/C/man3/pthread_setcancelstate.3:99 build/C/man3/pthread_setcancelstate.3:107 build/C/man3/pthread_setconcurrency.3:71 build/C/man3/pthread_setschedparam.3:122 build/C/man3/pthread_setschedprio.3:62 build/C/man3/pthread_sigqueue.3:77
1100 #. The raw sched_getaffinity() system call returns the size (in bytes)
1101 #. of the cpumask_t type.
1103 #: build/C/man3/pthread_attr_setaffinity_np.3:92
1105 "(B<pthread_attr_setaffinity_np>()) I<cpuset> specified a CPU that was "
1106 "outside the set supported by the kernel. (The kernel configuration option "
1107 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
1108 "type used to represent CPU sets.)"
1112 #: build/C/man3/pthread_attr_setaffinity_np.3:102
1114 "(B<pthread_attr_getaffinity_np>()) A CPU in the affinity mask of the thread "
1115 "attributes object referred to by I<attr> lies outside the range specified by "
1116 "I<cpusetsize> (i.e., I<cpuset>/I<cpusetsize> is too small)."
1120 #: build/C/man3/pthread_attr_setaffinity_np.3:106
1121 msgid "(B<pthread_attr_setaffinity_np>()) Could not allocate memory."
1125 #: build/C/man3/pthread_attr_setaffinity_np.3:108 build/C/man3/pthread_setaffinity_np.3:121
1126 msgid "These functions are provided by glibc since version 2.3.4."
1130 #: build/C/man3/pthread_attr_setaffinity_np.3:111 build/C/man3/pthread_cleanup_push_defer_np.3:104 build/C/man3/pthread_setaffinity_np.3:124 build/C/man3/pthread_tryjoin_np.3:115
1132 "These functions are nonstandard GNU extensions; hence the suffix \"_np\" "
1133 "(nonportable) in the names."
1137 #: build/C/man3/pthread_attr_setaffinity_np.3:118 build/C/man3/pthread_setaffinity_np.3:150
1139 "In glibc 2.3.3 only, versions of these functions were provided that did not "
1140 "have a I<cpusetsize> argument. Instead the CPU set size given to the "
1141 "underlying system calls was always I<sizeof(cpu_set_t)>."
1145 #: build/C/man3/pthread_attr_setaffinity_np.3:124
1147 "B<sched_setaffinity>(2), B<pthread_attr_init>(3), "
1148 "B<pthread_setaffinity_np>(3), B<cpuset>(7), B<pthreads>(7)"
1152 #: build/C/man3/pthread_attr_setdetachstate.3:26
1154 msgid "PTHREAD_ATTR_SETDETACHSTATE"
1158 #: build/C/man3/pthread_attr_setdetachstate.3:26 build/C/man3/pthread_attr_setschedpolicy.3:26
1164 #: build/C/man3/pthread_attr_setdetachstate.3:30
1166 "pthread_attr_setdetachstate, pthread_attr_getdetachstate - set/get detach "
1167 "state attribute in thread attributes object"
1171 #: build/C/man3/pthread_attr_setdetachstate.3:38
1174 "B<int pthread_attr_setdetachstate(pthread_attr_t *>I<attr>B<, int "
1175 ">I<detachstate>B<);>\n"
1176 "B<int pthread_attr_getdetachstate(pthread_attr_t *>I<attr>B<, int "
1177 "*>I<detachstate>B<);>\n"
1181 #: build/C/man3/pthread_attr_setdetachstate.3:53
1183 "The B<pthread_attr_setdetachstate>() function sets the detach state "
1184 "attribute of the thread attributes object referred to by I<attr> to the "
1185 "value specified in I<detachstate>. The detach state attribute determines "
1186 "whether a thread created using the thread attributes object I<attr> will be "
1187 "created in a joinable or a detached state."
1191 #: build/C/man3/pthread_attr_setdetachstate.3:56
1192 msgid "The following values may be specified in I<detachstate>:"
1196 #: build/C/man3/pthread_attr_setdetachstate.3:56
1198 msgid "B<PTHREAD_CREATE_DETACHED>"
1202 #: build/C/man3/pthread_attr_setdetachstate.3:61
1203 msgid "Threads that are created using I<attr> will be created in a detached state."
1207 #: build/C/man3/pthread_attr_setdetachstate.3:61
1209 msgid "B<PTHREAD_CREATE_JOINABLE>"
1213 #: build/C/man3/pthread_attr_setdetachstate.3:66
1214 msgid "Threads that are created using I<attr> will be created in a joinable state."
1218 #: build/C/man3/pthread_attr_setdetachstate.3:70
1220 "The default setting of the detach state attribute in a newly initialized "
1221 "thread attributes object is B<PTHREAD_CREATE_JOINABLE>."
1225 #: build/C/man3/pthread_attr_setdetachstate.3:77
1227 "The B<pthread_attr_getdetachstate>() returns the detach state attribute of "
1228 "the thread attributes object I<attr> in the buffer pointed to by "
1233 #: build/C/man3/pthread_attr_setdetachstate.3:83
1234 msgid "B<pthread_attr_setdetachstate>() can fail with the following error:"
1238 #: build/C/man3/pthread_attr_setdetachstate.3:87
1239 msgid "An invalid value was specified in I<detachstate>."
1243 #: build/C/man3/pthread_attr_setdetachstate.3:93
1244 msgid "See B<pthread_create>(3) for more details on detached and joinable threads."
1248 #: build/C/man3/pthread_attr_setdetachstate.3:101
1250 "A thread that is created in a joinable state should eventually either be "
1251 "joined using B<pthread_join>(3) or detached using B<pthread_detach>(3); see "
1252 "B<pthread_create>(3)."
1256 #: build/C/man3/pthread_attr_setdetachstate.3:108
1258 "It is an error to specify the thread ID of a thread that was created in a "
1259 "detached state in a later call to B<pthread_detach>(3) or "
1260 "B<pthread_join>(3)."
1264 #: build/C/man3/pthread_attr_setdetachstate.3:111 build/C/man3/pthread_attr_setstack.3:156
1265 msgid "See B<pthread_attr_init>(3)."
1269 #: build/C/man3/pthread_attr_setdetachstate.3:117
1271 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthread_detach>(3), "
1272 "B<pthread_join>(3), B<pthreads>(7)"
1276 #: build/C/man3/pthread_attr_setguardsize.3:26
1278 msgid "PTHREAD_ATTR_SETGUARDSIZE"
1282 #: build/C/man3/pthread_attr_setguardsize.3:26 build/C/man3/pthread_attr_setscope.3:26 build/C/man3/pthread_attr_setstack.3:26 build/C/man3/pthread_attr_setstackaddr.3:26 build/C/man3/pthread_self.3:26
1288 #: build/C/man3/pthread_attr_setguardsize.3:30
1290 "pthread_attr_setguardsize, pthread_attr_getguardsize - set/get guard size "
1291 "attribute in thread attributes object"
1295 #: build/C/man3/pthread_attr_setguardsize.3:38
1298 "B<int pthread_attr_setguardsize(pthread_attr_t *>I<attr>B<, size_t "
1299 ">I<guardsize>B<);>\n"
1300 "B<int pthread_attr_getguardsize(pthread_attr_t *>I<attr>B<, size_t "
1301 "*>I<guardsize>B<);>\n"
1305 #: build/C/man3/pthread_attr_setguardsize.3:49
1307 "The B<pthread_attr_setguardsize>() function sets the guard size attribute "
1308 "of the thread attributes object referred to by I<attr> to the value "
1309 "specified in I<guardsize>."
1313 #: build/C/man3/pthread_attr_setguardsize.3:59
1315 "If I<guardsize> is greater than 0, then for each new thread created using "
1316 "I<attr> the system allocates an additional region of at least I<guardsize> "
1317 "bytes at the end of the thread's stack to act as the guard area for the "
1318 "stack (but see BUGS)."
1322 #: build/C/man3/pthread_attr_setguardsize.3:65
1324 "If I<guardsize> is 0, then new threads created with I<attr> will not have a "
1329 #: build/C/man3/pthread_attr_setguardsize.3:67
1330 msgid "The default guard size is the same as the system page size."
1334 #: build/C/man3/pthread_attr_setguardsize.3:82
1336 "If the stack address attribute has been set in I<attr> (using "
1337 "B<pthread_attr_setstack>(3) or B<pthread_attr_setstackaddr>(3)), meaning "
1338 "that the caller is allocating the thread's stack, then the guard size "
1339 "attribute is ignored (i.e., no guard area is created by the system): it is "
1340 "the application's responsibility to handle stack overflow (perhaps by using "
1341 "B<mprotect>(2) to manually define a guard area at the end of the stack that "
1342 "it has allocated)."
1346 #: build/C/man3/pthread_attr_setguardsize.3:90
1348 "The B<pthread_attr_getguardsize>() function returns the guard size "
1349 "attribute of the thread attributes object referred to by I<attr> in the "
1350 "buffer pointed to by I<guardsize>."
1354 #: build/C/man3/pthread_attr_setguardsize.3:104
1356 "POSIX.1-2001 documents an B<EINVAL> error if I<attr> or I<guardsize> is "
1357 "invalid. On Linux these functions always succeed (but portable and "
1358 "future-proof applications should nevertheless handle a possible error "
1363 #: build/C/man3/pthread_attr_setguardsize.3:106 build/C/man3/pthread_attr_setstackaddr.3:83 build/C/man3/pthread_attr_setstacksize.3:83
1364 msgid "These functions are provided by glibc since version 2.1."
1368 #: build/C/man3/pthread_attr_setguardsize.3:122
1370 "A guard area consists of virtual memory pages that are protected to prevent "
1371 "read and write access. If a thread overflows its stack into the guard area, "
1372 "then, on most hard architectures, it receives a B<SIGSEGV> signal, thus "
1373 "notifying it of the overflow. Guard areas start on page boundaries, and the "
1374 "guard size is internally rounded up to the system page size when creating a "
1375 "thread. (Nevertheless, B<pthread_attr_getguardsize>() returns the guard "
1376 "size that was set by B<pthread_attr_setguardsize>().)"
1380 #: build/C/man3/pthread_attr_setguardsize.3:126
1382 "Setting a guard size of 0 may be useful to save memory in an application "
1383 "that creates many threads and knows that stack overflow can never occur."
1387 #: build/C/man3/pthread_attr_setguardsize.3:130
1389 "Choosing a guard size larger than the default size may be necessary for "
1390 "detecting stack overflows if a thread allocates large data structures on the "
1395 #: build/C/man3/pthread_attr_setguardsize.3:130 build/C/man3/pthread_attr_setinheritsched.3:103 build/C/man3/pthread_attr_setstacksize.3:96 build/C/man3/pthread_create.3:196 build/C/man3/pthread_exit.3:93
1401 #: build/C/man3/pthread_attr_setguardsize.3:141
1403 "As at glibc 2.8, the NPTL threading implementation includes the guard area "
1404 "within the stack size allocation, rather than allocating extra space at the "
1405 "end of the stack, as POSIX.1 requires. (This can result in an B<EINVAL> "
1406 "error from B<pthread_create>(3) if the guard size value is too large, "
1407 "leaving no space for the actual stack.)"
1410 #. glibc includes the guardsize within the allocated stack size,
1411 #. which looks pretty clearly to be in violation of POSIX.
1413 #. Filed bug, 22 Oct 2008:
1414 #. http://sources.redhat.com/bugzilla/show_bug.cgi?id=6973
1417 #. https//bugzilla.redhat.com/show_bug.cgi?id=435337
1418 #. Reportedly, LinuxThreads did the right thing, allocating
1419 #. extra space at the end of the stack:
1420 #. http://sourceware.org/ml/libc-alpha/2008-05/msg00086.html
1422 #: build/C/man3/pthread_attr_setguardsize.3:155
1424 "The obsolete LinuxThreads implementation did the right thing, allocating "
1425 "extra space at the end of the stack for the guard area."
1429 #: build/C/man3/pthread_attr_setguardsize.3:158
1430 msgid "See B<pthread_getattr_np>(3)."
1434 #: build/C/man3/pthread_attr_setguardsize.3:166
1436 "B<mmap>(2), B<mprotect>(2), B<pthread_attr_init>(3), "
1437 "B<pthread_attr_setstack>(3), B<pthread_attr_setstacksize>(3), "
1438 "B<pthread_create>(3), B<pthreads>(7)"
1442 #: build/C/man3/pthread_attr_setinheritsched.3:26
1444 msgid "PTHREAD_ATTR_SETINHERITSCHED"
1448 #: build/C/man3/pthread_attr_setinheritsched.3:26 build/C/man3/pthread_attr_setschedparam.3:26 build/C/man3/pthread_attr_setstacksize.3:26
1454 #: build/C/man3/pthread_attr_setinheritsched.3:30
1456 "pthread_attr_setinheritsched, pthread_attr_getinheritsched - set/get inherit "
1457 "scheduler attribute in thread attributes object"
1461 #: build/C/man3/pthread_attr_setinheritsched.3:38
1464 "B<int pthread_attr_setinheritsched(pthread_attr_t *>I<attr>B<,>\n"
1465 "B< int >I<inheritsched>B<);>\n"
1466 "B<int pthread_attr_getinheritsched(pthread_attr_t *>I<attr>B<,>\n"
1467 "B< int *>I<inheritsched>B<);>\n"
1471 #: build/C/man3/pthread_attr_setinheritsched.3:55
1473 "The B<pthread_attr_setinheritsched>() function sets the inherit scheduler "
1474 "attribute of the thread attributes object referred to by I<attr> to the "
1475 "value specified in I<inheritsched>. The inherit scheduler attribute "
1476 "determines whether a thread created using the thread attributes object "
1477 "I<attr> will inherit its scheduling attributes from the calling thread or "
1478 "whether it will take them from I<attr>."
1482 #: build/C/man3/pthread_attr_setinheritsched.3:58
1483 msgid "The following values may be specified in I<inheritsched>:"
1487 #: build/C/man3/pthread_attr_setinheritsched.3:58
1489 msgid "B<PTHREAD_INHERIT_SCHED>"
1493 #: build/C/man3/pthread_attr_setinheritsched.3:66
1495 "Threads that are created using I<attr> inherit scheduling attributes from "
1496 "the creating thread; the scheduling attributes in I<attr> are ignored."
1500 #: build/C/man3/pthread_attr_setinheritsched.3:66
1502 msgid "B<PTHREAD_EXPLICIT_SCHED>"
1505 #. FIXME what are the defaults for scheduler settings?
1507 #: build/C/man3/pthread_attr_setinheritsched.3:73
1509 "Threads that are created using I<attr> take their scheduling attributes from "
1510 "the values specified by the attributes object."
1514 #: build/C/man3/pthread_attr_setinheritsched.3:77
1516 "The default setting of the inherit scheduler attribute in a newly "
1517 "initialized thread attributes object is B<PTHREAD_INHERIT_SCHED>."
1521 #: build/C/man3/pthread_attr_setinheritsched.3:84
1523 "The B<pthread_attr_getinheritsched>() returns the inherit scheduler "
1524 "attribute of the thread attributes object I<attr> in the buffer pointed to "
1525 "by I<inheritsched>."
1529 #: build/C/man3/pthread_attr_setinheritsched.3:90
1530 msgid "B<pthread_attr_setinheritsched>() can fail with the following error:"
1534 #: build/C/man3/pthread_attr_setinheritsched.3:94
1535 msgid "Invalid value in I<inheritsched>."
1539 #. Available since glibc 2.0.
1541 #: build/C/man3/pthread_attr_setinheritsched.3:101
1543 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
1544 "to set the attribute to an unsupported value\") for "
1545 "B<pthread_attr_setinheritsched>()."
1548 #. FIXME . Track status of the following bug:
1549 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7007
1551 #: build/C/man3/pthread_attr_setinheritsched.3:119
1553 "As at glibc 2.8, if a thread attributes object is initialized using "
1554 "B<pthread_attr_init>(3), then the scheduling policy of the attributes object "
1555 "is set to B<SCHED_OTHER> and the scheduling priority is set to 0. However, "
1556 "if the inherit scheduler attribute is then set to B<PTHREAD_EXPLICIT_SCHED>, "
1557 "then a thread created using the attribute object wrongly inherits its "
1558 "scheduling attributes from the creating thread. This bug does not occur if "
1559 "either the scheduling policy or scheduling priority attribute is explicitly "
1560 "set in the thread attributes object before calling B<pthread_create>(3)."
1564 #: build/C/man3/pthread_attr_setinheritsched.3:122 build/C/man3/pthread_attr_setschedparam.3:98 build/C/man3/pthread_attr_setschedpolicy.3:94
1565 msgid "See B<pthread_setschedparam>(3)."
1569 #: build/C/man3/pthread_attr_setinheritsched.3:133
1571 "B<sched_setscheduler>(2), B<pthread_attr_init>(3), "
1572 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
1573 "B<pthread_create>(3), B<pthread_setschedparam>(3), "
1574 "B<pthread_setschedprio>(3), B<pthreads>(7)"
1578 #: build/C/man3/pthread_attr_setschedparam.3:26
1580 msgid "PTHREAD_ATTR_SETSCHEDPARAM"
1584 #: build/C/man3/pthread_attr_setschedparam.3:30
1586 "pthread_attr_setschedparam, pthread_attr_getschedparam - set/get scheduling "
1587 "parameter attributes in thread attributes object"
1591 #: build/C/man3/pthread_attr_setschedparam.3:38
1594 "B<int pthread_attr_setschedparam(pthread_attr_t *>I<attr>B<,>\n"
1595 "B< const struct sched_param *>I<param>B<);>\n"
1596 "B<int pthread_attr_getschedparam(pthread_attr_t *>I<attr>B<,>\n"
1597 "B< struct sched_param *>I<param>B<);>\n"
1601 #: build/C/man3/pthread_attr_setschedparam.3:52
1603 "The B<pthread_attr_setschedparam>() function sets the scheduling parameter "
1604 "attributes of the thread attributes object referred to by I<attr> to the "
1605 "values specified in the buffer pointed to by I<param>. These attributes "
1606 "determine the scheduling parameters of a thread created using the thread "
1607 "attributes object I<attr>."
1611 #: build/C/man3/pthread_attr_setschedparam.3:59
1613 "The B<pthread_attr_getschedparam>() returns the scheduling parameter "
1614 "attributes of the thread attributes object I<attr> in the buffer pointed to "
1619 #: build/C/man3/pthread_attr_setschedparam.3:61
1620 msgid "Scheduling parameters are maintained in the following structure:"
1624 #: build/C/man3/pthread_attr_setschedparam.3:67 build/C/man3/pthread_setschedparam.3:69
1627 "struct sched_param {\n"
1628 " int sched_priority; /* Scheduling priority */\n"
1633 #: build/C/man3/pthread_attr_setschedparam.3:74 build/C/man3/pthread_setschedparam.3:76
1635 "As can be seen, only one scheduling parameter is supported. For details of "
1636 "the permitted ranges for scheduling priorities in each scheduling policy, "
1637 "see B<sched_setscheduler>(2)."
1641 #. Available since glibc 2.0.
1643 #: build/C/man3/pthread_attr_setschedparam.3:89
1645 "POSIX.1 documents B<EINVAL> and B<ENOTSUP> errors for "
1646 "B<pthread_attr_setschedparam>(). On Linux these functions always succeed "
1647 "(but portable and future-proof applications should nevertheless handle a "
1648 "possible error return)."
1652 #: build/C/man3/pthread_attr_setschedparam.3:95
1654 "See B<pthread_attr_setschedpolicy>(3) for a list of the thread scheduling "
1655 "policies supported on Linux."
1659 #: build/C/man3/pthread_attr_setschedparam.3:110
1661 "B<sched_get_priority_min>(2), B<sched_setscheduler>(2), "
1662 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
1663 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), "
1664 "B<pthread_setschedparam>(3), B<pthread_setschedprio>(3), B<pthreads>(7)"
1668 #: build/C/man3/pthread_attr_setschedpolicy.3:26
1670 msgid "PTHREAD_ATTR_SETSCHEDPOLICY"
1674 #: build/C/man3/pthread_attr_setschedpolicy.3:30
1676 "pthread_attr_setschedpolicy, pthread_attr_getschedpolicy - set/get "
1677 "scheduling policy attribute in thread attributes object"
1681 #: build/C/man3/pthread_attr_setschedpolicy.3:38
1684 "B<int pthread_attr_setschedpolicy(pthread_attr_t *>I<attr>B<, int "
1686 "B<int pthread_attr_getschedpolicy(pthread_attr_t *>I<attr>B<, int "
1687 ">I<*policy>B<);>\n"
1691 #: build/C/man3/pthread_attr_setschedpolicy.3:52
1693 "The B<pthread_attr_setschedpolicy>() function sets the scheduling policy "
1694 "attribute of the thread attributes object referred to by I<attr> to the "
1695 "value specified in I<policy>. This attribute determines the scheduling "
1696 "policy of a thread created using the thread attributes object I<attr>."
1699 #. FIXME . pthread_setschedparam() places no restriction on the policy,
1700 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
1701 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
1703 #: build/C/man3/pthread_attr_setschedpolicy.3:65
1705 "The supported values for I<policy> are B<SCHED_FIFO>, B<SCHED_RR>, and "
1706 "B<SCHED_OTHER>, with the semantics described in B<sched_setscheduler>(2)."
1710 #: build/C/man3/pthread_attr_setschedpolicy.3:72
1712 "The B<pthread_attr_getschedpolicy>() returns the scheduling policy "
1713 "attribute of the thread attributes object I<attr> in the buffer pointed to "
1718 #: build/C/man3/pthread_attr_setschedpolicy.3:78
1719 msgid "B<pthread_attr_setschedpolicy>() can fail with the following error:"
1723 #: build/C/man3/pthread_attr_setschedpolicy.3:82
1724 msgid "Invalid value in I<policy>."
1728 #. Available since glibc 2.0.
1730 #: build/C/man3/pthread_attr_setschedpolicy.3:89
1732 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
1733 "to set the attribute to an unsupported value\") for "
1734 "B<pthread_attr_setschedpolicy>()."
1738 #: build/C/man3/pthread_attr_setschedpolicy.3:105
1740 "B<sched_setscheduler>(2), B<pthread_attr_init>(3), "
1741 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
1742 "B<pthread_create>(3), B<pthread_setschedparam>(3), "
1743 "B<pthread_setschedprio>(3), B<pthreads>(7)"
1747 #: build/C/man3/pthread_attr_setscope.3:26
1749 msgid "PTHREAD_ATTR_SETSCOPE"
1753 #: build/C/man3/pthread_attr_setscope.3:30
1755 "pthread_attr_setscope, pthread_attr_getscope - set/get contention scope "
1756 "attribute in thread attributes object"
1760 #: build/C/man3/pthread_attr_setscope.3:38
1763 "B<int pthread_attr_setscope(pthread_attr_t *>I<attr>B<, int >I<scope>B<);>\n"
1764 "B<int pthread_attr_getscope(pthread_attr_t *>I<attr>B<, int "
1769 #: build/C/man3/pthread_attr_setscope.3:53
1771 "The B<pthread_attr_setscope>() function sets the contention scope attribute "
1772 "of the thread attributes object referred to by I<attr> to the value "
1773 "specified in I<scope>. The contention scope attribute defines the set of "
1774 "threads against which a thread competes for resources such as the CPU. "
1775 "POSIX.1-2001 specifies two possible values for I<scope>:"
1779 #: build/C/man3/pthread_attr_setscope.3:53
1781 msgid "B<PTHREAD_SCOPE_SYSTEM>"
1785 #: build/C/man3/pthread_attr_setscope.3:61
1787 "The thread competes for resources with all other threads in all processes on "
1788 "the system that are in the same scheduling allocation domain (a group of one "
1789 "or more processors). B<PTHREAD_SCOPE_SYSTEM> threads are scheduled relative "
1790 "to one another according to their scheduling policy and priority."
1794 #: build/C/man3/pthread_attr_setscope.3:61
1796 msgid "B<PTHREAD_SCOPE_PROCESS>"
1800 #: build/C/man3/pthread_attr_setscope.3:76
1802 "The thread competes for resources with all other threads in the same process "
1803 "that were also created with the B<PTHREAD_SCOPE_PROCESS> contention scope. "
1804 "B<PTHREAD_SCOPE_PROCESS> threads are scheduled relative to other threads in "
1805 "the process according to their scheduling policy and priority. POSIX.1-2001 "
1806 "leaves it unspecified how these threads contend with other threads in other "
1807 "process on the system or with other threads in the same process that were "
1808 "created with the B<PTHREAD_SCOPE_SYSTEM> contention scope."
1812 #: build/C/man3/pthread_attr_setscope.3:83
1814 "POSIX.1-2001 only requires that an implementation support one of these "
1815 "contention scopes, but permits both to be supported. Linux supports "
1816 "B<PTHREAD_SCOPE_SYSTEM>, but not B<PTHREAD_SCOPE_PROCESS>."
1820 #: build/C/man3/pthread_attr_setscope.3:91
1822 "The B<pthread_attr_getscope>() function returns the contention scope "
1823 "attribute of the thread attributes object referred to by I<attr> in the "
1824 "buffer pointed to by I<scope>."
1828 #: build/C/man3/pthread_attr_setscope.3:97
1829 msgid "B<pthread_attr_setscope>() can fail with the following errors:"
1833 #: build/C/man3/pthread_attr_setscope.3:101
1834 msgid "An invalid value was specified in I<scope>."
1838 #: build/C/man3/pthread_attr_setscope.3:101
1844 #: build/C/man3/pthread_attr_setscope.3:107
1846 "I<scope> specified the value B<PTHREAD_SCOPE_PROCESS>, which is not "
1847 "supported on Linux."
1851 #: build/C/man3/pthread_attr_setscope.3:117
1853 "The B<PTHREAD_SCOPE_SYSTEM> contention scope typically indicates that a "
1854 "user-space thread is bound directly to a single kernel-scheduling entity. "
1855 "This is the case on Linux for the obsolete LinuxThreads implementation and "
1856 "the modern NPTL implementation, which are both 1:1 threading "
1861 #: build/C/man3/pthread_attr_setscope.3:120
1863 "POSIX.1-2001 specifies that the default contention scope is "
1864 "implementation-defined."
1868 #: build/C/man3/pthread_attr_setscope.3:130
1870 "B<pthread_attr_init>(3), B<pthread_attr_setaffinity_np>(3), "
1871 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
1872 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), B<pthreads>(7)"
1876 #: build/C/man3/pthread_attr_setstack.3:26
1878 msgid "PTHREAD_ATTR_SETSTACK"
1882 #: build/C/man3/pthread_attr_setstack.3:30
1884 "pthread_attr_setstack, pthread_attr_getstack - set/get stack attributes in "
1885 "thread attributes object"
1889 #: build/C/man3/pthread_attr_setstack.3:38
1892 "B<int pthread_attr_setstack(pthread_attr_t *>I<attr>B<,>\n"
1893 "B< void *>I<stackaddr>B<, size_t "
1894 ">I<stacksize>B<);>\n"
1895 "B<int pthread_attr_getstack(pthread_attr_t *>I<attr>B<,>\n"
1896 "B< void **>I<stackaddr>B<, size_t "
1897 "*>I<stacksize>B<);>\n"
1901 #: build/C/man3/pthread_attr_setstack.3:45 build/C/man3/pthread_sigqueue.3:41
1902 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
1906 #: build/C/man3/pthread_attr_setstack.3:50
1907 msgid "B<pthread_attr_getstack>(), B<pthread_attr_setstack>():"
1911 #: build/C/man3/pthread_attr_setstack.3:52
1912 msgid "_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600"
1916 #: build/C/man3/pthread_attr_setstack.3:68
1918 "The B<pthread_attr_setstack>() function sets the stack address and stack "
1919 "size attributes of the thread attributes object referred to by I<attr> to "
1920 "the values specified in I<stackaddr> and I<stacksize>, respectively. These "
1921 "attributes specify the location and size of the stack that should be used by "
1922 "a thread that is created using the thread attributes object I<attr>."
1926 #: build/C/man3/pthread_attr_setstack.3:74
1928 "I<stackaddr> should point to the lowest addressable byte of a buffer of "
1929 "I<stacksize> bytes that was allocated by the caller. The pages of the "
1930 "allocated buffer should be both readable and writable."
1934 #: build/C/man3/pthread_attr_setstack.3:85
1936 "The B<pthread_attr_getstack>() function returns the stack address and stack "
1937 "size attributes of the thread attributes object referred to by I<attr> in "
1938 "the buffers pointed to by I<stackaddr> and I<stacksize>, respectively."
1942 #: build/C/man3/pthread_attr_setstack.3:91
1943 msgid "B<pthread_attr_setstack>() can fail with the following error:"
1947 #: build/C/man3/pthread_attr_setstack.3:102
1949 "I<stacksize> is less than B<PTHREAD_STACK_MIN> (16384) bytes. On some "
1950 "systems, this error may also occur if I<stackaddr> or I<stackaddr\\ +\\ "
1951 "stacksize> is not suitably aligned."
1955 #: build/C/man3/pthread_attr_setstack.3:110
1957 "POSIX.1-2001 also documents an B<EACCES> error if the stack area described "
1958 "by I<stackaddr> and I<stacksize> is not both readable and writable by the "
1963 #: build/C/man3/pthread_attr_setstack.3:112
1964 msgid "These functions are provided by glibc since version 2.2."
1968 #: build/C/man3/pthread_attr_setstack.3:122
1970 "These functions are provided for applications that must ensure that a "
1971 "thread's stack is placed in a particular location. For most applications, "
1972 "this is not necessary, and the use of these functions should be avoided. "
1973 "(Use B<pthread_attr_setstacksize>(3) if an application simply requires a "
1974 "stack size other than the default.)"
1978 #: build/C/man3/pthread_attr_setstack.3:133
1980 "When an application employs B<pthread_attr_setstack>(), it takes over the "
1981 "responsibility of allocating the stack. Any guard size value that was set "
1982 "using B<pthread_attr_setguardsize>(3) is ignored. If deemed necessary, it "
1983 "is the application's responsibility to allocate a guard area (one or more "
1984 "pages protected against reading and writing) to handle the possibility of "
1989 #: build/C/man3/pthread_attr_setstack.3:144
1991 "The address specified in I<stackaddr> should be suitably aligned: for full "
1992 "portability, align it on a page boundary (I<sysconf(_SC_PAGESIZE)>). "
1993 "B<posix_memalign>(3) may be useful for allocation. Probably, I<stacksize> "
1994 "should also be a multiple of the system page size."
1998 #: build/C/man3/pthread_attr_setstack.3:153
2000 "If I<attr> is used to create multiple threads, then the caller must change "
2001 "the stack address attribute between calls to B<pthread_create>(3); "
2002 "otherwise, the threads will attempt to use the same memory area for their "
2003 "stacks, and chaos will ensue."
2007 #: build/C/man3/pthread_attr_setstack.3:168
2009 "B<mmap>(2), B<mprotect>(2), B<posix_memalign>(3), B<pthread_attr_init>(3), "
2010 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setstackaddr>(3), "
2011 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2015 #: build/C/man3/pthread_attr_setstackaddr.3:26
2017 msgid "PTHREAD_ATTR_SETSTACKADDR"
2021 #: build/C/man3/pthread_attr_setstackaddr.3:30
2023 "pthread_attr_setstackaddr, pthread_attr_getstackaddr - set/get stack address "
2024 "attribute in thread attributes object"
2028 #: build/C/man3/pthread_attr_setstackaddr.3:38
2031 "B<int pthread_attr_setstackaddr(pthread_attr_t *>I<attr>B<, void "
2032 "*>I<stackaddr>B<);>\n"
2033 "B<int pthread_attr_getstackaddr(pthread_attr_t *>I<attr>B<, void "
2034 "**>I<stackaddr>B<);>\n"
2038 #: build/C/man3/pthread_attr_setstackaddr.3:49
2040 "These functions are obsolete: B<do not use them.> Use "
2041 "B<pthread_attr_setstack>(3) and B<pthread_attr_getstack>(3) instead."
2045 #: build/C/man3/pthread_attr_setstackaddr.3:60
2047 "The B<pthread_attr_setstackaddr>() function sets the stack address "
2048 "attribute of the thread attributes object referred to by I<attr> to the "
2049 "value specified in I<stackaddr>. This attribute specifies the location of "
2050 "the stack that should be used by a thread that is created using the thread "
2051 "attributes object I<attr>."
2055 #: build/C/man3/pthread_attr_setstackaddr.3:66
2057 "I<stackaddr> should point to a buffer of at least B<PTHREAD_STACK_MIN> bytes "
2058 "that was allocated by the caller. The pages of the allocated buffer should "
2059 "be both readable and writable."
2063 #: build/C/man3/pthread_attr_setstackaddr.3:74
2065 "The B<pthread_attr_getstackaddr>() function returns the stack address "
2066 "attribute of the thread attributes object referred to by I<attr> in the "
2067 "buffer pointed to by I<stackaddr>."
2071 #: build/C/man3/pthread_attr_setstackaddr.3:81
2073 "No errors are defined (but applications should nevertheless handle a "
2074 "possible error return)."
2078 #: build/C/man3/pthread_attr_setstackaddr.3:86
2080 "POSIX.1-2001 specifies these functions but marks them as obsolete. "
2081 "POSIX.1-2008 removes the specification of these functions."
2085 #: build/C/man3/pthread_attr_setstackaddr.3:110
2087 "I<Do not use these functions!> They cannot be portably used, since they "
2088 "provide no way of specifying the direction of growth or the range of the "
2089 "stack. For example, on architectures with a stack that grows downward, "
2090 "I<stackaddr> specifies the next address past the I<highest> address of the "
2091 "allocated stack area. However, on architectures with a stack that grows "
2092 "upward, I<stackaddr> specifies the I<lowest> address in the allocated stack "
2093 "area. By contrast, the I<stackaddr> used by B<pthread_attr_setstack>(3) "
2094 "and B<pthread_attr_getstack>(3), is always a pointer to the lowest address "
2095 "in the allocated stack area (and the I<stacksize> argument specifies the "
2096 "range of the stack)."
2100 #: build/C/man3/pthread_attr_setstackaddr.3:116
2102 "B<pthread_attr_init>(3), B<pthread_attr_setstack>(3), "
2103 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2107 #: build/C/man3/pthread_attr_setstacksize.3:26
2109 msgid "PTHREAD_ATTR_SETSTACKSIZE"
2113 #: build/C/man3/pthread_attr_setstacksize.3:30
2115 "pthread_attr_setstacksize, pthread_attr_getstacksize - set/get stack size "
2116 "attribute in thread attributes object"
2120 #: build/C/man3/pthread_attr_setstacksize.3:38
2123 "B<int pthread_attr_setstacksize(pthread_attr_t *>I<attr>B<, size_t "
2124 ">I<stacksize>B<);>\n"
2125 "B<int pthread_attr_getstacksize(pthread_attr_t *>I<attr>B<, size_t "
2126 "*>I<stacksize>B<);>\n"
2130 #: build/C/man3/pthread_attr_setstacksize.3:49
2132 "The B<pthread_attr_setstacksize>() function sets the stack size attribute "
2133 "of the thread attributes object referred to by I<attr> to the value "
2134 "specified in I<stacksize>."
2138 #: build/C/man3/pthread_attr_setstacksize.3:53
2140 "The stack size attribute determines the minimum size (in bytes) that will be "
2141 "allocated for threads created using the thread attributes object I<attr>."
2145 #: build/C/man3/pthread_attr_setstacksize.3:61
2147 "The B<pthread_attr_getstacksize>() function returns the stack size "
2148 "attribute of the thread attributes object referred to by I<attr> in the "
2149 "buffer pointed to by I<stacksize>."
2153 #: build/C/man3/pthread_attr_setstacksize.3:67
2154 msgid "B<pthread_attr_setstacksize>() can fail with the following error:"
2158 #: build/C/man3/pthread_attr_setstacksize.3:72
2159 msgid "The stack size is less than B<PTHREAD_STACK_MIN> (16384) bytes."
2164 #: build/C/man3/pthread_attr_setstacksize.3:81
2166 "On some systems, B<pthread_attr_setstacksize>() can fail with the error "
2167 "B<EINVAL> if I<stacksize> is not a multiple of the system page size."
2171 #: build/C/man3/pthread_attr_setstacksize.3:88
2173 "For details on the default stack size of new threads, see "
2174 "B<pthread_create>(3)."
2178 #: build/C/man3/pthread_attr_setstacksize.3:91
2180 "A thread's stack size is fixed at the time of thread creation. Only the "
2181 "main thread can dynamically grow its stack."
2185 #: build/C/man3/pthread_attr_setstacksize.3:96
2187 "The B<pthread_attr_setstack>(3) function allows an application to set both "
2188 "the size and location of a caller-allocated stack that is to be used by a "
2193 #: build/C/man3/pthread_attr_setstacksize.3:108
2195 "As at glibc 2.8, if the specified I<stacksize> is not a multiple of "
2196 "B<STACK_ALIGN> (16 bytes on most architectures), it may be rounded "
2197 "I<downward>, in violation of POSIX.1-2001, which says that the allocated "
2198 "stack will be at least I<stacksize> bytes."
2202 #: build/C/man3/pthread_attr_setstacksize.3:111 build/C/man3/pthread_join.3:127
2203 msgid "See B<pthread_create>(3)."
2207 #: build/C/man3/pthread_attr_setstacksize.3:118
2209 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_attr_setguardsize>(3), "
2210 "B<pthread_attr_setstack>(3), B<pthread_create>(3), B<pthreads>(7)"
2214 #: build/C/man3/pthread_cancel.3:26
2216 msgid "PTHREAD_CANCEL"
2220 #: build/C/man3/pthread_cancel.3:26 build/C/man3/pthread_setschedparam.3:26
2226 #: build/C/man3/pthread_cancel.3:29
2227 msgid "pthread_cancel - send a cancellation request to a thread"
2231 #: build/C/man3/pthread_cancel.3:34
2233 msgid "B<int pthread_cancel(pthread_t >I<thread>B<);>\n"
2237 #: build/C/man3/pthread_cancel.3:46
2239 "The B<pthread_cancel>() function sends a cancellation request to the thread "
2240 "I<thread>. Whether and when the target thread reacts to the cancellation "
2241 "request depends on two attributes that are under the control of that thread: "
2242 "its cancelability I<state> and I<type>."
2246 #: build/C/man3/pthread_cancel.3:58
2248 "A thread's cancelability state, determined by B<pthread_setcancelstate>(3), "
2249 "can be I<enabled> (the default for new threads) or I<disabled>. If a thread "
2250 "has disabled cancellation, then a cancellation request remains queued until "
2251 "the thread enables cancellation. If a thread has enabled cancellation, then "
2252 "its cancelability type determines when cancellation occurs."
2256 #: build/C/man3/pthread_cancel.3:74
2258 "A thread's cancellation type, determined by B<pthread_setcanceltype>(3), may "
2259 "be either I<asynchronous> or I<deferred> (the default for new threads). "
2260 "Asynchronous cancelability means that the thread can be canceled at any time "
2261 "(usually immediately, but the system does not guarantee this). Deferred "
2262 "cancelability means that cancellation will be delayed until the thread next "
2263 "calls a function that is a I<cancellation point>. A list of functions that "
2264 "are or may be cancellation points is provided in I<pthreads>(7)."
2268 #: build/C/man3/pthread_cancel.3:78
2270 "When a cancellation requested is acted on, the following steps occur for "
2271 "I<thread> (in this order):"
2275 #: build/C/man3/pthread_cancel.3:78 build/C/man3/pthread_cleanup_push.3:69
2281 #: build/C/man3/pthread_cancel.3:83
2283 "Cancellation clean-up handlers are popped (in the reverse of the order in "
2284 "which they were pushed) and called. (See B<pthread_cleanup_push>(3).)"
2288 #: build/C/man3/pthread_cancel.3:83 build/C/man3/pthread_cleanup_push.3:73
2294 #: build/C/man3/pthread_cancel.3:88
2296 "Thread-specific data destructors are called, in an unspecified order. (See "
2297 "B<pthread_key_create>(3).)"
2301 #: build/C/man3/pthread_cancel.3:88 build/C/man3/pthread_cleanup_push.3:81
2307 #: build/C/man3/pthread_cancel.3:92
2308 msgid "The thread is terminated. (See B<pthread_exit>(3).)"
2312 #: build/C/man3/pthread_cancel.3:100
2314 "The above steps happen asynchronously with respect to the "
2315 "B<pthread_cancel>() call; the return status of B<pthread_cancel>() merely "
2316 "informs the caller whether the cancellation request was successfully queued."
2320 #: build/C/man3/pthread_cancel.3:109
2322 "After a canceled thread has terminated, a join with that thread using "
2323 "B<pthread_join>(3) obtains B<PTHREAD_CANCELED> as the thread's exit "
2324 "status. (Joining with a thread is the only way to know that cancellation "
2329 #: build/C/man3/pthread_cancel.3:114
2331 "On success, B<pthread_cancel>() returns 0; on error, it returns a nonzero "
2336 #: build/C/man3/pthread_cancel.3:115 build/C/man3/pthread_detach.3:59 build/C/man3/pthread_getcpuclockid.3:58 build/C/man3/pthread_join.3:93 build/C/man3/pthread_kill.3:61 build/C/man3/pthread_setaffinity_np.3:114 build/C/man3/pthread_setschedparam.3:114 build/C/man3/pthread_setschedprio.3:70 build/C/man3/pthread_sigqueue.3:85
2342 #: build/C/man3/pthread_cancel.3:122 build/C/man3/pthread_detach.3:64 build/C/man3/pthread_getcpuclockid.3:63 build/C/man3/pthread_join.3:98 build/C/man3/pthread_kill.3:66 build/C/man3/pthread_setaffinity_np.3:119 build/C/man3/pthread_setschedparam.3:119 build/C/man3/pthread_setschedprio.3:75
2343 msgid "No thread with the ID I<thread> could be found."
2347 #: build/C/man3/pthread_cancel.3:132
2349 "On Linux, cancellation is implemented using signals. Under the NPTL "
2350 "threading implementation, the first real-time signal (i.e., signal 32) is "
2351 "used for this purpose. On LinuxThreads, the second real-time signal is "
2352 "used, if real-time signals are available, otherwise B<SIGUSR2> is used."
2356 #: build/C/man3/pthread_cancel.3:138
2358 "The program below creates a thread and then cancels it. The main thread "
2359 "joins with the canceled thread to check that its exit status was "
2360 "B<PTHREAD_CANCELED>. The following shell session shows what happens when we "
2365 #: build/C/man3/pthread_cancel.3:146
2369 "thread_func(): started; cancellation disabled\n"
2370 "main(): sending cancellation request\n"
2371 "thread_func(): about to enable cancellation\n"
2372 "main(): thread was canceled\n"
2376 #: build/C/man3/pthread_cancel.3:156
2379 "#include E<lt>pthread.hE<gt>\n"
2380 "#include E<lt>stdio.hE<gt>\n"
2381 "#include E<lt>errno.hE<gt>\n"
2382 "#include E<lt>stdlib.hE<gt>\n"
2383 "#include E<lt>unistd.hE<gt>\n"
2387 #: build/C/man3/pthread_cancel.3:164
2391 "thread_func(void *ignored_argument)\n"
2397 #: build/C/man3/pthread_cancel.3:167
2400 " /* Disable cancellation for a while, so that we don\\(aqt\n"
2401 " immediately react to a cancellation request */\n"
2405 #: build/C/man3/pthread_cancel.3:171
2408 " s = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);\n"
2410 " handle_error_en(s, \"pthread_setcancelstate\");\n"
2414 #: build/C/man3/pthread_cancel.3:175
2417 " printf(\"thread_func(): started; cancellation disabled\\en\");\n"
2419 " printf(\"thread_func(): about to enable cancellation\\en\");\n"
2423 #: build/C/man3/pthread_cancel.3:179
2426 " s = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);\n"
2428 " handle_error_en(s, \"pthread_setcancelstate\");\n"
2432 #: build/C/man3/pthread_cancel.3:181
2434 msgid " /* sleep() is a cancellation point */\n"
2438 #: build/C/man3/pthread_cancel.3:183
2440 msgid " sleep(1000); /* Should get canceled while we sleep */\n"
2444 #: build/C/man3/pthread_cancel.3:185
2446 msgid " /* Should never get here */\n"
2450 #: build/C/man3/pthread_cancel.3:189
2453 " printf(\"thread_func(): not canceled!\\en\");\n"
2459 #: build/C/man3/pthread_cancel.3:196
2471 #: build/C/man3/pthread_cancel.3:198
2473 msgid " /* Start a thread and then send it a cancellation request */\n"
2477 #: build/C/man3/pthread_cancel.3:202
2480 " s = pthread_create(&thr, NULL, &thread_func, NULL);\n"
2482 " handle_error_en(s, \"pthread_create\");\n"
2486 #: build/C/man3/pthread_cancel.3:204
2488 msgid " sleep(2); /* Give thread a chance to get started */\n"
2492 #: build/C/man3/pthread_cancel.3:209
2495 " printf(\"main(): sending cancellation request\\en\");\n"
2496 " s = pthread_cancel(thr);\n"
2498 " handle_error_en(s, \"pthread_cancel\");\n"
2502 #: build/C/man3/pthread_cancel.3:211
2504 msgid " /* Join with thread to see what its exit status was */\n"
2508 #: build/C/man3/pthread_cancel.3:215 build/C/man3/pthread_cleanup_push.3:303
2511 " s = pthread_join(thr, &res);\n"
2513 " handle_error_en(s, \"pthread_join\");\n"
2517 #: build/C/man3/pthread_cancel.3:222
2520 " if (res == PTHREAD_CANCELED)\n"
2521 " printf(\"main(): thread was canceled\\en\");\n"
2523 " printf(\"main(): thread wasn\\(aqt canceled (shouldn\\(aqt "
2524 "happen!)\\en\");\n"
2525 " exit(EXIT_SUCCESS);\n"
2530 #: build/C/man3/pthread_cancel.3:235
2532 "B<pthread_cleanup_push>(3), B<pthread_create>(3), B<pthread_exit>(3), "
2533 "B<pthread_join>(3), B<pthread_key_create>(3), B<pthread_setcancelstate>(3), "
2534 "B<pthread_setcanceltype>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
2538 #: build/C/man3/pthread_cleanup_push.3:26
2540 msgid "PTHREAD_CLEANUP_PUSH"
2544 #: build/C/man3/pthread_cleanup_push.3:26 build/C/man3/pthread_setcancelstate.3:26
2550 #: build/C/man3/pthread_cleanup_push.3:30
2552 "pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancellation "
2557 #: build/C/man3/pthread_cleanup_push.3:37
2560 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *),>\n"
2561 "B< void *>I<arg>B<);>\n"
2562 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
2566 #: build/C/man3/pthread_cleanup_push.3:48
2568 "These functions manipulate the calling thread's stack of thread-cancellation "
2569 "clean-up handlers. A clean-up handler is a function that is automatically "
2570 "executed when a thread is canceled (or in various other circumstances "
2571 "described below); it might, for example, unlock a mutex so that it becomes "
2572 "available to other threads in the process."
2576 #: build/C/man3/pthread_cleanup_push.3:59
2578 "The B<pthread_cleanup_push>() function pushes I<routine> onto the top of "
2579 "the stack of clean-up handlers. When I<routine> is later invoked, it will "
2580 "be given I<arg> as its argument."
2584 #: build/C/man3/pthread_cleanup_push.3:66
2586 "The B<pthread_cleanup_pop>() function removes the routine at the top of the "
2587 "stack of clean-up handlers, and optionally executes it if I<execute> is "
2592 #: build/C/man3/pthread_cleanup_push.3:69
2594 "A cancellation clean-up handler is popped from the stack and executed in the "
2595 "following circumstances:"
2599 #: build/C/man3/pthread_cleanup_push.3:73
2601 "When a thread is canceled, all of the stacked clean-up handlers are popped "
2602 "and executed in the reverse of the order in which they were pushed onto the "
2607 #: build/C/man3/pthread_cleanup_push.3:81
2609 "When a thread terminates by calling B<pthread_exit>(3), all clean-up "
2610 "handlers are executed as described in the preceding point. (Clean-up "
2611 "handlers are I<not> called if the thread terminates by performing a "
2612 "I<return> from the thread start function.)"
2616 #: build/C/man3/pthread_cleanup_push.3:87
2618 "When a thread calls B<pthread_cleanup_pop>() with a nonzero I<execute> "
2619 "argument, the top-most clean-up handler is popped and executed."
2623 #: build/C/man3/pthread_cleanup_push.3:99
2625 "POSIX.1 permits B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() to "
2626 "be implemented as macros that expand to text containing \\(aqB<{>\\(aq and "
2627 "\\(aqB<}>\\(aq, respectively. For this reason, the caller must ensure that "
2628 "calls to these functions are paired within the same function, and at the "
2629 "same lexical nesting level. (In other words, a clean-up handler is only "
2630 "established during the execution of a specified section of code.)"
2634 #: build/C/man3/pthread_cleanup_push.3:119
2636 "Calling B<longjmp>(3) (B<siglongjmp>(3)) produces undefined results if any "
2637 "call has been made to B<pthread_cleanup_push>() or B<pthread_cleanup_pop>() "
2638 "without the matching call of the pair since the jump buffer was filled by "
2639 "B<setjmp>(3) (B<sigsetjmp>(3)). Likewise, calling B<longjmp>(3) "
2640 "(B<siglongjmp>(3)) from inside a clean-up handler produces undefined "
2641 "results unless the jump buffer was also filled by B<setjmp>(3) "
2642 "(B<sigsetjmp>(3)) inside the handler."
2646 #: build/C/man3/pthread_cleanup_push.3:121
2647 msgid "These functions do not return a value."
2651 #. Available since glibc 2.0
2653 #: build/C/man3/pthread_cleanup_push.3:125
2654 msgid "There are no errors."
2658 #: build/C/man3/pthread_cleanup_push.3:136
2660 "On Linux, the B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() "
2661 "functions I<are> implemented as macros that expand to text containing "
2662 "\\(aqB<{>\\(aq and \\(aqB<}>\\(aq, respectively. This means that variables "
2663 "declared within the scope of paired calls to these functions will only be "
2664 "visible within that scope."
2667 #. The text was actually added in the 2004 TC2
2669 #: build/C/man3/pthread_cleanup_push.3:151
2671 "POSIX.1 says that the effect of using I<return>, I<break>, I<continue>, or "
2672 "I<goto> to prematurely leave a block bracketed B<pthread_cleanup_push>() "
2673 "and B<pthread_cleanup_pop>() is undefined. Portable applications should "
2678 #: build/C/man3/pthread_cleanup_push.3:166
2680 "The program below provides a simple example of the use of the functions "
2681 "described in this page. The program creates a thread that executes a loop "
2682 "bracketed by B<pthread_cleanup_push>() and B<pthread_cleanup_pop>(). This "
2683 "loop increments a global variable, I<cnt>, once each second. Depending on "
2684 "what command-line arguments are supplied, the main thread sends the other "
2685 "thread a cancellation request, or sets a global variable that causes the "
2686 "other thread to exit its loop and terminate normally (by doing a I<return>)."
2690 #: build/C/man3/pthread_cleanup_push.3:169
2692 "In the following shell session, the main thread sends a cancellation request "
2693 "to the other thread:"
2697 #: build/C/man3/pthread_cleanup_push.3:179
2701 "New thread started\n"
2704 "Canceling thread\n"
2705 "Called clean-up handler\n"
2706 "Thread was canceled; cnt = 0\n"
2710 #: build/C/man3/pthread_cleanup_push.3:187
2712 "From the above, we see that the thread was canceled, and that the "
2713 "cancellation clean-up handler was called and it reset the value of the "
2714 "global variable I<cnt> to 0."
2718 #: build/C/man3/pthread_cleanup_push.3:190
2720 "In the next run, the main program sets a global variable that causes other "
2721 "thread to terminate normally:"
2725 #: build/C/man3/pthread_cleanup_push.3:198
2729 "New thread started\n"
2732 "Thread terminated normally; cnt = 2\n"
2736 #: build/C/man3/pthread_cleanup_push.3:206
2738 "From the above, we see that the clean-up handler was not executed (because "
2739 "I<cleanup_pop_arg> was 0), and therefore the value of I<cnt> was not reset."
2743 #: build/C/man3/pthread_cleanup_push.3:211
2745 "In the next run, the main program sets a global variable that causes the "
2746 "other thread to terminate normally, and supplies a nonzero value for "
2747 "I<cleanup_pop_arg>:"
2751 #: build/C/man3/pthread_cleanup_push.3:220
2754 "$ B<./a.out x 1>\n"
2755 "New thread started\n"
2758 "Called clean-up handler\n"
2759 "Thread terminated normally; cnt = 0\n"
2763 #: build/C/man3/pthread_cleanup_push.3:227
2765 "In the above, we see that although the thread was not canceled, the clean-up "
2766 "handler was executed, because the argument given to B<pthread_cleanup_pop>() "
2771 #: build/C/man3/pthread_cleanup_push.3:236
2774 "#include E<lt>pthread.hE<gt>\n"
2775 "#include E<lt>sys/types.hE<gt>\n"
2776 "#include E<lt>stdio.hE<gt>\n"
2777 "#include E<lt>stdlib.hE<gt>\n"
2778 "#include E<lt>unistd.hE<gt>\n"
2779 "#include E<lt>errno.hE<gt>\n"
2783 #: build/C/man3/pthread_cleanup_push.3:243
2786 "static int done = 0;\n"
2787 "static int cleanup_pop_arg = 0;\n"
2788 "static int cnt = 0;\n"
2792 #: build/C/man3/pthread_cleanup_push.3:250
2796 "cleanup_handler(void *arg)\n"
2798 " printf(\"Called clean-up handler\\en\");\n"
2804 #: build/C/man3/pthread_cleanup_push.3:255
2808 "thread_start(void *arg)\n"
2810 " time_t start, curr;\n"
2814 #: build/C/man3/pthread_cleanup_push.3:257
2816 msgid " printf(\"New thread started\\en\");\n"
2820 #: build/C/man3/pthread_cleanup_push.3:259
2822 msgid " pthread_cleanup_push(cleanup_handler, NULL);\n"
2826 #: build/C/man3/pthread_cleanup_push.3:261
2828 msgid " curr = start = time(NULL);\n"
2832 #: build/C/man3/pthread_cleanup_push.3:270
2835 " while (!done) {\n"
2836 " pthread_testcancel(); /* A cancellation point */\n"
2837 " if (curr E<lt> time(NULL)) {\n"
2838 " curr = time(NULL);\n"
2839 " printf(\"cnt = %d\\en\", cnt); /* A cancellation point */\n"
2846 #: build/C/man3/pthread_cleanup_push.3:274
2849 " pthread_cleanup_pop(cleanup_pop_arg);\n"
2855 #: build/C/man3/pthread_cleanup_push.3:281
2859 "main(int argc, char *argv[])\n"
2867 #: build/C/man3/pthread_cleanup_push.3:285
2870 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
2872 " handle_error_en(s, \"pthread_create\");\n"
2876 #: build/C/man3/pthread_cleanup_push.3:287
2878 msgid " sleep(2); /* Allow new thread to run a while */\n"
2882 #: build/C/man3/pthread_cleanup_push.3:292
2885 " if (argc E<gt> 1) {\n"
2886 " if (argc E<gt> 2)\n"
2887 " cleanup_pop_arg = atoi(argv[2]);\n"
2892 #: build/C/man3/pthread_cleanup_push.3:299
2896 " printf(\"Canceling thread\\en\");\n"
2897 " s = pthread_cancel(thr);\n"
2899 " handle_error_en(s, \"pthread_cancel\");\n"
2904 #: build/C/man3/pthread_cleanup_push.3:310
2907 " if (res == PTHREAD_CANCELED)\n"
2908 " printf(\"Thread was canceled; cnt = %d\\en\", cnt);\n"
2910 " printf(\"Thread terminated normally; cnt = %d\\en\", cnt);\n"
2911 " exit(EXIT_SUCCESS);\n"
2916 #: build/C/man3/pthread_cleanup_push.3:317
2918 "B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), "
2919 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
2923 #: build/C/man3/pthread_cleanup_push_defer_np.3:26
2925 msgid "PTHREAD_CLEANUP_PUSH_DEFER_NP"
2929 #: build/C/man3/pthread_cleanup_push_defer_np.3:26
2935 #: build/C/man3/pthread_cleanup_push_defer_np.3:30
2937 "pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np - push and pop "
2938 "thread cancellation clean-up handlers while saving cancelability type"
2942 #: build/C/man3/pthread_cleanup_push_defer_np.3:37
2945 "B<void pthread_cleanup_push_defer_np(void (*>I<routine>B<)(void *),>\n"
2946 "B< void *>I<arg>B<);>\n"
2947 "B<void pthread_cleanup_pop_restore_np(int >I<execute>B<);>\n"
2951 #: build/C/man3/pthread_cleanup_push_defer_np.3:40 build/C/man3/pthread_create.3:38 build/C/man3/pthread_detach.3:37 build/C/man3/pthread_join.3:37 build/C/man3/pthread_kill.3:37 build/C/man3/pthread_setname_np.3:39 build/C/man3/pthread_sigmask.3:38 build/C/man3/pthread_sigqueue.3:37 build/C/man3/pthread_tryjoin_np.3:42 build/C/man3/pthread_yield.3:37
2952 msgid "Compile and link with I<-pthread>."
2956 #: build/C/man3/pthread_cleanup_push_defer_np.3:46
2958 "These functions are the same as B<pthread_cleanup_push>(3) and "
2959 "B<pthread_cleanup_pop>(3), except for the differences noted on this page."
2963 #: build/C/man3/pthread_cleanup_push_defer_np.3:59
2965 "Like B<pthread_cleanup_push>(3), B<pthread_cleanup_push_defer_np>() pushes "
2966 "I<routine> onto the thread's stack of cancellation clean-up handlers. In "
2967 "addition, it also saves the thread's current cancelability type, and sets "
2968 "the cancelability type to \"deferred\" (see B<pthread_setcanceltype>(3)); "
2969 "this ensures that cancellation clean-up will occur even if the thread's "
2970 "cancelability type was \"asynchronous\" before the call."
2974 #: build/C/man3/pthread_cleanup_push_defer_np.3:68
2976 "Like B<pthread_cleanup_pop>(3), B<pthread_cleanup_pop_restore_np>() pops "
2977 "the top-most clean-up handler from the thread's stack of cancellation "
2978 "clean-up handlers. In addition, it restores the thread's cancelability type "
2979 "to its value at the time of the matching B<pthread_cleanup_push_defer_np>()."
2983 #: build/C/man3/pthread_cleanup_push_defer_np.3:74
2985 "The caller must ensure that calls to these functions are paired within the "
2986 "same function, and at the same lexical nesting level. Other restrictions "
2987 "apply, as described in B<pthread_cleanup_push>(3)."
2991 #: build/C/man3/pthread_cleanup_push_defer_np.3:76
2992 msgid "This sequence of calls:"
2996 #: build/C/man3/pthread_cleanup_push_defer_np.3:81
2999 "pthread_cleanup_push_defer_np(routine, arg);\n"
3000 "pthread_cleanup_pop_restore_np(execute);\n"
3004 #: build/C/man3/pthread_cleanup_push_defer_np.3:85
3005 msgid "is equivalent to (but shorter and more efficient than):"
3009 #: build/C/man3/pthread_cleanup_push_defer_np.3:91
3011 msgid "int oldtype;\n"
3015 #: build/C/man3/pthread_cleanup_push_defer_np.3:97
3018 "pthread_cleanup_push(routine, arg);\n"
3019 "pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);\n"
3021 "pthread_setcanceltype(oldtype, NULL);\n"
3022 "pthread_cleanup_pop(execute);\n"
3026 #: build/C/man3/pthread_cleanup_push_defer_np.3:110
3028 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
3029 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3033 #: build/C/man3/pthread_create.3:26
3035 msgid "PTHREAD_CREATE"
3039 #: build/C/man3/pthread_create.3:26 build/C/man3/pthread_sigmask.3:26
3045 #: build/C/man3/pthread_create.3:29
3046 msgid "pthread_create - create a new thread"
3050 #: build/C/man3/pthread_create.3:35
3053 "B<int pthread_create(pthread_t *>I<thread>B<, const pthread_attr_t "
3055 "B< void *(*>I<start_routine>B<) (void *), void "
3060 #: build/C/man3/pthread_create.3:47
3062 "The B<pthread_create>() function starts a new thread in the calling "
3063 "process. The new thread starts execution by invoking I<start_routine>(); "
3064 "I<arg> is passed as the sole argument of I<start_routine>()."
3068 #: build/C/man3/pthread_create.3:49
3069 msgid "The new thread terminates in one of the following ways:"
3073 #: build/C/man3/pthread_create.3:49 build/C/man3/pthread_create.3:55 build/C/man3/pthread_create.3:63 build/C/man3/pthread_create.3:66 build/C/man3/pthread_getattr_np.3:52 build/C/man3/pthread_getattr_np.3:55 build/C/man3/pthread_getattr_np.3:58
3079 #: build/C/man3/pthread_create.3:55
3081 "It calls B<pthread_exit>(3), specifying an exit status value that is "
3082 "available to another thread in the same process that calls "
3083 "B<pthread_join>(3)."
3087 #: build/C/man3/pthread_create.3:63
3089 "It returns from I<start_routine>(). This is equivalent to calling "
3090 "B<pthread_exit>(3) with the value supplied in the I<return> statement."
3094 #: build/C/man3/pthread_create.3:66
3095 msgid "It is canceled (see B<pthread_cancel>(3))."
3099 #: build/C/man3/pthread_create.3:72
3101 "Any of the threads in the process calls B<exit>(3), or the main thread "
3102 "performs a return from I<main>(). This causes the termination of all "
3103 "threads in the process."
3107 #: build/C/man3/pthread_create.3:86
3109 "The I<attr> argument points to a I<pthread_attr_t> structure whose contents "
3110 "are used at thread creation time to determine attributes for the new thread; "
3111 "this structure is initialized using B<pthread_attr_init>(3) and related "
3112 "functions. If I<attr> is NULL, then the thread is created with default "
3117 #: build/C/man3/pthread_create.3:93
3119 "Before returning, a successful call to B<pthread_create>() stores the ID of "
3120 "the new thread in the buffer pointed to by I<thread>; this identifier is "
3121 "used to refer to the thread in subsequent calls to other pthreads functions."
3125 #: build/C/man3/pthread_create.3:101
3127 "The new thread inherits a copy of the creating thread's signal mask "
3128 "(B<pthread_sigmask>(3)). The set of pending signals for the new thread is "
3129 "empty (B<sigpending>(2)). The new thread does not inherit the creating "
3130 "thread's alternate signal stack (B<sigaltstack>(2))."
3134 #: build/C/man3/pthread_create.3:104
3136 "The new thread inherits the calling thread's floating-point environment "
3140 #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
3142 #: build/C/man3/pthread_create.3:109
3144 "The initial value of the new thread's CPU-time clock is 0 (see "
3145 "B<pthread_getcpuclockid>(3))."
3149 #: build/C/man3/pthread_create.3:109
3151 msgid "Linux-specific details"
3155 #: build/C/man3/pthread_create.3:115
3157 "The new thread inherits copies of the calling thread's capability sets (see "
3158 "B<capabilities>(7)) and CPU affinity mask (see B<sched_setaffinity>(2))."
3162 #: build/C/man3/pthread_create.3:122
3164 "On success, B<pthread_create>() returns 0; on error, it returns an error "
3165 "number, and the contents of I<*thread> are undefined."
3169 #: build/C/man3/pthread_create.3:123 build/C/man3/pthread_sigqueue.3:71
3175 #: build/C/man3/pthread_create.3:137
3177 "Insufficient resources to create another thread, or a system-imposed limit "
3178 "on the number of threads was encountered. The latter case may occur in two "
3179 "ways: the B<RLIMIT_NPROC> soft resource limit (set via B<setrlimit>(2)), "
3180 "which limits the number of process for a real user ID, was reached; or the "
3181 "kernel's system-wide limit on the number of threads, "
3182 "I</proc/sys/kernel/threads-max>, was reached."
3186 #: build/C/man3/pthread_create.3:141
3187 msgid "Invalid settings in I<attr>."
3191 #: build/C/man3/pthread_create.3:141 build/C/man3/pthread_setschedparam.3:129 build/C/man3/pthread_setschedprio.3:66
3197 #: build/C/man3/pthread_create.3:146
3199 "No permission to set the scheduling policy and parameters specified in "
3204 #: build/C/man3/pthread_create.3:160
3206 "See B<pthread_self>(3) for further information on the thread ID returned in "
3207 "I<*thread> by B<pthread_create>(). Unless real-time scheduling policies are "
3208 "being employed, after a call to B<pthread_create>(), it is indeterminate "
3209 "which thread\\(emthe caller or the new thread\\(emwill next execute."
3213 #: build/C/man3/pthread_create.3:180
3215 "A thread may either be I<joinable> or I<detached>. If a thread is joinable, "
3216 "then another thread can call B<pthread_join>(3) to wait for the thread to "
3217 "terminate and fetch its exit status. Only when a terminated joinable thread "
3218 "has been joined are the last of its resources released back to the system. "
3219 "When a detached thread terminates, its resources are automatically released "
3220 "back to the system: it is not possible to join with the thread in order to "
3221 "obtain its exit status. Making a thread detached is useful for some types "
3222 "of daemon threads whose exit status the application does not need to care "
3223 "about. By default, a new thread is created in a joinable state, unless "
3224 "I<attr> was set to create the thread in a detached state (using "
3225 "B<pthread_attr_setdetachstate>(3))."
3228 #. FIXME . Perhaps some of the following detail should be in
3229 #. a future pthread_attr_setstacksize(3) page.
3231 #: build/C/man3/pthread_create.3:196
3233 "On Linux/x86-32, the default stack size for a new thread is 2 megabytes. "
3234 "Under the NPTL threading implementation, if the B<RLIMIT_STACK> soft "
3235 "resource limit I<at the time the program started> has any value other than "
3236 "\"unlimited\", then it determines the default stack size of new threads. "
3237 "Using B<pthread_attr_setstacksize>(3), the stack size attribute can be "
3238 "explicitly set in the I<attr> argument used to create a thread, in order to "
3239 "obtain a stack size other than the default."
3243 #: build/C/man3/pthread_create.3:202
3245 "In the obsolete LinuxThreads implementation, each of the threads in a "
3246 "process has a different process ID. This is in violation of the POSIX "
3247 "threads specification, and is the source of many other nonconformances to "
3248 "the standard; see B<pthreads>(7)."
3252 #: build/C/man3/pthread_create.3:206
3254 "The program below demonstrates the use of B<pthread_create>(), as well as a "
3255 "number of other functions in the pthreads API."
3259 #: build/C/man3/pthread_create.3:211
3261 "In the following run, on a system providing the NPTL threading "
3262 "implementation, the stack size defaults to the value given by the \"stack "
3263 "size\" resource limit:"
3267 #: build/C/man3/pthread_create.3:223
3271 "8192 # The stack size limit is 8 MB (0x80000 bytes)\n"
3272 "$B< ./a.out hola salut servus>\n"
3273 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
3274 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
3275 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
3276 "Joined with thread 1; returned value was HOLA\n"
3277 "Joined with thread 2; returned value was SALUT\n"
3278 "Joined with thread 3; returned value was SERVUS\n"
3282 #: build/C/man3/pthread_create.3:229
3284 "In the next run, the program explicitly sets a stack size of 1MB (using "
3285 "B<pthread_attr_setstacksize>(3)) for the created threads:"
3289 #: build/C/man3/pthread_create.3:239
3292 "$B< ./a.out -s 0x100000 hola salut servus>\n"
3293 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
3294 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
3295 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
3296 "Joined with thread 1; returned value was HOLA\n"
3297 "Joined with thread 2; returned value was SALUT\n"
3298 "Joined with thread 3; returned value was SERVUS\n"
3302 #: build/C/man3/pthread_create.3:251
3305 "#include E<lt>pthread.hE<gt>\n"
3306 "#include E<lt>string.hE<gt>\n"
3307 "#include E<lt>stdio.hE<gt>\n"
3308 "#include E<lt>stdlib.hE<gt>\n"
3309 "#include E<lt>unistd.hE<gt>\n"
3310 "#include E<lt>errno.hE<gt>\n"
3311 "#include E<lt>ctype.hE<gt>\n"
3315 #: build/C/man3/pthread_create.3:257 build/C/man3/pthread_getcpuclockid.3:110
3318 "#define handle_error(msg) \\e\n"
3319 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
3323 #: build/C/man3/pthread_create.3:263
3326 "struct thread_info { /* Used as argument to thread_start() */\n"
3327 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
3328 " int thread_num; /* Application-defined thread # */\n"
3329 " char *argv_string; /* From command-line argument */\n"
3334 #: build/C/man3/pthread_create.3:266
3337 "/* Thread start function: display address near top of our stack,\n"
3338 " and return upper-cased copy of argv_string */\n"
3342 #: build/C/man3/pthread_create.3:272
3346 "thread_start(void *arg)\n"
3348 " struct thread_info *tinfo = arg;\n"
3349 " char *uargv, *p;\n"
3353 #: build/C/man3/pthread_create.3:275
3356 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n"
3357 " tinfo-E<gt>thread_num, &p, tinfo-E<gt>argv_string);\n"
3361 #: build/C/man3/pthread_create.3:279
3364 " uargv = strdup(tinfo-E<gt>argv_string);\n"
3365 " if (uargv == NULL)\n"
3366 " handle_error(\"strdup\");\n"
3370 #: build/C/man3/pthread_create.3:282
3373 " for (p = uargv; *p != \\(aq\\e0\\(aq; p++)\n"
3374 " *p = toupper(*p);\n"
3378 #: build/C/man3/pthread_create.3:285
3386 #: build/C/man3/pthread_create.3:294
3390 "main(int argc, char *argv[])\n"
3392 " int s, tnum, opt, num_threads;\n"
3393 " struct thread_info *tinfo;\n"
3394 " pthread_attr_t attr;\n"
3395 " int stack_size;\n"
3400 #: build/C/man3/pthread_create.3:296
3402 msgid " /* The \"-s\" option specifies a stack size for our threads */\n"
3406 #: build/C/man3/pthread_create.3:303
3409 " stack_size = -1;\n"
3410 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
3412 " case \\(aqs\\(aq:\n"
3413 " stack_size = strtoul(optarg, NULL, 0);\n"
3418 #: build/C/man3/pthread_create.3:310
3422 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n"
3424 " exit(EXIT_FAILURE);\n"
3430 #: build/C/man3/pthread_create.3:312
3432 msgid " num_threads = argc - optind;\n"
3436 #: build/C/man3/pthread_create.3:314
3438 msgid " /* Initialize thread creation attributes */\n"
3442 #: build/C/man3/pthread_create.3:318
3445 " s = pthread_attr_init(&attr);\n"
3447 " handle_error_en(s, \"pthread_attr_init\");\n"
3451 #: build/C/man3/pthread_create.3:324
3454 " if (stack_size E<gt> 0) {\n"
3455 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
3457 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
3462 #: build/C/man3/pthread_create.3:326
3464 msgid " /* Allocate memory for pthread_create() arguments */\n"
3468 #: build/C/man3/pthread_create.3:330
3471 " tinfo = calloc(num_threads, sizeof(struct thread_info));\n"
3472 " if (tinfo == NULL)\n"
3473 " handle_error(\"calloc\");\n"
3477 #: build/C/man3/pthread_create.3:332
3479 msgid " /* Create one thread for each command-line argument */\n"
3483 #: build/C/man3/pthread_create.3:336
3486 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
3487 " tinfo[tnum].thread_num = tnum + 1;\n"
3488 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
3492 #: build/C/man3/pthread_create.3:339
3495 " /* The pthread_create() call stores the thread ID into\n"
3496 " corresponding element of tinfo[] */\n"
3500 #: build/C/man3/pthread_create.3:345
3503 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
3504 " &thread_start, &tinfo[tnum]);\n"
3506 " handle_error_en(s, \"pthread_create\");\n"
3511 #: build/C/man3/pthread_create.3:348
3514 " /* Destroy the thread attributes object, since it is no\n"
3515 " longer needed */\n"
3519 #: build/C/man3/pthread_create.3:352 build/C/man3/pthread_setschedparam.3:423
3522 " s = pthread_attr_destroy(&attr);\n"
3524 " handle_error_en(s, \"pthread_attr_destroy\");\n"
3528 #: build/C/man3/pthread_create.3:354
3530 msgid " /* Now join with each thread, and display its returned value */\n"
3534 #: build/C/man3/pthread_create.3:359
3537 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
3538 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
3540 " handle_error_en(s, \"pthread_join\");\n"
3544 #: build/C/man3/pthread_create.3:364
3547 " printf(\"Joined with thread %d; returned value was %s\\en\",\n"
3548 " tinfo[tnum].thread_num, (char *) res);\n"
3549 " free(res); /* Free memory allocated by thread */\n"
3554 #: build/C/man3/pthread_create.3:368
3558 " exit(EXIT_SUCCESS);\n"
3563 #: build/C/man3/pthread_create.3:382
3565 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
3566 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
3567 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), "
3572 #: build/C/man3/pthread_detach.3:26
3574 msgid "PTHREAD_DETACH"
3578 #: build/C/man3/pthread_detach.3:26 build/C/man3/pthread_join.3:26
3584 #: build/C/man3/pthread_detach.3:29
3585 msgid "pthread_detach - detach a thread"
3589 #: build/C/man3/pthread_detach.3:34
3591 msgid "B<int pthread_detach(pthread_t >I<thread>B<);>\n"
3595 #: build/C/man3/pthread_detach.3:46
3597 "The B<pthread_detach>() function marks the thread identified by I<thread> "
3598 "as detached. When a detached thread terminates, its resources are "
3599 "automatically released back to the system without the need for another "
3600 "thread to join with the terminated thread."
3604 #: build/C/man3/pthread_detach.3:49
3606 "Attempting to detach an already detached thread results in unspecified "
3611 #: build/C/man3/pthread_detach.3:54
3613 "On success, B<pthread_detach>() returns 0; on error, it returns an error "
3618 #: build/C/man3/pthread_detach.3:59 build/C/man3/pthread_join.3:89
3619 msgid "I<thread> is not a joinable thread."
3623 #: build/C/man3/pthread_detach.3:70
3625 "Once a thread has been detached, it can't be joined with B<pthread_join>(3) "
3626 "or be made joinable again."
3630 #: build/C/man3/pthread_detach.3:77
3632 "A new thread can be created in a detached state using "
3633 "B<pthread_attr_setdetachstate>(3) to set the detached attribute of the "
3634 "I<attr> argument of B<pthread_create>(3)."
3638 #: build/C/man3/pthread_detach.3:84
3640 "The detached attribute merely determines the behavior of the system when the "
3641 "thread terminates; it does not prevent the thread from being terminated if "
3642 "the process terminates using B<exit>(3) (or equivalently, if the main "
3647 #: build/C/man3/pthread_detach.3:93
3649 "Either B<pthread_join>(3) or B<pthread_detach>() should be called for each "
3650 "thread that an application creates, so that system resources for the thread "
3651 "can be released. (But note that the resources of all threads are freed when "
3652 "the process terminates.)"
3656 #: build/C/man3/pthread_detach.3:95
3657 msgid "The following statement detaches the calling thread:"
3661 #: build/C/man3/pthread_detach.3:97
3663 msgid " pthread_detach(pthread_self());\n"
3667 #: build/C/man3/pthread_detach.3:104
3669 "B<pthread_attr_setdetachstate>(3), B<pthread_cancel>(3), "
3670 "B<pthread_create>(3), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
3674 #: build/C/man3/pthread_equal.3:26
3676 msgid "PTHREAD_EQUAL"
3680 #: build/C/man3/pthread_equal.3:26 build/C/man3/pthread_exit.3:26
3686 #: build/C/man3/pthread_equal.3:29
3687 msgid "pthread_equal - compare thread IDs"
3691 #: build/C/man3/pthread_equal.3:34
3693 msgid "B<int pthread_equal(pthread_t >I<t1>B<, pthread_t >I<t2>B<);>\n"
3697 #: build/C/man3/pthread_equal.3:41
3698 msgid "The B<pthread_equal>() function compares two thread identifiers."
3702 #: build/C/man3/pthread_equal.3:45
3704 "If the two thread IDs are equal, B<pthread_equal>() returns a nonzero "
3705 "value; otherwise, it returns 0."
3709 #. Available since glibc 2.0
3711 #: build/C/man3/pthread_equal.3:47 build/C/man3/pthread_exit.3:75 build/C/man3/pthread_self.3:50 build/C/man3/pthread_testcancel.3:58
3712 msgid "This function always succeeds."
3716 #: build/C/man3/pthread_equal.3:56
3718 "The B<pthread_equal>() function is necessary because thread IDs should be "
3719 "considered opaque: there is no portable way for applications to directly "
3720 "compare two I<pthread_t> values."
3724 #: build/C/man3/pthread_equal.3:60
3725 msgid "B<pthread_create>(3), B<pthread_self>(3), B<pthreads>(7)"
3729 #: build/C/man3/pthread_exit.3:26
3731 msgid "PTHREAD_EXIT"
3735 #: build/C/man3/pthread_exit.3:29
3736 msgid "pthread_exit - terminate calling thread"
3740 #: build/C/man3/pthread_exit.3:34
3742 msgid "B<void pthread_exit(void *>I<retval>B<);>\n"
3746 #: build/C/man3/pthread_exit.3:45
3748 "The B<pthread_exit>() function terminates the calling thread and returns a "
3749 "value via I<retval> that (if the thread is joinable) is available to "
3750 "another thread in the same process that calls B<pthread_join>(3)."
3754 #: build/C/man3/pthread_exit.3:55
3756 "Any clean-up handlers established by B<pthread_cleanup_push>(3) that have "
3757 "not yet been popped, are popped (in the reverse of the order in which they "
3758 "were pushed) and executed. If the thread has any thread-specific data, "
3759 "then, after the clean-up handlers have been executed, the corresponding "
3760 "destructor functions are called, in an unspecified order."
3764 #: build/C/man3/pthread_exit.3:62
3766 "When a thread terminates, process-shared resources (e.g., mutexes, condition "
3767 "variables, semaphores, and file descriptors) are not released, and functions "
3768 "registered using B<atexit>(3) are not called."
3772 #: build/C/man3/pthread_exit.3:71
3774 "After the last thread in a process terminates, the process terminates as by "
3775 "calling B<exit>(3) with an exit status of zero; thus, process-shared "
3776 "resources are released and functions registered using B<atexit>(3) are "
3781 #: build/C/man3/pthread_exit.3:73
3782 msgid "This function does not return to the caller."
3786 #: build/C/man3/pthread_exit.3:82
3788 "Performing a return from the start function of any thread other than the "
3789 "main thread results in an implicit call to B<pthread_exit>(), using the "
3790 "function's return value as the thread's exit status."
3794 #: build/C/man3/pthread_exit.3:88
3796 "To allow other threads to continue execution, the main thread should "
3797 "terminate by calling B<pthread_exit>() rather than B<exit>(3)."
3801 #: build/C/man3/pthread_exit.3:93
3803 "The value pointed to by I<retval> should not be located on the calling "
3804 "thread's stack, since the contents of that stack are undefined after the "
3805 "thread terminates."
3809 #. FIXME . review a later kernel to see if this gets fixed
3810 #. http://thread.gmane.org/gmane.linux.kernel/611611
3811 #. http://marc.info/?l=linux-kernel&m=122525468300823&w=2
3813 #: build/C/man3/pthread_exit.3:105
3815 "Currently, there are limitations in the kernel implementation logic for "
3816 "B<wait>(2)ing on a stopped thread group with a dead thread group leader. "
3817 "This can manifest in problems such as a locked terminal if a stop signal is "
3818 "sent to a foreground process whose thread group leader has already called "
3819 "B<pthread_exit>()."
3823 #: build/C/man3/pthread_exit.3:109
3824 msgid "B<pthread_create>(3), B<pthread_join>(3), B<pthreads>(7)"
3828 #: build/C/man3/pthread_getattr_np.3:26
3830 msgid "PTHREAD_GETATTR_NP"
3834 #: build/C/man3/pthread_getattr_np.3:29
3835 msgid "pthread_getattr_np - get attributes of created thread"
3839 #: build/C/man3/pthread_getattr_np.3:35
3842 "B<int pthread_getattr_np(pthread_t >I<thread>B<, pthread_attr_t "
3847 #: build/C/man3/pthread_getattr_np.3:45
3849 "The B<pthread_getattr_np>() function initializes the thread attributes "
3850 "object referred to by I<attr> so that it contains actual attribute values "
3851 "describing the running thread I<thread>."
3855 #: build/C/man3/pthread_getattr_np.3:52
3857 "The returned attribute values may differ from the corresponding attribute "
3858 "values passed in the I<attr> object that was used to create the thread using "
3859 "B<pthread_create>(3). In particular, the following attributes may differ:"
3863 #: build/C/man3/pthread_getattr_np.3:55
3865 "the detach state, since a joinable thread may have detached itself after "
3870 #: build/C/man3/pthread_getattr_np.3:58
3871 msgid "the stack size, which the implementation may align to a suitable boundary."
3875 #: build/C/man3/pthread_getattr_np.3:63
3877 "and the guard size, which the implementation may round upward to a multiple "
3878 "of the page size, or ignore (i.e., treat as 0), if the application is "
3879 "allocating its own stack."
3883 #: build/C/man3/pthread_getattr_np.3:68
3885 "Furthermore, if the stack address attribute was not set in the thread "
3886 "attributes object used to create the thread, then the returned thread "
3887 "attributes object will report the actual stack address that the "
3888 "implementation selected for the thread."
3892 #: build/C/man3/pthread_getattr_np.3:73
3894 "When the thread attributes object returned by B<pthread_getattr_np>() is no "
3895 "longer required, it should be destroyed using B<pthread_attr_destroy>(3)."
3899 #: build/C/man3/pthread_getattr_np.3:76 build/C/man3/pthread_getcpuclockid.3:49
3901 "On success, this function returns 0; on error, it returns a nonzero error "
3905 #. Can happen (but unlikely) while trying to allocate memory for cpuset
3907 #: build/C/man3/pthread_getattr_np.3:81
3908 msgid "Insufficient memory."
3912 #: build/C/man3/pthread_getattr_np.3:96
3914 "In addition, if I<thread> refers to the main thread, then "
3915 "B<pthread_getattr_np>() can fail because of errors from various underlying "
3916 "calls: B<fopen>(3), if I</proc/self/maps> can't be opened; and "
3917 "B<getrlimit>(2), if the B<RLIMIT_STACK> resource limit is not supported."
3921 #: build/C/man3/pthread_getattr_np.3:98
3922 msgid "This function is available in glibc since version 2.2.3."
3926 #: build/C/man3/pthread_getattr_np.3:101 build/C/man3/pthread_kill_other_threads_np.3:50
3928 "This function is a nonstandard GNU extension; hence the suffix \"_np\" "
3929 "(nonportable) in the name."
3933 #: build/C/man3/pthread_getattr_np.3:111
3935 "The program below demonstrates the use of B<pthread_getattr_np>(). The "
3936 "program creates a thread that then uses B<pthread_getattr_np>() to retrieve "
3937 "and display its guard size, stack address, and stack size attributes. "
3938 "Command-line arguments can be used to set these attributes to values other "
3939 "than the default when creating the thread. The shell sessions below "
3940 "demonstrate the use of the program."
3944 #: build/C/man3/pthread_getattr_np.3:114
3946 "In the first run, on an x86-32 system, a thread is created using default "
3951 #: build/C/man3/pthread_getattr_np.3:124
3954 "$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2MB\n"
3957 "Attributes of created thread:\n"
3958 " Guard size = 4096 bytes\n"
3959 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
3960 " Stack size = 0x201000 (2101248) bytes\n"
3964 #: build/C/man3/pthread_getattr_np.3:130
3966 "In the following run, we see that if a guard size is specified, it is "
3967 "rounded up to the next multiple of the system page size (4096 bytes on "
3972 #: build/C/man3/pthread_getattr_np.3:138
3975 "$B< ./a.out -g 4097>\n"
3976 "Thread attributes object after initializations:\n"
3977 " Guard size = 4097 bytes\n"
3978 " Stack address = (nil)\n"
3979 " Stack size = 0x0 (0) bytes\n"
3983 #: build/C/man3/pthread_getattr_np.3:143
3986 "Attributes of created thread:\n"
3987 " Guard size = 8192 bytes\n"
3988 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
3989 " Stack size = 0x201000 (2101248) bytes\n"
3994 #. $ ./a.out \-s 0x8000
3995 #. Thread attributes object after initializations:
3996 #. Guard size = 4096 bytes
3997 #. Stack address = 0xffff8000 (EOS = (nil))
3998 #. Stack size = 0x8000 (32768) bytes
4000 #. Attributes of created thread:
4001 #. Guard size = 4096 bytes
4002 #. Stack address = 0x4001e000 (EOS = 0x40026000)
4003 #. Stack size = 0x8000 (32768) bytes
4007 #: build/C/man3/pthread_getattr_np.3:162
4009 "In the last run, the program manually allocates a stack for the thread. In "
4010 "this case, the guard size attribute is ignored."
4014 #: build/C/man3/pthread_getattr_np.3:167
4017 "$B< ./a.out -g 4096 -s 0x8000 -a>\n"
4018 "Allocated thread stack at 0x804d000\n"
4022 #: build/C/man3/pthread_getattr_np.3:172
4025 "Thread attributes object after initializations:\n"
4026 " Guard size = 4096 bytes\n"
4027 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4028 " Stack size = 0x8000 (32768) bytes\n"
4032 #: build/C/man3/pthread_getattr_np.3:177
4035 "Attributes of created thread:\n"
4036 " Guard size = 0 bytes\n"
4037 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4038 " Stack size = 0x8000 (32768) bytes\n"
4042 #: build/C/man3/pthread_getattr_np.3:198
4046 "display_stack_related_attributes(pthread_attr_t *attr, char *prefix)\n"
4049 " size_t stack_size, guard_size;\n"
4050 " void *stack_addr;\n"
4054 #: build/C/man3/pthread_getattr_np.3:203
4057 " s = pthread_attr_getguardsize(attr, &guard_size);\n"
4059 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
4060 " printf(\"%sGuard size = %d bytes\\en\", prefix, guard_size);\n"
4064 #: build/C/man3/pthread_getattr_np.3:214
4067 " s = pthread_attr_getstack(attr, &stack_addr, &stack_size);\n"
4069 " handle_error_en(s, \"pthread_attr_getstack\");\n"
4070 " printf(\"%sStack address = %p\", prefix, stack_addr);\n"
4071 " if (stack_size E<gt> 0)\n"
4072 " printf(\" (EOS = %p)\", (char *) stack_addr + stack_size);\n"
4073 " printf(\"\\en\");\n"
4074 " printf(\"%sStack size = 0x%x (%d) bytes\\en\",\n"
4075 " prefix, stack_size, stack_size);\n"
4080 #: build/C/man3/pthread_getattr_np.3:220
4084 "display_thread_attributes(pthread_t thread, char *prefix)\n"
4087 " pthread_attr_t attr;\n"
4091 #: build/C/man3/pthread_getattr_np.3:224
4094 " s = pthread_getattr_np(thread, &attr);\n"
4096 " handle_error_en(s, \"pthread_getattr_np\");\n"
4100 #: build/C/man3/pthread_getattr_np.3:226
4102 msgid " display_stack_related_attributes(&attr, prefix);\n"
4106 #: build/C/man3/pthread_getattr_np.3:231
4109 " s = pthread_attr_destroy(&attr);\n"
4111 " handle_error_en(s, \"pthread_attr_destroy\");\n"
4116 #: build/C/man3/pthread_getattr_np.3:237
4119 "static void * /* Start function for thread we create */\n"
4120 "thread_start(void *arg)\n"
4122 " printf(\"Attributes of created thread:\\en\");\n"
4123 " display_thread_attributes(pthread_self(), \"\\et\");\n"
4127 #: build/C/man3/pthread_getattr_np.3:251
4131 "usage(char *pname, char *msg)\n"
4133 " if (msg != NULL)\n"
4134 " fputs(msg, stderr);\n"
4135 " fprintf(stderr, \"Usage: %s [-s stack-size [-a]]\"\n"
4136 " \" [-g guard-size]\\en\", pname);\n"
4137 " fprintf(stderr, \"\\et\\et-a means program should allocate "
4139 " exit(EXIT_FAILURE);\n"
4144 #: build/C/man3/pthread_getattr_np.3:264
4147 "static pthread_attr_t * /* Get thread attributes from command line */\n"
4148 "get_thread_attributes_from_cl(int argc, char *argv[],\n"
4149 " pthread_attr_t *attrp)\n"
4151 " int s, opt, allocate_stack;\n"
4152 " long stack_size, guard_size;\n"
4153 " void *stack_addr;\n"
4154 " pthread_attr_t *ret_attrp = NULL; /* Set to attrp if we initialize\n"
4155 " a thread attributes object */\n"
4156 " allocate_stack = 0;\n"
4157 " stack_size = -1;\n"
4158 " guard_size = -1;\n"
4162 #: build/C/man3/pthread_getattr_np.3:273
4165 " while ((opt = getopt(argc, argv, \"ag:s:\")) != -1) {\n"
4167 " case \\(aqa\\(aq: allocate_stack = 1; break;\n"
4168 " case \\(aqg\\(aq: guard_size = strtoul(optarg, NULL, 0); break;\n"
4169 " case \\(aqs\\(aq: stack_size = strtoul(optarg, NULL, 0); break;\n"
4170 " default: usage(argv[0], NULL);\n"
4176 #: build/C/man3/pthread_getattr_np.3:276
4179 " if (allocate_stack && stack_size == -1)\n"
4180 " usage(argv[0], \"Specifying -a without -s makes no sense\\en\");\n"
4184 #: build/C/man3/pthread_getattr_np.3:279
4187 " if (argc E<gt> optind)\n"
4188 " usage(argv[0], \"Extraneous command-line arguments\\en\");\n"
4192 #: build/C/man3/pthread_getattr_np.3:282
4195 " if (stack_size E<gt>= 0 || guard_size E<gt> 0) {\n"
4196 " ret_attrp = attrp;\n"
4200 #: build/C/man3/pthread_getattr_np.3:287
4203 " s = pthread_attr_init(attrp);\n"
4205 " handle_error_en(s, \"pthread_attr_init\");\n"
4210 #: build/C/man3/pthread_getattr_np.3:299
4213 " if (stack_size E<gt>= 0) {\n"
4214 " if (!allocate_stack) {\n"
4215 " s = pthread_attr_setstacksize(attrp, stack_size);\n"
4217 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4219 " s = posix_memalign(&stack_addr, sysconf(_SC_PAGESIZE),\n"
4222 " handle_error_en(s, \"posix_memalign\");\n"
4223 " printf(\"Allocated thread stack at %p\\en\\en\", stack_addr);\n"
4227 #: build/C/man3/pthread_getattr_np.3:305
4230 " s = pthread_attr_setstack(attrp, stack_addr, stack_size);\n"
4232 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4238 #: build/C/man3/pthread_getattr_np.3:311
4241 " if (guard_size E<gt>= 0) {\n"
4242 " s = pthread_attr_setguardsize(attrp, guard_size);\n"
4244 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4249 #: build/C/man3/pthread_getattr_np.3:314
4252 " return ret_attrp;\n"
4257 #: build/C/man3/pthread_getattr_np.3:323
4261 "main(int argc, char *argv[])\n"
4265 " pthread_attr_t attr;\n"
4266 " pthread_attr_t *attrp = NULL; /* Set to &attr if we initialize\n"
4267 " a thread attributes object */\n"
4271 #: build/C/man3/pthread_getattr_np.3:325
4273 msgid " attrp = get_thread_attributes_from_cl(argc, argv, &attr);\n"
4277 #: build/C/man3/pthread_getattr_np.3:331
4280 " if (attrp != NULL) {\n"
4281 " printf(\"Thread attributes object after initializations:\\en\");\n"
4282 " display_stack_related_attributes(attrp, \"\\et\");\n"
4283 " printf(\"\\en\");\n"
4288 #: build/C/man3/pthread_getattr_np.3:361
4290 "B<pthread_attr_getaffinity_np>(3), B<pthread_attr_getdetachstate>(3), "
4291 "B<pthread_attr_getguardsize>(3), B<pthread_attr_getinheritsched>(3), "
4292 "B<pthread_attr_getschedparam>(3), B<pthread_attr_getschedpolicy>(3), "
4293 "B<pthread_attr_getscope>(3), B<pthread_attr_getstack>(3), "
4294 "B<pthread_attr_getstackaddr>(3), B<pthread_attr_getstacksize>(3), "
4295 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthreads>(7)"
4299 #: build/C/man3/pthread_getcpuclockid.3:26
4301 msgid "PTHREAD_GETCPUCLOCKID"
4305 #: build/C/man3/pthread_getcpuclockid.3:26
4311 #: build/C/man3/pthread_getcpuclockid.3:29
4312 msgid "pthread_getcpuclockid - retrieve ID of a thread's CPU time clock"
4316 #: build/C/man3/pthread_getcpuclockid.3:33
4319 "B<#include E<lt>pthread.hE<gt>>\n"
4320 "B<#include E<lt>time.hE<gt>>\n"
4324 #: build/C/man3/pthread_getcpuclockid.3:35
4327 "B<int pthread_getcpuclockid(pthread_t >I<thread>B<, clockid_t "
4331 #. The clockid is constructed as follows:
4332 #. *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE)
4333 #. where CLOCK_IDFIELD_SIZE is 3.
4335 #: build/C/man3/pthread_getcpuclockid.3:46
4337 "The B<pthread_getcpuclockid>() function returns the clock ID for the CPU "
4338 "time clock of the thread I<thread>."
4342 #: build/C/man3/pthread_getcpuclockid.3:50
4347 #. CLOCK_THREAD_CPUTIME_ID not defined
4349 #. Looking at nptl/pthread_getcpuclockid.c an ERANGE error would
4350 #. be possible if kernel thread IDs took more than 29 bits (which
4351 #. they currently cannot).
4353 #: build/C/man3/pthread_getcpuclockid.3:58
4354 msgid "Per-thread CPU time clocks are not supported by the system."
4358 #: build/C/man3/pthread_getcpuclockid.3:65
4359 msgid "This function is available in glibc since version 2.2."
4363 #: build/C/man3/pthread_getcpuclockid.3:78
4365 "When I<thread> refers to the calling thread, this function returns an "
4366 "identifier that refers to the same clock manipulated by B<clock_gettime>(2) "
4367 "and B<clock_settime>(2) when given the clock ID B<CLOCK_THREAD_CPUTIME_ID>."
4371 #: build/C/man3/pthread_getcpuclockid.3:84
4373 "The program below creates a thread and then uses B<clock_gettime>(2) to "
4374 "retrieve the total process CPU time, and the per-thread CPU time consumed by "
4375 "the two threads. The following shell session shows an example run:"
4379 #: build/C/man3/pthread_getcpuclockid.3:93
4383 "Main thread sleeping\n"
4384 "Subthread starting infinite loop\n"
4385 "Main thread consuming some CPU time...\n"
4386 "Process total CPU time: 1.368\n"
4387 "Main thread CPU time: 0.376\n"
4388 "Subthread CPU time: 0.992\n"
4392 #: build/C/man3/pthread_getcpuclockid.3:99
4394 msgid "/* Link with \"-lrt\" */\n"
4398 #: build/C/man3/pthread_getcpuclockid.3:107
4401 "#include E<lt>time.hE<gt>\n"
4402 "#include E<lt>stdio.hE<gt>\n"
4403 "#include E<lt>stdlib.hE<gt>\n"
4404 "#include E<lt>unistd.hE<gt>\n"
4405 "#include E<lt>pthread.hE<gt>\n"
4406 "#include E<lt>string.hE<gt>\n"
4407 "#include E<lt>errno.hE<gt>\n"
4411 #: build/C/man3/pthread_getcpuclockid.3:121
4415 "thread_start(void *arg)\n"
4417 " printf(\"Subthread starting infinite loop\\en\");\n"
4424 #: build/C/man3/pthread_getcpuclockid.3:126
4428 "pclock(char *msg, clockid_t cid)\n"
4430 " struct timespec ts;\n"
4434 #: build/C/man3/pthread_getcpuclockid.3:132
4437 " printf(\"%s\", msg);\n"
4438 " if (clock_gettime(cid, &ts) == -1)\n"
4439 " handle_error(\"clock_gettime\");\n"
4440 " printf(\"%4ld.%03ld\\en\", ts.tv_sec, ts.tv_nsec / 1000000);\n"
4445 #: build/C/man3/pthread_getcpuclockid.3:139
4449 "main(int argc, char *argv[])\n"
4451 " pthread_t thread;\n"
4457 #: build/C/man3/pthread_getcpuclockid.3:143
4460 " s = pthread_create(&thread, NULL, thread_start, NULL);\n"
4462 " handle_error_en(s, \"pthread_create\");\n"
4466 #: build/C/man3/pthread_getcpuclockid.3:146
4469 " printf(\"Main thread sleeping\\en\");\n"
4474 #: build/C/man3/pthread_getcpuclockid.3:150
4477 " printf(\"Main thread consuming some CPU time...\\en\");\n"
4478 " for (j = 0; j E<lt> 2000000; j++)\n"
4483 #: build/C/man3/pthread_getcpuclockid.3:152
4485 msgid " pclock(\"Process total CPU time: \", CLOCK_PROCESS_CPUTIME_ID);\n"
4489 #: build/C/man3/pthread_getcpuclockid.3:157
4492 " s = pthread_getcpuclockid(pthread_self(), &cid);\n"
4494 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
4495 " pclock(\"Main thread CPU time: \", cid);\n"
4499 #: build/C/man3/pthread_getcpuclockid.3:160
4502 " /* The preceding 4 lines of code could have been replaced by:\n"
4503 " pclock(\"Main thread CPU time: \", CLOCK_THREAD_CPUTIME_ID); */\n"
4507 #: build/C/man3/pthread_getcpuclockid.3:165
4510 " s = pthread_getcpuclockid(thread, &cid);\n"
4512 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
4513 " pclock(\"Subthread CPU time: 1 \", cid);\n"
4517 #: build/C/man3/pthread_getcpuclockid.3:168
4520 " exit(EXIT_SUCCESS); /* Terminates both threads */\n"
4525 #: build/C/man3/pthread_getcpuclockid.3:177
4527 "B<clock_gettime>(2), B<clock_settime>(2), B<timer_create>(2), "
4528 "B<clock_getcpuclockid>(3), B<pthread_self>(3), B<pthreads>(7), B<time>(7)"
4532 #: build/C/man3/pthread_join.3:26
4534 msgid "PTHREAD_JOIN"
4538 #: build/C/man3/pthread_join.3:29
4539 msgid "pthread_join - join with a terminated thread"
4543 #: build/C/man3/pthread_join.3:34
4545 msgid "B<int pthread_join(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
4549 #: build/C/man3/pthread_join.3:49
4551 "The B<pthread_join>() function waits for the thread specified by I<thread> "
4552 "to terminate. If that thread has already terminated, then B<pthread_join>() "
4553 "returns immediately. The thread specified by I<thread> must be joinable."
4557 #: build/C/man3/pthread_join.3:63
4559 "If I<retval> is not NULL, then B<pthread_join>() copies the exit status of "
4560 "the target thread (i.e., the value that the target thread supplied to "
4561 "B<pthread_exit>(3)) into the location pointed to by I<*retval>. If the "
4562 "target thread was canceled, then B<PTHREAD_CANCELED> is placed in "
4567 #: build/C/man3/pthread_join.3:70
4569 "If multiple threads simultaneously try to join with the same thread, the "
4570 "results are undefined. If the thread calling B<pthread_join>() is "
4571 "canceled, then the target thread will remain joinable (i.e., it will not be "
4576 #: build/C/man3/pthread_join.3:75
4578 "On success, B<pthread_join>() returns 0; on error, it returns an error "
4583 #: build/C/man3/pthread_join.3:76
4588 #. The following verified by testing on glibc 2.8/NPTL:
4589 #. The following verified by testing on glibc 2.8/NPTL:
4591 #: build/C/man3/pthread_join.3:85
4593 "A deadlock was detected (e.g., two threads tried to join with each other); "
4594 "or I<thread> specifies the calling thread."
4597 #. POSIX.1-2001 does not specify this error case.
4599 #: build/C/man3/pthread_join.3:93
4600 msgid "Another thread is already waiting to join with this thread."
4604 #: build/C/man3/pthread_join.3:104
4606 "After a successful call to B<pthread_join>(), the caller is guaranteed that "
4607 "the target thread has terminated."
4611 #: build/C/man3/pthread_join.3:107
4613 "Joining with a thread that has previously been joined results in undefined "
4618 #: build/C/man3/pthread_join.3:115
4620 "Failure to join with a thread that is joinable (i.e., one that is not "
4621 "detached), produces a \"zombie thread\". Avoid doing this, since each "
4622 "zombie thread consumes some system resources, and when enough zombie threads "
4623 "have accumulated, it will no longer be possible to create new threads (or "
4628 #: build/C/man3/pthread_join.3:121
4630 "There is no pthreads analog of I<waitpid(-1,\\ &status,\\ 0)>, that is, "
4631 "\"join with any terminated thread\". If you believe you need this "
4632 "functionality, you probably need to rethink your application design."
4636 #: build/C/man3/pthread_join.3:124
4638 "All of the threads in a process are peers: any thread can join with any "
4639 "other thread in the process."
4643 #: build/C/man3/pthread_join.3:134
4645 "B<pthread_cancel>(3), B<pthread_create>(3), B<pthread_detach>(3), "
4646 "B<pthread_exit>(3), B<pthread_tryjoin_np>(3), B<pthreads>(7)"
4650 #: build/C/man3/pthread_kill.3:26
4652 msgid "PTHREAD_KILL"
4656 #: build/C/man3/pthread_kill.3:26 build/C/man3/pthread_sigqueue.3:25
4662 #: build/C/man3/pthread_kill.3:29
4663 msgid "pthread_kill - send a signal to a thread"
4667 #: build/C/man3/pthread_kill.3:32 build/C/man3/pthread_sigmask.3:32
4669 msgid "B<#include E<lt>signal.hE<gt>>\n"
4673 #: build/C/man3/pthread_kill.3:34
4675 msgid "B<int pthread_kill(pthread_t >I<thread>B<, int >I<sig>B<);>\n"
4679 #: build/C/man3/pthread_kill.3:47
4681 "The B<pthread_kill>() function sends the signal I<sig> to I<thread>, a "
4682 "thread in the same process as the caller. The signal is asynchronously "
4683 "directed to I<thread>."
4687 #: build/C/man3/pthread_kill.3:52
4689 "If I<sig> is 0, then no signal is sent, but error checking is still "
4690 "performed; this can be used to check for the existence of a thread ID."
4694 #: build/C/man3/pthread_kill.3:57
4696 "On success, B<pthread_kill>() returns 0; on error, it returns an error "
4697 "number, and no signal is sent."
4701 #: build/C/man3/pthread_kill.3:61
4702 msgid "An invalid signal was specified."
4706 #: build/C/man3/pthread_kill.3:75
4708 "Signal dispositions are process-wide: if a signal handler is installed, the "
4709 "handler will be invoked in the thread I<thread>, but if the disposition of "
4710 "the signal is \"stop\", \"continue\", or \"terminate\", this action will "
4711 "affect the whole process."
4715 #: build/C/man3/pthread_kill.3:84
4717 "B<kill>(2), B<sigaction>(2), B<sigpending>(2), B<pthread_self>(3), "
4718 "B<pthread_sigmask>(3), B<raise>(3), B<pthreads>(7), B<signal>(7)"
4722 #: build/C/man3/pthread_kill_other_threads_np.3:26
4724 msgid "PTHREAD_KILL_OTHER_THREADS_NP"
4728 #: build/C/man3/pthread_kill_other_threads_np.3:26
4734 #: build/C/man3/pthread_kill_other_threads_np.3:29
4735 msgid "pthread_kill_other_threads_np - terminate all other threads in process"
4739 #: build/C/man3/pthread_kill_other_threads_np.3:34
4741 msgid "B<void pthread_kill_other_threads_np(void);>\n"
4745 #. Available since glibc 2.0
4747 #: build/C/man3/pthread_kill_other_threads_np.3:47
4749 "B<pthread_kill_other_threads_np>() only has an effect in the LinuxThreads "
4750 "threading implementation. On that implementation, calling this function "
4751 "causes the immediate termination of all threads in the application, except "
4752 "the calling thread. The cancellation state and cancellation type of the "
4753 "to-be-terminated threads are ignored, and the cleanup handlers are not "
4754 "called in those threads."
4758 #: build/C/man3/pthread_kill_other_threads_np.3:59
4760 "B<pthread_kill_other_threads_np>() is intended to be called just before a "
4761 "thread calls B<execve>(2) or a similar function. This function is designed "
4762 "to address a limitation in the obsolete LinuxThreads implementation whereby "
4763 "the other threads of an application are not automatically terminated (as "
4764 "POSIX.1-2001 requires) during B<execve>(2)."
4768 #: build/C/man3/pthread_kill_other_threads_np.3:66
4770 "In the NPTL threading implementation, B<pthread_kill_other_threads_np>() "
4771 "exists, but does nothing. (Nothing needs to be done, because the "
4772 "implementation does the right thing during an B<execve>(2).)"
4776 #: build/C/man3/pthread_kill_other_threads_np.3:72
4778 "B<execve>(2), B<pthread_cancel>(3), B<pthread_setcancelstate>(3), "
4779 "B<pthread_setcanceltype>(3), B<pthreads>(7)"
4783 #: build/C/man3/pthread_self.3:26
4785 msgid "PTHREAD_SELF"
4789 #: build/C/man3/pthread_self.3:29
4790 msgid "pthread_self - obtain ID of the calling thread"
4794 #: build/C/man3/pthread_self.3:34
4796 msgid "B<pthread_t pthread_self(void);>\n"
4800 #: build/C/man3/pthread_self.3:46
4802 "The B<pthread_self>() function returns the ID of the calling thread. This "
4803 "is the same value that is returned in I<*thread> in the B<pthread_create>(3) "
4804 "call that created this thread."
4808 #: build/C/man3/pthread_self.3:48
4809 msgid "This function always succeeds, returning the calling thread's ID."
4813 #: build/C/man3/pthread_self.3:63
4815 "POSIX.1 allows an implementation wide freedom in choosing the type used to "
4816 "represent a thread ID; for example, representation using either an "
4817 "arithmetic type or a structure is permitted. Therefore, variables of type "
4818 "I<pthread_t> can't portably be compared using the C equality operator "
4819 "(B<==>); use B<pthread_equal>(3) instead."
4823 #: build/C/man3/pthread_self.3:67
4825 "Thread identifiers should be considered opaque: any attempt to use a thread "
4826 "ID other than in pthreads calls is nonportable and can lead to unspecified "
4831 #: build/C/man3/pthread_self.3:71
4833 "Thread IDs are only guaranteed to be unique within a process. A thread ID "
4834 "may be reused after a terminated thread has been joined, or a detached "
4835 "thread has terminated."
4839 #: build/C/man3/pthread_self.3:76
4841 "The thread ID returned by B<pthread_self>() is not the same thing as the "
4842 "kernel thread ID returned by a call to B<gettid>(2)."
4846 #: build/C/man3/pthread_self.3:80
4847 msgid "B<pthread_create>(3), B<pthread_equal>(3), B<pthreads>(7)"
4851 #: build/C/man3/pthread_setaffinity_np.3:26
4853 msgid "PTHREAD_SETAFFINITY_NP"
4857 #: build/C/man3/pthread_setaffinity_np.3:30
4859 "pthread_setaffinity_np, pthread_getaffinity_np - set/get CPU affinity of a "
4864 #: build/C/man3/pthread_setaffinity_np.3:39
4867 "B<int pthread_setaffinity_np(pthread_t >I<thread>B<, size_t "
4868 ">I<cpusetsize>B<,>\n"
4869 "B< const cpu_set_t *>I<cpuset>B<);>\n"
4870 "B<int pthread_getaffinity_np(pthread_t >I<thread>B<, size_t "
4871 ">I<cpusetsize>B<,>\n"
4872 "B< cpu_set_t *>I<cpuset>B<);>\n"
4876 #: build/C/man3/pthread_setaffinity_np.3:54
4878 "The B<pthread_setaffinity_np>() function sets the CPU affinity mask of the "
4879 "thread I<thread> to the CPU set pointed to by I<cpuset>. If the call is "
4880 "successful, and the thread is not currently running on one of the CPUs in "
4881 "I<cpuset>, then it is migrated to one of those CPUs."
4885 #: build/C/man3/pthread_setaffinity_np.3:61
4887 "The B<pthread_getaffinity_np>() function returns the CPU affinity mask of "
4888 "the thread I<thread> in the buffer pointed to by I<cpuset>."
4892 #: build/C/man3/pthread_setaffinity_np.3:77
4894 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
4895 "by I<cpuset>. Typically, this argument would be specified as "
4896 "I<sizeof(cpu_set_t)>. (It may be some other value, if using the macros "
4897 "described in B<CPU_SET>(3) for dynamically allocating a CPU set.)"
4901 #: build/C/man3/pthread_setaffinity_np.3:81
4907 #: build/C/man3/pthread_setaffinity_np.3:84
4908 msgid "A supplied memory address was invalid."
4912 #: build/C/man3/pthread_setaffinity_np.3:93
4914 "(B<pthread_setaffinity_np>()) The affinity bit mask I<mask> contains no "
4915 "processors that are currently physically on the system and permitted to the "
4916 "thread according to any restrictions that may be imposed by the \"cpuset\" "
4917 "mechanism described in B<cpuset>(7)."
4921 #. Loic Domaigne commented: it seems that in the future the
4922 #. kernel developers want to make cpumask_t dynamic, so
4923 #. CONFIG_NR_CPUS might become obsolete in the future.
4925 #. The raw sched_getaffinity() system call returns the size (in bytes)
4926 #. of the cpumask_t type.
4928 #: build/C/man3/pthread_setaffinity_np.3:109
4930 "(B<pthread_setaffinity_np>()) I<cpuset> specified a CPU that was outside "
4931 "the set supported by the kernel. (The kernel configuration option "
4932 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
4933 "type used to represent CPU sets.)"
4937 #: build/C/man3/pthread_setaffinity_np.3:114
4939 "(B<pthread_getaffinity_np>()) I<cpusetsize> is smaller than the size of the "
4940 "affinity mask used by the kernel."
4944 #: build/C/man3/pthread_setaffinity_np.3:137
4946 "After a call to B<pthread_setaffinity_np>(), the set of CPUs on which the "
4947 "thread will actually run is the intersection of the set specified in the "
4948 "I<cpuset> argument and the set of CPUs actually present on the system. The "
4949 "system may further restrict the set of CPUs on which the thread runs if the "
4950 "\"cpuset\" mechanism described in B<cpuset>(7) is being used. These "
4951 "restrictions on the actual set of CPUs on which the thread will run are "
4952 "silently imposed by the kernel."
4956 #: build/C/man3/pthread_setaffinity_np.3:143
4958 "These functions are implemented on top of the B<sched_setaffinity>(2) and "
4959 "B<sched_getaffinity>(2) system calls."
4963 #: build/C/man3/pthread_setaffinity_np.3:154
4965 "A new thread created by B<pthread_create>(3) inherits a copy of its "
4966 "creator's CPU affinity mask."
4970 #: build/C/man3/pthread_setaffinity_np.3:162
4972 "In the following program, the main thread uses B<pthread_setaffinity_np>() "
4973 "to set its CPU affinity mask to include CPUs 0 to 7 (which may not all be "
4974 "available on the system), and then calls B<pthread_getaffinity_np>() to "
4975 "check the resulting CPU affinity mask of the thread."
4979 #: build/C/man3/pthread_setaffinity_np.3:169
4982 "#define _GNU_SOURCE\n"
4983 "#include E<lt>pthread.hE<gt>\n"
4984 "#include E<lt>stdio.hE<gt>\n"
4985 "#include E<lt>stdlib.hE<gt>\n"
4986 "#include E<lt>errno.hE<gt>\n"
4990 #: build/C/man3/pthread_setaffinity_np.3:179
4994 "main(int argc, char *argv[])\n"
4997 " cpu_set_t cpuset;\n"
4998 " pthread_t thread;\n"
5002 #: build/C/man3/pthread_setaffinity_np.3:181
5004 msgid " thread = pthread_self();\n"
5008 #: build/C/man3/pthread_setaffinity_np.3:183
5010 msgid " /* Set affinity mask to include CPUs 0 to 7 */\n"
5014 #: build/C/man3/pthread_setaffinity_np.3:187
5017 " CPU_ZERO(&cpuset);\n"
5018 " for (j = 0; j E<lt> 8; j++)\n"
5019 " CPU_SET(j, &cpuset);\n"
5023 #: build/C/man3/pthread_setaffinity_np.3:191
5026 " s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5028 " handle_error_en(s, \"pthread_setaffinity_np\");\n"
5032 #: build/C/man3/pthread_setaffinity_np.3:193
5034 msgid " /* Check the actual affinity mask assigned to the thread */\n"
5038 #: build/C/man3/pthread_setaffinity_np.3:197
5041 " s = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5043 " handle_error_en(s, \"pthread_getaffinity_np\");\n"
5047 #: build/C/man3/pthread_setaffinity_np.3:202
5050 " printf(\"Set returned by pthread_getaffinity_np() contained:\\en\");\n"
5051 " for (j = 0; j E<lt> CPU_SETSIZE; j++)\n"
5052 " if (CPU_ISSET(j, &cpuset))\n"
5053 " printf(\" CPU %d\\en\", j);\n"
5057 #: build/C/man3/pthread_setaffinity_np.3:205 build/C/man3/pthread_setschedparam.3:430
5060 " exit(EXIT_SUCCESS);\n"
5065 #: build/C/man3/pthread_setaffinity_np.3:214
5067 "B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
5068 "B<pthread_attr_setaffinity_np>(3), B<pthread_self>(3), B<sched_getcpu>(3), "
5069 "B<cpuset>(7), B<pthreads>(7)"
5073 #: build/C/man3/pthread_setcancelstate.3:26
5075 msgid "PTHREAD_SETCANCELSTATE"
5079 #: build/C/man3/pthread_setcancelstate.3:30
5081 "pthread_setcancelstate, pthread_setcanceltype - set cancelability state and "
5086 #: build/C/man3/pthread_setcancelstate.3:36
5089 "B<int pthread_setcancelstate(int >I<state>B<, int *>I<oldstate>B<);>\n"
5090 "B<int pthread_setcanceltype(int >I<type>B<, int *>I<oldtype>B<);>\n"
5094 #: build/C/man3/pthread_setcancelstate.3:51
5096 "The B<pthread_setcancelstate>() sets the cancelability state of the calling "
5097 "thread to the value given in I<state>. The previous cancelability state of "
5098 "the thread is returned in the buffer pointed to by I<oldstate>. The "
5099 "I<state> argument must have one of the following values:"
5103 #: build/C/man3/pthread_setcancelstate.3:51
5105 msgid "B<PTHREAD_CANCEL_ENABLE>"
5109 #: build/C/man3/pthread_setcancelstate.3:58
5111 "The thread is cancelable. This is the default cancelability state in all "
5112 "new threads, including the initial thread. The thread's cancelability type "
5113 "determines when a cancelable thread will respond to a cancellation request."
5117 #: build/C/man3/pthread_setcancelstate.3:58
5119 msgid "B<PTHREAD_CANCEL_DISABLE>"
5123 #: build/C/man3/pthread_setcancelstate.3:63
5125 "The thread is not cancelable. If a cancellation request is received, it is "
5126 "blocked until cancelability is enabled."
5130 #: build/C/man3/pthread_setcancelstate.3:75
5132 "The B<pthread_setcanceltype>() sets the cancelability type of the calling "
5133 "thread to the value given in I<type>. The previous cancelability type of "
5134 "the thread is returned in the buffer pointed to by I<oldtype>. The I<type> "
5135 "argument must have one of the following values:"
5139 #: build/C/man3/pthread_setcancelstate.3:75
5141 msgid "B<PTHREAD_CANCEL_DEFERRED>"
5145 #: build/C/man3/pthread_setcancelstate.3:82
5147 "A cancellation request is deferred until the thread next calls a function "
5148 "that is a cancellation point (see B<pthreads>(7)). This is the default "
5149 "cancelability type in all new threads, including the initial thread."
5153 #: build/C/man3/pthread_setcancelstate.3:82
5155 msgid "B<PTHREAD_CANCEL_ASYNCHRONOUS>"
5159 #: build/C/man3/pthread_setcancelstate.3:88
5161 "The thread can be canceled at any time. (Typically, it will be canceled "
5162 "immediately upon receiving a cancellation request, but the system doesn't "
5167 #: build/C/man3/pthread_setcancelstate.3:92
5169 "The set-and-get operation performed by each of these functions is atomic "
5170 "with respect to other threads in the process calling the same function."
5174 #: build/C/man3/pthread_setcancelstate.3:99
5175 msgid "The B<pthread_setcancelstate>() can fail with the following error:"
5179 #: build/C/man3/pthread_setcancelstate.3:103
5180 msgid "Invalid value for I<state>."
5184 #: build/C/man3/pthread_setcancelstate.3:107
5185 msgid "The B<pthread_setcanceltype>() can fail with the following error:"
5189 #. Available since glibc 2.0
5191 #: build/C/man3/pthread_setcancelstate.3:113
5192 msgid "Invalid value for I<type>."
5196 #: build/C/man3/pthread_setcancelstate.3:118
5198 "For details of what happens when a thread is canceled, see "
5199 "B<pthread_cancel>(3)."
5203 #: build/C/man3/pthread_setcancelstate.3:125
5205 "Briefly disabling cancelability is useful if a thread performs some critical "
5206 "action that must not be interrupted by a cancellation request. Beware of "
5207 "disabling cancelability for long periods, or around operations that may "
5208 "block for long periods, since that will render the thread unresponsive to "
5209 "cancellation requests."
5213 #: build/C/man3/pthread_setcancelstate.3:156
5215 "Setting the cancelability type to B<PTHREAD_CANCEL_ASYNCHRONOUS> is rarely "
5216 "useful. Since the thread could be canceled at I<any> time, it cannot safely "
5217 "reserve resources (e.g., allocating memory with B<malloc>(3)), acquire "
5218 "mutexes, semaphores, or locks, and so on. Reserving resources is unsafe "
5219 "because the application has no way of knowing what the state of these "
5220 "resources is when the thread is canceled; that is, did cancellation occur "
5221 "before the resources were reserved, while they were reserved, or after they "
5222 "were released? Furthermore, some internal data structures (e.g., the linked "
5223 "list of free blocks managed by the B<malloc>(3) family of functions) may be "
5224 "left in an inconsistent state if cancellation occurs in the middle of the "
5225 "function call. Consequently, clean-up handlers cease to be useful. "
5226 "Functions that can be safely asynchronously canceled are called "
5227 "I<async-cancel-safe functions>. POSIX.1-2001 only requires that "
5228 "B<pthread_cancel>(3), B<pthread_setcancelstate>(), and "
5229 "B<pthread_setcanceltype>() be async-cancel-safe. In general, other library "
5230 "functions can't be safely called from an asynchronously cancelable thread. "
5231 "One of the few circumstances in which asynchronous cancelability is useful "
5232 "is for cancellation of a thread that is in a pure compute-bound loop."
5235 #. It looks like at least Solaris, FreeBSD and Tru64 support this.
5237 #: build/C/man3/pthread_setcancelstate.3:174
5239 "The Linux threading implementations permit the I<oldstate> argument of "
5240 "B<pthread_setcancelstate>() to be NULL, in which case the information about "
5241 "the previous cancelability state is not returned to the caller. Many other "
5242 "implementations also permit a NULL I<oldstat> argument, but POSIX.1-2001 "
5243 "does not specify this point, so portable applications should always specify "
5244 "a non-NULL value in I<oldstate>. A precisely analogous set of statements "
5245 "applies for the I<oldtype> argument of B<pthread_setcanceltype>()."
5249 #: build/C/man3/pthread_setcancelstate.3:177
5250 msgid "See B<pthread_cancel>(3)."
5254 #: build/C/man3/pthread_setcancelstate.3:182
5256 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), B<pthread_testcancel>(3), "
5261 #: build/C/man3/pthread_setconcurrency.3:25
5263 msgid "PTHREAD_SETCONCURRENCY"
5267 #: build/C/man3/pthread_setconcurrency.3:25
5273 #: build/C/man3/pthread_setconcurrency.3:29
5275 "pthread_setconcurrency, pthread_getconcurrency - set/get the concurrency "
5280 #: build/C/man3/pthread_setconcurrency.3:35
5283 "B<int pthread_setconcurrency(int >I<new_level>B<);>\n"
5284 "B<int pthread_getconcurrency(void);>\n"
5288 #: build/C/man3/pthread_setconcurrency.3:48
5290 "The B<pthread_setconcurrency>() function informs the implementation of the "
5291 "application's desired concurrency level, specified in I<new_level>. The "
5292 "implementation only takes this as a hint: POSIX.1 does not specify the level "
5293 "of concurrency that should be provided as a result of calling "
5294 "B<pthread_setconcurrency>()."
5298 #: build/C/man3/pthread_setconcurrency.3:53
5300 "Specifying I<new_level> as 0 instructs the implementation to manage the "
5301 "concurrency level as it deems appropriate."
5305 #: build/C/man3/pthread_setconcurrency.3:56
5307 "B<pthread_getconcurrency>() returns the current value of the concurrency "
5308 "level for this process."
5312 #: build/C/man3/pthread_setconcurrency.3:61
5314 "On success, B<pthread_setconcurrency>() returns 0; on error, it returns a "
5315 "nonzero error number."
5319 #: build/C/man3/pthread_setconcurrency.3:68
5321 "B<pthread_getconcurrency>() always succeeds, returning the concurrency "
5322 "level set by a previous call to B<pthread_setconcurrency>(), or 0, if "
5323 "B<pthread_setconcurrency>() has not previously been called."
5327 #: build/C/man3/pthread_setconcurrency.3:71
5328 msgid "B<pthread_setconcurrency>() can fail with the following error:"
5332 #: build/C/man3/pthread_setconcurrency.3:75
5333 msgid "I<new_level> is negative."
5337 #: build/C/man3/pthread_setconcurrency.3:81
5339 "POSIX.1-2001 also documents an B<EAGAIN> error (\"the value specified by "
5340 "I<new_level> would cause a system resource to be exceeded\")."
5344 #: build/C/man3/pthread_setconcurrency.3:83
5345 msgid "These functions are available in glibc since version 2.1."
5349 #: build/C/man3/pthread_setconcurrency.3:87
5350 msgid "The default concurrency level is 0."
5354 #: build/C/man3/pthread_setconcurrency.3:94
5356 "Concurrency levels are only meaningful for M:N threading implementations, "
5357 "where at any moment a subset of a process's set of user-level threads may be "
5358 "bound to a smaller number of kernel-scheduling entities. Setting the "
5359 "concurrency level allows the application to give the system a hint as to the "
5360 "number of kernel-scheduling entities that should be provided for efficient "
5361 "execution of the application."
5365 #: build/C/man3/pthread_setconcurrency.3:100
5367 "Both LinuxThreads and NPTL are 1:1 threading implementations, so setting the "
5368 "concurrency level has no meaning. In other words, on Linux these functions "
5369 "merely exist for compatibility with other systems, and they have no effect "
5370 "on the execution of a program."
5374 #: build/C/man3/pthread_setconcurrency.3:103
5375 msgid "B<pthread_attr_setscope>(3), B<pthreads>(7)"
5379 #: build/C/man3/pthread_setname_np.3:26
5381 msgid "PTHREAD_SETNAME_NP"
5385 #: build/C/man3/pthread_setname_np.3:26
5391 #: build/C/man3/pthread_setname_np.3:29
5392 msgid "pthread_setname_np, pthread_getname_np - set/get the name of a thread"
5396 #: build/C/man3/pthread_setname_np.3:36
5399 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
5400 "B<#include E<lt>pthread.hE<gt>>\n"
5401 "B<int pthread_setname_np(pthread_t *>I<thread>B<, const char "
5403 "B<int pthread_getname_np(pthread_t *>I<thread>B<,>\n"
5404 "B< const char *>I<name>B<, size_t >I<len>B<);>\n"
5408 #: build/C/man3/pthread_setname_np.3:55
5410 "By default, all the threads created using B<pthread_create>() inherit the "
5411 "program name. The B<pthread_setname_np>() function can be used to set a "
5412 "unique name for a thread, which can be useful for debugging multithreaded "
5413 "applications. The thread name is a meaningful C language string, whose "
5414 "length is restricted to 16 characters, including the terminating null byte. "
5415 "The I<thread> argument specifies the thread whose name is to be changed; "
5416 "I<name> specifies the new name."
5420 #: build/C/man3/pthread_setname_np.3:72
5422 "The B<pthread_getname_np>() function can be used to retrieve the name of "
5423 "the thread. The I<thread> argument specifies the thread whose name is to be "
5424 "retrieved. The buffer I<name> is used to return the thread name; I<len> "
5425 "specifies the number of bytes available in I<name>. The buffer specified by "
5426 "I<name> should be at least 16 characters in length. The returned thread "
5427 "name in the output buffer will be null terminated."
5431 #: build/C/man3/pthread_setname_np.3:79
5432 msgid "The B<pthread_setname_np>() function can fail with the following error:"
5436 #: build/C/man3/pthread_setname_np.3:79 build/C/man3/pthread_setname_np.3:88
5442 #: build/C/man3/pthread_setname_np.3:84
5444 "The length of the string specified pointed to by I<name> exceeds the allowed "
5449 #: build/C/man3/pthread_setname_np.3:88
5450 msgid "The B<pthread_getname_np>() function can fail with the following error:"
5454 #: build/C/man3/pthread_setname_np.3:95
5456 "The buffer specified by I<name> and I<len> is too small to hold the thread "
5461 #: build/C/man3/pthread_setname_np.3:100
5463 "If either of these functions fails to open I</proc/self/task/[tid]/comm>, "
5464 "then the call may fail with one of the errors described in B<open>(2)."
5468 #: build/C/man3/pthread_setname_np.3:102
5469 msgid "These functions first appeared in glibc in version 2.12."
5473 #: build/C/man3/pthread_setname_np.3:104
5474 msgid "These functions are nonstandard GNU extensions."
5478 #: build/C/man3/pthread_setname_np.3:112
5480 "B<pthread_setname_np>() internally writes to the thread specific comm file "
5481 "under I</proc> filesystem: I</proc/self/task/[tid]/comm>. "
5482 "B<pthread_getname_np>() retrieves it from the same location."
5486 #: build/C/man3/pthread_setname_np.3:118
5488 "The program below demonstrates the use of B<pthread_setname_np>() and "
5489 "B<pthread_getname_np>()."
5493 #: build/C/man3/pthread_setname_np.3:120
5494 msgid "The following shell session shows a sample run of the program:"
5498 #: build/C/man3/pthread_setname_np.3:136
5502 "Created a thread. Default name is: a.out\n"
5503 "The thread name after setting it is THREADFOO.\n"
5504 "B<^Z> # Suspend the program\n"
5505 "[1]+ Stopped ./a.out\n"
5506 "$ B<ps H -C a.out -o 'pid tid cmd comm'>\n"
5507 " PID TID CMD COMMAND\n"
5508 " 5990 5990 ./a.out a.out\n"
5509 " 5990 5991 ./a.out THREADFOO\n"
5510 "$ B<cat /proc/5990/task/5990/comm>\n"
5512 "$ B<cat /proc/5990/task/5991/comm>\n"
5517 #: build/C/man3/pthread_setname_np.3:148
5520 "#define _GNU_SOURCE\n"
5521 "#include E<lt>pthread.hE<gt>\n"
5522 "#include E<lt>stdio.hE<gt>\n"
5523 "#include E<lt>string.hE<gt>\n"
5524 "#include E<lt>unistd.hE<gt>\n"
5525 "#include E<lt>errno.hE<gt>\n"
5526 "#include E<lt>stdlib.hE<gt>\n"
5530 #: build/C/man3/pthread_setname_np.3:150
5532 msgid "#define NAMELEN 16\n"
5536 #: build/C/man3/pthread_setname_np.3:154
5539 "#define errExitEN(en, msg) \\e\n"
5540 " do { errno = en; perror(msg); exit(EXIT_FAILURE); \\e\n"
5545 #: build/C/man3/pthread_setname_np.3:161
5549 "threadfunc(void *parm)\n"
5551 " sleep(5); // allow main program to set the thread name\n"
5557 #: build/C/man3/pthread_setname_np.3:168
5561 "main(int argc, char **argv)\n"
5563 " pthread_t thread;\n"
5565 " char thread_name[NAMELEN];\n"
5569 #: build/C/man3/pthread_setname_np.3:172
5572 " rc = pthread_create(&thread, NULL, threadfunc, NULL);\n"
5574 " errExitEN(rc, \"pthread_create\");\n"
5578 #: build/C/man3/pthread_setname_np.3:176
5581 " rc = pthread_getname_np(thread, thread_name, NAMELEN);\n"
5583 " errExitEN(rc, \"pthread_getname_np\");\n"
5587 #: build/C/man3/pthread_setname_np.3:181
5590 " printf(\"Created a thread. Default name is: %s\\en\", thread_name);\n"
5591 " rc = pthread_setname_np(thread, (argc E<gt> 1) ? argv[1] : "
5594 " errExitEN(rc, \"pthread_setname_np\");\n"
5598 #: build/C/man3/pthread_setname_np.3:183
5600 msgid " sleep(2);\n"
5604 #: build/C/man3/pthread_setname_np.3:189
5607 " rc = pthread_getname_np(thread, thread_name,\n"
5608 " (argc E<gt> 2) ? atoi(argv[1]) : NAMELEN);\n"
5610 " errExitEN(rc, \"pthread_getname_np\");\n"
5611 " printf(\"The thread name after setting it is %s.\\en\", thread_name);\n"
5615 #: build/C/man3/pthread_setname_np.3:193
5618 " rc = pthread_join(thread, NULL);\n"
5620 " errExitEN(rc, \"pthread_join\");\n"
5624 #: build/C/man3/pthread_setname_np.3:197
5627 " printf(\"Done\\en\");\n"
5628 " exit(EXIT_SUCCESS);\n"
5633 #: build/C/man3/pthread_setname_np.3:204
5634 msgid "B<prctl>(2), B<pthread_create>(3), B<pthreads>(7)"
5638 #: build/C/man3/pthread_setschedparam.3:26
5640 msgid "PTHREAD_SETSCHEDPARAM"
5644 #: build/C/man3/pthread_setschedparam.3:30
5646 "pthread_setschedparam, pthread_getschedparam - set/get scheduling policy and "
5647 "parameters of a thread"
5651 #: build/C/man3/pthread_setschedparam.3:38
5654 "B<pthread_setschedparam(pthread_t >I<thread>B<, int >I<policy>B<,>\n"
5655 "B< const struct sched_param *>I<param>B<);>\n"
5656 "B<pthread_getschedparam(pthread_t >I<thread>B<, int *>I<policy>B<,>\n"
5657 "B< struct sched_param *>I<param>B<);>\n"
5661 #: build/C/man3/pthread_setschedparam.3:46
5663 "The B<pthread_setschedparam>() function sets the scheduling policy and "
5664 "parameters of the thread I<thread>."
5667 #. FIXME . pthread_setschedparam() places no restriction on the policy,
5668 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
5669 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
5671 #: build/C/man3/pthread_setschedparam.3:57
5673 "I<policy> specifies the new scheduling policy for I<thread>. The supported "
5674 "values for I<policy>, and their semantics, are described in "
5675 "B<sched_setscheduler>(2)."
5679 #: build/C/man3/pthread_setschedparam.3:63
5681 "The structure pointed to by I<param> specifies the new scheduling parameters "
5682 "for I<thread>. Scheduling parameters are maintained in the following "
5686 #. FIXME . nptl/pthread_setschedparam.c has the following
5687 #. /* If the thread should have higher priority because of some
5688 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
5689 #. Eventually (perhaps after writing the mutexattr pages), we
5690 #. may want to add something on the topic to this page.
5692 #: build/C/man3/pthread_setschedparam.3:104
5694 "The B<pthread_getschedparam>() function returns the scheduling policy and "
5695 "parameters of the thread I<thread>, in the buffers pointed to by I<policy> "
5696 "and I<param>, respectively. The returned priority value is that set by the "
5697 "most recent B<pthread_setschedparam>(), B<pthread_setschedprio>(3), or "
5698 "B<pthread_create>(3) call that affected I<thread>. The returned priority "
5699 "does not reflect any temporary priority adjustments as a result of calls to "
5700 "any priority inheritance or priority ceiling functions (see, for example, "
5701 "B<pthread_mutexattr_setprioceiling>(3) and "
5702 "B<pthread_mutexattr_setprotocol>(3))."
5706 #: build/C/man3/pthread_setschedparam.3:112
5708 "On success, these functions return 0; on error, they return a nonzero error "
5709 "number. If B<pthread_setschedparam>() fails, the scheduling policy and "
5710 "parameters of I<thread> are not changed."
5714 #: build/C/man3/pthread_setschedparam.3:114
5715 msgid "Both of these functions can fail with the following error:"
5719 #: build/C/man3/pthread_setschedparam.3:122
5720 msgid "B<pthread_setschedparam>() may additionally fail with the following errors:"
5724 #: build/C/man3/pthread_setschedparam.3:129
5726 "I<policy> is not a recognized policy, or I<param> does not make sense for "
5731 #: build/C/man3/pthread_setschedparam.3:133
5733 "The caller does not have appropriate privileges to set the specified "
5734 "scheduling policy and parameters."
5738 #. Available since glibc 2.0
5740 #: build/C/man3/pthread_setschedparam.3:141
5742 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
5743 "policy or scheduling parameters to an unsupported value\") error for "
5744 "B<pthread_setschedparam>()."
5748 #: build/C/man3/pthread_setschedparam.3:149
5750 "For a description of the permissions required to, and the effect of, "
5751 "changing a thread's scheduling policy and priority, and details of the "
5752 "permitted ranges for priorities in each scheduling policy, see "
5753 "B<sched_setscheduler>(2)."
5757 #: build/C/man3/pthread_setschedparam.3:156
5759 "The program below demonstrates the use of B<pthread_setschedparam>() and "
5760 "B<pthread_getschedparam>(), as well as the use of a number of other "
5761 "scheduling-related pthreads functions."
5765 #: build/C/man3/pthread_setschedparam.3:172
5767 "In the following run, the main thread sets its scheduling policy to "
5768 "B<SCHED_FIFO> with a priority of 10, and initializes a thread attributes "
5769 "object with a scheduling policy attribute of B<SCHED_RR> and a scheduling "
5770 "priority attribute of 20. The program then sets (using "
5771 "B<pthread_attr_setinheritsched>(3)) the inherit scheduler attribute of the "
5772 "thread attributes object to B<PTHREAD_EXPLICIT_SCHED>, meaning that threads "
5773 "created using this attributes object should take their scheduling attributes "
5774 "from the thread attributes object. The program then creates a thread using "
5775 "the thread attributes object, and that thread displays its scheduling policy "
5780 #: build/C/man3/pthread_setschedparam.3:180
5783 "$ B<su> # Need privilege to set real-time scheduling policies\n"
5785 "# B<./a.out -mf10 -ar20 -i e>\n"
5786 "Scheduler settings of main thread\n"
5787 " policy=SCHED_FIFO, priority=10\n"
5791 #: build/C/man3/pthread_setschedparam.3:184
5794 "Scheduler settings in \\(aqattr\\(aq\n"
5795 " policy=SCHED_RR, priority=20\n"
5796 " inheritsched is EXPLICIT\n"
5800 #: build/C/man3/pthread_setschedparam.3:187
5803 "Scheduler attributes of new thread\n"
5804 " policy=SCHED_RR, priority=20\n"
5808 #: build/C/man3/pthread_setschedparam.3:192
5810 "In the above output, one can see that the scheduling policy and priority "
5811 "were taken from the values specified in the thread attributes object."
5815 #: build/C/man3/pthread_setschedparam.3:199
5817 "The next run is the same as the previous, except that the inherit scheduler "
5818 "attribute is set to B<PTHREAD_INHERIT_SCHED>, meaning that threads created "
5819 "using the thread attributes object should ignore the scheduling attributes "
5820 "specified in the attributes object and instead take their scheduling "
5821 "attributes from the creating thread."
5825 #: build/C/man3/pthread_setschedparam.3:205
5828 "# B<./a.out -mf10 -ar20 -i i>\n"
5829 "Scheduler settings of main thread\n"
5830 " policy=SCHED_FIFO, priority=10\n"
5834 #: build/C/man3/pthread_setschedparam.3:209
5837 "Scheduler settings in \\(aqattr\\(aq\n"
5838 " policy=SCHED_RR, priority=20\n"
5839 " inheritsched is INHERIT\n"
5843 #: build/C/man3/pthread_setschedparam.3:212
5846 "Scheduler attributes of new thread\n"
5847 " policy=SCHED_FIFO, priority=10\n"
5851 #: build/C/man3/pthread_setschedparam.3:218
5853 "In the above output, one can see that the scheduling policy and priority "
5854 "were taken from the creating thread, rather than the thread attributes "
5859 #: build/C/man3/pthread_setschedparam.3:224
5861 "Note that if we had omitted the I<-i\\ i> option, the output would have been "
5862 "the same, since B<PTHREAD_INHERIT_SCHED> is the default for the inherit "
5863 "scheduler attribute."
5867 #: build/C/man3/pthread_setschedparam.3:228
5869 msgid "/* pthreads_sched_test.c */\n"
5873 #: build/C/man3/pthread_setschedparam.3:234
5876 "#include E<lt>pthread.hE<gt>\n"
5877 "#include E<lt>stdio.hE<gt>\n"
5878 "#include E<lt>stdlib.hE<gt>\n"
5879 "#include E<lt>unistd.hE<gt>\n"
5880 "#include E<lt>errno.hE<gt>\n"
5884 #: build/C/man3/pthread_setschedparam.3:243
5888 "usage(char *prog_name, char *msg)\n"
5890 " if (msg != NULL)\n"
5891 " fputs(msg, stderr);\n"
5895 #: build/C/man3/pthread_setschedparam.3:260
5898 " fprintf(stderr, \"Usage: %s [options]\\en\", prog_name);\n"
5899 " fprintf(stderr, \"Options are:\\en\");\n"
5900 "#define fpe(msg) fprintf(stderr, \"\\et%s\", msg); /* Shorter */\n"
5901 " fpe(\"-aE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and "
5902 "priority in\\en\");\n"
5903 " fpe(\" thread attributes object\\en\");\n"
5904 " fpe(\" E<lt>policyE<gt> can be\\en\");\n"
5905 " fpe(\" f SCHED_FIFO\\en\");\n"
5906 " fpe(\" r SCHED_RR\\en\");\n"
5907 " fpe(\" o SCHED_OTHER\\en\");\n"
5908 " fpe(\"-A Use default thread attributes object\\en\");\n"
5909 " fpe(\"-i {e|s} Set inherit scheduler attribute to\\en\");\n"
5910 " fpe(\" \\(aqexplicit\\(aq or \\(aqinherit\\(aq\\en\");\n"
5911 " fpe(\"-mE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and "
5912 "priority on\\en\");\n"
5913 " fpe(\" main thread before pthread_create() "
5915 " exit(EXIT_FAILURE);\n"
5920 #: build/C/man3/pthread_setschedparam.3:271
5924 "get_policy(char p, int *policy)\n"
5927 " case \\(aqf\\(aq: *policy = SCHED_FIFO; return 1;\n"
5928 " case \\(aqr\\(aq: *policy = SCHED_RR; return 1;\n"
5929 " case \\(aqo\\(aq: *policy = SCHED_OTHER; return 1;\n"
5930 " default: return 0;\n"
5936 #: build/C/man3/pthread_setschedparam.3:282
5940 "display_sched_attr(int policy, struct sched_param *param)\n"
5942 " printf(\" policy=%s, priority=%d\\en\",\n"
5943 " (policy == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
5944 " (policy == SCHED_RR) ? \"SCHED_RR\" :\n"
5945 " (policy == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
5947 " param-E<gt>sched_priority);\n"
5952 #: build/C/man3/pthread_setschedparam.3:288
5956 "display_thread_sched_attr(char *msg)\n"
5959 " struct sched_param param;\n"
5963 #: build/C/man3/pthread_setschedparam.3:292
5966 " s = pthread_getschedparam(pthread_self(), &policy, ¶m);\n"
5968 " handle_error_en(s, \"pthread_getschedparam\");\n"
5972 #: build/C/man3/pthread_setschedparam.3:296
5975 " printf(\"%s\\en\", msg);\n"
5976 " display_sched_attr(policy, ¶m);\n"
5981 #: build/C/man3/pthread_setschedparam.3:301
5985 "thread_start(void *arg)\n"
5987 " display_thread_sched_attr(\"Scheduler attributes of new thread\");\n"
5991 #: build/C/man3/pthread_setschedparam.3:304
5999 #: build/C/man3/pthread_setschedparam.3:314
6003 "main(int argc, char *argv[])\n"
6005 " int s, opt, inheritsched, use_null_attrib, policy;\n"
6006 " pthread_t thread;\n"
6007 " pthread_attr_t attr;\n"
6008 " pthread_attr_t *attrp;\n"
6009 " char *attr_sched_str, *main_sched_str, *inheritsched_str;\n"
6010 " struct sched_param param;\n"
6014 #: build/C/man3/pthread_setschedparam.3:316
6016 msgid " /* Process command-line options */\n"
6020 #: build/C/man3/pthread_setschedparam.3:321
6023 " use_null_attrib = 0;\n"
6024 " attr_sched_str = NULL;\n"
6025 " main_sched_str = NULL;\n"
6026 " inheritsched_str = NULL;\n"
6030 #: build/C/man3/pthread_setschedparam.3:331
6033 " while ((opt = getopt(argc, argv, \"a:Ai:m:\")) != -1) {\n"
6035 " case \\(aqa\\(aq: attr_sched_str = optarg; break;\n"
6036 " case \\(aqA\\(aq: use_null_attrib = 1; break;\n"
6037 " case \\(aqi\\(aq: inheritsched_str = optarg; break;\n"
6038 " case \\(aqm\\(aq: main_sched_str = optarg; break;\n"
6039 " default: usage(argv[0], \"Unrecognized option\\en\");\n"
6045 #: build/C/man3/pthread_setschedparam.3:335
6048 " if (use_null_attrib &&\n"
6049 " (inheritsched_str != NULL || attr_sched_str != NULL))\n"
6050 " usage(argv[0], \"Can\\(aqt specify -A with -i or -a\\en\");\n"
6054 #: build/C/man3/pthread_setschedparam.3:338
6057 " /* Optionally set scheduling attributes of main thread,\n"
6058 " and display the attributes */\n"
6062 #: build/C/man3/pthread_setschedparam.3:343
6065 " if (main_sched_str != NULL) {\n"
6066 " if (!get_policy(main_sched_str[0], &policy))\n"
6067 " usage(argv[0], \"Bad policy for main thread (-s)\\en\");\n"
6068 " param.sched_priority = strtol(&main_sched_str[1], NULL, 0);\n"
6072 #: build/C/man3/pthread_setschedparam.3:348
6075 " s = pthread_setschedparam(pthread_self(), policy, ¶m);\n"
6077 " handle_error_en(s, \"pthread_setschedparam\");\n"
6082 #: build/C/man3/pthread_setschedparam.3:351
6085 " display_thread_sched_attr(\"Scheduler settings of main thread\");\n"
6086 " printf(\"\\en\");\n"
6090 #: build/C/man3/pthread_setschedparam.3:353
6092 msgid " /* Initialize thread attributes object according to options */\n"
6096 #: build/C/man3/pthread_setschedparam.3:362
6099 " if (!use_null_attrib) {\n"
6100 " s = pthread_attr_init(&attr);\n"
6102 " handle_error_en(s, \"pthread_attr_init\");\n"
6108 #: build/C/man3/pthread_setschedparam.3:370
6111 " if (inheritsched_str != NULL) {\n"
6112 " if (inheritsched_str[0] == \\(aqe\\(aq)\n"
6113 " inheritsched = PTHREAD_EXPLICIT_SCHED;\n"
6114 " else if (inheritsched_str[0] == \\(aqi\\(aq)\n"
6115 " inheritsched = PTHREAD_INHERIT_SCHED;\n"
6117 " usage(argv[0], \"Value for -i must be \\(aqe\\(aq or "
6118 "\\(aqi\\(aq\\en\");\n"
6122 #: build/C/man3/pthread_setschedparam.3:375
6125 " s = pthread_attr_setinheritsched(&attr, inheritsched);\n"
6127 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
6132 #: build/C/man3/pthread_setschedparam.3:381
6135 " if (attr_sched_str != NULL) {\n"
6136 " if (!get_policy(attr_sched_str[0], &policy))\n"
6138 " \"Bad policy for \\(aqattr\\(aq (-a)\\en\");\n"
6139 " param.sched_priority = strtol(&attr_sched_str[1], NULL, 0);\n"
6143 #: build/C/man3/pthread_setschedparam.3:389
6146 " s = pthread_attr_setschedpolicy(&attr, policy);\n"
6148 " handle_error_en(s, \"pthread_attr_setschedpolicy\");\n"
6149 " s = pthread_attr_setschedparam(&attr, ¶m);\n"
6151 " handle_error_en(s, \"pthread_attr_setschedparam\");\n"
6156 #: build/C/man3/pthread_setschedparam.3:392
6159 " /* If we initialized a thread attributes object, display\n"
6160 " the scheduling attributes that were set in the object */\n"
6164 #: build/C/man3/pthread_setschedparam.3:400
6167 " if (attrp != NULL) {\n"
6168 " s = pthread_attr_getschedparam(&attr, ¶m);\n"
6170 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
6171 " s = pthread_attr_getschedpolicy(&attr, &policy);\n"
6173 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
6177 #: build/C/man3/pthread_setschedparam.3:403
6180 " printf(\"Scheduler settings in \\(aqattr\\(aq\\en\");\n"
6181 " display_sched_attr(policy, ¶m);\n"
6185 #: build/C/man3/pthread_setschedparam.3:411
6188 " s = pthread_attr_getinheritsched(&attr, &inheritsched);\n"
6189 " printf(\" inheritsched is %s\\en\",\n"
6190 " (inheritsched == PTHREAD_INHERIT_SCHED) ? \"INHERIT\" :\n"
6191 " (inheritsched == PTHREAD_EXPLICIT_SCHED) ? \"EXPLICIT\" :\n"
6193 " printf(\"\\en\");\n"
6198 #: build/C/man3/pthread_setschedparam.3:413
6200 msgid " /* Create a thread that will display its scheduling attributes */\n"
6204 #: build/C/man3/pthread_setschedparam.3:417
6207 " s = pthread_create(&thread, attrp, &thread_start, NULL);\n"
6209 " handle_error_en(s, \"pthread_create\");\n"
6213 #: build/C/man3/pthread_setschedparam.3:419
6215 msgid " /* Destroy unneeded thread attributes object */\n"
6219 #: build/C/man3/pthread_setschedparam.3:427
6222 " s = pthread_join(thread, NULL);\n"
6224 " handle_error_en(s, \"pthread_join\");\n"
6228 #: build/C/man3/pthread_setschedparam.3:445
6230 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<sched_setscheduler>(2), "
6231 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
6232 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
6233 "B<pthread_create>(3), B<pthread_self>(3), B<pthread_setschedprio>(3), "
6238 #: build/C/man3/pthread_setschedprio.3:26
6240 msgid "PTHREAD_SETSCHEDPRIO"
6244 #: build/C/man3/pthread_setschedprio.3:26
6250 #: build/C/man3/pthread_setschedprio.3:29
6251 msgid "pthread_setschedprio - set scheduling priority of a thread"
6255 #: build/C/man3/pthread_setschedprio.3:34
6257 msgid "B<pthread_setschedprio(pthread_t >I<thread>B<, int >I<prio>B<);>\n"
6260 #. FIXME . nptl/pthread_setschedprio.c has the following
6261 #. /* If the thread should have higher priority because of some
6262 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
6263 #. Eventually (perhaps after writing the mutexattr pages), we
6264 #. may want to add something on the topic to this page.
6265 #. nptl/pthread_setschedparam.c has a similar case.
6267 #: build/C/man3/pthread_setschedprio.3:53
6269 "The B<pthread_setschedprio>() function sets the scheduling priority of the "
6270 "thread I<thread> to the value specified in I<prio>. (By contrast "
6271 "B<pthread_setschedparam>(3) changes both the scheduling policy and priority "
6276 #: build/C/man3/pthread_setschedprio.3:61
6278 "On success, this function returns 0; on error, it returns a nonzero error "
6279 "number. If B<pthread_setschedprio>() fails, the scheduling priority of "
6280 "I<thread> is not changed."
6284 #: build/C/man3/pthread_setschedprio.3:66
6285 msgid "I<prio> is not valid for the scheduling policy of the specified thread."
6289 #: build/C/man3/pthread_setschedprio.3:70
6291 "The caller does not have appropriate privileges to set the specified "
6296 #: build/C/man3/pthread_setschedprio.3:81
6298 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
6299 "priority to an unsupported value\") error for B<pthread_setschedparam>(3)."
6303 #: build/C/man3/pthread_setschedprio.3:83
6304 msgid "This function is available in glibc since version 2.3.4."
6308 #: build/C/man3/pthread_setschedprio.3:91
6310 "For a description of the permissions required to, and the effect of, "
6311 "changing a thread's scheduling priority, and details of the permitted ranges "
6312 "for priorities in each scheduling policy, see B<sched_setscheduler>(2)."
6316 #: build/C/man3/pthread_setschedprio.3:105
6318 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<sched_setscheduler>(2), "
6319 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
6320 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
6321 "B<pthread_create>(3), B<pthread_self>(3), B<pthread_setschedparam>(3), "
6326 #: build/C/man3/pthread_sigmask.3:26
6328 msgid "PTHREAD_SIGMASK"
6332 #: build/C/man3/pthread_sigmask.3:29
6333 msgid "pthread_sigmask - examine and change mask of blocked signals"
6337 #: build/C/man3/pthread_sigmask.3:35
6340 "B<int pthread_sigmask(int >I<how>B<, const sigset_t *>I<set>B<, sigset_t "
6341 "*>I<oldset>B<);>\n"
6345 #: build/C/man3/pthread_sigmask.3:46
6347 "The B<pthread_sigmask>() function is just like B<sigprocmask>(2), with the "
6348 "difference that its use in multithreaded programs is explicitly specified by "
6349 "POSIX.1-2001. Other differences are noted in this page."
6353 #: build/C/man3/pthread_sigmask.3:49
6355 "For a description of the arguments and operation of this function, see "
6356 "B<sigprocmask>(2)."
6360 #: build/C/man3/pthread_sigmask.3:54
6362 "On success, B<pthread_sigmask>() returns 0; on error, it returns an error "
6367 #: build/C/man3/pthread_sigmask.3:57
6368 msgid "See B<sigprocmask>(2)."
6372 #: build/C/man3/pthread_sigmask.3:61
6373 msgid "A new thread inherits a copy of its creator's signal mask."
6377 #: build/C/man3/pthread_sigmask.3:66
6379 "The program below blocks some signals in the main thread, and then creates a "
6380 "dedicated thread to fetch those signals via B<sigwait>(3). The following "
6381 "shell session demonstrates its use:"
6385 #: build/C/man3/pthread_sigmask.3:77
6390 "$B< kill -QUIT %1>\n"
6391 "Signal handling thread got signal 3\n"
6392 "$B< kill -USR1 %1>\n"
6393 "Signal handling thread got signal 10\n"
6394 "$B< kill -TERM %1>\n"
6395 "[1]+ Terminated ./a.out\n"
6399 #: build/C/man3/pthread_sigmask.3:88
6402 "#include E<lt>pthread.hE<gt>\n"
6403 "#include E<lt>stdio.hE<gt>\n"
6404 "#include E<lt>stdlib.hE<gt>\n"
6405 "#include E<lt>unistd.hE<gt>\n"
6406 "#include E<lt>signal.hE<gt>\n"
6407 "#include E<lt>errno.hE<gt>\n"
6411 #: build/C/man3/pthread_sigmask.3:90
6413 msgid "/* Simple error handling functions */\n"
6417 #: build/C/man3/pthread_sigmask.3:99
6421 "sig_thread(void *arg)\n"
6423 " sigset_t *set = arg;\n"
6428 #: build/C/man3/pthread_sigmask.3:107
6432 " s = sigwait(set, &sig);\n"
6434 " handle_error_en(s, \"sigwait\");\n"
6435 " printf(\"Signal handling thread got signal %d\\en\", sig);\n"
6441 #: build/C/man3/pthread_sigmask.3:114
6445 "main(int argc, char *argv[])\n"
6447 " pthread_t thread;\n"
6453 #: build/C/man3/pthread_sigmask.3:117
6456 " /* Block SIGQUIT and SIGUSR1; other threads created by main()\n"
6457 " will inherit a copy of the signal mask. */\n"
6461 #: build/C/man3/pthread_sigmask.3:124
6464 " sigemptyset(&set);\n"
6465 " sigaddset(&set, SIGQUIT);\n"
6466 " sigaddset(&set, SIGUSR1);\n"
6467 " s = pthread_sigmask(SIG_BLOCK, &set, NULL);\n"
6469 " handle_error_en(s, \"pthread_sigmask\");\n"
6473 #: build/C/man3/pthread_sigmask.3:128
6476 " s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);\n"
6478 " handle_error_en(s, \"pthread_create\");\n"
6482 #: build/C/man3/pthread_sigmask.3:131
6485 " /* Main thread carries on to create other threads and/or do\n"
6490 #: build/C/man3/pthread_sigmask.3:134
6493 " pause(); /* Dummy pause so we can test program */\n"
6498 #: build/C/man3/pthread_sigmask.3:144
6500 "B<sigaction>(2), B<sigpending>(2), B<sigprocmask>(2), B<pthread_create>(3), "
6501 "B<pthread_kill>(3), B<sigsetops>(3), B<pthreads>(7), B<signal>(7)"
6505 #: build/C/man3/pthread_sigqueue.3:25
6507 msgid "PTHREAD_SIGQUEUE"
6511 #: build/C/man3/pthread_sigqueue.3:28
6512 msgid "pthread_sigqueue - queue a signal and data to a thread"
6516 #: build/C/man3/pthread_sigqueue.3:34
6519 "B<int pthread_sigqueue(pthread_t *>I<thread>B<, int >I<sig>B<,>\n"
6520 "B< const union sigval >I<value>B<);>\n"
6524 #: build/C/man3/pthread_sigqueue.3:45
6525 msgid "B<pthread_sigqueue>(): _GNU_SOURCE"
6529 #: build/C/man3/pthread_sigqueue.3:53
6531 "The B<pthread_sigqueue>() function performs a similar task to "
6532 "B<sigqueue>(3), but, rather than sending a signal to a process, it sends a "
6533 "signal to a thread in the same process as the calling thread."
6537 #: build/C/man3/pthread_sigqueue.3:65
6539 "The I<thread> argument is the ID of a thread in the same process as the "
6540 "caller. The I<sig> argument specifies the signal to be sent. The I<value> "
6541 "argument specifies data to accompany the signal; see B<sigqueue>(3) for "
6546 #: build/C/man3/pthread_sigqueue.3:70
6548 "On success, B<pthread_sigqueue>() returns 0; on error, it returns an error "
6553 #: build/C/man3/pthread_sigqueue.3:77
6555 "The limit of signals which may be queued has been reached. (See "
6556 "B<signal>(7) for further information.)"
6560 #: build/C/man3/pthread_sigqueue.3:81
6561 msgid "I<sig> was invalid."
6565 #: build/C/man3/pthread_sigqueue.3:81
6571 #: build/C/man3/pthread_sigqueue.3:85
6572 msgid "B<pthread_sigqueue>() is not supported on this system."
6576 #: build/C/man3/pthread_sigqueue.3:89
6577 msgid "I<thread> is not valid."
6581 #: build/C/man3/pthread_sigqueue.3:93
6582 msgid "The B<pthread_sigqueue>() function first appeared in glibc 2.11."
6586 #: build/C/man3/pthread_sigqueue.3:95
6587 msgid "This function is a GNU extension."
6591 #: build/C/man3/pthread_sigqueue.3:103
6593 "B<rt_tgsigqueueinfo>(2), B<sigaction>(2), B<pthread_sigmask>(3), "
6594 "B<sigqueue>(3), B<sigwait>(3), B<pthreads>(7), B<signal>(7)"
6598 #: build/C/man3/pthread_testcancel.3:26
6600 msgid "PTHREAD_TESTCANCEL"
6604 #: build/C/man3/pthread_testcancel.3:26
6610 #: build/C/man3/pthread_testcancel.3:29
6611 msgid "pthread_testcancel - request delivery of any pending cancellation request"
6615 #: build/C/man3/pthread_testcancel.3:34
6617 msgid "B<void pthread_testcancel(void);>\n"
6621 #: build/C/man3/pthread_testcancel.3:43
6623 "Calling B<pthread_testcancel>() creates a cancellation point within the "
6624 "calling thread, so that a thread that is otherwise executing code that "
6625 "contains no cancellation points will respond to a cancellation request."
6629 #: build/C/man3/pthread_testcancel.3:50
6631 "If cancelability is disabled (using B<pthread_setcancelstate>(3)), or no "
6632 "cancellation request is pending, then a call to B<pthread_testcancel>() has "
6637 #: build/C/man3/pthread_testcancel.3:54
6639 "This function does not return a value. If the calling thread is canceled as "
6640 "a consequence of a call to this function, then the function does not return."
6644 #: build/C/man3/pthread_testcancel.3:63
6645 msgid "See B<pthread_cleanup_push>(3)."
6649 #: build/C/man3/pthread_testcancel.3:68
6651 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
6652 "B<pthread_setcancelstate>(3), B<pthreads>(7)"
6656 #: build/C/man3/pthread_tryjoin_np.3:26
6658 msgid "PTHREAD_TRYJOIN_NP"
6662 #: build/C/man3/pthread_tryjoin_np.3:30
6664 "pthread_tryjoin_np, pthread_timedjoin_np - try to join with a terminated "
6669 #: build/C/man3/pthread_tryjoin_np.3:36
6671 msgid "B<int pthread_tryjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
6675 #: build/C/man3/pthread_tryjoin_np.3:39
6678 "B<int pthread_timedjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<,>\n"
6679 "B< const struct timespec *>I<abstime>B<);>\n"
6683 #: build/C/man3/pthread_tryjoin_np.3:46
6685 "These functions operate in the same way as B<pthread_join>(3), except for "
6686 "the differences described on this page."
6690 #: build/C/man3/pthread_tryjoin_np.3:58
6692 "The B<pthread_tryjoin_np>() function performs a nonblocking join with the "
6693 "thread I<thread>, returning the exit status of the thread in I<*retval>. If "
6694 "I<thread> has not yet terminated, then instead of blocking, as is done by "
6695 "B<pthread_join>(3), the call returns an error."
6699 #: build/C/man3/pthread_tryjoin_np.3:76
6701 "The B<pthread_timedjoin_np>() function performs a join-with-timeout. If "
6702 "I<thread> has not yet terminated, then the call blocks until a maximum time, "
6703 "specified in I<abstime>. If the timeout expires before I<thread> "
6704 "terminates, the call returns an error. The I<abstime> argument is a "
6705 "structure of the following form, specifying an absolute time measured since "
6706 "the Epoch (see B<time>(2)):"
6710 #: build/C/man3/pthread_tryjoin_np.3:83
6713 "struct timespec {\n"
6714 " time_t tv_sec; /* seconds */\n"
6715 " long tv_nsec; /* nanoseconds */\n"
6720 #: build/C/man3/pthread_tryjoin_np.3:89
6721 msgid "On success, these functions return 0; on error, they return an error number."
6725 #: build/C/man3/pthread_tryjoin_np.3:94
6727 "These functions can fail with the same errors as B<pthread_join>(3). "
6728 "B<pthread_tryjoin_np>() can in addition fail with the following error:"
6732 #: build/C/man3/pthread_tryjoin_np.3:94
6738 #: build/C/man3/pthread_tryjoin_np.3:98
6739 msgid "I<thread> had not yet terminated at the time of the call."
6743 #: build/C/man3/pthread_tryjoin_np.3:101
6744 msgid "B<pthread_timedjoin_np>() can in addition fail with the following error:"
6748 #: build/C/man3/pthread_tryjoin_np.3:101
6750 msgid "B<ETIMEDOUT>"
6754 #: build/C/man3/pthread_tryjoin_np.3:106
6755 msgid "The call timed out before I<thread> terminated."
6759 #: build/C/man3/pthread_tryjoin_np.3:110
6760 msgid "B<pthread_timedjoin_np>() never returns the error B<EINTR>."
6764 #: build/C/man3/pthread_tryjoin_np.3:112
6765 msgid "These functions first appeared in glibc in version 2.3.3."
6769 #: build/C/man3/pthread_tryjoin_np.3:117
6770 msgid "The following code waits to join for up to 5 seconds:"
6774 #: build/C/man3/pthread_tryjoin_np.3:121
6777 " struct timespec ts;\n"
6782 #: build/C/man3/pthread_tryjoin_np.3:123
6788 #: build/C/man3/pthread_tryjoin_np.3:127
6791 " if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {\n"
6792 "\t/* Handle error */\n"
6797 #: build/C/man3/pthread_tryjoin_np.3:129
6799 msgid " ts.tv_sec += 5;\n"
6803 #: build/C/man3/pthread_tryjoin_np.3:134
6806 " s = pthread_timedjoin_np(thread, NULL, &ts);\n"
6808 " /* Handle error */\n"
6813 #: build/C/man3/pthread_tryjoin_np.3:140
6814 msgid "B<clock_gettime>(2), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
6818 #: build/C/man3/pthread_yield.3:25
6820 msgid "PTHREAD_YIELD"
6824 #: build/C/man3/pthread_yield.3:25
6830 #: build/C/man3/pthread_yield.3:28
6831 msgid "pthread_yield - yield the processor"
6835 #: build/C/man3/pthread_yield.3:34
6837 msgid "B<int pthread_yield(void);>\n"
6841 #: build/C/man3/pthread_yield.3:44
6843 "B<pthread_yield>() causes the calling thread to relinquish the CPU. The "
6844 "thread is placed at the end of the run queue for its static priority and "
6845 "another thread is scheduled to run. For further details, see "
6850 #: build/C/man3/pthread_yield.3:49
6852 "On success, B<pthread_yield>() returns 0; on error, it returns an error "
6857 #: build/C/man3/pthread_yield.3:53
6859 "On Linux, this call always succeeds (but portable and future-proof "
6860 "applications should nevertheless handle a possible error return)."
6863 #. e.g., the BSDs, Tru64, AIX, and Irix.
6865 #: build/C/man3/pthread_yield.3:59
6867 "This call is nonstandard, but present on several other systems. Use the "
6868 "standardized B<sched_yield>(2) instead."
6872 #: build/C/man3/pthread_yield.3:62
6873 msgid "On Linux, this function is implemented as a call to B<sched_yield>(2)."
6877 #: build/C/man3/pthread_yield.3:66
6878 msgid "B<sched_setscheduler>(2), B<sched_yield>(2), B<pthreads>(7)"
6882 #: build/C/man7/pthreads.7:26
6888 #: build/C/man7/pthreads.7:26
6894 #: build/C/man7/pthreads.7:29
6895 msgid "pthreads - POSIX threads"
6899 #: build/C/man7/pthreads.7:36
6901 "POSIX.1 specifies a set of interfaces (functions, header files) for threaded "
6902 "programming commonly known as POSIX threads, or Pthreads. A single process "
6903 "can contain multiple threads, all of which are executing the same program. "
6904 "These threads share the same global memory (data and heap segments), but "
6905 "each thread has its own stack (automatic variables)."
6909 #: build/C/man7/pthreads.7:39
6911 "POSIX.1 also requires that threads share a range of other attributes (i.e., "
6912 "these attributes are process-wide rather than per-thread):"
6916 #: build/C/man7/pthreads.7:39 build/C/man7/pthreads.7:41 build/C/man7/pthreads.7:43 build/C/man7/pthreads.7:45 build/C/man7/pthreads.7:47 build/C/man7/pthreads.7:49 build/C/man7/pthreads.7:51 build/C/man7/pthreads.7:54 build/C/man7/pthreads.7:56 build/C/man7/pthreads.7:59 build/C/man7/pthreads.7:65 build/C/man7/pthreads.7:70 build/C/man7/pthreads.7:73 build/C/man7/pthreads.7:76 build/C/man7/pthreads.7:84 build/C/man7/pthreads.7:88 build/C/man7/pthreads.7:91 build/C/man7/pthreads.7:95 build/C/man7/pthreads.7:98 build/C/man7/pthreads.7:105 build/C/man7/pthreads.7:108 build/C/man7/pthreads.7:685 build/C/man7/pthreads.7:692 build/C/man7/pthreads.7:704 build/C/man7/pthreads.7:714 build/C/man7/pthreads.7:718 build/C/man7/pthreads.7:727 build/C/man7/pthreads.7:737 build/C/man7/pthreads.7:744 build/C/man7/pthreads.7:751 build/C/man7/pthreads.7:753 build/C/man7/pthreads.7:756 build/C/man7/pthreads.7:762 build/C/man7/pthreads.7:765 build/C/man7/pthreads.7:767 build/C/man7/pthreads.7:769 build/C/man7/pthreads.7:779 build/C/man7/pthreads.7:799 build/C/man7/pthreads.7:808 build/C/man7/pthreads.7:814 build/C/man7/pthreads.7:816 build/C/man7/pthreads.7:818 build/C/man7/pthreads.7:822 build/C/man7/pthreads.7:827 build/C/man7/pthreads.7:835
6922 #: build/C/man7/pthreads.7:41
6927 #: build/C/man7/pthreads.7:43
6928 msgid "parent process ID"
6932 #: build/C/man7/pthreads.7:45
6933 msgid "process group ID and session ID"
6937 #: build/C/man7/pthreads.7:47
6938 msgid "controlling terminal"
6942 #: build/C/man7/pthreads.7:49
6943 msgid "user and group IDs"
6947 #: build/C/man7/pthreads.7:51
6948 msgid "open file descriptors"
6952 #: build/C/man7/pthreads.7:54
6953 msgid "record locks (see B<fcntl>(2))"
6957 #: build/C/man7/pthreads.7:56
6958 msgid "signal dispositions"
6962 #: build/C/man7/pthreads.7:59
6963 msgid "file mode creation mask (B<umask>(2))"
6967 #: build/C/man7/pthreads.7:65
6968 msgid "current directory (B<chdir>(2)) and root directory (B<chroot>(2))"
6972 #: build/C/man7/pthreads.7:70
6973 msgid "interval timers (B<setitimer>(2)) and POSIX timers (B<timer_create>(2))"
6977 #: build/C/man7/pthreads.7:73
6978 msgid "nice value (B<setpriority>(2))"
6982 #: build/C/man7/pthreads.7:76
6983 msgid "resource limits (B<setrlimit>(2))"
6987 #: build/C/man7/pthreads.7:81
6989 "measurements of the consumption of CPU time (B<times>(2)) and resources "
6994 #: build/C/man7/pthreads.7:84
6996 "As well as the stack, POSIX.1 specifies that various other attributes are "
6997 "distinct for each thread, including:"
7001 #: build/C/man7/pthreads.7:88
7002 msgid "thread ID (the I<pthread_t> data type)"
7006 #: build/C/man7/pthreads.7:91
7007 msgid "signal mask (B<pthread_sigmask>(3))"
7011 #: build/C/man7/pthreads.7:95
7012 msgid "the I<errno> variable"
7016 #: build/C/man7/pthreads.7:98
7017 msgid "alternate signal stack (B<sigaltstack>(2))"
7021 #: build/C/man7/pthreads.7:103
7023 "real-time scheduling policy and priority (B<sched_setscheduler>(2) and "
7024 "B<sched_setparam>(2))"
7028 #: build/C/man7/pthreads.7:105
7029 msgid "The following Linux-specific features are also per-thread:"
7033 #: build/C/man7/pthreads.7:108
7034 msgid "capabilities (see B<capabilities>(7))"
7038 #: build/C/man7/pthreads.7:111
7039 msgid "CPU affinity (B<sched_setaffinity>(2))"
7043 #: build/C/man7/pthreads.7:111
7045 msgid "Pthreads function return values"
7049 #: build/C/man7/pthreads.7:118
7051 "Most pthreads functions return 0 on success, and an error number of "
7052 "failure. Note that the pthreads functions do not set I<errno>. For each of "
7053 "the pthreads functions that can return an error, POSIX.1-2001 specifies that "
7054 "the function can never fail with the error B<EINTR>."
7058 #: build/C/man7/pthreads.7:118
7064 #: build/C/man7/pthreads.7:132
7066 "Each of the threads in a process has a unique thread identifier (stored in "
7067 "the type I<pthread_t>). This identifier is returned to the caller of "
7068 "B<pthread_create>(3), and a thread can obtain its own thread identifier "
7069 "using B<pthread_self>(3). Thread IDs are only guaranteed to be unique "
7070 "within a process. A thread ID may be reused after a terminated thread has "
7071 "been joined, or a detached thread has terminated. In all pthreads functions "
7072 "that accept a thread ID as an argument, that ID by definition refers to a "
7073 "thread in the same process as the caller."
7077 #: build/C/man7/pthreads.7:132
7079 msgid "Thread-safe functions"
7083 #: build/C/man7/pthreads.7:136
7085 "A thread-safe function is one that can be safely (i.e., it will deliver the "
7086 "same results regardless of whether it is) called from multiple threads at "
7091 #: build/C/man7/pthreads.7:140
7093 "POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the "
7094 "standard shall be thread-safe, except for the following functions:"
7098 #: build/C/man7/pthreads.7:234
7105 "ctermid() if passed a non-NULL argument\n"
7119 "ecvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7124 "fcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7126 "gcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7128 "getchar_unlocked()\n"
7134 "gethostbyaddr() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7135 "gethostbyname() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7142 "getprotobyname()\n"
7143 "getprotobynumber()\n"
7171 "putchar_unlocked()\n"
7182 "strsignal() [Added in POSIX.1-2008]\n"
7184 "system() [Added in POSIX.1-2008]\n"
7185 "tmpnam() if passed a non-NULL argument\n"
7188 "wcrtomb() if its final argument is NULL\n"
7189 "wcsrtombs() if its final argument is NULL\n"
7195 #: build/C/man7/pthreads.7:236
7197 msgid "Async-cancel-safe functions"
7201 #: build/C/man7/pthreads.7:240
7203 "An async-cancel-safe function is one that can be safely called in an "
7204 "application where asynchronous cancelability is enabled (see "
7205 "B<pthread_setcancelstate>(3))."
7209 #: build/C/man7/pthreads.7:243
7211 "Only the following functions are required to be async-cancel-safe by "
7212 "POSIX.1-2001 and POSIX.1-2008:"
7216 #: build/C/man7/pthreads.7:249
7219 "pthread_cancel()\n"
7220 "pthread_setcancelstate()\n"
7221 "pthread_setcanceltype()\n"
7225 #: build/C/man7/pthreads.7:251
7227 msgid "Cancellation points"
7231 #: build/C/man7/pthreads.7:258
7233 "POSIX.1 specifies that certain functions must, and certain other functions "
7234 "may, be cancellation points. If a thread is cancelable, its cancelability "
7235 "type is deferred, and a cancellation request is pending for the thread, then "
7236 "the thread is canceled when it calls a function that is a cancellation "
7241 #: build/C/man7/pthreads.7:261
7243 "The following functions are required to be cancellation points by "
7244 "POSIX.1-2001 and/or POSIX.1-2008:"
7248 #: build/C/man7/pthreads.7:324
7253 "clock_nanosleep()\n"
7257 "fcntl() F_SETLKW\n"
7265 "mq_timedreceive()\n"
7272 "openat() [Added in POSIX.1-2008]\n"
7277 "pthread_cond_timedwait()\n"
7278 "pthread_cond_wait()\n"
7280 "pthread_testcancel()\n"
7295 "sigpause() [POSIX.1-2001 only (moves to \"may\" list in POSIX.1-2008)]\n"
7303 "usleep() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7312 #: build/C/man7/pthreads.7:329
7314 "The following functions may be cancellation points according to POSIX.1-2001 "
7315 "and/or POSIX.1-2008:"
7319 #: build/C/man7/pthreads.7:557
7328 "chmod() [Added in POSIX.1-2008]\n"
7329 "chown() [Added in POSIX.1-2008]\n"
7343 "dprintf() [Added in POSIX.1-2008]\n"
7351 "faccessat() [Added in POSIX.1-2008]\n"
7352 "fchmod() [Added in POSIX.1-2008]\n"
7353 "fchmodat() [Added in POSIX.1-2008]\n"
7354 "fchown() [Added in POSIX.1-2008]\n"
7355 "fchownat() [Added in POSIX.1-2008]\n"
7357 "fcntl() (for any value of cmd argument)\n"
7379 "fstatat() [Added in POSIX.1-2008]\n"
7383 "futimens() [Added in POSIX.1-2008]\n"
7391 "getchar_unlocked()\n"
7394 "getdelim() [Added in POSIX.1-2008]\n"
7400 "gethostbyaddr() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7401 "gethostbyname() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7405 "getline() [Added in POSIX.1-2008]\n"
7412 "getopt() (if opterr is nonzero)\n"
7413 "getprotobyname()\n"
7414 "getprotobynumber()\n"
7430 "getwd() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7436 "linkat() [Added in POSIX.1-2008]\n"
7437 "lio_listio() [Added in POSIX.1-2008]\n"
7440 "lockf() [Added in POSIX.1-2008]\n"
7443 "mkdir() [Added in POSIX.1-2008]\n"
7444 "mkdirat() [Added in POSIX.1-2008]\n"
7445 "mkdtemp() [Added in POSIX.1-2008]\n"
7446 "mkfifo() [Added in POSIX.1-2008]\n"
7447 "mkfifoat() [Added in POSIX.1-2008]\n"
7448 "mknod() [Added in POSIX.1-2008]\n"
7449 "mknodat() [Added in POSIX.1-2008]\n"
7460 "posix_fallocate()\n"
7465 "posix_trace_clear()\n"
7466 "posix_trace_close()\n"
7467 "posix_trace_create()\n"
7468 "posix_trace_create_withlog()\n"
7469 "posix_trace_eventtypelist_getnext_id()\n"
7470 "posix_trace_eventtypelist_rewind()\n"
7471 "posix_trace_flush()\n"
7472 "posix_trace_get_attr()\n"
7473 "posix_trace_get_filter()\n"
7474 "posix_trace_get_status()\n"
7475 "posix_trace_getnext_event()\n"
7476 "posix_trace_open()\n"
7477 "posix_trace_rewind()\n"
7478 "posix_trace_set_filter()\n"
7479 "posix_trace_shutdown()\n"
7480 "posix_trace_timedgetnext_event()\n"
7481 "posix_typed_mem_open()\n"
7483 "psiginfo() [Added in POSIX.1-2008]\n"
7484 "psignal() [Added in POSIX.1-2008]\n"
7485 "pthread_rwlock_rdlock()\n"
7486 "pthread_rwlock_timedrdlock()\n"
7487 "pthread_rwlock_timedwrlock()\n"
7488 "pthread_rwlock_wrlock()\n"
7492 "putchar_unlocked()\n"
7499 "readlink() [Added in POSIX.1-2008]\n"
7500 "readlinkat() [Added in POSIX.1-2008]\n"
7503 "renameat() [Added in POSIX.1-2008]\n"
7506 "scandir() [Added in POSIX.1-2008]\n"
7517 "sigpause() [Added in POSIX.1-2008]\n"
7523 "symlinkat() [Added in POSIX.1-2008]\n"
7534 "unlinkat() [Added in POSIX.1-2008]\n"
7535 "utime() [Added in POSIX.1-2008]\n"
7536 "utimensat() [Added in POSIX.1-2008]\n"
7537 "utimes() [Added in POSIX.1-2008]\n"
7538 "vdprintf() [Added in POSIX.1-2008]\n"
7549 #. So, scanning "cancellation point" comments in the glibc 2.8 header
7550 #. files, it looks as though at least the following nonstandard
7551 #. functions are cancellation points:
7591 #. getprotobynumber_r
7606 #. getwchar_unlocked
7613 #. pthread_timedjoin_np
7619 #. putwchar_unlocked
7640 #: build/C/man7/pthreads.7:655
7642 "An implementation may also mark other functions not specified in the "
7643 "standard as cancellation points. In particular, an implementation is likely "
7644 "to mark any nonstandard function that may block as a cancellation point. "
7645 "(This includes most functions that can touch files.)"
7649 #: build/C/man7/pthreads.7:655
7651 msgid "Compiling on Linux"
7655 #: build/C/man7/pthreads.7:658
7657 "On Linux, programs that use the Pthreads API should be compiled using I<cc "
7662 #: build/C/man7/pthreads.7:658
7664 msgid "Linux implementations of POSIX threads"
7668 #: build/C/man7/pthreads.7:661
7670 "Over time, two threading implementations have been provided by the GNU C "
7675 #: build/C/man7/pthreads.7:661
7677 msgid "B<LinuxThreads>"
7681 #: build/C/man7/pthreads.7:665
7683 "This is the original Pthreads implementation. Since glibc 2.4, this "
7684 "implementation is no longer supported."
7688 #: build/C/man7/pthreads.7:665
7690 msgid "B<NPTL> (Native POSIX Threads Library)"
7694 #: build/C/man7/pthreads.7:673
7696 "This is the modern Pthreads implementation. By comparison with "
7697 "LinuxThreads, NPTL provides closer conformance to the requirements of the "
7698 "POSIX.1 specification and better performance when creating large numbers of "
7699 "threads. NPTL is available since glibc 2.3.2, and requires features that "
7700 "are present in the Linux 2.6 kernel."
7704 #: build/C/man7/pthreads.7:683
7706 "Both of these are so-called 1:1 implementations, meaning that each thread "
7707 "maps to a kernel scheduling entity. Both threading implementations employ "
7708 "the Linux B<clone>(2) system call. In NPTL, thread synchronization "
7709 "primitives (mutexes, thread joining, and so on) are implemented using the "
7710 "Linux B<futex>(2) system call."
7714 #: build/C/man7/pthreads.7:683
7716 msgid "LinuxThreads"
7720 #: build/C/man7/pthreads.7:685
7721 msgid "The notable features of this implementation are the following:"
7725 #: build/C/man7/pthreads.7:692
7727 "In addition to the main (initial) thread, and the threads that the program "
7728 "creates using B<pthread_create>(3), the implementation creates a \"manager\" "
7729 "thread. This thread handles thread creation and termination. (Problems can "
7730 "result if this thread is inadvertently killed.)"
7734 #: build/C/man7/pthreads.7:704
7736 "Signals are used internally by the implementation. On Linux 2.2 and later, "
7737 "the first three real-time signals are used (see also B<signal>(7)). On "
7738 "older Linux kernels, B<SIGUSR1> and B<SIGUSR2> are used. Applications must "
7739 "avoid the use of whichever set of signals is employed by the implementation."
7743 #: build/C/man7/pthreads.7:711
7745 "Threads do not share process IDs. (In effect, LinuxThreads threads are "
7746 "implemented as processes which share more information than usual, but which "
7747 "do not share a common process ID.) LinuxThreads threads (including the "
7748 "manager thread) are visible as separate processes using B<ps>(1)."
7752 #: build/C/man7/pthreads.7:714
7754 "The LinuxThreads implementation deviates from the POSIX.1 specification in a "
7755 "number of ways, including the following:"
7759 #: build/C/man7/pthreads.7:718
7760 msgid "Calls to B<getpid>(2) return a different value in each thread."
7764 #: build/C/man7/pthreads.7:727
7766 "Calls to B<getppid>(2) in threads other than the main thread return the "
7767 "process ID of the manager thread; instead B<getppid>(2) in these threads "
7768 "should return the same value as B<getppid>(2) in the main thread."
7772 #: build/C/man7/pthreads.7:737
7774 "When one thread creates a new child process using B<fork>(2), any thread "
7775 "should be able to B<wait>(2) on the child. However, the implementation "
7776 "only allows the thread that created the child to B<wait>(2) on it."
7780 #: build/C/man7/pthreads.7:744
7782 "When a thread calls B<execve>(2), all other threads are terminated (as "
7783 "required by POSIX.1). However, the resulting process has the same PID as "
7784 "the thread that called B<execve>(2): it should have the same PID as the main "
7789 #: build/C/man7/pthreads.7:751
7791 "Threads do not share user and group IDs. This can cause complications with "
7792 "set-user-ID programs and can cause failures in Pthreads functions if an "
7793 "application changes its credentials using B<seteuid>(2) or similar."
7797 #: build/C/man7/pthreads.7:753
7798 msgid "Threads do not share a common session ID and process group ID."
7802 #: build/C/man7/pthreads.7:756
7803 msgid "Threads do not share record locks created using B<fcntl>(2)."
7807 #: build/C/man7/pthreads.7:762
7809 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
7810 "rather than process-wide."
7814 #: build/C/man7/pthreads.7:765
7815 msgid "Threads do not share semaphore undo values (see B<semop>(2))."
7819 #: build/C/man7/pthreads.7:767
7820 msgid "Threads do not share interval timers."
7823 #. FIXME . bug report filed for NPTL nice nonconformance
7824 #. http://bugzilla.kernel.org/show_bug.cgi?id=6258
7825 #. Sep 08: there is a patch by Denys Vlasenko to address this
7826 #. "make setpriority POSIX compliant; introduce PRIO_THREAD extension"
7827 #. Monitor this to see if it makes it into mainline.
7829 #: build/C/man7/pthreads.7:769 build/C/man7/pthreads.7:806
7830 msgid "Threads do not share a common nice value."
7834 #: build/C/man7/pthreads.7:779
7836 "POSIX.1 distinguishes the notions of signals that are directed to the "
7837 "process as a whole and signals that are directed to individual threads. "
7838 "According to POSIX.1, a process-directed signal (sent using B<kill>(2), for "
7839 "example) should be handled by a single, arbitrarily selected thread within "
7840 "the process. LinuxThreads does not support the notion of process-directed "
7841 "signals: signals may only be sent to specific threads."
7845 #: build/C/man7/pthreads.7:788
7847 "Threads have distinct alternate signal stack settings. However, a new "
7848 "thread's alternate signal stack settings are copied from the thread that "
7849 "created it, so that the threads initially share an alternate signal stack. "
7850 "(A new thread should start with no alternate signal stack defined. If two "
7851 "threads handle signals on their shared alternate signal stack at the same "
7852 "time, unpredictable program failures are likely to occur.)"
7856 #: build/C/man7/pthreads.7:788
7862 #: build/C/man7/pthreads.7:797
7864 "With NPTL, all of the threads in a process are placed in the same thread "
7865 "group; all members of a thread group share the same PID. NPTL does not "
7866 "employ a manager thread. NPTL makes internal use of the first two real-time "
7867 "signals (see also B<signal>(7)); these signals cannot be used in "
7872 #: build/C/man7/pthreads.7:799
7873 msgid "NPTL still has at least one nonconformance with POSIX.1:"
7877 #: build/C/man7/pthreads.7:808
7878 msgid "Some NPTL nonconformances only occur with older kernels:"
7882 #: build/C/man7/pthreads.7:814
7884 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
7885 "rather than process-wide (fixed in kernel 2.6.9)."
7889 #: build/C/man7/pthreads.7:816
7890 msgid "Threads do not share resource limits (fixed in kernel 2.6.10)."
7894 #: build/C/man7/pthreads.7:818
7895 msgid "Threads do not share interval timers (fixed in kernel 2.6.12)."
7899 #: build/C/man7/pthreads.7:822
7901 "Only the main thread is permitted to start a new session using B<setsid>(2) "
7902 "(fixed in kernel 2.6.16)."
7906 #: build/C/man7/pthreads.7:827
7908 "Only the main thread is permitted to make the process into a process group "
7909 "leader using B<setpgid>(2) (fixed in kernel 2.6.16)."
7913 #: build/C/man7/pthreads.7:833
7915 "Threads have distinct alternate signal stack settings. However, a new "
7916 "thread's alternate signal stack settings are copied from the thread that "
7917 "created it, so that the threads initially share an alternate signal stack "
7918 "(fixed in kernel 2.6.16)."
7922 #: build/C/man7/pthreads.7:835
7923 msgid "Note the following further points about the NPTL implementation:"
7927 #: build/C/man7/pthreads.7:849
7929 "If the stack size soft resource limit (see the description of "
7930 "B<RLIMIT_STACK> in B<setrlimit>(2)) is set to a value other than "
7931 "I<unlimited>, then this value defines the default stack size for new "
7932 "threads. To be effective, this limit must be set before the program is "
7933 "executed, perhaps using the I<ulimit -s> shell built-in command (I<limit "
7934 "stacksize> in the C shell)."
7938 #: build/C/man7/pthreads.7:849
7940 msgid "Determining the threading implementation"
7944 #: build/C/man7/pthreads.7:854
7946 "Since glibc 2.3.2, the B<getconf>(1) command can be used to determine the "
7947 "system's threading implementation, for example:"
7951 #: build/C/man7/pthreads.7:859
7954 "bash$ getconf GNU_LIBPTHREAD_VERSION\n"
7959 #: build/C/man7/pthreads.7:864
7961 "With older glibc versions, a command such as the following should be "
7962 "sufficient to determine the default threading implementation:"
7966 #: build/C/man7/pthreads.7:870
7969 "bash$ $( ldd /bin/ls | grep libc.so | awk \\(aq{print $3}\\(aq ) | \\e\n"
7970 " egrep -i \\(aqthreads|nptl\\(aq\n"
7971 " Native POSIX Threads Library by Ulrich Drepper et al\n"
7975 #: build/C/man7/pthreads.7:872
7977 msgid "Selecting the threading implementation: LD_ASSUME_KERNEL"
7981 #: build/C/man7/pthreads.7:887
7983 "On systems with a glibc that supports both LinuxThreads and NPTL (i.e., "
7984 "glibc 2.3.I<x>), the B<LD_ASSUME_KERNEL> environment variable can be used to "
7985 "override the dynamic linker's default choice of threading implementation. "
7986 "This variable tells the dynamic linker to assume that it is running on top "
7987 "of a particular kernel version. By specifying a kernel version that does "
7988 "not provide the support required by NPTL, we can force the use of "
7989 "LinuxThreads. (The most likely reason for doing this is to run a (broken) "
7990 "application that depends on some nonconformant behavior in LinuxThreads.) "
7995 #: build/C/man7/pthreads.7:893
7998 "bash$ $( LD_ASSUME_KERNEL=2.2.5 ldd /bin/ls | grep libc.so | \\e\n"
7999 " awk \\(aq{print $3}\\(aq ) | egrep -i "
8000 "\\(aqthreads|ntpl\\(aq\n"
8001 " linuxthreads-0.10 by Xavier Leroy\n"
8005 #: build/C/man7/pthreads.7:905
8007 "B<clone>(2), B<futex>(2), B<gettid>(2), B<proc>(5), B<futex>(7), "
8008 "B<sigevent>(7), B<signal>(7),"
8012 #: build/C/man7/pthreads.7:929
8014 "Various Pthreads manual pages, for example: B<pthread_attr_init>(3), "
8015 "B<pthread_atfork>(3), B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
8016 "B<pthread_cond_signal>(3), B<pthread_cond_wait>(3), B<pthread_create>(3), "
8017 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
8018 "B<pthread_key_create>(3), B<pthread_kill>(3), B<pthread_mutex_lock>(3), "
8019 "B<pthread_mutex_unlock>(3), B<pthread_once>(3), "
8020 "B<pthread_setcancelstate>(3), B<pthread_setcanceltype>(3), "
8021 "B<pthread_setspecific>(3), B<pthread_sigmask>(3), B<pthread_sigqueue>(3), "
8022 "and B<pthread_testcancel>(3)"