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: 2015-01-21 20:35+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=UTF-8\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_rwlockattr_setkind_np.3:25 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_rwlockattr_setkind_np.3:26 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_rwlockattr_setkind_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:53 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:49 build/C/man3/pthread_kill_other_threads_np.3:35 build/C/man3/pthread_rwlockattr_setkind_np.3:54 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:50 build/C/man3/pthread_sigqueue.3:46 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:49
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:57
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:67
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:94
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:101
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:114
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:118
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:135
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:142
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:142 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:93 build/C/man3/pthread_attr_setschedparam.3:85 build/C/man3/pthread_attr_setschedpolicy.3:83 build/C/man3/pthread_attr_setscope.3:103 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:112 build/C/man3/pthread_cleanup_push.3:121 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:63 build/C/man3/pthread_rwlockattr_setkind_np.3:96 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:61 build/C/man3/pthread_sigqueue.3:66 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:151
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:151 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:96 build/C/man3/pthread_attr_setschedparam.3:88 build/C/man3/pthread_attr_setschedpolicy.3:86 build/C/man3/pthread_attr_setscope.3:106 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:117 build/C/man3/pthread_cleanup_push.3:123 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:68 build/C/man3/pthread_rwlockattr_setkind_np.3:104 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:66 build/C/man3/pthread_sigqueue.3:71 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:153
189 msgid "None defined."
193 #: build/C/man3/getcontext.3:153 build/C/man3/makecontext.3:105 build/C/man3/pthread_attr_setdetachstate.3:87 build/C/man3/pthread_attr_setguardsize.3:106 build/C/man3/pthread_attr_setinheritsched.3:110 build/C/man3/pthread_attr_setschedparam.3:100 build/C/man3/pthread_attr_setschedpolicy.3:100 build/C/man3/pthread_attr_setscope.3:119 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_equal.3:47 build/C/man3/pthread_exit.3:75 build/C/man3/pthread_getcpuclockid.3:65 build/C/man3/pthread_kill.3:72 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_setschedparam.3:141 build/C/man3/pthread_setschedprio.3:83 build/C/man3/pthread_sigmask.3:69 build/C/man3/pthread_sigqueue.3:94 build/C/man3/pthread_testcancel.3:58 build/C/man3/pthread_yield.3:53
199 #: build/C/man3/getcontext.3:154 build/C/man3/makecontext.3:106 build/C/man3/pthread_attr_setdetachstate.3:88 build/C/man3/pthread_attr_setguardsize.3:107 build/C/man3/pthread_attr_setinheritsched.3:111 build/C/man3/pthread_attr_setschedparam.3:101 build/C/man3/pthread_attr_setschedpolicy.3:101 build/C/man3/pthread_attr_setscope.3:120 build/C/man3/pthread_attr_setstack.3:113 build/C/man3/pthread_attr_setstackaddr.3:84 build/C/man3/pthread_attr_setstacksize.3:84 build/C/man3/pthread_equal.3:48 build/C/man3/pthread_exit.3:76 build/C/man3/pthread_getcpuclockid.3:66 build/C/man3/pthread_kill.3:73 build/C/man3/pthread_kill_other_threads_np.3:48 build/C/man3/pthread_self.3:51 build/C/man3/pthread_setaffinity_np.3:122 build/C/man3/pthread_setcancelstate.3:114 build/C/man3/pthread_setconcurrency.3:84 build/C/man3/pthread_setschedparam.3:142 build/C/man3/pthread_setschedprio.3:84 build/C/man3/pthread_sigmask.3:70 build/C/man3/pthread_sigqueue.3:95 build/C/man3/pthread_testcancel.3:59 build/C/man3/pthread_yield.3:54
201 msgid "Multithreading (see pthreads(7))"
205 #: build/C/man3/getcontext.3:160
206 msgid "The B<getcontext>() and B<setcontext>() functions are thread-safe."
210 #: build/C/man3/getcontext.3:160 build/C/man3/makecontext.3:112 build/C/man3/pthread_attr_init.3:79 build/C/man3/pthread_attr_setaffinity_np.3:108 build/C/man3/pthread_attr_setdetachstate.3:94 build/C/man3/pthread_attr_setguardsize.3:113 build/C/man3/pthread_attr_setinheritsched.3:117 build/C/man3/pthread_attr_setschedparam.3:107 build/C/man3/pthread_attr_setschedpolicy.3:107 build/C/man3/pthread_attr_setscope.3:126 build/C/man3/pthread_attr_setstack.3:119 build/C/man3/pthread_attr_setstackaddr.3:90 build/C/man3/pthread_attr_setstacksize.3:90 build/C/man3/pthread_cancel.3:125 build/C/man3/pthread_cleanup_push.3:127 build/C/man3/pthread_cleanup_push_defer_np.3:114 build/C/man3/pthread_create.3:153 build/C/man3/pthread_detach.3:64 build/C/man3/pthread_equal.3:52 build/C/man3/pthread_exit.3:80 build/C/man3/pthread_getattr_np.3:98 build/C/man3/pthread_getcpuclockid.3:70 build/C/man3/pthread_join.3:98 build/C/man3/pthread_kill.3:77 build/C/man3/pthread_kill_other_threads_np.3:52 build/C/man3/pthread_rwlockattr_setkind_np.3:127 build/C/man3/pthread_self.3:55 build/C/man3/pthread_setaffinity_np.3:128 build/C/man3/pthread_setcancelstate.3:120 build/C/man3/pthread_setconcurrency.3:90 build/C/man3/pthread_setname_np.3:102 build/C/man3/pthread_setschedparam.3:148 build/C/man3/pthread_setschedprio.3:88 build/C/man3/pthread_sigmask.3:74 build/C/man3/pthread_sigqueue.3:99 build/C/man3/pthread_testcancel.3:63 build/C/man3/pthread_tryjoin_np.3:120 build/C/man3/pthread_yield.3:58
212 msgid "CONFORMING TO"
216 #: build/C/man3/getcontext.3:166
218 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specification of "
219 "B<getcontext>(), citing portability issues, and recommending that "
220 "applications be rewritten to use POSIX threads instead."
224 #: build/C/man3/getcontext.3:166 build/C/man3/makecontext.3:120 build/C/man3/pthread_attr_init.3:81 build/C/man3/pthread_attr_setaffinity_np.3:111 build/C/man3/pthread_attr_setdetachstate.3:96 build/C/man3/pthread_attr_setguardsize.3:115 build/C/man3/pthread_attr_setschedparam.3:109 build/C/man3/pthread_attr_setscope.3:128 build/C/man3/pthread_attr_setstack.3:121 build/C/man3/pthread_attr_setstackaddr.3:93 build/C/man3/pthread_attr_setstacksize.3:92 build/C/man3/pthread_cancel.3:127 build/C/man3/pthread_cleanup_push.3:129 build/C/man3/pthread_create.3:155 build/C/man3/pthread_detach.3:66 build/C/man3/pthread_equal.3:54 build/C/man3/pthread_exit.3:82 build/C/man3/pthread_getcpuclockid.3:72 build/C/man3/pthread_join.3:100 build/C/man3/pthread_kill.3:79 build/C/man3/pthread_kill_other_threads_np.3:55 build/C/man3/pthread_self.3:57 build/C/man3/pthread_setaffinity_np.3:131 build/C/man3/pthread_setcancelstate.3:122 build/C/man3/pthread_setconcurrency.3:92 build/C/man3/pthread_setname_np.3:104 build/C/man3/pthread_setschedparam.3:150 build/C/man3/pthread_setschedprio.3:90 build/C/man3/pthread_sigmask.3:76 build/C/man3/pthread_yield.3:64
230 #: build/C/man3/getcontext.3:183
232 "The earliest incarnation of this mechanism was the "
233 "B<setjmp>(3)/B<longjmp>(3) mechanism. Since that does not define the "
234 "handling of the signal context, the next stage was the "
235 "B<sigsetjmp>(3)/B<siglongjmp>(3) pair. The present mechanism gives much "
236 "more control. On the other hand, there is no easy way to detect whether a "
237 "return from B<getcontext>() is from the first call, or via a "
238 "B<setcontext>() call. The user has to invent her own bookkeeping device, "
239 "and a register variable won't do since registers are restored."
243 #: build/C/man3/getcontext.3:194
245 "When a signal occurs, the current user context is saved and a new context is "
246 "created by the kernel for the signal handler. Do not leave the handler "
247 "using B<longjmp>(3): it is undefined what would happen with contexts. Use "
248 "B<siglongjmp>(3) or B<setcontext>() instead."
252 #: build/C/man3/getcontext.3:194 build/C/man3/makecontext.3:227 build/C/man3/pthread_attr_init.3:297 build/C/man3/pthread_attr_setaffinity_np.3:118 build/C/man3/pthread_attr_setdetachstate.3:118 build/C/man3/pthread_attr_setguardsize.3:165 build/C/man3/pthread_attr_setinheritsched.3:138 build/C/man3/pthread_attr_setschedparam.3:116 build/C/man3/pthread_attr_setschedpolicy.3:112 build/C/man3/pthread_attr_setscope.3:139 build/C/man3/pthread_attr_setstack.3:162 build/C/man3/pthread_attr_setstackaddr.3:117 build/C/man3/pthread_attr_setstacksize.3:118 build/C/man3/pthread_cancel.3:226 build/C/man3/pthread_cleanup_push.3:315 build/C/man3/pthread_cleanup_push_defer_np.3:117 build/C/man3/pthread_create.3:376 build/C/man3/pthread_detach.3:97 build/C/man3/pthread_equal.3:61 build/C/man3/pthread_exit.3:110 build/C/man3/pthread_getattr_np.3:345 build/C/man3/pthread_getcpuclockid.3:175 build/C/man3/pthread_join.3:127 build/C/man3/pthread_kill.3:99 build/C/man3/pthread_kill_other_threads_np.3:71 build/C/man3/pthread_rwlockattr_setkind_np.3:130 build/C/man3/pthread_self.3:81 build/C/man3/pthread_setaffinity_np.3:213 build/C/man3/pthread_setcancelstate.3:186 build/C/man3/pthread_setconcurrency.3:107 build/C/man3/pthread_setname_np.3:200 build/C/man3/pthread_setschedparam.3:440 build/C/man3/pthread_setschedprio.3:96 build/C/man3/pthread_sigmask.3:152 build/C/man3/pthread_sigqueue.3:101 build/C/man3/pthread_testcancel.3:68 build/C/man3/pthread_tryjoin_np.3:143 build/C/man3/pthread_yield.3:67 build/C/man7/pthreads.7:893
258 #: build/C/man3/getcontext.3:200
260 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<longjmp>(3), "
261 "B<makecontext>(3), B<sigsetjmp>(3)"
265 #: build/C/man3/makecontext.3:28
271 #: build/C/man3/makecontext.3:28 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_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_cleanup_push_defer_np.3:26 build/C/man3/pthread_create.3:26 build/C/man3/pthread_setname_np.3:26 build/C/man3/pthread_setschedprio.3:26 build/C/man3/pthread_sigqueue.3:25
277 #: build/C/man3/makecontext.3:28
283 #: build/C/man3/makecontext.3:31
284 msgid "makecontext, swapcontext - manipulate user context"
288 #: build/C/man3/makecontext.3:36
290 "B<void makecontext(ucontext_t *>I<ucp>B<, void (*>I<func>B<)(),> B<int "
295 #: build/C/man3/makecontext.3:38
296 msgid "B<int swapcontext(ucontext_t *>I<oucp>B<, const ucontext_t *>I<ucp>B<);>"
300 #: build/C/man3/makecontext.3:49
302 "In a System V-like environment, one has the type I<ucontext_t> defined in "
303 "I<E<lt>ucontext.hE<gt>> and the four functions B<getcontext>(3), "
304 "B<setcontext>(3), B<makecontext>() and B<swapcontext>() that allow "
305 "user-level context switching between multiple threads of control within a "
310 #: build/C/man3/makecontext.3:52
311 msgid "For the type and the first two functions, see B<getcontext>(3)."
315 #: build/C/man3/makecontext.3:64
317 "The B<makecontext>() function modifies the context pointed to by I<ucp> "
318 "(which was obtained from a call to B<getcontext>(3)). Before invoking "
319 "B<makecontext>(), the caller must allocate a new stack for this context and "
320 "assign its address to I<ucp-E<gt>uc_stack>, and define a successor context "
321 "and assign its address to I<ucp-E<gt>uc_link>."
325 #: build/C/man3/makecontext.3:78
327 "When this context is later activated (using B<setcontext>(3) or "
328 "B<swapcontext>()) the function I<func> is called, and passed the series of "
329 "integer (I<int>) arguments that follow I<argc>; the caller must specify the "
330 "number of these arguments in I<argc>. When this function returns, the "
331 "successor context is activated. If the successor context pointer is NULL, "
336 #: build/C/man3/makecontext.3:84
338 "The B<swapcontext>() function saves the current context in the structure "
339 "pointed to by I<oucp>, and then activates the context pointed to by I<ucp>."
343 #: build/C/man3/makecontext.3:96
345 "When successful, B<swapcontext>() does not return. (But we may return "
346 "later, in case I<oucp> is activated, in which case it looks like "
347 "B<swapcontext>() returns 0.) On error, B<swapcontext>() returns -1 and "
348 "sets I<errno> appropriately."
352 #: build/C/man3/makecontext.3:97 build/C/man3/pthread_attr_setaffinity_np.3:102 build/C/man3/pthread_getattr_np.3:77
358 #: build/C/man3/makecontext.3:100
359 msgid "Insufficient stack space left."
363 #: 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_rwlockattr_setkind_np.3:121 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:90 build/C/man3/pthread_tryjoin_np.3:118
369 #: build/C/man3/makecontext.3:105
371 "B<makecontext>() and B<swapcontext>() are provided in glibc since version "
376 #: build/C/man3/makecontext.3:112
377 msgid "The B<makecontext>() and B<swapcontext>() functions are thread-safe."
381 #: build/C/man3/makecontext.3:120
383 "SUSv2, POSIX.1-2001. POSIX.1-2008 removes the specifications of "
384 "B<makecontext>() and B<swapcontext>(), citing portability issues, and "
385 "recommending that applications be rewritten to use POSIX threads instead."
389 #: build/C/man3/makecontext.3:128
391 "The interpretation of I<ucp-E<gt>uc_stack> is just as in B<sigaltstack>(2), "
392 "namely, this struct contains the start and length of a memory area to be "
393 "used as the stack, regardless of the direction of growth of the stack. "
394 "Thus, it is not necessary for the user program to worry about this "
399 #: build/C/man3/makecontext.3:144
401 "On architectures where I<int> and pointer types are the same size (e.g., "
402 "x86-32, where both types are 32 bits), you may be able to get away with "
403 "passing pointers as arguments to B<makecontext>() following I<argc>. "
404 "However, doing this is not guaranteed to be portable, is undefined according "
405 "to the standards, and won't work on architectures where pointers are larger "
406 "than I<int>s. Nevertheless, starting with version 2.8, glibc makes some "
407 "changes to B<makecontext>(), to permit this on some 64-bit architectures "
412 #: build/C/man3/makecontext.3:144 build/C/man3/pthread_attr_init.3:87 build/C/man3/pthread_attr_setdetachstate.3:115 build/C/man3/pthread_attr_setguardsize.3:162 build/C/man3/pthread_attr_setinheritsched.3:135 build/C/man3/pthread_attr_setschedparam.3:113 build/C/man3/pthread_attr_setschedpolicy.3:109 build/C/man3/pthread_attr_setstack.3:159 build/C/man3/pthread_attr_setstacksize.3:115 build/C/man3/pthread_cancel.3:135 build/C/man3/pthread_cleanup_push.3:155 build/C/man3/pthread_create.3:209 build/C/man3/pthread_detach.3:93 build/C/man3/pthread_getattr_np.3:101 build/C/man3/pthread_getcpuclockid.3:83 build/C/man3/pthread_join.3:124 build/C/man3/pthread_setaffinity_np.3:161 build/C/man3/pthread_setcancelstate.3:183 build/C/man3/pthread_setname_np.3:114 build/C/man3/pthread_setschedparam.3:156 build/C/man3/pthread_sigmask.3:78 build/C/man3/pthread_testcancel.3:65 build/C/man3/pthread_tryjoin_np.3:123
418 #: build/C/man3/makecontext.3:152
420 "The example program below demonstrates the use of B<getcontext>(3), "
421 "B<makecontext>(), and B<swapcontext>(). Running the program produces the "
426 #: build/C/man3/makecontext.3:164
430 "main: swapcontext(&uctx_main, &uctx_func2)\n"
432 "func2: swapcontext(&uctx_func2, &uctx_func1)\n"
434 "func1: swapcontext(&uctx_func1, &uctx_func2)\n"
441 #: build/C/man3/makecontext.3:166 build/C/man3/pthread_attr_init.3:148 build/C/man3/pthread_cancel.3:151 build/C/man3/pthread_cleanup_push.3:231 build/C/man3/pthread_create.3:248 build/C/man3/pthread_getattr_np.3:179 build/C/man3/pthread_getcpuclockid.3:101 build/C/man3/pthread_setname_np.3:140 build/C/man3/pthread_setschedparam.3:231 build/C/man3/pthread_sigmask.3:96
443 msgid "Program source"
447 #: build/C/man3/makecontext.3:172
450 "#include E<lt>ucontext.hE<gt>\n"
451 "#include E<lt>stdio.hE<gt>\n"
452 "#include E<lt>stdlib.hE<gt>\n"
456 #: build/C/man3/makecontext.3:174
458 msgid "static ucontext_t uctx_main, uctx_func1, uctx_func2;\n"
462 #: build/C/man3/makecontext.3:177
465 "#define handle_error(msg) \\e\n"
466 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
470 #: build/C/man3/makecontext.3:187
476 " printf(\"func1: started\\en\");\n"
477 " printf(\"func1: swapcontext(&uctx_func1, &uctx_func2)\\en\");\n"
478 " if (swapcontext(&uctx_func1, &uctx_func2) == -1)\n"
479 " handle_error(\"swapcontext\");\n"
480 " printf(\"func1: returning\\en\");\n"
485 #: build/C/man3/makecontext.3:197
491 " printf(\"func2: started\\en\");\n"
492 " printf(\"func2: swapcontext(&uctx_func2, &uctx_func1)\\en\");\n"
493 " if (swapcontext(&uctx_func2, &uctx_func1) == -1)\n"
494 " handle_error(\"swapcontext\");\n"
495 " printf(\"func2: returning\\en\");\n"
500 #: build/C/man3/makecontext.3:203
504 "main(int argc, char *argv[])\n"
506 " char func1_stack[16384];\n"
507 " char func2_stack[16384];\n"
511 #: build/C/man3/makecontext.3:210
514 " if (getcontext(&uctx_func1) == -1)\n"
515 " handle_error(\"getcontext\");\n"
516 " uctx_func1.uc_stack.ss_sp = func1_stack;\n"
517 " uctx_func1.uc_stack.ss_size = sizeof(func1_stack);\n"
518 " uctx_func1.uc_link = &uctx_main;\n"
519 " makecontext(&uctx_func1, func1, 0);\n"
523 #: build/C/man3/makecontext.3:218
526 " if (getcontext(&uctx_func2) == -1)\n"
527 " handle_error(\"getcontext\");\n"
528 " uctx_func2.uc_stack.ss_sp = func2_stack;\n"
529 " uctx_func2.uc_stack.ss_size = sizeof(func2_stack);\n"
530 " /* Successor context is f1(), unless argc E<gt> 1 */\n"
531 " uctx_func2.uc_link = (argc E<gt> 1) ? NULL : &uctx_func1;\n"
532 " makecontext(&uctx_func2, func2, 0);\n"
536 #: build/C/man3/makecontext.3:222
539 " printf(\"main: swapcontext(&uctx_main, &uctx_func2)\\en\");\n"
540 " if (swapcontext(&uctx_main, &uctx_func2) == -1)\n"
541 " handle_error(\"swapcontext\");\n"
545 #: build/C/man3/makecontext.3:226
548 " printf(\"main: exiting\\en\");\n"
549 " exit(EXIT_SUCCESS);\n"
554 #: build/C/man3/makecontext.3:232
556 "B<sigaction>(2), B<sigaltstack>(2), B<sigprocmask>(2), B<getcontext>(3), "
561 #: build/C/man3/pthread_attr_init.3:26
563 msgid "PTHREAD_ATTR_INIT"
567 #: build/C/man3/pthread_attr_init.3:26
573 #: build/C/man3/pthread_attr_init.3:30
575 "pthread_attr_init, pthread_attr_destroy - initialize and destroy thread "
580 #: 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_rwlockattr_setkind_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_testcancel.3:32
582 msgid "B<#include E<lt>pthread.hE<gt>>\n"
586 #: build/C/man3/pthread_attr_init.3:36
589 "B<int pthread_attr_init(pthread_attr_t *>I<attr>B<);>\n"
590 "B<int pthread_attr_destroy(pthread_attr_t *>I<attr>B<);>\n"
594 #: 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_rwlockattr_setkind_np.3:39 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
596 msgid "Compile and link with I<-pthread>.\n"
600 #: build/C/man3/pthread_attr_init.3:50
602 "The B<pthread_attr_init>() function initializes the thread attributes "
603 "object pointed to by I<attr> with default attribute values. After this "
604 "call, individual attributes of the object can be set using various related "
605 "functions (listed under SEE ALSO), and then the object can be used in one or "
606 "more B<pthread_create>(3) calls that create threads."
610 #: build/C/man3/pthread_attr_init.3:55
612 "Calling B<pthread_attr_init>() on a thread attributes object that has "
613 "already been initialized results in undefined behavior."
617 #: build/C/man3/pthread_attr_init.3:62
619 "When a thread attributes object is no longer required, it should be "
620 "destroyed using the B<pthread_attr_destroy>() function. Destroying a "
621 "thread attributes object has no effect on threads that were created using "
626 #: build/C/man3/pthread_attr_init.3:68
628 "Once a thread attributes object has been destroyed, it can be reinitialized "
629 "using B<pthread_attr_init>(). Any other use of a destroyed thread "
630 "attributes object has undefined results."
634 #: 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:96 build/C/man3/pthread_attr_setschedparam.3:88 build/C/man3/pthread_attr_setschedpolicy.3:86 build/C/man3/pthread_attr_setscope.3:106 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
636 "On success, these functions return 0; on error, they return a nonzero error "
641 #: build/C/man3/pthread_attr_init.3:79
643 "POSIX.1-2001 documents an B<ENOMEM> error for B<pthread_attr_init>(); on "
644 "Linux these functions always succeed (but portable and future-proof "
645 "applications should nevertheless handle a possible error return)."
649 #: build/C/man3/pthread_attr_init.3:81 build/C/man3/pthread_attr_setdetachstate.3:96 build/C/man3/pthread_attr_setguardsize.3:115 build/C/man3/pthread_attr_setinheritsched.3:119 build/C/man3/pthread_attr_setschedparam.3:109 build/C/man3/pthread_attr_setschedpolicy.3:109 build/C/man3/pthread_attr_setscope.3:128 build/C/man3/pthread_attr_setstack.3:121 build/C/man3/pthread_attr_setstacksize.3:92 build/C/man3/pthread_cancel.3:127 build/C/man3/pthread_cleanup_push.3:129 build/C/man3/pthread_create.3:155 build/C/man3/pthread_detach.3:66 build/C/man3/pthread_equal.3:54 build/C/man3/pthread_exit.3:82 build/C/man3/pthread_getcpuclockid.3:72 build/C/man3/pthread_join.3:100 build/C/man3/pthread_self.3:57 build/C/man3/pthread_setcancelstate.3:122 build/C/man3/pthread_setconcurrency.3:92 build/C/man3/pthread_setschedparam.3:150 build/C/man3/pthread_setschedprio.3:90 build/C/man3/pthread_sigmask.3:76 build/C/man3/pthread_testcancel.3:65
650 msgid "POSIX.1-2001."
654 #: build/C/man3/pthread_attr_init.3:87
656 "The I<pthread_attr_t> type should be treated as opaque: any access to the "
657 "object other than via pthreads functions is nonportable and produces "
662 #: build/C/man3/pthread_attr_init.3:96
664 "The program below optionally makes use of B<pthread_attr_init>() and "
665 "various related functions to initialize a thread attributes object that is "
666 "used to create a single thread. Once created, the thread uses the "
667 "B<pthread_getattr_np>(3) function (a nonstandard GNU extension) to retrieve "
668 "the thread's attributes, and then displays those attributes."
672 #: build/C/man3/pthread_attr_init.3:105
674 "If the program is run with no command-line argument, then it passes NULL as "
675 "the I<attr> argument of B<pthread_create>(3), so that the thread is created "
676 "with default attributes. Running the program on Linux/x86-32 with the NPTL "
677 "threading implementation, we see the following:"
680 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
682 #: build/C/man3/pthread_attr_init.3:121
685 "$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2MB\n"
688 "Thread attributes:\n"
689 " Detach state = PTHREAD_CREATE_JOINABLE\n"
690 " Scope = PTHREAD_SCOPE_SYSTEM\n"
691 " Inherit scheduler = PTHREAD_INHERIT_SCHED\n"
692 " Scheduling policy = SCHED_OTHER\n"
693 " Scheduling priority = 0\n"
694 " Guard size = 4096 bytes\n"
695 " Stack address = 0x40196000\n"
696 " Stack size = 0x201000 bytes\n"
700 #: build/C/man3/pthread_attr_init.3:131
702 "When we supply a stack size as a command-line argument, the program "
703 "initializes a thread attributes object, sets various attributes in that "
704 "object, and passes a pointer to the object in the call to "
705 "B<pthread_create>(3). Running the program on Linux/x86-32 with the NPTL "
706 "threading implementation, we see the following:"
709 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
711 #: build/C/man3/pthread_attr_init.3:146
714 "$B< ./a.out 0x3000000>\n"
715 "posix_memalign() allocated at 0x40197000\n"
716 "Thread attributes:\n"
717 " Detach state = PTHREAD_CREATE_DETACHED\n"
718 " Scope = PTHREAD_SCOPE_SYSTEM\n"
719 " Inherit scheduler = PTHREAD_EXPLICIT_SCHED\n"
720 " Scheduling policy = SCHED_OTHER\n"
721 " Scheduling priority = 0\n"
722 " Guard size = 0 bytes\n"
723 " Stack address = 0x40197000\n"
724 " Stack size = 0x3000000 bytes\n"
728 #: build/C/man3/pthread_attr_init.3:157 build/C/man3/pthread_getattr_np.3:188
731 "#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n"
732 "#include E<lt>pthread.hE<gt>\n"
733 "#include E<lt>stdio.hE<gt>\n"
734 "#include E<lt>stdlib.hE<gt>\n"
735 "#include E<lt>unistd.hE<gt>\n"
736 "#include E<lt>errno.hE<gt>\n"
740 #: build/C/man3/pthread_attr_init.3:160 build/C/man3/pthread_cancel.3:162 build/C/man3/pthread_cleanup_push.3:243 build/C/man3/pthread_create.3:261 build/C/man3/pthread_getattr_np.3:191 build/C/man3/pthread_getcpuclockid.3:119 build/C/man3/pthread_setaffinity_np.3:179 build/C/man3/pthread_setschedparam.3:244 build/C/man3/pthread_sigmask.3:110
743 "#define handle_error_en(en, msg) \\e\n"
744 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
748 #: build/C/man3/pthread_attr_init.3:168
752 "display_pthread_attr(pthread_attr_t *attr, char *prefix)\n"
757 " struct sched_param sp;\n"
761 #: build/C/man3/pthread_attr_init.3:176
764 " s = pthread_attr_getdetachstate(attr, &i);\n"
766 " handle_error_en(s, \"pthread_attr_getdetachstate\");\n"
767 " printf(\"%sDetach state = %s\\en\", prefix,\n"
768 " (i == PTHREAD_CREATE_DETACHED) ? \"PTHREAD_CREATE_DETACHED\" :\n"
769 " (i == PTHREAD_CREATE_JOINABLE) ? \"PTHREAD_CREATE_JOINABLE\" :\n"
774 #: build/C/man3/pthread_attr_init.3:184
777 " s = pthread_attr_getscope(attr, &i);\n"
779 " handle_error_en(s, \"pthread_attr_getscope\");\n"
780 " printf(\"%sScope = %s\\en\", prefix,\n"
781 " (i == PTHREAD_SCOPE_SYSTEM) ? \"PTHREAD_SCOPE_SYSTEM\" :\n"
782 " (i == PTHREAD_SCOPE_PROCESS) ? \"PTHREAD_SCOPE_PROCESS\" :\n"
787 #: build/C/man3/pthread_attr_init.3:192
790 " s = pthread_attr_getinheritsched(attr, &i);\n"
792 " handle_error_en(s, \"pthread_attr_getinheritsched\");\n"
793 " printf(\"%sInherit scheduler = %s\\en\", prefix,\n"
794 " (i == PTHREAD_INHERIT_SCHED) ? \"PTHREAD_INHERIT_SCHED\" :\n"
795 " (i == PTHREAD_EXPLICIT_SCHED) ? \"PTHREAD_EXPLICIT_SCHED\" :\n"
800 #: build/C/man3/pthread_attr_init.3:201
803 " s = pthread_attr_getschedpolicy(attr, &i);\n"
805 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
806 " printf(\"%sScheduling policy = %s\\en\", prefix,\n"
807 " (i == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
808 " (i == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
809 " (i == SCHED_RR) ? \"SCHED_RR\" :\n"
814 #: build/C/man3/pthread_attr_init.3:206
817 " s = pthread_attr_getschedparam(attr, &sp);\n"
819 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
820 " printf(\"%sScheduling priority = %d\\en\", prefix, sp.sched_priority);\n"
824 #: build/C/man3/pthread_attr_init.3:211
827 " s = pthread_attr_getguardsize(attr, &v);\n"
829 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
830 " printf(\"%sGuard size = %d bytes\\en\", prefix, v);\n"
834 #: build/C/man3/pthread_attr_init.3:218
837 " s = pthread_attr_getstack(attr, &stkaddr, &v);\n"
839 " handle_error_en(s, \"pthread_attr_getstack\");\n"
840 " printf(\"%sStack address = %p\\en\", prefix, stkaddr);\n"
841 " printf(\"%sStack size = 0x%x bytes\\en\", prefix, v);\n"
846 #: build/C/man3/pthread_attr_init.3:224
850 "thread_start(void *arg)\n"
853 " pthread_attr_t gattr;\n"
857 #: build/C/man3/pthread_attr_init.3:228
860 " /* pthread_getattr_np() is a non-standard GNU extension that\n"
861 " retrieves the attributes of the thread specified in its\n"
862 " first argument */\n"
866 #: build/C/man3/pthread_attr_init.3:232
869 " s = pthread_getattr_np(pthread_self(), &gattr);\n"
871 " handle_error_en(s, \"pthread_getattr_np\");\n"
875 #: build/C/man3/pthread_attr_init.3:235
878 " printf(\"Thread attributes:\\en\");\n"
879 " display_pthread_attr(&gattr, \"\\et\");\n"
883 #: build/C/man3/pthread_attr_init.3:238 build/C/man3/pthread_getattr_np.3:240
886 " exit(EXIT_SUCCESS); /* Terminate all threads */\n"
891 #: build/C/man3/pthread_attr_init.3:246
895 "main(int argc, char *argv[])\n"
898 " pthread_attr_t attr;\n"
899 " pthread_attr_t *attrp; /* NULL or &attr */\n"
904 #: build/C/man3/pthread_attr_init.3:248 build/C/man3/pthread_setschedparam.3:362
906 msgid " attrp = NULL;\n"
910 #: build/C/man3/pthread_attr_init.3:252
913 " /* If a command-line argument was supplied, use it to set the\n"
914 " stack-size attribute and set a few other thread attributes,\n"
915 " and set attrp pointing to thread attributes object */\n"
919 #: build/C/man3/pthread_attr_init.3:256
922 " if (argc E<gt> 1) {\n"
928 #: build/C/man3/pthread_attr_init.3:258
930 msgid " attrp = &attr;\n"
934 #: build/C/man3/pthread_attr_init.3:262
937 " s = pthread_attr_init(&attr);\n"
939 " handle_error_en(s, \"pthread_attr_init\");\n"
943 #: build/C/man3/pthread_attr_init.3:266
946 " s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n"
948 " handle_error_en(s, \"pthread_attr_setdetachstate\");\n"
952 #: build/C/man3/pthread_attr_init.3:270
955 " s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n"
957 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
961 #: build/C/man3/pthread_attr_init.3:272
963 msgid " stack_size = strtoul(argv[1], NULL, 0);\n"
967 #: build/C/man3/pthread_attr_init.3:276
970 " s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);\n"
972 " handle_error_en(s, \"posix_memalign\");\n"
976 #: build/C/man3/pthread_attr_init.3:278
978 msgid " printf(\"posix_memalign() allocated at %p\\en\", sp);\n"
982 #: build/C/man3/pthread_attr_init.3:283
985 " s = pthread_attr_setstack(&attr, sp, stack_size);\n"
987 " handle_error_en(s, \"pthread_attr_setstack\");\n"
992 #: build/C/man3/pthread_attr_init.3:287 build/C/man3/pthread_getattr_np.3:335
995 " s = pthread_create(&thr, attrp, &thread_start, NULL);\n"
997 " handle_error_en(s, \"pthread_create\");\n"
1001 #: build/C/man3/pthread_attr_init.3:293 build/C/man3/pthread_getattr_np.3:341
1004 " if (attrp != NULL) {\n"
1005 " s = pthread_attr_destroy(attrp);\n"
1007 " handle_error_en(s, \"pthread_attr_destroy\");\n"
1012 #: build/C/man3/pthread_attr_init.3:296 build/C/man3/pthread_getattr_np.3:344
1015 " pause(); /* Terminates when other thread calls exit() */\n"
1020 #: build/C/man3/pthread_attr_init.3:312
1022 "B<pthread_attr_setaffinity_np>(3), B<pthread_attr_setdetachstate>(3), "
1023 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setinheritsched>(3), "
1024 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
1025 "B<pthread_attr_setscope>(3), B<pthread_attr_setstack>(3), "
1026 "B<pthread_attr_setstackaddr>(3), B<pthread_attr_setstacksize>(3), "
1027 "B<pthread_create>(3), B<pthread_getattr_np>(3), B<pthreads>(7)"
1031 #: build/C/man3/pthread_attr_setaffinity_np.3:26
1033 msgid "PTHREAD_ATTR_SETAFFINITY_NP"
1037 #: build/C/man3/pthread_attr_setaffinity_np.3:30
1039 "pthread_attr_setaffinity_np, pthread_attr_getaffinity_np - set/get CPU "
1040 "affinity attribute in thread attributes object"
1044 #: 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
1047 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
1048 "B<#include E<lt>pthread.hE<gt>>\n"
1052 #: build/C/man3/pthread_attr_setaffinity_np.3:39
1055 "B<int pthread_attr_setaffinity_np(pthread_attr_t *>I<attr>B<,>\n"
1056 "B< size_t >I<cpusetsize>B<, const cpu_set_t "
1057 "*>I<cpuset>B<);>\n"
1058 "B<int pthread_attr_getaffinity_np(const pthread_attr_t *>I<attr>B<,>\n"
1059 "B< size_t >I<cpusetsize>B<, cpu_set_t *>I<cpuset>B<);>\n"
1063 #: build/C/man3/pthread_attr_setaffinity_np.3:54
1065 "The B<pthread_attr_setaffinity_np>() function sets the CPU affinity mask "
1066 "attribute of the thread attributes object referred to by I<attr> to the "
1067 "value specified in I<cpuset>. This attribute determines the CPU affinity "
1068 "mask of a thread created using the thread attributes object I<attr>."
1072 #: build/C/man3/pthread_attr_setaffinity_np.3:63
1074 "The B<pthread_attr_getaffinity_np>() function returns the CPU affinity mask "
1075 "attribute of the thread attributes object referred to by I<attr> in the "
1076 "buffer pointed to by I<cpuset>."
1080 #: build/C/man3/pthread_attr_setaffinity_np.3:70
1082 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
1083 "by I<cpuset>. Typically, this argument would be specified as "
1084 "I<sizeof(cpu_set_t)>."
1088 #: build/C/man3/pthread_attr_setaffinity_np.3:76 build/C/man3/pthread_setaffinity_np.3:67
1090 "For more details on CPU affinity masks, see B<sched_setaffinity>(2). For a "
1091 "description of a set of macros that can be used to manipulate and inspect "
1092 "CPU sets, see B<CPU_SET>(3)."
1096 #: 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:99 build/C/man3/pthread_attr_setschedpolicy.3:89 build/C/man3/pthread_attr_setscope.3:109 build/C/man3/pthread_attr_setstack.3:91 build/C/man3/pthread_attr_setstacksize.3:67 build/C/man3/pthread_create.3:144 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:69 build/C/man3/pthread_rwlockattr_setkind_np.3:105 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:78 build/C/man3/pthread_tryjoin_np.3:106
1102 #. The raw sched_getaffinity() system call returns the size (in bytes)
1103 #. of the cpumask_t type.
1105 #: build/C/man3/pthread_attr_setaffinity_np.3:92
1107 "(B<pthread_attr_setaffinity_np>()) I<cpuset> specified a CPU that was "
1108 "outside the set supported by the kernel. (The kernel configuration option "
1109 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
1110 "type used to represent CPU sets.)"
1114 #: build/C/man3/pthread_attr_setaffinity_np.3:102
1116 "(B<pthread_attr_getaffinity_np>()) A CPU in the affinity mask of the thread "
1117 "attributes object referred to by I<attr> lies outside the range specified by "
1118 "I<cpusetsize> (i.e., I<cpuset>/I<cpusetsize> is too small)."
1122 #: build/C/man3/pthread_attr_setaffinity_np.3:106
1123 msgid "(B<pthread_attr_setaffinity_np>()) Could not allocate memory."
1127 #: build/C/man3/pthread_attr_setaffinity_np.3:108 build/C/man3/pthread_setaffinity_np.3:121
1128 msgid "These functions are provided by glibc since version 2.3.4."
1132 #: build/C/man3/pthread_attr_setaffinity_np.3:111 build/C/man3/pthread_cleanup_push_defer_np.3:117 build/C/man3/pthread_setaffinity_np.3:131 build/C/man3/pthread_tryjoin_np.3:123
1134 "These functions are nonstandard GNU extensions; hence the suffix \"_np\" "
1135 "(nonportable) in the names."
1139 #: build/C/man3/pthread_attr_setaffinity_np.3:118 build/C/man3/pthread_setaffinity_np.3:157
1141 "In glibc 2.3.3 only, versions of these functions were provided that did not "
1142 "have a I<cpusetsize> argument. Instead the CPU set size given to the "
1143 "underlying system calls was always I<sizeof(cpu_set_t)>."
1147 #: build/C/man3/pthread_attr_setaffinity_np.3:123
1149 "B<sched_setaffinity>(2), B<pthread_attr_init>(3), "
1150 "B<pthread_setaffinity_np>(3), B<cpuset>(7), B<pthreads>(7)"
1154 #: build/C/man3/pthread_attr_setdetachstate.3:26
1156 msgid "PTHREAD_ATTR_SETDETACHSTATE"
1160 #: build/C/man3/pthread_attr_setdetachstate.3:30
1162 "pthread_attr_setdetachstate, pthread_attr_getdetachstate - set/get detach "
1163 "state attribute in thread attributes object"
1167 #: build/C/man3/pthread_attr_setdetachstate.3:38
1170 "B<int pthread_attr_setdetachstate(pthread_attr_t *>I<attr>B<, int "
1171 ">I<detachstate>B<);>\n"
1172 "B<int pthread_attr_getdetachstate(const pthread_attr_t *>I<attr>B<, int "
1173 "*>I<detachstate>B<);>\n"
1177 #: build/C/man3/pthread_attr_setdetachstate.3:53
1179 "The B<pthread_attr_setdetachstate>() function sets the detach state "
1180 "attribute of the thread attributes object referred to by I<attr> to the "
1181 "value specified in I<detachstate>. The detach state attribute determines "
1182 "whether a thread created using the thread attributes object I<attr> will be "
1183 "created in a joinable or a detached state."
1187 #: build/C/man3/pthread_attr_setdetachstate.3:56
1188 msgid "The following values may be specified in I<detachstate>:"
1192 #: build/C/man3/pthread_attr_setdetachstate.3:56
1194 msgid "B<PTHREAD_CREATE_DETACHED>"
1198 #: build/C/man3/pthread_attr_setdetachstate.3:61
1199 msgid "Threads that are created using I<attr> will be created in a detached state."
1203 #: build/C/man3/pthread_attr_setdetachstate.3:61
1205 msgid "B<PTHREAD_CREATE_JOINABLE>"
1209 #: build/C/man3/pthread_attr_setdetachstate.3:66
1210 msgid "Threads that are created using I<attr> will be created in a joinable state."
1214 #: build/C/man3/pthread_attr_setdetachstate.3:70
1216 "The default setting of the detach state attribute in a newly initialized "
1217 "thread attributes object is B<PTHREAD_CREATE_JOINABLE>."
1221 #: build/C/man3/pthread_attr_setdetachstate.3:77
1223 "The B<pthread_attr_getdetachstate>() returns the detach state attribute of "
1224 "the thread attributes object I<attr> in the buffer pointed to by "
1229 #: build/C/man3/pthread_attr_setdetachstate.3:83
1230 msgid "B<pthread_attr_setdetachstate>() can fail with the following error:"
1234 #: build/C/man3/pthread_attr_setdetachstate.3:87
1235 msgid "An invalid value was specified in I<detachstate>."
1239 #: build/C/man3/pthread_attr_setdetachstate.3:94
1241 "The B<pthread_attr_setdetachstate>() and B<pthread_attr_getdetachstate>() "
1242 "functions are thread-safe."
1246 #: build/C/man3/pthread_attr_setdetachstate.3:100
1247 msgid "See B<pthread_create>(3) for more details on detached and joinable threads."
1251 #: build/C/man3/pthread_attr_setdetachstate.3:108
1253 "A thread that is created in a joinable state should eventually either be "
1254 "joined using B<pthread_join>(3) or detached using B<pthread_detach>(3); see "
1255 "B<pthread_create>(3)."
1259 #: build/C/man3/pthread_attr_setdetachstate.3:115
1261 "It is an error to specify the thread ID of a thread that was created in a "
1262 "detached state in a later call to B<pthread_detach>(3) or "
1263 "B<pthread_join>(3)."
1267 #: build/C/man3/pthread_attr_setdetachstate.3:118 build/C/man3/pthread_attr_setstack.3:162
1268 msgid "See B<pthread_attr_init>(3)."
1272 #: build/C/man3/pthread_attr_setdetachstate.3:123
1274 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthread_detach>(3), "
1275 "B<pthread_join>(3), B<pthreads>(7)"
1279 #: build/C/man3/pthread_attr_setguardsize.3:26
1281 msgid "PTHREAD_ATTR_SETGUARDSIZE"
1285 #: build/C/man3/pthread_attr_setguardsize.3:30
1287 "pthread_attr_setguardsize, pthread_attr_getguardsize - set/get guard size "
1288 "attribute in thread attributes object"
1292 #: build/C/man3/pthread_attr_setguardsize.3:38
1295 "B<int pthread_attr_setguardsize(pthread_attr_t *>I<attr>B<, size_t "
1296 ">I<guardsize>B<);>\n"
1297 "B<int pthread_attr_getguardsize(const pthread_attr_t *>I<attr>B<, size_t "
1298 "*>I<guardsize>B<);>\n"
1302 #: build/C/man3/pthread_attr_setguardsize.3:49
1304 "The B<pthread_attr_setguardsize>() function sets the guard size attribute "
1305 "of the thread attributes object referred to by I<attr> to the value "
1306 "specified in I<guardsize>."
1310 #: build/C/man3/pthread_attr_setguardsize.3:59
1312 "If I<guardsize> is greater than 0, then for each new thread created using "
1313 "I<attr> the system allocates an additional region of at least I<guardsize> "
1314 "bytes at the end of the thread's stack to act as the guard area for the "
1315 "stack (but see BUGS)."
1319 #: build/C/man3/pthread_attr_setguardsize.3:65
1321 "If I<guardsize> is 0, then new threads created with I<attr> will not have a "
1326 #: build/C/man3/pthread_attr_setguardsize.3:67
1327 msgid "The default guard size is the same as the system page size."
1331 #: build/C/man3/pthread_attr_setguardsize.3:82
1333 "If the stack address attribute has been set in I<attr> (using "
1334 "B<pthread_attr_setstack>(3) or B<pthread_attr_setstackaddr>(3)), meaning "
1335 "that the caller is allocating the thread's stack, then the guard size "
1336 "attribute is ignored (i.e., no guard area is created by the system): it is "
1337 "the application's responsibility to handle stack overflow (perhaps by using "
1338 "B<mprotect>(2) to manually define a guard area at the end of the stack that "
1339 "it has allocated)."
1343 #: build/C/man3/pthread_attr_setguardsize.3:90
1345 "The B<pthread_attr_getguardsize>() function returns the guard size "
1346 "attribute of the thread attributes object referred to by I<attr> in the "
1347 "buffer pointed to by I<guardsize>."
1351 #: build/C/man3/pthread_attr_setguardsize.3:104
1353 "POSIX.1-2001 documents an B<EINVAL> error if I<attr> or I<guardsize> is "
1354 "invalid. On Linux these functions always succeed (but portable and "
1355 "future-proof applications should nevertheless handle a possible error "
1360 #: build/C/man3/pthread_attr_setguardsize.3:106 build/C/man3/pthread_attr_setstackaddr.3:83 build/C/man3/pthread_attr_setstacksize.3:83
1361 msgid "These functions are provided by glibc since version 2.1."
1365 #: build/C/man3/pthread_attr_setguardsize.3:113
1367 "The B<pthread_attr_setguardsize>() and B<pthread_attr_getguardsize>() "
1368 "functions are thread-safe."
1372 #: build/C/man3/pthread_attr_setguardsize.3:129
1374 "A guard area consists of virtual memory pages that are protected to prevent "
1375 "read and write access. If a thread overflows its stack into the guard area, "
1376 "then, on most hard architectures, it receives a B<SIGSEGV> signal, thus "
1377 "notifying it of the overflow. Guard areas start on page boundaries, and the "
1378 "guard size is internally rounded up to the system page size when creating a "
1379 "thread. (Nevertheless, B<pthread_attr_getguardsize>() returns the guard "
1380 "size that was set by B<pthread_attr_setguardsize>().)"
1384 #: build/C/man3/pthread_attr_setguardsize.3:133
1386 "Setting a guard size of 0 may be useful to save memory in an application "
1387 "that creates many threads and knows that stack overflow can never occur."
1391 #: build/C/man3/pthread_attr_setguardsize.3:137
1393 "Choosing a guard size larger than the default size may be necessary for "
1394 "detecting stack overflows if a thread allocates large data structures on the "
1399 #: build/C/man3/pthread_attr_setguardsize.3:137 build/C/man3/pthread_attr_setinheritsched.3:119 build/C/man3/pthread_attr_setstacksize.3:103 build/C/man3/pthread_create.3:203 build/C/man3/pthread_exit.3:98 build/C/man3/pthread_rwlockattr_setkind_np.3:109
1405 #: build/C/man3/pthread_attr_setguardsize.3:148
1407 "As at glibc 2.8, the NPTL threading implementation includes the guard area "
1408 "within the stack size allocation, rather than allocating extra space at the "
1409 "end of the stack, as POSIX.1 requires. (This can result in an B<EINVAL> "
1410 "error from B<pthread_create>(3) if the guard size value is too large, "
1411 "leaving no space for the actual stack.)"
1414 #. glibc includes the guardsize within the allocated stack size,
1415 #. which looks pretty clearly to be in violation of POSIX.
1417 #. Filed bug, 22 Oct 2008:
1418 #. http://sources.redhat.com/bugzilla/show_bug.cgi?id=6973
1421 #. https//bugzilla.redhat.com/show_bug.cgi?id=435337
1422 #. Reportedly, LinuxThreads did the right thing, allocating
1423 #. extra space at the end of the stack:
1424 #. http://sourceware.org/ml/libc-alpha/2008-05/msg00086.html
1426 #: build/C/man3/pthread_attr_setguardsize.3:162
1428 "The obsolete LinuxThreads implementation did the right thing, allocating "
1429 "extra space at the end of the stack for the guard area."
1433 #: build/C/man3/pthread_attr_setguardsize.3:165
1434 msgid "See B<pthread_getattr_np>(3)."
1438 #: build/C/man3/pthread_attr_setguardsize.3:172
1440 "B<mmap>(2), B<mprotect>(2), B<pthread_attr_init>(3), "
1441 "B<pthread_attr_setstack>(3), B<pthread_attr_setstacksize>(3), "
1442 "B<pthread_create>(3), B<pthreads>(7)"
1446 #: build/C/man3/pthread_attr_setinheritsched.3:26
1448 msgid "PTHREAD_ATTR_SETINHERITSCHED"
1452 #: 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/man7/pthreads.7:26
1458 #: build/C/man3/pthread_attr_setinheritsched.3:30
1460 "pthread_attr_setinheritsched, pthread_attr_getinheritsched - set/get "
1461 "inherit-scheduler attribute in thread attributes object"
1465 #: build/C/man3/pthread_attr_setinheritsched.3:38
1468 "B<int pthread_attr_setinheritsched(pthread_attr_t *>I<attr>B<,>\n"
1469 "B< int >I<inheritsched>B<);>\n"
1470 "B<int pthread_attr_getinheritsched(const pthread_attr_t *>I<attr>B<,>\n"
1471 "B< int *>I<inheritsched>B<);>\n"
1475 #: build/C/man3/pthread_attr_setinheritsched.3:55
1477 "The B<pthread_attr_setinheritsched>() function sets the inherit-scheduler "
1478 "attribute of the thread attributes object referred to by I<attr> to the "
1479 "value specified in I<inheritsched>. The inherit-scheduler attribute "
1480 "determines whether a thread created using the thread attributes object "
1481 "I<attr> will inherit its scheduling attributes from the calling thread or "
1482 "whether it will take them from I<attr>."
1486 #: build/C/man3/pthread_attr_setinheritsched.3:64
1488 "The following scheduling attributes are affected by the inherit-scheduler "
1489 "attribute: scheduling policy (B<pthread_attr_setschedpolicy>(3)), scheduling "
1490 "priority (B<pthread_attr_setschedparam>(3)), and contention scope "
1491 "(B<pthread_attr_setscope>(3))."
1495 #: build/C/man3/pthread_attr_setinheritsched.3:67
1496 msgid "The following values may be specified in I<inheritsched>:"
1500 #: build/C/man3/pthread_attr_setinheritsched.3:67
1502 msgid "B<PTHREAD_INHERIT_SCHED>"
1506 #: build/C/man3/pthread_attr_setinheritsched.3:75
1508 "Threads that are created using I<attr> inherit scheduling attributes from "
1509 "the creating thread; the scheduling attributes in I<attr> are ignored."
1513 #: build/C/man3/pthread_attr_setinheritsched.3:75
1515 msgid "B<PTHREAD_EXPLICIT_SCHED>"
1518 #. FIXME Document the defaults for scheduler settings
1520 #: build/C/man3/pthread_attr_setinheritsched.3:82
1522 "Threads that are created using I<attr> take their scheduling attributes from "
1523 "the values specified by the attributes object."
1527 #: build/C/man3/pthread_attr_setinheritsched.3:86
1529 "The default setting of the inherit-scheduler attribute in a newly "
1530 "initialized thread attributes object is B<PTHREAD_INHERIT_SCHED>."
1534 #: build/C/man3/pthread_attr_setinheritsched.3:93
1536 "The B<pthread_attr_getinheritsched>() returns the inherit-scheduler "
1537 "attribute of the thread attributes object I<attr> in the buffer pointed to "
1538 "by I<inheritsched>."
1542 #: build/C/man3/pthread_attr_setinheritsched.3:99
1543 msgid "B<pthread_attr_setinheritsched>() can fail with the following error:"
1547 #: build/C/man3/pthread_attr_setinheritsched.3:103
1548 msgid "Invalid value in I<inheritsched>."
1552 #. Available since glibc 2.0.
1554 #: build/C/man3/pthread_attr_setinheritsched.3:110
1556 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
1557 "to set the attribute to an unsupported value\") for "
1558 "B<pthread_attr_setinheritsched>()."
1562 #: build/C/man3/pthread_attr_setinheritsched.3:117
1564 "The B<pthread_attr_setinheritsched>() and B<pthread_attr_getinheritsched>() "
1565 "functions are thread-safe."
1568 #. FIXME . Track status of the following bug:
1569 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7007
1571 #: build/C/man3/pthread_attr_setinheritsched.3:135
1573 "As at glibc 2.8, if a thread attributes object is initialized using "
1574 "B<pthread_attr_init>(3), then the scheduling policy of the attributes object "
1575 "is set to B<SCHED_OTHER> and the scheduling priority is set to 0. However, "
1576 "if the inherit-scheduler attribute is then set to B<PTHREAD_EXPLICIT_SCHED>, "
1577 "then a thread created using the attribute object wrongly inherits its "
1578 "scheduling attributes from the creating thread. This bug does not occur if "
1579 "either the scheduling policy or scheduling priority attribute is explicitly "
1580 "set in the thread attributes object before calling B<pthread_create>(3)."
1584 #: build/C/man3/pthread_attr_setinheritsched.3:138 build/C/man3/pthread_attr_setschedparam.3:116 build/C/man3/pthread_attr_setschedpolicy.3:112
1585 msgid "See B<pthread_setschedparam>(3)."
1589 #: build/C/man3/pthread_attr_setinheritsched.3:149
1591 "B<pthread_attr_init>(3), B<pthread_attr_setschedparam>(3), "
1592 "B<pthread_attr_setschedpolicy>(3), B<pthread_attr_setscope>(3), "
1593 "B<pthread_create>(3), B<pthread_setschedparam>(3), "
1594 "B<pthread_setschedprio>(3), B<pthreads>(7), B<sched>(7)"
1598 #: build/C/man3/pthread_attr_setschedparam.3:26
1600 msgid "PTHREAD_ATTR_SETSCHEDPARAM"
1604 #: build/C/man3/pthread_attr_setschedparam.3:30
1606 "pthread_attr_setschedparam, pthread_attr_getschedparam - set/get scheduling "
1607 "parameter attributes in thread attributes object"
1611 #: build/C/man3/pthread_attr_setschedparam.3:38
1614 "B<int pthread_attr_setschedparam(pthread_attr_t *>I<attr>B<,>\n"
1615 "B< const struct sched_param *>I<param>B<);>\n"
1616 "B<int pthread_attr_getschedparam(const pthread_attr_t *>I<attr>B<,>\n"
1617 "B< struct sched_param *>I<param>B<);>\n"
1621 #: build/C/man3/pthread_attr_setschedparam.3:52
1623 "The B<pthread_attr_setschedparam>() function sets the scheduling parameter "
1624 "attributes of the thread attributes object referred to by I<attr> to the "
1625 "values specified in the buffer pointed to by I<param>. These attributes "
1626 "determine the scheduling parameters of a thread created using the thread "
1627 "attributes object I<attr>."
1631 #: build/C/man3/pthread_attr_setschedparam.3:59
1633 "The B<pthread_attr_getschedparam>() returns the scheduling parameter "
1634 "attributes of the thread attributes object I<attr> in the buffer pointed to "
1639 #: build/C/man3/pthread_attr_setschedparam.3:61
1640 msgid "Scheduling parameters are maintained in the following structure:"
1644 #: build/C/man3/pthread_attr_setschedparam.3:67 build/C/man3/pthread_setschedparam.3:69
1647 "struct sched_param {\n"
1648 " int sched_priority; /* Scheduling priority */\n"
1653 #: build/C/man3/pthread_attr_setschedparam.3:74 build/C/man3/pthread_setschedparam.3:76
1655 "As can be seen, only one scheduling parameter is supported. For details of "
1656 "the permitted ranges for scheduling priorities in each scheduling policy, "
1661 #: build/C/man3/pthread_attr_setschedparam.3:85
1663 "In order for the parameter setting made by B<pthread_attr_setschedparam>() "
1664 "to have effect when calling B<pthread_create>(3), the caller must use "
1665 "B<pthread_attr_setinheritsched>(3) to set the inherit-scheduler attribute "
1666 "of the attributes object I<attr> to B<PTHREAD_EXPLICIT_SCHED>."
1670 #. Available since glibc 2.0.
1672 #: build/C/man3/pthread_attr_setschedparam.3:100
1674 "POSIX.1 documents B<EINVAL> and B<ENOTSUP> errors for "
1675 "B<pthread_attr_setschedparam>(). On Linux these functions always succeed "
1676 "(but portable and future-proof applications should nevertheless handle a "
1677 "possible error return)."
1681 #: build/C/man3/pthread_attr_setschedparam.3:107
1683 "The B<pthread_attr_setschedparam>() and B<pthread_attr_getschedparam>() "
1684 "functions are thread-safe."
1688 #: build/C/man3/pthread_attr_setschedparam.3:113
1690 "See B<pthread_attr_setschedpolicy>(3) for a list of the thread scheduling "
1691 "policies supported on Linux."
1695 #: build/C/man3/pthread_attr_setschedparam.3:127
1697 "B<sched_get_priority_min>(2), B<pthread_attr_init>(3), "
1698 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedpolicy>(3), "
1699 "B<pthread_create>(3), B<pthread_setschedparam>(3), "
1700 "B<pthread_setschedprio>(3), B<pthreads>(7), B<sched>(7)"
1704 #: build/C/man3/pthread_attr_setschedpolicy.3:26
1706 msgid "PTHREAD_ATTR_SETSCHEDPOLICY"
1710 #: build/C/man3/pthread_attr_setschedpolicy.3:30
1712 "pthread_attr_setschedpolicy, pthread_attr_getschedpolicy - set/get "
1713 "scheduling policy attribute in thread attributes object"
1717 #: build/C/man3/pthread_attr_setschedpolicy.3:38
1720 "B<int pthread_attr_setschedpolicy(pthread_attr_t *>I<attr>B<, int "
1722 "B<int pthread_attr_getschedpolicy(const pthread_attr_t *>I<attr>B<, int "
1723 ">I<*policy>B<);>\n"
1727 #: build/C/man3/pthread_attr_setschedpolicy.3:52
1729 "The B<pthread_attr_setschedpolicy>() function sets the scheduling policy "
1730 "attribute of the thread attributes object referred to by I<attr> to the "
1731 "value specified in I<policy>. This attribute determines the scheduling "
1732 "policy of a thread created using the thread attributes object I<attr>."
1735 #. FIXME . pthread_setschedparam() places no restriction on the policy,
1736 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
1737 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
1739 #: build/C/man3/pthread_attr_setschedpolicy.3:65
1741 "The supported values for I<policy> are B<SCHED_FIFO>, B<SCHED_RR>, and "
1742 "B<SCHED_OTHER>, with the semantics described in B<sched>(7)."
1746 #: build/C/man3/pthread_attr_setschedpolicy.3:72
1748 "The B<pthread_attr_getschedpolicy>() returns the scheduling policy "
1749 "attribute of the thread attributes object I<attr> in the buffer pointed to "
1754 #: build/C/man3/pthread_attr_setschedpolicy.3:83
1756 "In order for the policy setting made by B<pthread_attr_setschedpolicy>() to "
1757 "have effect when calling B<pthread_create>(3), the caller must use "
1758 "B<pthread_attr_setinheritsched>(3) to set the inherit-scheduler attribute "
1759 "of the attributes object I<attr> to B<PTHREAD_EXPLICIT_SCHED>."
1763 #: build/C/man3/pthread_attr_setschedpolicy.3:89
1764 msgid "B<pthread_attr_setschedpolicy>() can fail with the following error:"
1768 #: build/C/man3/pthread_attr_setschedpolicy.3:93
1769 msgid "Invalid value in I<policy>."
1773 #. Available since glibc 2.0.
1775 #: build/C/man3/pthread_attr_setschedpolicy.3:100
1777 "POSIX.1-2001 also documents an optional B<ENOTSUP> error (\"attempt was made "
1778 "to set the attribute to an unsupported value\") for "
1779 "B<pthread_attr_setschedpolicy>()."
1783 #: build/C/man3/pthread_attr_setschedpolicy.3:107
1785 "The B<pthread_attr_setschedpolicy>() and B<pthread_attr_getschedpolicy>() "
1786 "functions are thread-safe."
1790 #: build/C/man3/pthread_attr_setschedpolicy.3:122
1792 "B<pthread_attr_init>(3), B<pthread_attr_setinheritsched>(3), "
1793 "B<pthread_attr_setschedparam>(3), B<pthread_create>(3), "
1794 "B<pthread_setschedparam>(3), B<pthread_setschedprio>(3), B<pthreads>(7), "
1799 #: build/C/man3/pthread_attr_setscope.3:26
1801 msgid "PTHREAD_ATTR_SETSCOPE"
1805 #: build/C/man3/pthread_attr_setscope.3:30
1807 "pthread_attr_setscope, pthread_attr_getscope - set/get contention scope "
1808 "attribute in thread attributes object"
1812 #: build/C/man3/pthread_attr_setscope.3:38
1815 "B<int pthread_attr_setscope(pthread_attr_t *>I<attr>B<, int >I<scope>B<);>\n"
1816 "B<int pthread_attr_getscope(const pthread_attr_t *>I<attr>B<, int "
1821 #: build/C/man3/pthread_attr_setscope.3:53
1823 "The B<pthread_attr_setscope>() function sets the contention scope attribute "
1824 "of the thread attributes object referred to by I<attr> to the value "
1825 "specified in I<scope>. The contention scope attribute defines the set of "
1826 "threads against which a thread competes for resources such as the CPU. "
1827 "POSIX.1-2001 specifies two possible values for I<scope>:"
1831 #: build/C/man3/pthread_attr_setscope.3:53
1833 msgid "B<PTHREAD_SCOPE_SYSTEM>"
1837 #: build/C/man3/pthread_attr_setscope.3:61
1839 "The thread competes for resources with all other threads in all processes on "
1840 "the system that are in the same scheduling allocation domain (a group of one "
1841 "or more processors). B<PTHREAD_SCOPE_SYSTEM> threads are scheduled relative "
1842 "to one another according to their scheduling policy and priority."
1846 #: build/C/man3/pthread_attr_setscope.3:61
1848 msgid "B<PTHREAD_SCOPE_PROCESS>"
1852 #: build/C/man3/pthread_attr_setscope.3:76
1854 "The thread competes for resources with all other threads in the same process "
1855 "that were also created with the B<PTHREAD_SCOPE_PROCESS> contention scope. "
1856 "B<PTHREAD_SCOPE_PROCESS> threads are scheduled relative to other threads in "
1857 "the process according to their scheduling policy and priority. POSIX.1-2001 "
1858 "leaves it unspecified how these threads contend with other threads in other "
1859 "process on the system or with other threads in the same process that were "
1860 "created with the B<PTHREAD_SCOPE_SYSTEM> contention scope."
1864 #: build/C/man3/pthread_attr_setscope.3:83
1866 "POSIX.1-2001 requires that an implementation support at least one of these "
1867 "contention scopes. Linux supports B<PTHREAD_SCOPE_SYSTEM>, but not "
1868 "B<PTHREAD_SCOPE_PROCESS>."
1872 #: build/C/man3/pthread_attr_setscope.3:95
1874 "On systems that support multiple contention scopes, then, in order for the "
1875 "parameter setting made by B<pthread_attr_setscope>() to have effect when "
1876 "calling B<pthread_create>(3), the caller must use "
1877 "B<pthread_attr_setinheritsched>(3) to set the inherit-scheduler attribute "
1878 "of the attributes object I<attr> to B<PTHREAD_EXPLICIT_SCHED>."
1882 #: build/C/man3/pthread_attr_setscope.3:103
1884 "The B<pthread_attr_getscope>() function returns the contention scope "
1885 "attribute of the thread attributes object referred to by I<attr> in the "
1886 "buffer pointed to by I<scope>."
1890 #: build/C/man3/pthread_attr_setscope.3:109
1891 msgid "B<pthread_attr_setscope>() can fail with the following errors:"
1895 #: build/C/man3/pthread_attr_setscope.3:113
1896 msgid "An invalid value was specified in I<scope>."
1900 #: build/C/man3/pthread_attr_setscope.3:113
1906 #: build/C/man3/pthread_attr_setscope.3:119
1908 "I<scope> specified the value B<PTHREAD_SCOPE_PROCESS>, which is not "
1909 "supported on Linux."
1913 #: build/C/man3/pthread_attr_setscope.3:126
1915 "The B<pthread_attr_setscope>() and B<pthread_attr_getscope>() functions "
1920 #: build/C/man3/pthread_attr_setscope.3:136
1922 "The B<PTHREAD_SCOPE_SYSTEM> contention scope typically indicates that a "
1923 "user-space thread is bound directly to a single kernel-scheduling entity. "
1924 "This is the case on Linux for the obsolete LinuxThreads implementation and "
1925 "the modern NPTL implementation, which are both 1:1 threading "
1930 #: build/C/man3/pthread_attr_setscope.3:139
1932 "POSIX.1-2001 specifies that the default contention scope is "
1933 "implementation-defined."
1937 #: build/C/man3/pthread_attr_setscope.3:148
1939 "B<pthread_attr_init>(3), B<pthread_attr_setaffinity_np>(3), "
1940 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
1941 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), B<pthreads>(7)"
1945 #: build/C/man3/pthread_attr_setstack.3:26
1947 msgid "PTHREAD_ATTR_SETSTACK"
1951 #: build/C/man3/pthread_attr_setstack.3:30
1953 "pthread_attr_setstack, pthread_attr_getstack - set/get stack attributes in "
1954 "thread attributes object"
1958 #: build/C/man3/pthread_attr_setstack.3:38
1961 "B<int pthread_attr_setstack(pthread_attr_t *>I<attr>B<,>\n"
1962 "B< void *>I<stackaddr>B<, size_t "
1963 ">I<stacksize>B<);>\n"
1964 "B<int pthread_attr_getstack(const pthread_attr_t *>I<attr>B<,>\n"
1965 "B< void **>I<stackaddr>B<, size_t "
1966 "*>I<stacksize>B<);>\n"
1970 #: build/C/man3/pthread_attr_setstack.3:45 build/C/man3/pthread_cleanup_push_defer_np.3:44 build/C/man3/pthread_kill.3:41 build/C/man3/pthread_rwlockattr_setkind_np.3:44 build/C/man3/pthread_sigmask.3:42 build/C/man3/pthread_sigqueue.3:42
1971 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
1975 #: build/C/man3/pthread_attr_setstack.3:50
1976 msgid "B<pthread_attr_getstack>(), B<pthread_attr_setstack>():"
1980 #: build/C/man3/pthread_attr_setstack.3:52
1981 msgid "_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600"
1985 #: build/C/man3/pthread_attr_setstack.3:68
1987 "The B<pthread_attr_setstack>() function sets the stack address and stack "
1988 "size attributes of the thread attributes object referred to by I<attr> to "
1989 "the values specified in I<stackaddr> and I<stacksize>, respectively. These "
1990 "attributes specify the location and size of the stack that should be used by "
1991 "a thread that is created using the thread attributes object I<attr>."
1995 #: build/C/man3/pthread_attr_setstack.3:74
1997 "I<stackaddr> should point to the lowest addressable byte of a buffer of "
1998 "I<stacksize> bytes that was allocated by the caller. The pages of the "
1999 "allocated buffer should be both readable and writable."
2003 #: build/C/man3/pthread_attr_setstack.3:85
2005 "The B<pthread_attr_getstack>() function returns the stack address and stack "
2006 "size attributes of the thread attributes object referred to by I<attr> in "
2007 "the buffers pointed to by I<stackaddr> and I<stacksize>, respectively."
2011 #: build/C/man3/pthread_attr_setstack.3:91
2012 msgid "B<pthread_attr_setstack>() can fail with the following error:"
2016 #: build/C/man3/pthread_attr_setstack.3:102
2018 "I<stacksize> is less than B<PTHREAD_STACK_MIN> (16384) bytes. On some "
2019 "systems, this error may also occur if I<stackaddr> or I<stackaddr\\ +\\ "
2020 "stacksize> is not suitably aligned."
2024 #: build/C/man3/pthread_attr_setstack.3:110
2026 "POSIX.1-2001 also documents an B<EACCES> error if the stack area described "
2027 "by I<stackaddr> and I<stacksize> is not both readable and writable by the "
2032 #: build/C/man3/pthread_attr_setstack.3:112
2033 msgid "These functions are provided by glibc since version 2.2."
2037 #: build/C/man3/pthread_attr_setstack.3:119
2039 "The B<pthread_attr_setstack>() and B<pthread_attr_getstack>() functions "
2044 #: build/C/man3/pthread_attr_setstack.3:129
2046 "These functions are provided for applications that must ensure that a "
2047 "thread's stack is placed in a particular location. For most applications, "
2048 "this is not necessary, and the use of these functions should be avoided. "
2049 "(Use B<pthread_attr_setstacksize>(3) if an application simply requires a "
2050 "stack size other than the default.)"
2054 #: build/C/man3/pthread_attr_setstack.3:140
2056 "When an application employs B<pthread_attr_setstack>(), it takes over the "
2057 "responsibility of allocating the stack. Any guard size value that was set "
2058 "using B<pthread_attr_setguardsize>(3) is ignored. If deemed necessary, it "
2059 "is the application's responsibility to allocate a guard area (one or more "
2060 "pages protected against reading and writing) to handle the possibility of "
2065 #: build/C/man3/pthread_attr_setstack.3:151
2067 "The address specified in I<stackaddr> should be suitably aligned: for full "
2068 "portability, align it on a page boundary (I<sysconf(_SC_PAGESIZE)>). "
2069 "B<posix_memalign>(3) may be useful for allocation. Probably, I<stacksize> "
2070 "should also be a multiple of the system page size."
2074 #: build/C/man3/pthread_attr_setstack.3:159
2076 "If I<attr> is used to create multiple threads, then the caller must change "
2077 "the stack address attribute between calls to B<pthread_create>(3); "
2078 "otherwise, the threads will attempt to use the same memory area for their "
2079 "stacks, and chaos will ensue."
2083 #: build/C/man3/pthread_attr_setstack.3:173
2085 "B<mmap>(2), B<mprotect>(2), B<posix_memalign>(3), B<pthread_attr_init>(3), "
2086 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setstackaddr>(3), "
2087 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2091 #: build/C/man3/pthread_attr_setstackaddr.3:26
2093 msgid "PTHREAD_ATTR_SETSTACKADDR"
2097 #: build/C/man3/pthread_attr_setstackaddr.3:30
2099 "pthread_attr_setstackaddr, pthread_attr_getstackaddr - set/get stack address "
2100 "attribute in thread attributes object"
2104 #: build/C/man3/pthread_attr_setstackaddr.3:38
2107 "B<int pthread_attr_setstackaddr(pthread_attr_t *>I<attr>B<, void "
2108 "*>I<stackaddr>B<);>\n"
2109 "B<int pthread_attr_getstackaddr(const pthread_attr_t *>I<attr>B<, void "
2110 "**>I<stackaddr>B<);>\n"
2114 #: build/C/man3/pthread_attr_setstackaddr.3:49
2116 "These functions are obsolete: B<do not use them.> Use "
2117 "B<pthread_attr_setstack>(3) and B<pthread_attr_getstack>(3) instead."
2121 #: build/C/man3/pthread_attr_setstackaddr.3:60
2123 "The B<pthread_attr_setstackaddr>() function sets the stack address "
2124 "attribute of the thread attributes object referred to by I<attr> to the "
2125 "value specified in I<stackaddr>. This attribute specifies the location of "
2126 "the stack that should be used by a thread that is created using the thread "
2127 "attributes object I<attr>."
2131 #: build/C/man3/pthread_attr_setstackaddr.3:66
2133 "I<stackaddr> should point to a buffer of at least B<PTHREAD_STACK_MIN> bytes "
2134 "that was allocated by the caller. The pages of the allocated buffer should "
2135 "be both readable and writable."
2139 #: build/C/man3/pthread_attr_setstackaddr.3:74
2141 "The B<pthread_attr_getstackaddr>() function returns the stack address "
2142 "attribute of the thread attributes object referred to by I<attr> in the "
2143 "buffer pointed to by I<stackaddr>."
2147 #: build/C/man3/pthread_attr_setstackaddr.3:81
2149 "No errors are defined (but applications should nevertheless handle a "
2150 "possible error return)."
2154 #: build/C/man3/pthread_attr_setstackaddr.3:90
2156 "The B<pthread_attr_setstackaddr>() and B<pthread_attr_getstackaddr>() "
2157 "functions are thread-safe."
2161 #: build/C/man3/pthread_attr_setstackaddr.3:93
2163 "POSIX.1-2001 specifies these functions but marks them as obsolete. "
2164 "POSIX.1-2008 removes the specification of these functions."
2168 #: build/C/man3/pthread_attr_setstackaddr.3:117
2170 "I<Do not use these functions!> They cannot be portably used, since they "
2171 "provide no way of specifying the direction of growth or the range of the "
2172 "stack. For example, on architectures with a stack that grows downward, "
2173 "I<stackaddr> specifies the next address past the I<highest> address of the "
2174 "allocated stack area. However, on architectures with a stack that grows "
2175 "upward, I<stackaddr> specifies the I<lowest> address in the allocated stack "
2176 "area. By contrast, the I<stackaddr> used by B<pthread_attr_setstack>(3) "
2177 "and B<pthread_attr_getstack>(3), is always a pointer to the lowest address "
2178 "in the allocated stack area (and the I<stacksize> argument specifies the "
2179 "range of the stack)."
2183 #: build/C/man3/pthread_attr_setstackaddr.3:122
2185 "B<pthread_attr_init>(3), B<pthread_attr_setstack>(3), "
2186 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), B<pthreads>(7)"
2190 #: build/C/man3/pthread_attr_setstacksize.3:26
2192 msgid "PTHREAD_ATTR_SETSTACKSIZE"
2196 #: build/C/man3/pthread_attr_setstacksize.3:30
2198 "pthread_attr_setstacksize, pthread_attr_getstacksize - set/get stack size "
2199 "attribute in thread attributes object"
2203 #: build/C/man3/pthread_attr_setstacksize.3:38
2206 "B<int pthread_attr_setstacksize(pthread_attr_t *>I<attr>B<, size_t "
2207 ">I<stacksize>B<);>\n"
2208 "B<int pthread_attr_getstacksize(const pthread_attr_t *>I<attr>B<, size_t "
2209 "*>I<stacksize>B<);>\n"
2213 #: build/C/man3/pthread_attr_setstacksize.3:49
2215 "The B<pthread_attr_setstacksize>() function sets the stack size attribute "
2216 "of the thread attributes object referred to by I<attr> to the value "
2217 "specified in I<stacksize>."
2221 #: build/C/man3/pthread_attr_setstacksize.3:53
2223 "The stack size attribute determines the minimum size (in bytes) that will be "
2224 "allocated for threads created using the thread attributes object I<attr>."
2228 #: build/C/man3/pthread_attr_setstacksize.3:61
2230 "The B<pthread_attr_getstacksize>() function returns the stack size "
2231 "attribute of the thread attributes object referred to by I<attr> in the "
2232 "buffer pointed to by I<stacksize>."
2236 #: build/C/man3/pthread_attr_setstacksize.3:67
2237 msgid "B<pthread_attr_setstacksize>() can fail with the following error:"
2241 #: build/C/man3/pthread_attr_setstacksize.3:72
2242 msgid "The stack size is less than B<PTHREAD_STACK_MIN> (16384) bytes."
2247 #: build/C/man3/pthread_attr_setstacksize.3:81
2249 "On some systems, B<pthread_attr_setstacksize>() can fail with the error "
2250 "B<EINVAL> if I<stacksize> is not a multiple of the system page size."
2254 #: build/C/man3/pthread_attr_setstacksize.3:90
2256 "The B<pthread_attr_setstacksize>() and B<pthread_attr_getstacksize>() "
2257 "functions are thread-safe."
2261 #: build/C/man3/pthread_attr_setstacksize.3:95
2263 "For details on the default stack size of new threads, see "
2264 "B<pthread_create>(3)."
2268 #: build/C/man3/pthread_attr_setstacksize.3:98
2270 "A thread's stack size is fixed at the time of thread creation. Only the "
2271 "main thread can dynamically grow its stack."
2275 #: build/C/man3/pthread_attr_setstacksize.3:103
2277 "The B<pthread_attr_setstack>(3) function allows an application to set both "
2278 "the size and location of a caller-allocated stack that is to be used by a "
2283 #: build/C/man3/pthread_attr_setstacksize.3:115
2285 "As at glibc 2.8, if the specified I<stacksize> is not a multiple of "
2286 "B<STACK_ALIGN> (16 bytes on most architectures), it may be rounded "
2287 "I<downward>, in violation of POSIX.1-2001, which says that the allocated "
2288 "stack will be at least I<stacksize> bytes."
2292 #: build/C/man3/pthread_attr_setstacksize.3:118 build/C/man3/pthread_join.3:127
2293 msgid "See B<pthread_create>(3)."
2297 #: build/C/man3/pthread_attr_setstacksize.3:124
2299 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_attr_setguardsize>(3), "
2300 "B<pthread_attr_setstack>(3), B<pthread_create>(3), B<pthreads>(7)"
2304 #: build/C/man3/pthread_cancel.3:26
2306 msgid "PTHREAD_CANCEL"
2310 #: build/C/man3/pthread_cancel.3:26
2316 #: build/C/man3/pthread_cancel.3:29
2317 msgid "pthread_cancel - send a cancellation request to a thread"
2321 #: build/C/man3/pthread_cancel.3:34
2323 msgid "B<int pthread_cancel(pthread_t >I<thread>B<);>\n"
2327 #: build/C/man3/pthread_cancel.3:49
2329 "The B<pthread_cancel>() function sends a cancellation request to the thread "
2330 "I<thread>. Whether and when the target thread reacts to the cancellation "
2331 "request depends on two attributes that are under the control of that thread: "
2332 "its cancelability I<state> and I<type>."
2336 #: build/C/man3/pthread_cancel.3:61
2338 "A thread's cancelability state, determined by B<pthread_setcancelstate>(3), "
2339 "can be I<enabled> (the default for new threads) or I<disabled>. If a thread "
2340 "has disabled cancellation, then a cancellation request remains queued until "
2341 "the thread enables cancellation. If a thread has enabled cancellation, then "
2342 "its cancelability type determines when cancellation occurs."
2346 #: build/C/man3/pthread_cancel.3:77
2348 "A thread's cancellation type, determined by B<pthread_setcanceltype>(3), may "
2349 "be either I<asynchronous> or I<deferred> (the default for new threads). "
2350 "Asynchronous cancelability means that the thread can be canceled at any time "
2351 "(usually immediately, but the system does not guarantee this). Deferred "
2352 "cancelability means that cancellation will be delayed until the thread next "
2353 "calls a function that is a I<cancellation point>. A list of functions that "
2354 "are or may be cancellation points is provided in B<pthreads>(7)."
2358 #: build/C/man3/pthread_cancel.3:81
2360 "When a cancellation requested is acted on, the following steps occur for "
2361 "I<thread> (in this order):"
2365 #: build/C/man3/pthread_cancel.3:81 build/C/man3/pthread_cleanup_push.3:69
2371 #: build/C/man3/pthread_cancel.3:86
2373 "Cancellation clean-up handlers are popped (in the reverse of the order in "
2374 "which they were pushed) and called. (See B<pthread_cleanup_push>(3).)"
2378 #: build/C/man3/pthread_cancel.3:86 build/C/man3/pthread_cleanup_push.3:73
2384 #: build/C/man3/pthread_cancel.3:91
2386 "Thread-specific data destructors are called, in an unspecified order. (See "
2387 "B<pthread_key_create>(3).)"
2391 #: build/C/man3/pthread_cancel.3:91 build/C/man3/pthread_cleanup_push.3:83
2397 #: build/C/man3/pthread_cancel.3:95
2398 msgid "The thread is terminated. (See B<pthread_exit>(3).)"
2402 #: build/C/man3/pthread_cancel.3:103
2404 "The above steps happen asynchronously with respect to the "
2405 "B<pthread_cancel>() call; the return status of B<pthread_cancel>() merely "
2406 "informs the caller whether the cancellation request was successfully queued."
2410 #: build/C/man3/pthread_cancel.3:112
2412 "After a canceled thread has terminated, a join with that thread using "
2413 "B<pthread_join>(3) obtains B<PTHREAD_CANCELED> as the thread's exit "
2414 "status. (Joining with a thread is the only way to know that cancellation "
2419 #: build/C/man3/pthread_cancel.3:117
2421 "On success, B<pthread_cancel>() returns 0; on error, it returns a nonzero "
2426 #: build/C/man3/pthread_cancel.3:118 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_setaffinity_np.3:114 build/C/man3/pthread_setschedparam.3:114 build/C/man3/pthread_setschedprio.3:70 build/C/man3/pthread_sigqueue.3:86
2432 #: build/C/man3/pthread_cancel.3:125 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_setaffinity_np.3:119 build/C/man3/pthread_setschedparam.3:119 build/C/man3/pthread_setschedprio.3:75
2433 msgid "No thread with the ID I<thread> could be found."
2437 #: build/C/man3/pthread_cancel.3:135
2439 "On Linux, cancellation is implemented using signals. Under the NPTL "
2440 "threading implementation, the first real-time signal (i.e., signal 32) is "
2441 "used for this purpose. On LinuxThreads, the second real-time signal is "
2442 "used, if real-time signals are available, otherwise B<SIGUSR2> is used."
2446 #: build/C/man3/pthread_cancel.3:141
2448 "The program below creates a thread and then cancels it. The main thread "
2449 "joins with the canceled thread to check that its exit status was "
2450 "B<PTHREAD_CANCELED>. The following shell session shows what happens when we "
2455 #: build/C/man3/pthread_cancel.3:149
2459 "thread_func(): started; cancellation disabled\n"
2460 "main(): sending cancellation request\n"
2461 "thread_func(): about to enable cancellation\n"
2462 "main(): thread was canceled\n"
2466 #: build/C/man3/pthread_cancel.3:159
2469 "#include E<lt>pthread.hE<gt>\n"
2470 "#include E<lt>stdio.hE<gt>\n"
2471 "#include E<lt>errno.hE<gt>\n"
2472 "#include E<lt>stdlib.hE<gt>\n"
2473 "#include E<lt>unistd.hE<gt>\n"
2477 #: build/C/man3/pthread_cancel.3:167
2481 "thread_func(void *ignored_argument)\n"
2487 #: build/C/man3/pthread_cancel.3:170
2490 " /* Disable cancellation for a while, so that we don\\(aqt\n"
2491 " immediately react to a cancellation request */\n"
2495 #: build/C/man3/pthread_cancel.3:174
2498 " s = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);\n"
2500 " handle_error_en(s, \"pthread_setcancelstate\");\n"
2504 #: build/C/man3/pthread_cancel.3:178
2507 " printf(\"thread_func(): started; cancellation disabled\\en\");\n"
2509 " printf(\"thread_func(): about to enable cancellation\\en\");\n"
2513 #: build/C/man3/pthread_cancel.3:182
2516 " s = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);\n"
2518 " handle_error_en(s, \"pthread_setcancelstate\");\n"
2522 #: build/C/man3/pthread_cancel.3:184
2524 msgid " /* sleep() is a cancellation point */\n"
2528 #: build/C/man3/pthread_cancel.3:186
2530 msgid " sleep(1000); /* Should get canceled while we sleep */\n"
2534 #: build/C/man3/pthread_cancel.3:188
2536 msgid " /* Should never get here */\n"
2540 #: build/C/man3/pthread_cancel.3:192
2543 " printf(\"thread_func(): not canceled!\\en\");\n"
2549 #: build/C/man3/pthread_cancel.3:199
2561 #: build/C/man3/pthread_cancel.3:201
2563 msgid " /* Start a thread and then send it a cancellation request */\n"
2567 #: build/C/man3/pthread_cancel.3:205
2570 " s = pthread_create(&thr, NULL, &thread_func, NULL);\n"
2572 " handle_error_en(s, \"pthread_create\");\n"
2576 #: build/C/man3/pthread_cancel.3:207
2578 msgid " sleep(2); /* Give thread a chance to get started */\n"
2582 #: build/C/man3/pthread_cancel.3:212
2585 " printf(\"main(): sending cancellation request\\en\");\n"
2586 " s = pthread_cancel(thr);\n"
2588 " handle_error_en(s, \"pthread_cancel\");\n"
2592 #: build/C/man3/pthread_cancel.3:214
2594 msgid " /* Join with thread to see what its exit status was */\n"
2598 #: build/C/man3/pthread_cancel.3:218 build/C/man3/pthread_cleanup_push.3:307
2601 " s = pthread_join(thr, &res);\n"
2603 " handle_error_en(s, \"pthread_join\");\n"
2607 #: build/C/man3/pthread_cancel.3:225
2610 " if (res == PTHREAD_CANCELED)\n"
2611 " printf(\"main(): thread was canceled\\en\");\n"
2613 " printf(\"main(): thread wasn\\(aqt canceled (shouldn\\(aqt "
2614 "happen!)\\en\");\n"
2615 " exit(EXIT_SUCCESS);\n"
2620 #: build/C/man3/pthread_cancel.3:237
2622 "B<pthread_cleanup_push>(3), B<pthread_create>(3), B<pthread_exit>(3), "
2623 "B<pthread_join>(3), B<pthread_key_create>(3), B<pthread_setcancelstate>(3), "
2624 "B<pthread_setcanceltype>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
2628 #: build/C/man3/pthread_cleanup_push.3:26
2630 msgid "PTHREAD_CLEANUP_PUSH"
2634 #: build/C/man3/pthread_cleanup_push.3:26
2640 #: build/C/man3/pthread_cleanup_push.3:30
2642 "pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancellation "
2647 #: build/C/man3/pthread_cleanup_push.3:37
2650 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *),>\n"
2651 "B< void *>I<arg>B<);>\n"
2652 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
2656 #: build/C/man3/pthread_cleanup_push.3:48
2658 "These functions manipulate the calling thread's stack of thread-cancellation "
2659 "clean-up handlers. A clean-up handler is a function that is automatically "
2660 "executed when a thread is canceled (or in various other circumstances "
2661 "described below); it might, for example, unlock a mutex so that it becomes "
2662 "available to other threads in the process."
2666 #: build/C/man3/pthread_cleanup_push.3:59
2668 "The B<pthread_cleanup_push>() function pushes I<routine> onto the top of "
2669 "the stack of clean-up handlers. When I<routine> is later invoked, it will "
2670 "be given I<arg> as its argument."
2674 #: build/C/man3/pthread_cleanup_push.3:66
2676 "The B<pthread_cleanup_pop>() function removes the routine at the top of the "
2677 "stack of clean-up handlers, and optionally executes it if I<execute> is "
2682 #: build/C/man3/pthread_cleanup_push.3:69
2684 "A cancellation clean-up handler is popped from the stack and executed in the "
2685 "following circumstances:"
2689 #: build/C/man3/pthread_cleanup_push.3:73
2691 "When a thread is canceled, all of the stacked clean-up handlers are popped "
2692 "and executed in the reverse of the order in which they were pushed onto the "
2697 #: build/C/man3/pthread_cleanup_push.3:83
2699 "When a thread terminates by calling B<pthread_exit>(3), all clean-up "
2700 "handlers are executed as described in the preceding point. (Clean-up "
2701 "handlers are I<not> called if the thread terminates by performing a "
2702 "I<return> from the thread start function.)"
2706 #: build/C/man3/pthread_cleanup_push.3:89
2708 "When a thread calls B<pthread_cleanup_pop>() with a nonzero I<execute> "
2709 "argument, the top-most clean-up handler is popped and executed."
2713 #: build/C/man3/pthread_cleanup_push.3:101
2715 "POSIX.1 permits B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() to "
2716 "be implemented as macros that expand to text containing \\(aqB<{>\\(aq and "
2717 "\\(aqB<}>\\(aq, respectively. For this reason, the caller must ensure that "
2718 "calls to these functions are paired within the same function, and at the "
2719 "same lexical nesting level. (In other words, a clean-up handler is "
2720 "established only during the execution of a specified section of code.)"
2724 #: build/C/man3/pthread_cleanup_push.3:121
2726 "Calling B<longjmp>(3) (B<siglongjmp>(3)) produces undefined results if any "
2727 "call has been made to B<pthread_cleanup_push>() or B<pthread_cleanup_pop>() "
2728 "without the matching call of the pair since the jump buffer was filled by "
2729 "B<setjmp>(3) (B<sigsetjmp>(3)). Likewise, calling B<longjmp>(3) "
2730 "(B<siglongjmp>(3)) from inside a clean-up handler produces undefined "
2731 "results unless the jump buffer was also filled by B<setjmp>(3) "
2732 "(B<sigsetjmp>(3)) inside the handler."
2736 #: build/C/man3/pthread_cleanup_push.3:123
2737 msgid "These functions do not return a value."
2741 #. Available since glibc 2.0
2743 #: build/C/man3/pthread_cleanup_push.3:127
2744 msgid "There are no errors."
2748 #: build/C/man3/pthread_cleanup_push.3:140
2750 "On Linux, the B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() "
2751 "functions I<are> implemented as macros that expand to text containing "
2752 "\\(aqB<{>\\(aq and \\(aqB<}>\\(aq, respectively. This means that variables "
2753 "declared within the scope of paired calls to these functions will be visible "
2754 "within only that scope."
2757 #. The text was actually added in the 2004 TC2
2759 #: build/C/man3/pthread_cleanup_push.3:155
2761 "POSIX.1 says that the effect of using I<return>, I<break>, I<continue>, or "
2762 "I<goto> to prematurely leave a block bracketed B<pthread_cleanup_push>() "
2763 "and B<pthread_cleanup_pop>() is undefined. Portable applications should "
2768 #: build/C/man3/pthread_cleanup_push.3:170
2770 "The program below provides a simple example of the use of the functions "
2771 "described in this page. The program creates a thread that executes a loop "
2772 "bracketed by B<pthread_cleanup_push>() and B<pthread_cleanup_pop>(). This "
2773 "loop increments a global variable, I<cnt>, once each second. Depending on "
2774 "what command-line arguments are supplied, the main thread sends the other "
2775 "thread a cancellation request, or sets a global variable that causes the "
2776 "other thread to exit its loop and terminate normally (by doing a I<return>)."
2780 #: build/C/man3/pthread_cleanup_push.3:173
2782 "In the following shell session, the main thread sends a cancellation request "
2783 "to the other thread:"
2787 #: build/C/man3/pthread_cleanup_push.3:183
2791 "New thread started\n"
2794 "Canceling thread\n"
2795 "Called clean-up handler\n"
2796 "Thread was canceled; cnt = 0\n"
2800 #: build/C/man3/pthread_cleanup_push.3:191
2802 "From the above, we see that the thread was canceled, and that the "
2803 "cancellation clean-up handler was called and it reset the value of the "
2804 "global variable I<cnt> to 0."
2808 #: build/C/man3/pthread_cleanup_push.3:194
2810 "In the next run, the main program sets a global variable that causes other "
2811 "thread to terminate normally:"
2815 #: build/C/man3/pthread_cleanup_push.3:202
2819 "New thread started\n"
2822 "Thread terminated normally; cnt = 2\n"
2826 #: build/C/man3/pthread_cleanup_push.3:210
2828 "From the above, we see that the clean-up handler was not executed (because "
2829 "I<cleanup_pop_arg> was 0), and therefore the value of I<cnt> was not reset."
2833 #: build/C/man3/pthread_cleanup_push.3:215
2835 "In the next run, the main program sets a global variable that causes the "
2836 "other thread to terminate normally, and supplies a nonzero value for "
2837 "I<cleanup_pop_arg>:"
2841 #: build/C/man3/pthread_cleanup_push.3:224
2844 "$ B<./a.out x 1>\n"
2845 "New thread started\n"
2848 "Called clean-up handler\n"
2849 "Thread terminated normally; cnt = 0\n"
2853 #: build/C/man3/pthread_cleanup_push.3:231
2855 "In the above, we see that although the thread was not canceled, the clean-up "
2856 "handler was executed, because the argument given to B<pthread_cleanup_pop>() "
2861 #: build/C/man3/pthread_cleanup_push.3:240
2864 "#include E<lt>pthread.hE<gt>\n"
2865 "#include E<lt>sys/types.hE<gt>\n"
2866 "#include E<lt>stdio.hE<gt>\n"
2867 "#include E<lt>stdlib.hE<gt>\n"
2868 "#include E<lt>unistd.hE<gt>\n"
2869 "#include E<lt>errno.hE<gt>\n"
2873 #: build/C/man3/pthread_cleanup_push.3:247
2876 "static int done = 0;\n"
2877 "static int cleanup_pop_arg = 0;\n"
2878 "static int cnt = 0;\n"
2882 #: build/C/man3/pthread_cleanup_push.3:254
2886 "cleanup_handler(void *arg)\n"
2888 " printf(\"Called clean-up handler\\en\");\n"
2894 #: build/C/man3/pthread_cleanup_push.3:259
2898 "thread_start(void *arg)\n"
2900 " time_t start, curr;\n"
2904 #: build/C/man3/pthread_cleanup_push.3:261
2906 msgid " printf(\"New thread started\\en\");\n"
2910 #: build/C/man3/pthread_cleanup_push.3:263
2912 msgid " pthread_cleanup_push(cleanup_handler, NULL);\n"
2916 #: build/C/man3/pthread_cleanup_push.3:265
2918 msgid " curr = start = time(NULL);\n"
2922 #: build/C/man3/pthread_cleanup_push.3:274
2925 " while (!done) {\n"
2926 " pthread_testcancel(); /* A cancellation point */\n"
2927 " if (curr E<lt> time(NULL)) {\n"
2928 " curr = time(NULL);\n"
2929 " printf(\"cnt = %d\\en\", cnt); /* A cancellation point */\n"
2936 #: build/C/man3/pthread_cleanup_push.3:278
2939 " pthread_cleanup_pop(cleanup_pop_arg);\n"
2945 #: build/C/man3/pthread_cleanup_push.3:285
2949 "main(int argc, char *argv[])\n"
2957 #: build/C/man3/pthread_cleanup_push.3:289
2960 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
2962 " handle_error_en(s, \"pthread_create\");\n"
2966 #: build/C/man3/pthread_cleanup_push.3:291
2968 msgid " sleep(2); /* Allow new thread to run a while */\n"
2972 #: build/C/man3/pthread_cleanup_push.3:296
2975 " if (argc E<gt> 1) {\n"
2976 " if (argc E<gt> 2)\n"
2977 " cleanup_pop_arg = atoi(argv[2]);\n"
2982 #: build/C/man3/pthread_cleanup_push.3:303
2986 " printf(\"Canceling thread\\en\");\n"
2987 " s = pthread_cancel(thr);\n"
2989 " handle_error_en(s, \"pthread_cancel\");\n"
2994 #: build/C/man3/pthread_cleanup_push.3:314
2997 " if (res == PTHREAD_CANCELED)\n"
2998 " printf(\"Thread was canceled; cnt = %d\\en\", cnt);\n"
3000 " printf(\"Thread terminated normally; cnt = %d\\en\", cnt);\n"
3001 " exit(EXIT_SUCCESS);\n"
3006 #: build/C/man3/pthread_cleanup_push.3:320
3008 "B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), "
3009 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3013 #: build/C/man3/pthread_cleanup_push_defer_np.3:26
3015 msgid "PTHREAD_CLEANUP_PUSH_DEFER_NP"
3019 #: build/C/man3/pthread_cleanup_push_defer_np.3:30
3021 "pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np - push and pop "
3022 "thread cancellation clean-up handlers while saving cancelability type"
3026 #: build/C/man3/pthread_cleanup_push_defer_np.3:37
3029 "B<void pthread_cleanup_push_defer_np(void (*>I<routine>B<)(void *),>\n"
3030 "B< void *>I<arg>B<);>\n"
3031 "B<void pthread_cleanup_pop_restore_np(int >I<execute>B<);>\n"
3035 #: 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:38 build/C/man3/pthread_tryjoin_np.3:42 build/C/man3/pthread_yield.3:37
3036 msgid "Compile and link with I<-pthread>."
3040 #: build/C/man3/pthread_cleanup_push_defer_np.3:49
3041 msgid "B<pthread_cleanup_push_defer_np>(), B<pthread_cleanup_pop_defer_np>():"
3045 #: build/C/man3/pthread_cleanup_push_defer_np.3:51
3050 #: build/C/man3/pthread_cleanup_push_defer_np.3:59
3052 "These functions are the same as B<pthread_cleanup_push>(3) and "
3053 "B<pthread_cleanup_pop>(3), except for the differences noted on this page."
3057 #: build/C/man3/pthread_cleanup_push_defer_np.3:72
3059 "Like B<pthread_cleanup_push>(3), B<pthread_cleanup_push_defer_np>() pushes "
3060 "I<routine> onto the thread's stack of cancellation clean-up handlers. In "
3061 "addition, it also saves the thread's current cancelability type, and sets "
3062 "the cancelability type to \"deferred\" (see B<pthread_setcanceltype>(3)); "
3063 "this ensures that cancellation clean-up will occur even if the thread's "
3064 "cancelability type was \"asynchronous\" before the call."
3068 #: build/C/man3/pthread_cleanup_push_defer_np.3:81
3070 "Like B<pthread_cleanup_pop>(3), B<pthread_cleanup_pop_restore_np>() pops "
3071 "the top-most clean-up handler from the thread's stack of cancellation "
3072 "clean-up handlers. In addition, it restores the thread's cancelability type "
3073 "to its value at the time of the matching B<pthread_cleanup_push_defer_np>()."
3077 #: build/C/man3/pthread_cleanup_push_defer_np.3:87
3079 "The caller must ensure that calls to these functions are paired within the "
3080 "same function, and at the same lexical nesting level. Other restrictions "
3081 "apply, as described in B<pthread_cleanup_push>(3)."
3085 #: build/C/man3/pthread_cleanup_push_defer_np.3:89
3086 msgid "This sequence of calls:"
3090 #: build/C/man3/pthread_cleanup_push_defer_np.3:94
3093 "pthread_cleanup_push_defer_np(routine, arg);\n"
3094 "pthread_cleanup_pop_restore_np(execute);\n"
3098 #: build/C/man3/pthread_cleanup_push_defer_np.3:98
3099 msgid "is equivalent to (but shorter and more efficient than):"
3103 #: build/C/man3/pthread_cleanup_push_defer_np.3:104
3105 msgid "int oldtype;\n"
3109 #: build/C/man3/pthread_cleanup_push_defer_np.3:110
3112 "pthread_cleanup_push(routine, arg);\n"
3113 "pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);\n"
3115 "pthread_setcanceltype(oldtype, NULL);\n"
3116 "pthread_cleanup_pop(execute);\n"
3120 #: build/C/man3/pthread_cleanup_push_defer_np.3:122
3122 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
3123 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
3127 #: build/C/man3/pthread_create.3:26
3129 msgid "PTHREAD_CREATE"
3133 #: build/C/man3/pthread_create.3:29
3134 msgid "pthread_create - create a new thread"
3138 #: build/C/man3/pthread_create.3:35
3141 "B<int pthread_create(pthread_t *>I<thread>B<, const pthread_attr_t "
3143 "B< void *(*>I<start_routine>B<) (void *), void "
3148 #: build/C/man3/pthread_create.3:47
3150 "The B<pthread_create>() function starts a new thread in the calling "
3151 "process. The new thread starts execution by invoking I<start_routine>(); "
3152 "I<arg> is passed as the sole argument of I<start_routine>()."
3156 #: build/C/man3/pthread_create.3:49
3157 msgid "The new thread terminates in one of the following ways:"
3161 #: 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
3167 #: build/C/man3/pthread_create.3:55
3169 "It calls B<pthread_exit>(3), specifying an exit status value that is "
3170 "available to another thread in the same process that calls "
3171 "B<pthread_join>(3)."
3175 #: build/C/man3/pthread_create.3:63
3177 "It returns from I<start_routine>(). This is equivalent to calling "
3178 "B<pthread_exit>(3) with the value supplied in the I<return> statement."
3182 #: build/C/man3/pthread_create.3:66
3183 msgid "It is canceled (see B<pthread_cancel>(3))."
3187 #: build/C/man3/pthread_create.3:72
3189 "Any of the threads in the process calls B<exit>(3), or the main thread "
3190 "performs a return from I<main>(). This causes the termination of all "
3191 "threads in the process."
3195 #: build/C/man3/pthread_create.3:86
3197 "The I<attr> argument points to a I<pthread_attr_t> structure whose contents "
3198 "are used at thread creation time to determine attributes for the new thread; "
3199 "this structure is initialized using B<pthread_attr_init>(3) and related "
3200 "functions. If I<attr> is NULL, then the thread is created with default "
3205 #: build/C/man3/pthread_create.3:93
3207 "Before returning, a successful call to B<pthread_create>() stores the ID of "
3208 "the new thread in the buffer pointed to by I<thread>; this identifier is "
3209 "used to refer to the thread in subsequent calls to other pthreads functions."
3213 #: build/C/man3/pthread_create.3:101
3215 "The new thread inherits a copy of the creating thread's signal mask "
3216 "(B<pthread_sigmask>(3)). The set of pending signals for the new thread is "
3217 "empty (B<sigpending>(2)). The new thread does not inherit the creating "
3218 "thread's alternate signal stack (B<sigaltstack>(2))."
3222 #: build/C/man3/pthread_create.3:104
3224 "The new thread inherits the calling thread's floating-point environment "
3228 #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
3230 #: build/C/man3/pthread_create.3:109
3232 "The initial value of the new thread's CPU-time clock is 0 (see "
3233 "B<pthread_getcpuclockid>(3))."
3237 #: build/C/man3/pthread_create.3:109
3239 msgid "Linux-specific details"
3243 #: build/C/man3/pthread_create.3:115
3245 "The new thread inherits copies of the calling thread's capability sets (see "
3246 "B<capabilities>(7)) and CPU affinity mask (see B<sched_setaffinity>(2))."
3250 #: build/C/man3/pthread_create.3:122
3252 "On success, B<pthread_create>() returns 0; on error, it returns an error "
3253 "number, and the contents of I<*thread> are undefined."
3257 #: build/C/man3/pthread_create.3:123 build/C/man3/pthread_create.3:126 build/C/man3/pthread_sigqueue.3:72
3263 #: build/C/man3/pthread_create.3:126
3264 msgid "Insufficient resources to create another thread."
3267 #. NOTE! The following should match the description in fork(2)
3269 #: build/C/man3/pthread_create.3:144
3271 "A system-imposed limit on the number of threads was encountered. There are "
3272 "a number of limits that may trigger this error: the B<RLIMIT_NPROC> soft "
3273 "resource limit (set via B<setrlimit>(2)), which limits the number of "
3274 "processes and threads for a real user ID, was reached; the kernel's "
3275 "system-wide limit on the number of processes and threads, "
3276 "I</proc/sys/kernel/threads-max>, was reached (see B<proc>(5)); or the "
3277 "maximum number of PIDs, I</proc/sys/kernel/pid_max>, was reached (see "
3282 #: build/C/man3/pthread_create.3:148
3283 msgid "Invalid settings in I<attr>."
3287 #: build/C/man3/pthread_create.3:148 build/C/man3/pthread_setschedparam.3:129 build/C/man3/pthread_setschedprio.3:66
3293 #: build/C/man3/pthread_create.3:153
3295 "No permission to set the scheduling policy and parameters specified in "
3300 #: build/C/man3/pthread_create.3:167
3302 "See B<pthread_self>(3) for further information on the thread ID returned in "
3303 "I<*thread> by B<pthread_create>(). Unless real-time scheduling policies are "
3304 "being employed, after a call to B<pthread_create>(), it is indeterminate "
3305 "which thread\\(emthe caller or the new thread\\(emwill next execute."
3309 #: build/C/man3/pthread_create.3:187
3311 "A thread may either be I<joinable> or I<detached>. If a thread is joinable, "
3312 "then another thread can call B<pthread_join>(3) to wait for the thread to "
3313 "terminate and fetch its exit status. Only when a terminated joinable thread "
3314 "has been joined are the last of its resources released back to the system. "
3315 "When a detached thread terminates, its resources are automatically released "
3316 "back to the system: it is not possible to join with the thread in order to "
3317 "obtain its exit status. Making a thread detached is useful for some types "
3318 "of daemon threads whose exit status the application does not need to care "
3319 "about. By default, a new thread is created in a joinable state, unless "
3320 "I<attr> was set to create the thread in a detached state (using "
3321 "B<pthread_attr_setdetachstate>(3))."
3324 #. FIXME . Perhaps some of the following detail should be in
3325 #. a future pthread_attr_setstacksize(3) page.
3327 #: build/C/man3/pthread_create.3:203
3329 "On Linux/x86-32, the default stack size for a new thread is 2 megabytes. "
3330 "Under the NPTL threading implementation, if the B<RLIMIT_STACK> soft "
3331 "resource limit I<at the time the program started> has any value other than "
3332 "\"unlimited\", then it determines the default stack size of new threads. "
3333 "Using B<pthread_attr_setstacksize>(3), the stack size attribute can be "
3334 "explicitly set in the I<attr> argument used to create a thread, in order to "
3335 "obtain a stack size other than the default."
3339 #: build/C/man3/pthread_create.3:209
3341 "In the obsolete LinuxThreads implementation, each of the threads in a "
3342 "process has a different process ID. This is in violation of the POSIX "
3343 "threads specification, and is the source of many other nonconformances to "
3344 "the standard; see B<pthreads>(7)."
3348 #: build/C/man3/pthread_create.3:213
3350 "The program below demonstrates the use of B<pthread_create>(), as well as a "
3351 "number of other functions in the pthreads API."
3355 #: build/C/man3/pthread_create.3:218
3357 "In the following run, on a system providing the NPTL threading "
3358 "implementation, the stack size defaults to the value given by the \"stack "
3359 "size\" resource limit:"
3363 #: build/C/man3/pthread_create.3:230
3367 "8192 # The stack size limit is 8 MB (0x800000 bytes)\n"
3368 "$B< ./a.out hola salut servus>\n"
3369 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
3370 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
3371 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
3372 "Joined with thread 1; returned value was HOLA\n"
3373 "Joined with thread 2; returned value was SALUT\n"
3374 "Joined with thread 3; returned value was SERVUS\n"
3378 #: build/C/man3/pthread_create.3:236
3380 "In the next run, the program explicitly sets a stack size of 1MB (using "
3381 "B<pthread_attr_setstacksize>(3)) for the created threads:"
3385 #: build/C/man3/pthread_create.3:246
3388 "$B< ./a.out -s 0x100000 hola salut servus>\n"
3389 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
3390 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
3391 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
3392 "Joined with thread 1; returned value was HOLA\n"
3393 "Joined with thread 2; returned value was SALUT\n"
3394 "Joined with thread 3; returned value was SERVUS\n"
3398 #: build/C/man3/pthread_create.3:258
3401 "#include E<lt>pthread.hE<gt>\n"
3402 "#include E<lt>string.hE<gt>\n"
3403 "#include E<lt>stdio.hE<gt>\n"
3404 "#include E<lt>stdlib.hE<gt>\n"
3405 "#include E<lt>unistd.hE<gt>\n"
3406 "#include E<lt>errno.hE<gt>\n"
3407 "#include E<lt>ctype.hE<gt>\n"
3411 #: build/C/man3/pthread_create.3:264 build/C/man3/pthread_getcpuclockid.3:116
3414 "#define handle_error(msg) \\e\n"
3415 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
3419 #: build/C/man3/pthread_create.3:270
3422 "struct thread_info { /* Used as argument to thread_start() */\n"
3423 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
3424 " int thread_num; /* Application-defined thread # */\n"
3425 " char *argv_string; /* From command-line argument */\n"
3430 #: build/C/man3/pthread_create.3:273
3433 "/* Thread start function: display address near top of our stack,\n"
3434 " and return upper-cased copy of argv_string */\n"
3438 #: build/C/man3/pthread_create.3:279
3442 "thread_start(void *arg)\n"
3444 " struct thread_info *tinfo = arg;\n"
3445 " char *uargv, *p;\n"
3449 #: build/C/man3/pthread_create.3:282
3452 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n"
3453 " tinfo-E<gt>thread_num, &p, tinfo-E<gt>argv_string);\n"
3457 #: build/C/man3/pthread_create.3:286
3460 " uargv = strdup(tinfo-E<gt>argv_string);\n"
3461 " if (uargv == NULL)\n"
3462 " handle_error(\"strdup\");\n"
3466 #: build/C/man3/pthread_create.3:289
3469 " for (p = uargv; *p != \\(aq\\e0\\(aq; p++)\n"
3470 " *p = toupper(*p);\n"
3474 #: build/C/man3/pthread_create.3:292
3482 #: build/C/man3/pthread_create.3:301
3486 "main(int argc, char *argv[])\n"
3488 " int s, tnum, opt, num_threads;\n"
3489 " struct thread_info *tinfo;\n"
3490 " pthread_attr_t attr;\n"
3491 " int stack_size;\n"
3496 #: build/C/man3/pthread_create.3:303
3498 msgid " /* The \"-s\" option specifies a stack size for our threads */\n"
3502 #: build/C/man3/pthread_create.3:310
3505 " stack_size = -1;\n"
3506 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
3508 " case \\(aqs\\(aq:\n"
3509 " stack_size = strtoul(optarg, NULL, 0);\n"
3514 #: build/C/man3/pthread_create.3:317
3518 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n"
3520 " exit(EXIT_FAILURE);\n"
3526 #: build/C/man3/pthread_create.3:319
3528 msgid " num_threads = argc - optind;\n"
3532 #: build/C/man3/pthread_create.3:321
3534 msgid " /* Initialize thread creation attributes */\n"
3538 #: build/C/man3/pthread_create.3:325
3541 " s = pthread_attr_init(&attr);\n"
3543 " handle_error_en(s, \"pthread_attr_init\");\n"
3547 #: build/C/man3/pthread_create.3:331
3550 " if (stack_size E<gt> 0) {\n"
3551 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
3553 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
3558 #: build/C/man3/pthread_create.3:333
3560 msgid " /* Allocate memory for pthread_create() arguments */\n"
3564 #: build/C/man3/pthread_create.3:337
3567 " tinfo = calloc(num_threads, sizeof(struct thread_info));\n"
3568 " if (tinfo == NULL)\n"
3569 " handle_error(\"calloc\");\n"
3573 #: build/C/man3/pthread_create.3:339
3575 msgid " /* Create one thread for each command-line argument */\n"
3579 #: build/C/man3/pthread_create.3:343
3582 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
3583 " tinfo[tnum].thread_num = tnum + 1;\n"
3584 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
3588 #: build/C/man3/pthread_create.3:346
3591 " /* The pthread_create() call stores the thread ID into\n"
3592 " corresponding element of tinfo[] */\n"
3596 #: build/C/man3/pthread_create.3:352
3599 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
3600 " &thread_start, &tinfo[tnum]);\n"
3602 " handle_error_en(s, \"pthread_create\");\n"
3607 #: build/C/man3/pthread_create.3:355
3610 " /* Destroy the thread attributes object, since it is no\n"
3611 " longer needed */\n"
3615 #: build/C/man3/pthread_create.3:359
3618 " s = pthread_attr_destroy(&attr);\n"
3620 " handle_error_en(s, \"pthread_attr_destroy\");\n"
3624 #: build/C/man3/pthread_create.3:361
3626 msgid " /* Now join with each thread, and display its returned value */\n"
3630 #: build/C/man3/pthread_create.3:366
3633 " for (tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
3634 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
3636 " handle_error_en(s, \"pthread_join\");\n"
3640 #: build/C/man3/pthread_create.3:371
3643 " printf(\"Joined with thread %d; returned value was %s\\en\",\n"
3644 " tinfo[tnum].thread_num, (char *) res);\n"
3645 " free(res); /* Free memory allocated by thread */\n"
3650 #: build/C/man3/pthread_create.3:375
3654 " exit(EXIT_SUCCESS);\n"
3659 #: build/C/man3/pthread_create.3:388
3661 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
3662 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
3663 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), "
3668 #: build/C/man3/pthread_detach.3:26
3670 msgid "PTHREAD_DETACH"
3674 #: build/C/man3/pthread_detach.3:26 build/C/man3/pthread_join.3:26
3680 #: build/C/man3/pthread_detach.3:29
3681 msgid "pthread_detach - detach a thread"
3685 #: build/C/man3/pthread_detach.3:34
3687 msgid "B<int pthread_detach(pthread_t >I<thread>B<);>\n"
3691 #: build/C/man3/pthread_detach.3:46
3693 "The B<pthread_detach>() function marks the thread identified by I<thread> "
3694 "as detached. When a detached thread terminates, its resources are "
3695 "automatically released back to the system without the need for another "
3696 "thread to join with the terminated thread."
3700 #: build/C/man3/pthread_detach.3:49
3702 "Attempting to detach an already detached thread results in unspecified "
3707 #: build/C/man3/pthread_detach.3:54
3709 "On success, B<pthread_detach>() returns 0; on error, it returns an error "
3714 #: build/C/man3/pthread_detach.3:59 build/C/man3/pthread_join.3:89
3715 msgid "I<thread> is not a joinable thread."
3719 #: build/C/man3/pthread_detach.3:70
3721 "Once a thread has been detached, it can't be joined with B<pthread_join>(3) "
3722 "or be made joinable again."
3726 #: build/C/man3/pthread_detach.3:77
3728 "A new thread can be created in a detached state using "
3729 "B<pthread_attr_setdetachstate>(3) to set the detached attribute of the "
3730 "I<attr> argument of B<pthread_create>(3)."
3734 #: build/C/man3/pthread_detach.3:84
3736 "The detached attribute merely determines the behavior of the system when the "
3737 "thread terminates; it does not prevent the thread from being terminated if "
3738 "the process terminates using B<exit>(3) (or equivalently, if the main "
3743 #: build/C/man3/pthread_detach.3:93
3745 "Either B<pthread_join>(3) or B<pthread_detach>() should be called for each "
3746 "thread that an application creates, so that system resources for the thread "
3747 "can be released. (But note that the resources of all threads are freed when "
3748 "the process terminates.)"
3752 #: build/C/man3/pthread_detach.3:95
3753 msgid "The following statement detaches the calling thread:"
3757 #: build/C/man3/pthread_detach.3:97
3759 msgid " pthread_detach(pthread_self());\n"
3763 #: build/C/man3/pthread_detach.3:103
3765 "B<pthread_attr_setdetachstate>(3), B<pthread_cancel>(3), "
3766 "B<pthread_create>(3), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
3770 #: build/C/man3/pthread_equal.3:26
3772 msgid "PTHREAD_EQUAL"
3776 #: build/C/man3/pthread_equal.3:26 build/C/man3/pthread_exit.3:26 build/C/man3/pthread_getcpuclockid.3:26 build/C/man3/pthread_setaffinity_np.3:26 build/C/man3/pthread_setconcurrency.3:25
3782 #: build/C/man3/pthread_equal.3:29
3783 msgid "pthread_equal - compare thread IDs"
3787 #: build/C/man3/pthread_equal.3:34
3789 msgid "B<int pthread_equal(pthread_t >I<t1>B<, pthread_t >I<t2>B<);>\n"
3793 #: build/C/man3/pthread_equal.3:41
3794 msgid "The B<pthread_equal>() function compares two thread identifiers."
3798 #: build/C/man3/pthread_equal.3:45
3800 "If the two thread IDs are equal, B<pthread_equal>() returns a nonzero "
3801 "value; otherwise, it returns 0."
3805 #. Available since glibc 2.0
3807 #: 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
3808 msgid "This function always succeeds."
3812 #: build/C/man3/pthread_equal.3:52
3813 msgid "The B<pthread_equal>() function is thread-safe."
3817 #: build/C/man3/pthread_equal.3:61
3819 "The B<pthread_equal>() function is necessary because thread IDs should be "
3820 "considered opaque: there is no portable way for applications to directly "
3821 "compare two I<pthread_t> values."
3825 #: build/C/man3/pthread_equal.3:64
3826 msgid "B<pthread_create>(3), B<pthread_self>(3), B<pthreads>(7)"
3830 #: build/C/man3/pthread_exit.3:26
3832 msgid "PTHREAD_EXIT"
3836 #: build/C/man3/pthread_exit.3:29
3837 msgid "pthread_exit - terminate calling thread"
3841 #: build/C/man3/pthread_exit.3:34
3843 msgid "B<void pthread_exit(void *>I<retval>B<);>\n"
3847 #: build/C/man3/pthread_exit.3:45
3849 "The B<pthread_exit>() function terminates the calling thread and returns a "
3850 "value via I<retval> that (if the thread is joinable) is available to "
3851 "another thread in the same process that calls B<pthread_join>(3)."
3855 #: build/C/man3/pthread_exit.3:55
3857 "Any clean-up handlers established by B<pthread_cleanup_push>(3) that have "
3858 "not yet been popped, are popped (in the reverse of the order in which they "
3859 "were pushed) and executed. If the thread has any thread-specific data, "
3860 "then, after the clean-up handlers have been executed, the corresponding "
3861 "destructor functions are called, in an unspecified order."
3865 #: build/C/man3/pthread_exit.3:62
3867 "When a thread terminates, process-shared resources (e.g., mutexes, condition "
3868 "variables, semaphores, and file descriptors) are not released, and functions "
3869 "registered using B<atexit>(3) are not called."
3873 #: build/C/man3/pthread_exit.3:71
3875 "After the last thread in a process terminates, the process terminates as by "
3876 "calling B<exit>(3) with an exit status of zero; thus, process-shared "
3877 "resources are released and functions registered using B<atexit>(3) are "
3882 #: build/C/man3/pthread_exit.3:73
3883 msgid "This function does not return to the caller."
3887 #: build/C/man3/pthread_exit.3:80
3888 msgid "The B<pthread_exit>() function is thread-safe."
3892 #: build/C/man3/pthread_exit.3:87
3894 "Performing a return from the start function of any thread other than the "
3895 "main thread results in an implicit call to B<pthread_exit>(), using the "
3896 "function's return value as the thread's exit status."
3900 #: build/C/man3/pthread_exit.3:93
3902 "To allow other threads to continue execution, the main thread should "
3903 "terminate by calling B<pthread_exit>() rather than B<exit>(3)."
3907 #: build/C/man3/pthread_exit.3:98
3909 "The value pointed to by I<retval> should not be located on the calling "
3910 "thread's stack, since the contents of that stack are undefined after the "
3911 "thread terminates."
3915 #. FIXME . review a later kernel to see if this gets fixed
3916 #. http://thread.gmane.org/gmane.linux.kernel/611611
3917 #. http://marc.info/?l=linux-kernel&m=122525468300823&w=2
3919 #: build/C/man3/pthread_exit.3:110
3921 "Currently, there are limitations in the kernel implementation logic for "
3922 "B<wait>(2)ing on a stopped thread group with a dead thread group leader. "
3923 "This can manifest in problems such as a locked terminal if a stop signal is "
3924 "sent to a foreground process whose thread group leader has already called "
3925 "B<pthread_exit>()."
3929 #: build/C/man3/pthread_exit.3:113
3930 msgid "B<pthread_create>(3), B<pthread_join>(3), B<pthreads>(7)"
3934 #: build/C/man3/pthread_getattr_np.3:26
3936 msgid "PTHREAD_GETATTR_NP"
3940 #: build/C/man3/pthread_getattr_np.3:26
3946 #: build/C/man3/pthread_getattr_np.3:29
3947 msgid "pthread_getattr_np - get attributes of created thread"
3951 #: build/C/man3/pthread_getattr_np.3:35
3954 "B<int pthread_getattr_np(pthread_t >I<thread>B<, pthread_attr_t "
3959 #: build/C/man3/pthread_getattr_np.3:45
3961 "The B<pthread_getattr_np>() function initializes the thread attributes "
3962 "object referred to by I<attr> so that it contains actual attribute values "
3963 "describing the running thread I<thread>."
3967 #: build/C/man3/pthread_getattr_np.3:52
3969 "The returned attribute values may differ from the corresponding attribute "
3970 "values passed in the I<attr> object that was used to create the thread using "
3971 "B<pthread_create>(3). In particular, the following attributes may differ:"
3975 #: build/C/man3/pthread_getattr_np.3:55
3977 "the detach state, since a joinable thread may have detached itself after "
3982 #: build/C/man3/pthread_getattr_np.3:58
3983 msgid "the stack size, which the implementation may align to a suitable boundary."
3987 #: build/C/man3/pthread_getattr_np.3:63
3989 "and the guard size, which the implementation may round upward to a multiple "
3990 "of the page size, or ignore (i.e., treat as 0), if the application is "
3991 "allocating its own stack."
3995 #: build/C/man3/pthread_getattr_np.3:68
3997 "Furthermore, if the stack address attribute was not set in the thread "
3998 "attributes object used to create the thread, then the returned thread "
3999 "attributes object will report the actual stack address that the "
4000 "implementation selected for the thread."
4004 #: build/C/man3/pthread_getattr_np.3:73
4006 "When the thread attributes object returned by B<pthread_getattr_np>() is no "
4007 "longer required, it should be destroyed using B<pthread_attr_destroy>(3)."
4011 #: build/C/man3/pthread_getattr_np.3:76 build/C/man3/pthread_getcpuclockid.3:49
4013 "On success, this function returns 0; on error, it returns a nonzero error "
4017 #. Can happen (but unlikely) while trying to allocate memory for cpuset
4019 #: build/C/man3/pthread_getattr_np.3:81
4020 msgid "Insufficient memory."
4024 #: build/C/man3/pthread_getattr_np.3:96
4026 "In addition, if I<thread> refers to the main thread, then "
4027 "B<pthread_getattr_np>() can fail because of errors from various underlying "
4028 "calls: B<fopen>(3), if I</proc/self/maps> can't be opened; and "
4029 "B<getrlimit>(2), if the B<RLIMIT_STACK> resource limit is not supported."
4033 #: build/C/man3/pthread_getattr_np.3:98
4034 msgid "This function is available in glibc since version 2.2.3."
4038 #: build/C/man3/pthread_getattr_np.3:101 build/C/man3/pthread_kill_other_threads_np.3:55
4040 "This function is a nonstandard GNU extension; hence the suffix \"_np\" "
4041 "(nonportable) in the name."
4045 #: build/C/man3/pthread_getattr_np.3:111
4047 "The program below demonstrates the use of B<pthread_getattr_np>(). The "
4048 "program creates a thread that then uses B<pthread_getattr_np>() to retrieve "
4049 "and display its guard size, stack address, and stack size attributes. "
4050 "Command-line arguments can be used to set these attributes to values other "
4051 "than the default when creating the thread. The shell sessions below "
4052 "demonstrate the use of the program."
4056 #: build/C/man3/pthread_getattr_np.3:114
4058 "In the first run, on an x86-32 system, a thread is created using default "
4063 #: build/C/man3/pthread_getattr_np.3:124
4066 "$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2MB\n"
4069 "Attributes of created thread:\n"
4070 " Guard size = 4096 bytes\n"
4071 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
4072 " Stack size = 0x201000 (2101248) bytes\n"
4076 #: build/C/man3/pthread_getattr_np.3:130
4078 "In the following run, we see that if a guard size is specified, it is "
4079 "rounded up to the next multiple of the system page size (4096 bytes on "
4084 #: build/C/man3/pthread_getattr_np.3:138
4087 "$B< ./a.out -g 4097>\n"
4088 "Thread attributes object after initializations:\n"
4089 " Guard size = 4097 bytes\n"
4090 " Stack address = (nil)\n"
4091 " Stack size = 0x0 (0) bytes\n"
4095 #: build/C/man3/pthread_getattr_np.3:143
4098 "Attributes of created thread:\n"
4099 " Guard size = 8192 bytes\n"
4100 " Stack address = 0x40196000 (EOS = 0x40397000)\n"
4101 " Stack size = 0x201000 (2101248) bytes\n"
4106 #. $ ./a.out \-s 0x8000
4107 #. Thread attributes object after initializations:
4108 #. Guard size = 4096 bytes
4109 #. Stack address = 0xffff8000 (EOS = (nil))
4110 #. Stack size = 0x8000 (32768) bytes
4112 #. Attributes of created thread:
4113 #. Guard size = 4096 bytes
4114 #. Stack address = 0x4001e000 (EOS = 0x40026000)
4115 #. Stack size = 0x8000 (32768) bytes
4119 #: build/C/man3/pthread_getattr_np.3:162
4121 "In the last run, the program manually allocates a stack for the thread. In "
4122 "this case, the guard size attribute is ignored."
4126 #: build/C/man3/pthread_getattr_np.3:167
4129 "$B< ./a.out -g 4096 -s 0x8000 -a>\n"
4130 "Allocated thread stack at 0x804d000\n"
4134 #: build/C/man3/pthread_getattr_np.3:172
4137 "Thread attributes object after initializations:\n"
4138 " Guard size = 4096 bytes\n"
4139 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4140 " Stack size = 0x8000 (32768) bytes\n"
4144 #: build/C/man3/pthread_getattr_np.3:177
4147 "Attributes of created thread:\n"
4148 " Guard size = 0 bytes\n"
4149 " Stack address = 0x804d000 (EOS = 0x8055000)\n"
4150 " Stack size = 0x8000 (32768) bytes\n"
4154 #: build/C/man3/pthread_getattr_np.3:198
4158 "display_stack_related_attributes(pthread_attr_t *attr, char *prefix)\n"
4161 " size_t stack_size, guard_size;\n"
4162 " void *stack_addr;\n"
4166 #: build/C/man3/pthread_getattr_np.3:203
4169 " s = pthread_attr_getguardsize(attr, &guard_size);\n"
4171 " handle_error_en(s, \"pthread_attr_getguardsize\");\n"
4172 " printf(\"%sGuard size = %d bytes\\en\", prefix, guard_size);\n"
4176 #: build/C/man3/pthread_getattr_np.3:214
4179 " s = pthread_attr_getstack(attr, &stack_addr, &stack_size);\n"
4181 " handle_error_en(s, \"pthread_attr_getstack\");\n"
4182 " printf(\"%sStack address = %p\", prefix, stack_addr);\n"
4183 " if (stack_size E<gt> 0)\n"
4184 " printf(\" (EOS = %p)\", (char *) stack_addr + stack_size);\n"
4185 " printf(\"\\en\");\n"
4186 " printf(\"%sStack size = 0x%x (%d) bytes\\en\",\n"
4187 " prefix, stack_size, stack_size);\n"
4192 #: build/C/man3/pthread_getattr_np.3:220
4196 "display_thread_attributes(pthread_t thread, char *prefix)\n"
4199 " pthread_attr_t attr;\n"
4203 #: build/C/man3/pthread_getattr_np.3:224
4206 " s = pthread_getattr_np(thread, &attr);\n"
4208 " handle_error_en(s, \"pthread_getattr_np\");\n"
4212 #: build/C/man3/pthread_getattr_np.3:226
4214 msgid " display_stack_related_attributes(&attr, prefix);\n"
4218 #: build/C/man3/pthread_getattr_np.3:231
4221 " s = pthread_attr_destroy(&attr);\n"
4223 " handle_error_en(s, \"pthread_attr_destroy\");\n"
4228 #: build/C/man3/pthread_getattr_np.3:237
4231 "static void * /* Start function for thread we create */\n"
4232 "thread_start(void *arg)\n"
4234 " printf(\"Attributes of created thread:\\en\");\n"
4235 " display_thread_attributes(pthread_self(), \"\\et\");\n"
4239 #: build/C/man3/pthread_getattr_np.3:251
4243 "usage(char *pname, char *msg)\n"
4245 " if (msg != NULL)\n"
4246 " fputs(msg, stderr);\n"
4247 " fprintf(stderr, \"Usage: %s [-s stack-size [-a]]\"\n"
4248 " \" [-g guard-size]\\en\", pname);\n"
4249 " fprintf(stderr, \"\\et\\et-a means program should allocate "
4251 " exit(EXIT_FAILURE);\n"
4256 #: build/C/man3/pthread_getattr_np.3:264
4259 "static pthread_attr_t * /* Get thread attributes from command line */\n"
4260 "get_thread_attributes_from_cl(int argc, char *argv[],\n"
4261 " pthread_attr_t *attrp)\n"
4263 " int s, opt, allocate_stack;\n"
4264 " long stack_size, guard_size;\n"
4265 " void *stack_addr;\n"
4266 " pthread_attr_t *ret_attrp = NULL; /* Set to attrp if we initialize\n"
4267 " a thread attributes object */\n"
4268 " allocate_stack = 0;\n"
4269 " stack_size = -1;\n"
4270 " guard_size = -1;\n"
4274 #: build/C/man3/pthread_getattr_np.3:273
4277 " while ((opt = getopt(argc, argv, \"ag:s:\")) != -1) {\n"
4279 " case \\(aqa\\(aq: allocate_stack = 1; break;\n"
4280 " case \\(aqg\\(aq: guard_size = strtoul(optarg, NULL, 0); break;\n"
4281 " case \\(aqs\\(aq: stack_size = strtoul(optarg, NULL, 0); break;\n"
4282 " default: usage(argv[0], NULL);\n"
4288 #: build/C/man3/pthread_getattr_np.3:276
4291 " if (allocate_stack && stack_size == -1)\n"
4292 " usage(argv[0], \"Specifying -a without -s makes no sense\\en\");\n"
4296 #: build/C/man3/pthread_getattr_np.3:279
4299 " if (argc E<gt> optind)\n"
4300 " usage(argv[0], \"Extraneous command-line arguments\\en\");\n"
4304 #: build/C/man3/pthread_getattr_np.3:282
4307 " if (stack_size E<gt>= 0 || guard_size E<gt> 0) {\n"
4308 " ret_attrp = attrp;\n"
4312 #: build/C/man3/pthread_getattr_np.3:287
4315 " s = pthread_attr_init(attrp);\n"
4317 " handle_error_en(s, \"pthread_attr_init\");\n"
4322 #: build/C/man3/pthread_getattr_np.3:299
4325 " if (stack_size E<gt>= 0) {\n"
4326 " if (!allocate_stack) {\n"
4327 " s = pthread_attr_setstacksize(attrp, stack_size);\n"
4329 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4331 " s = posix_memalign(&stack_addr, sysconf(_SC_PAGESIZE),\n"
4334 " handle_error_en(s, \"posix_memalign\");\n"
4335 " printf(\"Allocated thread stack at %p\\en\\en\", stack_addr);\n"
4339 #: build/C/man3/pthread_getattr_np.3:305
4342 " s = pthread_attr_setstack(attrp, stack_addr, stack_size);\n"
4344 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4350 #: build/C/man3/pthread_getattr_np.3:311
4353 " if (guard_size E<gt>= 0) {\n"
4354 " s = pthread_attr_setguardsize(attrp, guard_size);\n"
4356 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
4361 #: build/C/man3/pthread_getattr_np.3:314
4364 " return ret_attrp;\n"
4369 #: build/C/man3/pthread_getattr_np.3:323
4373 "main(int argc, char *argv[])\n"
4377 " pthread_attr_t attr;\n"
4378 " pthread_attr_t *attrp = NULL; /* Set to &attr if we initialize\n"
4379 " a thread attributes object */\n"
4383 #: build/C/man3/pthread_getattr_np.3:325
4385 msgid " attrp = get_thread_attributes_from_cl(argc, argv, &attr);\n"
4389 #: build/C/man3/pthread_getattr_np.3:331
4392 " if (attrp != NULL) {\n"
4393 " printf(\"Thread attributes object after initializations:\\en\");\n"
4394 " display_stack_related_attributes(attrp, \"\\et\");\n"
4395 " printf(\"\\en\");\n"
4400 #: build/C/man3/pthread_getattr_np.3:360
4402 "B<pthread_attr_getaffinity_np>(3), B<pthread_attr_getdetachstate>(3), "
4403 "B<pthread_attr_getguardsize>(3), B<pthread_attr_getinheritsched>(3), "
4404 "B<pthread_attr_getschedparam>(3), B<pthread_attr_getschedpolicy>(3), "
4405 "B<pthread_attr_getscope>(3), B<pthread_attr_getstack>(3), "
4406 "B<pthread_attr_getstackaddr>(3), B<pthread_attr_getstacksize>(3), "
4407 "B<pthread_attr_init>(3), B<pthread_create>(3), B<pthreads>(7)"
4411 #: build/C/man3/pthread_getcpuclockid.3:26
4413 msgid "PTHREAD_GETCPUCLOCKID"
4417 #: build/C/man3/pthread_getcpuclockid.3:29
4418 msgid "pthread_getcpuclockid - retrieve ID of a thread's CPU time clock"
4422 #: build/C/man3/pthread_getcpuclockid.3:33
4425 "B<#include E<lt>pthread.hE<gt>>\n"
4426 "B<#include E<lt>time.hE<gt>>\n"
4430 #: build/C/man3/pthread_getcpuclockid.3:35
4433 "B<int pthread_getcpuclockid(pthread_t >I<thread>B<, clockid_t "
4434 "*>I<clock_id>B<);>\n"
4437 #. The clockid is constructed as follows:
4438 #. *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE)
4439 #. where CLOCK_IDFIELD_SIZE is 3.
4441 #: build/C/man3/pthread_getcpuclockid.3:46
4443 "The B<pthread_getcpuclockid>() function returns the clock ID for the CPU "
4444 "time clock of the thread I<thread>."
4448 #: build/C/man3/pthread_getcpuclockid.3:50
4453 #. CLOCK_THREAD_CPUTIME_ID not defined
4455 #. Looking at nptl/pthread_getcpuclockid.c an ERANGE error would
4456 #. be possible if kernel thread IDs took more than 29 bits (which
4457 #. they currently cannot).
4459 #: build/C/man3/pthread_getcpuclockid.3:58
4460 msgid "Per-thread CPU time clocks are not supported by the system."
4464 #: build/C/man3/pthread_getcpuclockid.3:65
4465 msgid "This function is available in glibc since version 2.2."
4469 #: build/C/man3/pthread_getcpuclockid.3:70
4470 msgid "The B<pthread_getcpuclockid>() function is thread-safe."
4474 #: build/C/man3/pthread_getcpuclockid.3:83
4476 "When I<thread> refers to the calling thread, this function returns an "
4477 "identifier that refers to the same clock manipulated by B<clock_gettime>(2) "
4478 "and B<clock_settime>(2) when given the clock ID B<CLOCK_THREAD_CPUTIME_ID>."
4482 #: build/C/man3/pthread_getcpuclockid.3:89
4484 "The program below creates a thread and then uses B<clock_gettime>(2) to "
4485 "retrieve the total process CPU time, and the per-thread CPU time consumed by "
4486 "the two threads. The following shell session shows an example run:"
4490 #: build/C/man3/pthread_getcpuclockid.3:99
4494 "Main thread sleeping\n"
4495 "Subthread starting infinite loop\n"
4496 "Main thread consuming some CPU time...\n"
4497 "Process total CPU time: 1.368\n"
4498 "Main thread CPU time: 0.376\n"
4499 "Subthread CPU time: 0.992\n"
4503 #: build/C/man3/pthread_getcpuclockid.3:105
4505 msgid "/* Link with \"-lrt\" */\n"
4509 #: build/C/man3/pthread_getcpuclockid.3:113
4512 "#include E<lt>time.hE<gt>\n"
4513 "#include E<lt>stdio.hE<gt>\n"
4514 "#include E<lt>stdlib.hE<gt>\n"
4515 "#include E<lt>unistd.hE<gt>\n"
4516 "#include E<lt>pthread.hE<gt>\n"
4517 "#include E<lt>string.hE<gt>\n"
4518 "#include E<lt>errno.hE<gt>\n"
4522 #: build/C/man3/pthread_getcpuclockid.3:127
4526 "thread_start(void *arg)\n"
4528 " printf(\"Subthread starting infinite loop\\en\");\n"
4535 #: build/C/man3/pthread_getcpuclockid.3:132
4539 "pclock(char *msg, clockid_t cid)\n"
4541 " struct timespec ts;\n"
4545 #: build/C/man3/pthread_getcpuclockid.3:138
4548 " printf(\"%s\", msg);\n"
4549 " if (clock_gettime(cid, &ts) == -1)\n"
4550 " handle_error(\"clock_gettime\");\n"
4551 " printf(\"%4ld.%03ld\\en\", ts.tv_sec, ts.tv_nsec / 1000000);\n"
4556 #: build/C/man3/pthread_getcpuclockid.3:145
4560 "main(int argc, char *argv[])\n"
4562 " pthread_t thread;\n"
4568 #: build/C/man3/pthread_getcpuclockid.3:149
4571 " s = pthread_create(&thread, NULL, thread_start, NULL);\n"
4573 " handle_error_en(s, \"pthread_create\");\n"
4577 #: build/C/man3/pthread_getcpuclockid.3:152
4580 " printf(\"Main thread sleeping\\en\");\n"
4585 #: build/C/man3/pthread_getcpuclockid.3:156
4588 " printf(\"Main thread consuming some CPU time...\\en\");\n"
4589 " for (j = 0; j E<lt> 2000000; j++)\n"
4594 #: build/C/man3/pthread_getcpuclockid.3:158
4596 msgid " pclock(\"Process total CPU time: \", CLOCK_PROCESS_CPUTIME_ID);\n"
4600 #: build/C/man3/pthread_getcpuclockid.3:163
4603 " s = pthread_getcpuclockid(pthread_self(), &cid);\n"
4605 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
4606 " pclock(\"Main thread CPU time: \", cid);\n"
4610 #: build/C/man3/pthread_getcpuclockid.3:166
4613 " /* The preceding 4 lines of code could have been replaced by:\n"
4614 " pclock(\"Main thread CPU time: \", CLOCK_THREAD_CPUTIME_ID); */\n"
4618 #: build/C/man3/pthread_getcpuclockid.3:171
4621 " s = pthread_getcpuclockid(thread, &cid);\n"
4623 " handle_error_en(s, \"pthread_getcpuclockid\");\n"
4624 " pclock(\"Subthread CPU time: 1 \", cid);\n"
4628 #: build/C/man3/pthread_getcpuclockid.3:174
4631 " exit(EXIT_SUCCESS); /* Terminates both threads */\n"
4636 #: build/C/man3/pthread_getcpuclockid.3:182
4638 "B<clock_gettime>(2), B<clock_settime>(2), B<timer_create>(2), "
4639 "B<clock_getcpuclockid>(3), B<pthread_self>(3), B<pthreads>(7), B<time>(7)"
4643 #: build/C/man3/pthread_join.3:26
4645 msgid "PTHREAD_JOIN"
4649 #: build/C/man3/pthread_join.3:29
4650 msgid "pthread_join - join with a terminated thread"
4654 #: build/C/man3/pthread_join.3:34
4656 msgid "B<int pthread_join(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
4660 #: build/C/man3/pthread_join.3:49
4662 "The B<pthread_join>() function waits for the thread specified by I<thread> "
4663 "to terminate. If that thread has already terminated, then B<pthread_join>() "
4664 "returns immediately. The thread specified by I<thread> must be joinable."
4668 #: build/C/man3/pthread_join.3:63
4670 "If I<retval> is not NULL, then B<pthread_join>() copies the exit status of "
4671 "the target thread (i.e., the value that the target thread supplied to "
4672 "B<pthread_exit>(3)) into the location pointed to by I<*retval>. If the "
4673 "target thread was canceled, then B<PTHREAD_CANCELED> is placed in "
4678 #: build/C/man3/pthread_join.3:70
4680 "If multiple threads simultaneously try to join with the same thread, the "
4681 "results are undefined. If the thread calling B<pthread_join>() is "
4682 "canceled, then the target thread will remain joinable (i.e., it will not be "
4687 #: build/C/man3/pthread_join.3:75
4689 "On success, B<pthread_join>() returns 0; on error, it returns an error "
4694 #: build/C/man3/pthread_join.3:76
4699 #. The following verified by testing on glibc 2.8/NPTL:
4700 #. The following verified by testing on glibc 2.8/NPTL:
4702 #: build/C/man3/pthread_join.3:85
4704 "A deadlock was detected (e.g., two threads tried to join with each other); "
4705 "or I<thread> specifies the calling thread."
4708 #. POSIX.1-2001 does not specify this error case.
4710 #: build/C/man3/pthread_join.3:93
4711 msgid "Another thread is already waiting to join with this thread."
4715 #: build/C/man3/pthread_join.3:104
4717 "After a successful call to B<pthread_join>(), the caller is guaranteed that "
4718 "the target thread has terminated."
4722 #: build/C/man3/pthread_join.3:107
4724 "Joining with a thread that has previously been joined results in undefined "
4729 #: build/C/man3/pthread_join.3:115
4731 "Failure to join with a thread that is joinable (i.e., one that is not "
4732 "detached), produces a \"zombie thread\". Avoid doing this, since each "
4733 "zombie thread consumes some system resources, and when enough zombie threads "
4734 "have accumulated, it will no longer be possible to create new threads (or "
4739 #: build/C/man3/pthread_join.3:121
4741 "There is no pthreads analog of I<waitpid(-1,\\ &status,\\ 0)>, that is, "
4742 "\"join with any terminated thread\". If you believe you need this "
4743 "functionality, you probably need to rethink your application design."
4747 #: build/C/man3/pthread_join.3:124
4749 "All of the threads in a process are peers: any thread can join with any "
4750 "other thread in the process."
4754 #: build/C/man3/pthread_join.3:133
4756 "B<pthread_cancel>(3), B<pthread_create>(3), B<pthread_detach>(3), "
4757 "B<pthread_exit>(3), B<pthread_tryjoin_np>(3), B<pthreads>(7)"
4761 #: build/C/man3/pthread_kill.3:26
4763 msgid "PTHREAD_KILL"
4767 #: 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_setcancelstate.3:26 build/C/man3/pthread_yield.3:25
4773 #: build/C/man3/pthread_kill.3:29
4774 msgid "pthread_kill - send a signal to a thread"
4778 #: build/C/man3/pthread_kill.3:32 build/C/man3/pthread_sigmask.3:32
4780 msgid "B<#include E<lt>signal.hE<gt>>\n"
4784 #: build/C/man3/pthread_kill.3:34
4786 msgid "B<int pthread_kill(pthread_t >I<thread>B<, int >I<sig>B<);>\n"
4790 #: build/C/man3/pthread_kill.3:45
4791 msgid "B<pthread_kill>():"
4795 #: build/C/man3/pthread_kill.3:47 build/C/man3/pthread_sigmask.3:48
4796 msgid "_POSIX_C_SOURCE\\ E<gt>=\\ 199506L || _XOPEN_SOURCE\\ E<gt>=\\ 500"
4800 #: build/C/man3/pthread_kill.3:59
4802 "The B<pthread_kill>() function sends the signal I<sig> to I<thread>, a "
4803 "thread in the same process as the caller. The signal is asynchronously "
4804 "directed to I<thread>."
4808 #: build/C/man3/pthread_kill.3:63
4810 "If I<sig> is 0, then no signal is sent, but error checking is still "
4815 #: build/C/man3/pthread_kill.3:68
4817 "On success, B<pthread_kill>() returns 0; on error, it returns an error "
4818 "number, and no signal is sent."
4822 #: build/C/man3/pthread_kill.3:72
4823 msgid "An invalid signal was specified."
4827 #: build/C/man3/pthread_kill.3:77
4828 msgid "The B<pthread_kill>() function is thread-safe."
4832 #: build/C/man3/pthread_kill.3:79
4833 msgid "POSIX.1-2008."
4837 #: build/C/man3/pthread_kill.3:86
4839 "Signal dispositions are process-wide: if a signal handler is installed, the "
4840 "handler will be invoked in the thread I<thread>, but if the disposition of "
4841 "the signal is \"stop\", \"continue\", or \"terminate\", this action will "
4842 "affect the whole process."
4846 #: build/C/man3/pthread_kill.3:99
4848 "POSIX.1-2008 recommends that if an implementation detects the use of a "
4849 "thread ID after the end of its lifetime, B<pthread_kill>() should return "
4850 "the error B<ESRCH>. The glibc implementation returns this error in the "
4851 "cases where an invalid thread ID can be detected. But note also that POSIX "
4852 "says that an attempt to use a thread ID whose lifetime has ended produces "
4853 "undefined behavior, and an attempt to use an invalid thread ID in a call to "
4854 "B<pthread_kill>() can, for example, cause a segmentation fault."
4858 #: build/C/man3/pthread_kill.3:107
4860 "B<kill>(2), B<sigaction>(2), B<sigpending>(2), B<pthread_self>(3), "
4861 "B<pthread_sigmask>(3), B<raise>(3), B<pthreads>(7), B<signal>(7)"
4865 #: build/C/man3/pthread_kill_other_threads_np.3:26
4867 msgid "PTHREAD_KILL_OTHER_THREADS_NP"
4871 #: build/C/man3/pthread_kill_other_threads_np.3:29
4872 msgid "pthread_kill_other_threads_np - terminate all other threads in process"
4876 #: build/C/man3/pthread_kill_other_threads_np.3:34
4878 msgid "B<void pthread_kill_other_threads_np(void);>\n"
4882 #. Available since glibc 2.0
4884 #: build/C/man3/pthread_kill_other_threads_np.3:47
4886 "B<pthread_kill_other_threads_np>() has an effect only in the LinuxThreads "
4887 "threading implementation. On that implementation, calling this function "
4888 "causes the immediate termination of all threads in the application, except "
4889 "the calling thread. The cancellation state and cancellation type of the "
4890 "to-be-terminated threads are ignored, and the cleanup handlers are not "
4891 "called in those threads."
4895 #: build/C/man3/pthread_kill_other_threads_np.3:52
4896 msgid "The B<pthread_kill_other_threads_np>() function is thread-safe."
4900 #: build/C/man3/pthread_kill_other_threads_np.3:64
4902 "B<pthread_kill_other_threads_np>() is intended to be called just before a "
4903 "thread calls B<execve>(2) or a similar function. This function is designed "
4904 "to address a limitation in the obsolete LinuxThreads implementation whereby "
4905 "the other threads of an application are not automatically terminated (as "
4906 "POSIX.1-2001 requires) during B<execve>(2)."
4910 #: build/C/man3/pthread_kill_other_threads_np.3:71
4912 "In the NPTL threading implementation, B<pthread_kill_other_threads_np>() "
4913 "exists, but does nothing. (Nothing needs to be done, because the "
4914 "implementation does the right thing during an B<execve>(2).)"
4918 #: build/C/man3/pthread_kill_other_threads_np.3:76
4920 "B<execve>(2), B<pthread_cancel>(3), B<pthread_setcancelstate>(3), "
4921 "B<pthread_setcanceltype>(3), B<pthreads>(7)"
4925 #: build/C/man3/pthread_rwlockattr_setkind_np.3:25
4927 msgid "PTHREAD_RWLOCKATTR_SETKIND_NP"
4931 #: build/C/man3/pthread_rwlockattr_setkind_np.3:25
4937 #: build/C/man3/pthread_rwlockattr_setkind_np.3:29
4939 "pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np - set/get the "
4940 "read-write lock kind of the thread read-write lock attribute object"
4944 #: build/C/man3/pthread_rwlockattr_setkind_np.3:37
4947 "B<int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *>I<attr>B<,>\n"
4948 "B< int >I<pref>B<);>\n"
4949 "B<int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t "
4951 "B< int *>I<pref>B<);>\n"
4955 #: build/C/man3/pthread_rwlockattr_setkind_np.3:48
4956 msgid "B<pthread_rwlockattr_setkind_np>(), B<pthread_rwlockattr_getkind_np>():"
4960 #: build/C/man3/pthread_rwlockattr_setkind_np.3:52
4961 msgid "_XOPEN_SOURCE\\ E<gt>=\\ 500 || _POSIX_C_SOURCE E<gt>= 200809L"
4965 #: build/C/man3/pthread_rwlockattr_setkind_np.3:65
4967 "The B<pthread_rwlockattr_setkind_np>() function sets the \"lock kind\" "
4968 "attribute of the read-write lock attribute object referred to by I<attr> to "
4969 "the value specified in I<pref>. The argument I<pref> may be set to one of "
4974 #: build/C/man3/pthread_rwlockattr_setkind_np.3:65
4976 msgid "B<PTHREAD_RWLOCK_PREFER_READER_NP>"
4980 #: build/C/man3/pthread_rwlockattr_setkind_np.3:78
4982 "This is the default. A thread may hold multiple read locks; that is, read "
4983 "locks are recursive. According to The Single Unix Specification, the "
4984 "behavior is unspecified when a reader tries to place a lock, and there is no "
4985 "write lock but writers are waiting. Giving preference to the reader, as is "
4986 "set by B<PTHREAD_RWLOCK_PREFER_READER_NP>, implies that the reader will "
4987 "receive the requested lock, even if a writer is waiting. As long as there "
4988 "are readers, the writer will be starved."
4992 #: build/C/man3/pthread_rwlockattr_setkind_np.3:78
4994 msgid "B<PTHREAD_RWLOCK_PREFER_WRITER_NP>"
4998 #: build/C/man3/pthread_rwlockattr_setkind_np.3:83
5000 "This is intended as the write lock analog of "
5001 "B<PTHREAD_RWLOCK_PREFER_READER_NP>. But see BUGS."
5005 #: build/C/man3/pthread_rwlockattr_setkind_np.3:83
5007 msgid "B<PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP>"
5011 #: build/C/man3/pthread_rwlockattr_setkind_np.3:88
5013 "Setting the lock kind to this avoids writer starvation as long as any read "
5014 "locking is not done in a recursive fashion."
5018 #: build/C/man3/pthread_rwlockattr_setkind_np.3:96
5020 "The B<pthread_rwlockattr_getkind_np>() function returns the value of the "
5021 "lock kind attribute of the read-write lock attribute object referred to by "
5022 "I<attr> in the pointer I<pref>."
5026 #: build/C/man3/pthread_rwlockattr_setkind_np.3:104
5028 "On success, these functions return 0. Given valid pointer arguments, "
5029 "B<pthread_rwlockattr_getkind_np>() always succeeds. On error, "
5030 "B<pthread_rwlockattr_setkind_np>() returns a non-zero error number."
5034 #: build/C/man3/pthread_rwlockattr_setkind_np.3:109
5035 msgid "I<pref> specifies an unsupported value."
5038 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7057
5040 #: build/C/man3/pthread_rwlockattr_setkind_np.3:121
5042 "Setting the value read-write lock kind to B<PTHREAD_RWLOCK_PREFER_WRITER_NP> "
5043 "results in the same behavior as setting the value to "
5044 "B<PTHREAD_RWLOCK_PREFER_READER_NP>. As long as a reader thread holds the "
5045 "lock, the thread holding a write lock will be starved. Setting the lock "
5046 "kind to B<PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP> allows writers to "
5047 "run, but, as the name implies a writer may not lock recursively."
5051 #: build/C/man3/pthread_rwlockattr_setkind_np.3:127
5053 "The B<pthread_rwlockattr_getkind_np>() and "
5054 "B<pthread_rwlockattr_setkind_np>() functions first appeared in glibc 2.1."
5058 #: build/C/man3/pthread_rwlockattr_setkind_np.3:130
5060 "These functions are non-standard GNU extensions; hence the suffix \"_np\" "
5061 "(non-portable) in the names."
5065 #: build/C/man3/pthread_rwlockattr_setkind_np.3:131
5066 msgid "B<pthreads>(7)"
5070 #: build/C/man3/pthread_self.3:26
5072 msgid "PTHREAD_SELF"
5076 #: build/C/man3/pthread_self.3:29
5077 msgid "pthread_self - obtain ID of the calling thread"
5081 #: build/C/man3/pthread_self.3:34
5083 msgid "B<pthread_t pthread_self(void);>\n"
5087 #: build/C/man3/pthread_self.3:46
5089 "The B<pthread_self>() function returns the ID of the calling thread. This "
5090 "is the same value that is returned in I<*thread> in the B<pthread_create>(3) "
5091 "call that created this thread."
5095 #: build/C/man3/pthread_self.3:48
5096 msgid "This function always succeeds, returning the calling thread's ID."
5100 #: build/C/man3/pthread_self.3:55
5101 msgid "The B<pthread_self>() function is thread-safe."
5105 #: build/C/man3/pthread_self.3:68
5107 "POSIX.1 allows an implementation wide freedom in choosing the type used to "
5108 "represent a thread ID; for example, representation using either an "
5109 "arithmetic type or a structure is permitted. Therefore, variables of type "
5110 "I<pthread_t> can't portably be compared using the C equality operator "
5111 "(B<==>); use B<pthread_equal>(3) instead."
5115 #: build/C/man3/pthread_self.3:72
5117 "Thread identifiers should be considered opaque: any attempt to use a thread "
5118 "ID other than in pthreads calls is nonportable and can lead to unspecified "
5123 #: build/C/man3/pthread_self.3:76
5125 "Thread IDs are guaranteed to be unique only within a process. A thread ID "
5126 "may be reused after a terminated thread has been joined, or a detached "
5127 "thread has terminated."
5131 #: build/C/man3/pthread_self.3:81
5133 "The thread ID returned by B<pthread_self>() is not the same thing as the "
5134 "kernel thread ID returned by a call to B<gettid>(2)."
5138 #: build/C/man3/pthread_self.3:84
5139 msgid "B<pthread_create>(3), B<pthread_equal>(3), B<pthreads>(7)"
5143 #: build/C/man3/pthread_setaffinity_np.3:26
5145 msgid "PTHREAD_SETAFFINITY_NP"
5149 #: build/C/man3/pthread_setaffinity_np.3:30
5151 "pthread_setaffinity_np, pthread_getaffinity_np - set/get CPU affinity of a "
5156 #: build/C/man3/pthread_setaffinity_np.3:39
5159 "B<int pthread_setaffinity_np(pthread_t >I<thread>B<, size_t "
5160 ">I<cpusetsize>B<,>\n"
5161 "B< const cpu_set_t *>I<cpuset>B<);>\n"
5162 "B<int pthread_getaffinity_np(pthread_t >I<thread>B<, size_t "
5163 ">I<cpusetsize>B<,>\n"
5164 "B< cpu_set_t *>I<cpuset>B<);>\n"
5168 #: build/C/man3/pthread_setaffinity_np.3:54
5170 "The B<pthread_setaffinity_np>() function sets the CPU affinity mask of the "
5171 "thread I<thread> to the CPU set pointed to by I<cpuset>. If the call is "
5172 "successful, and the thread is not currently running on one of the CPUs in "
5173 "I<cpuset>, then it is migrated to one of those CPUs."
5177 #: build/C/man3/pthread_setaffinity_np.3:61
5179 "The B<pthread_getaffinity_np>() function returns the CPU affinity mask of "
5180 "the thread I<thread> in the buffer pointed to by I<cpuset>."
5184 #: build/C/man3/pthread_setaffinity_np.3:77
5186 "The argument I<cpusetsize> is the length (in bytes) of the buffer pointed to "
5187 "by I<cpuset>. Typically, this argument would be specified as "
5188 "I<sizeof(cpu_set_t)>. (It may be some other value, if using the macros "
5189 "described in B<CPU_SET>(3) for dynamically allocating a CPU set.)"
5193 #: build/C/man3/pthread_setaffinity_np.3:81
5199 #: build/C/man3/pthread_setaffinity_np.3:84
5200 msgid "A supplied memory address was invalid."
5204 #: build/C/man3/pthread_setaffinity_np.3:93
5206 "(B<pthread_setaffinity_np>()) The affinity bit mask I<mask> contains no "
5207 "processors that are currently physically on the system and permitted to the "
5208 "thread according to any restrictions that may be imposed by the \"cpuset\" "
5209 "mechanism described in B<cpuset>(7)."
5213 #. Loic Domaigne commented: it seems that in the future the
5214 #. kernel developers want to make cpumask_t dynamic, so
5215 #. CONFIG_NR_CPUS might become obsolete in the future.
5217 #. The raw sched_getaffinity() system call returns the size (in bytes)
5218 #. of the cpumask_t type.
5220 #: build/C/man3/pthread_setaffinity_np.3:109
5222 "(B<pthread_setaffinity_np>()) I<cpuset> specified a CPU that was outside "
5223 "the set supported by the kernel. (The kernel configuration option "
5224 "B<CONFIG_NR_CPUS> defines the range of the set supported by the kernel data "
5225 "type used to represent CPU sets.)"
5229 #: build/C/man3/pthread_setaffinity_np.3:114
5231 "(B<pthread_getaffinity_np>()) I<cpusetsize> is smaller than the size of the "
5232 "affinity mask used by the kernel."
5236 #: build/C/man3/pthread_setaffinity_np.3:128
5238 "The B<pthread_setaffinity_np>() and B<pthread_getaffinity_np>() functions "
5243 #: build/C/man3/pthread_setaffinity_np.3:144
5245 "After a call to B<pthread_setaffinity_np>(), the set of CPUs on which the "
5246 "thread will actually run is the intersection of the set specified in the "
5247 "I<cpuset> argument and the set of CPUs actually present on the system. The "
5248 "system may further restrict the set of CPUs on which the thread runs if the "
5249 "\"cpuset\" mechanism described in B<cpuset>(7) is being used. These "
5250 "restrictions on the actual set of CPUs on which the thread will run are "
5251 "silently imposed by the kernel."
5255 #: build/C/man3/pthread_setaffinity_np.3:150
5257 "These functions are implemented on top of the B<sched_setaffinity>(2) and "
5258 "B<sched_getaffinity>(2) system calls."
5262 #: build/C/man3/pthread_setaffinity_np.3:161
5264 "A new thread created by B<pthread_create>(3) inherits a copy of its "
5265 "creator's CPU affinity mask."
5269 #: build/C/man3/pthread_setaffinity_np.3:169
5271 "In the following program, the main thread uses B<pthread_setaffinity_np>() "
5272 "to set its CPU affinity mask to include CPUs 0 to 7 (which may not all be "
5273 "available on the system), and then calls B<pthread_getaffinity_np>() to "
5274 "check the resulting CPU affinity mask of the thread."
5278 #: build/C/man3/pthread_setaffinity_np.3:176
5281 "#define _GNU_SOURCE\n"
5282 "#include E<lt>pthread.hE<gt>\n"
5283 "#include E<lt>stdio.hE<gt>\n"
5284 "#include E<lt>stdlib.hE<gt>\n"
5285 "#include E<lt>errno.hE<gt>\n"
5289 #: build/C/man3/pthread_setaffinity_np.3:186
5293 "main(int argc, char *argv[])\n"
5296 " cpu_set_t cpuset;\n"
5297 " pthread_t thread;\n"
5301 #: build/C/man3/pthread_setaffinity_np.3:188
5303 msgid " thread = pthread_self();\n"
5307 #: build/C/man3/pthread_setaffinity_np.3:190
5309 msgid " /* Set affinity mask to include CPUs 0 to 7 */\n"
5313 #: build/C/man3/pthread_setaffinity_np.3:194
5316 " CPU_ZERO(&cpuset);\n"
5317 " for (j = 0; j E<lt> 8; j++)\n"
5318 " CPU_SET(j, &cpuset);\n"
5322 #: build/C/man3/pthread_setaffinity_np.3:198
5325 " s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5327 " handle_error_en(s, \"pthread_setaffinity_np\");\n"
5331 #: build/C/man3/pthread_setaffinity_np.3:200
5333 msgid " /* Check the actual affinity mask assigned to the thread */\n"
5337 #: build/C/man3/pthread_setaffinity_np.3:204
5340 " s = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);\n"
5342 " handle_error_en(s, \"pthread_getaffinity_np\");\n"
5346 #: build/C/man3/pthread_setaffinity_np.3:209
5349 " printf(\"Set returned by pthread_getaffinity_np() contained:\\en\");\n"
5350 " for (j = 0; j E<lt> CPU_SETSIZE; j++)\n"
5351 " if (CPU_ISSET(j, &cpuset))\n"
5352 " printf(\" CPU %d\\en\", j);\n"
5356 #: build/C/man3/pthread_setaffinity_np.3:212 build/C/man3/pthread_setschedparam.3:439
5359 " exit(EXIT_SUCCESS);\n"
5364 #: build/C/man3/pthread_setaffinity_np.3:220
5366 "B<sched_setaffinity>(2), B<pthread_attr_setaffinity_np>(3), "
5367 "B<pthread_self>(3), B<sched_getcpu>(3), B<cpuset>(7), B<pthreads>(7), "
5372 #: build/C/man3/pthread_setcancelstate.3:26
5374 msgid "PTHREAD_SETCANCELSTATE"
5378 #: build/C/man3/pthread_setcancelstate.3:30
5380 "pthread_setcancelstate, pthread_setcanceltype - set cancelability state and "
5385 #: build/C/man3/pthread_setcancelstate.3:36
5388 "B<int pthread_setcancelstate(int >I<state>B<, int *>I<oldstate>B<);>\n"
5389 "B<int pthread_setcanceltype(int >I<type>B<, int *>I<oldtype>B<);>\n"
5393 #: build/C/man3/pthread_setcancelstate.3:51
5395 "The B<pthread_setcancelstate>() sets the cancelability state of the calling "
5396 "thread to the value given in I<state>. The previous cancelability state of "
5397 "the thread is returned in the buffer pointed to by I<oldstate>. The "
5398 "I<state> argument must have one of the following values:"
5402 #: build/C/man3/pthread_setcancelstate.3:51
5404 msgid "B<PTHREAD_CANCEL_ENABLE>"
5408 #: build/C/man3/pthread_setcancelstate.3:58
5410 "The thread is cancelable. This is the default cancelability state in all "
5411 "new threads, including the initial thread. The thread's cancelability type "
5412 "determines when a cancelable thread will respond to a cancellation request."
5416 #: build/C/man3/pthread_setcancelstate.3:58
5418 msgid "B<PTHREAD_CANCEL_DISABLE>"
5422 #: build/C/man3/pthread_setcancelstate.3:63
5424 "The thread is not cancelable. If a cancellation request is received, it is "
5425 "blocked until cancelability is enabled."
5429 #: build/C/man3/pthread_setcancelstate.3:75
5431 "The B<pthread_setcanceltype>() sets the cancelability type of the calling "
5432 "thread to the value given in I<type>. The previous cancelability type of "
5433 "the thread is returned in the buffer pointed to by I<oldtype>. The I<type> "
5434 "argument must have one of the following values:"
5438 #: build/C/man3/pthread_setcancelstate.3:75
5440 msgid "B<PTHREAD_CANCEL_DEFERRED>"
5444 #: build/C/man3/pthread_setcancelstate.3:82
5446 "A cancellation request is deferred until the thread next calls a function "
5447 "that is a cancellation point (see B<pthreads>(7)). This is the default "
5448 "cancelability type in all new threads, including the initial thread."
5452 #: build/C/man3/pthread_setcancelstate.3:82
5454 msgid "B<PTHREAD_CANCEL_ASYNCHRONOUS>"
5458 #: build/C/man3/pthread_setcancelstate.3:88
5460 "The thread can be canceled at any time. (Typically, it will be canceled "
5461 "immediately upon receiving a cancellation request, but the system doesn't "
5466 #: build/C/man3/pthread_setcancelstate.3:92
5468 "The set-and-get operation performed by each of these functions is atomic "
5469 "with respect to other threads in the process calling the same function."
5473 #: build/C/man3/pthread_setcancelstate.3:99
5474 msgid "The B<pthread_setcancelstate>() can fail with the following error:"
5478 #: build/C/man3/pthread_setcancelstate.3:103
5479 msgid "Invalid value for I<state>."
5483 #: build/C/man3/pthread_setcancelstate.3:107
5484 msgid "The B<pthread_setcanceltype>() can fail with the following error:"
5488 #. Available since glibc 2.0
5490 #: build/C/man3/pthread_setcancelstate.3:113
5491 msgid "Invalid value for I<type>."
5495 #: build/C/man3/pthread_setcancelstate.3:120
5497 "The B<pthread_setcancelstate>() and B<pthread_setcanceltype>() functions "
5502 #: build/C/man3/pthread_setcancelstate.3:125
5504 "For details of what happens when a thread is canceled, see "
5505 "B<pthread_cancel>(3)."
5509 #: build/C/man3/pthread_setcancelstate.3:132
5511 "Briefly disabling cancelability is useful if a thread performs some critical "
5512 "action that must not be interrupted by a cancellation request. Beware of "
5513 "disabling cancelability for long periods, or around operations that may "
5514 "block for long periods, since that will render the thread unresponsive to "
5515 "cancellation requests."
5519 #: build/C/man3/pthread_setcancelstate.3:132
5521 msgid "Asynchronous cancelability"
5525 #: build/C/man3/pthread_setcancelstate.3:151
5527 "Setting the cancelability type to B<PTHREAD_CANCEL_ASYNCHRONOUS> is rarely "
5528 "useful. Since the thread could be canceled at I<any> time, it cannot safely "
5529 "reserve resources (e.g., allocating memory with B<malloc>(3)), acquire "
5530 "mutexes, semaphores, or locks, and so on. Reserving resources is unsafe "
5531 "because the application has no way of knowing what the state of these "
5532 "resources is when the thread is canceled; that is, did cancellation occur "
5533 "before the resources were reserved, while they were reserved, or after they "
5534 "were released? Furthermore, some internal data structures (e.g., the linked "
5535 "list of free blocks managed by the B<malloc>(3) family of functions) may be "
5536 "left in an inconsistent state if cancellation occurs in the middle of the "
5537 "function call. Consequently, clean-up handlers cease to be useful."
5541 #: build/C/man3/pthread_setcancelstate.3:162
5543 "Functions that can be safely asynchronously canceled are called "
5544 "I<async-cancel-safe functions>. POSIX.1-2001 requires only that "
5545 "B<pthread_cancel>(3), B<pthread_setcancelstate>(), and "
5546 "B<pthread_setcanceltype>() be async-cancel-safe. In general, other library "
5547 "functions can't be safely called from an asynchronously cancelable thread."
5551 #: build/C/man3/pthread_setcancelstate.3:165
5553 "One of the few circumstances in which asynchronous cancelability is useful "
5554 "is for cancellation of a thread that is in a pure compute-bound loop."
5558 #: build/C/man3/pthread_setcancelstate.3:165
5560 msgid "Portability notes"
5563 #. It looks like at least Solaris, FreeBSD and Tru64 support this.
5565 #: build/C/man3/pthread_setcancelstate.3:183
5567 "The Linux threading implementations permit the I<oldstate> argument of "
5568 "B<pthread_setcancelstate>() to be NULL, in which case the information about "
5569 "the previous cancelability state is not returned to the caller. Many other "
5570 "implementations also permit a NULL I<oldstat> argument, but POSIX.1-2001 "
5571 "does not specify this point, so portable applications should always specify "
5572 "a non-NULL value in I<oldstate>. A precisely analogous set of statements "
5573 "applies for the I<oldtype> argument of B<pthread_setcanceltype>()."
5577 #: build/C/man3/pthread_setcancelstate.3:186
5578 msgid "See B<pthread_cancel>(3)."
5582 #: build/C/man3/pthread_setcancelstate.3:190
5584 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), B<pthread_testcancel>(3), "
5589 #: build/C/man3/pthread_setconcurrency.3:25
5591 msgid "PTHREAD_SETCONCURRENCY"
5595 #: build/C/man3/pthread_setconcurrency.3:29
5597 "pthread_setconcurrency, pthread_getconcurrency - set/get the concurrency "
5602 #: build/C/man3/pthread_setconcurrency.3:35
5605 "B<int pthread_setconcurrency(int >I<new_level>B<);>\n"
5606 "B<int pthread_getconcurrency(void);>\n"
5610 #: build/C/man3/pthread_setconcurrency.3:48
5612 "The B<pthread_setconcurrency>() function informs the implementation of the "
5613 "application's desired concurrency level, specified in I<new_level>. The "
5614 "implementation takes this only as a hint: POSIX.1 does not specify the level "
5615 "of concurrency that should be provided as a result of calling "
5616 "B<pthread_setconcurrency>()."
5620 #: build/C/man3/pthread_setconcurrency.3:53
5622 "Specifying I<new_level> as 0 instructs the implementation to manage the "
5623 "concurrency level as it deems appropriate."
5627 #: build/C/man3/pthread_setconcurrency.3:56
5629 "B<pthread_getconcurrency>() returns the current value of the concurrency "
5630 "level for this process."
5634 #: build/C/man3/pthread_setconcurrency.3:61
5636 "On success, B<pthread_setconcurrency>() returns 0; on error, it returns a "
5637 "nonzero error number."
5641 #: build/C/man3/pthread_setconcurrency.3:68
5643 "B<pthread_getconcurrency>() always succeeds, returning the concurrency "
5644 "level set by a previous call to B<pthread_setconcurrency>(), or 0, if "
5645 "B<pthread_setconcurrency>() has not previously been called."
5649 #: build/C/man3/pthread_setconcurrency.3:71
5650 msgid "B<pthread_setconcurrency>() can fail with the following error:"
5654 #: build/C/man3/pthread_setconcurrency.3:75
5655 msgid "I<new_level> is negative."
5659 #: build/C/man3/pthread_setconcurrency.3:81
5661 "POSIX.1-2001 also documents an B<EAGAIN> error (\"the value specified by "
5662 "I<new_level> would cause a system resource to be exceeded\")."
5666 #: build/C/man3/pthread_setconcurrency.3:83
5667 msgid "These functions are available in glibc since version 2.1."
5671 #: build/C/man3/pthread_setconcurrency.3:90
5673 "The B<pthread_setconcurrency>() and B<pthread_getconcurrency>() functions "
5678 #: build/C/man3/pthread_setconcurrency.3:94
5679 msgid "The default concurrency level is 0."
5683 #: build/C/man3/pthread_setconcurrency.3:101
5685 "Concurrency levels are meaningful only for M:N threading implementations, "
5686 "where at any moment a subset of a process's set of user-level threads may be "
5687 "bound to a smaller number of kernel-scheduling entities. Setting the "
5688 "concurrency level allows the application to give the system a hint as to the "
5689 "number of kernel-scheduling entities that should be provided for efficient "
5690 "execution of the application."
5694 #: build/C/man3/pthread_setconcurrency.3:107
5696 "Both LinuxThreads and NPTL are 1:1 threading implementations, so setting the "
5697 "concurrency level has no meaning. In other words, on Linux these functions "
5698 "merely exist for compatibility with other systems, and they have no effect "
5699 "on the execution of a program."
5703 #: build/C/man3/pthread_setconcurrency.3:109
5704 msgid "B<pthread_attr_setscope>(3), B<pthreads>(7)"
5708 #: build/C/man3/pthread_setname_np.3:26
5710 msgid "PTHREAD_SETNAME_NP"
5714 #: build/C/man3/pthread_setname_np.3:29
5715 msgid "pthread_setname_np, pthread_getname_np - set/get the name of a thread"
5719 #: build/C/man3/pthread_setname_np.3:36
5722 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
5723 "B<#include E<lt>pthread.hE<gt>>\n"
5724 "B<int pthread_setname_np(pthread_t >I<thread>B<, const char *>I<name>B<);>\n"
5725 "B<int pthread_getname_np(pthread_t >I<thread>B<,>\n"
5726 "B< char *>I<name>B<, size_t >I<len>B<);>\n"
5730 #: build/C/man3/pthread_setname_np.3:55
5732 "By default, all the threads created using B<pthread_create>() inherit the "
5733 "program name. The B<pthread_setname_np>() function can be used to set a "
5734 "unique name for a thread, which can be useful for debugging multithreaded "
5735 "applications. The thread name is a meaningful C language string, whose "
5736 "length is restricted to 16 characters, including the terminating null byte "
5737 "(\\(aq\\e0\\(aq). The I<thread> argument specifies the thread whose name is "
5738 "to be changed; I<name> specifies the new name."
5742 #: build/C/man3/pthread_setname_np.3:72
5744 "The B<pthread_getname_np>() function can be used to retrieve the name of "
5745 "the thread. The I<thread> argument specifies the thread whose name is to be "
5746 "retrieved. The buffer I<name> is used to return the thread name; I<len> "
5747 "specifies the number of bytes available in I<name>. The buffer specified by "
5748 "I<name> should be at least 16 characters in length. The returned thread "
5749 "name in the output buffer will be null terminated."
5753 #: build/C/man3/pthread_setname_np.3:79
5754 msgid "The B<pthread_setname_np>() function can fail with the following error:"
5758 #: build/C/man3/pthread_setname_np.3:79 build/C/man3/pthread_setname_np.3:88
5764 #: build/C/man3/pthread_setname_np.3:84
5766 "The length of the string specified pointed to by I<name> exceeds the allowed "
5771 #: build/C/man3/pthread_setname_np.3:88
5772 msgid "The B<pthread_getname_np>() function can fail with the following error:"
5776 #: build/C/man3/pthread_setname_np.3:95
5778 "The buffer specified by I<name> and I<len> is too small to hold the thread "
5783 #: build/C/man3/pthread_setname_np.3:100
5785 "If either of these functions fails to open I</proc/self/task/[tid]/comm>, "
5786 "then the call may fail with one of the errors described in B<open>(2)."
5790 #: build/C/man3/pthread_setname_np.3:102
5791 msgid "These functions first appeared in glibc in version 2.12."
5795 #: build/C/man3/pthread_setname_np.3:104
5796 msgid "These functions are nonstandard GNU extensions."
5800 #: build/C/man3/pthread_setname_np.3:114
5802 "B<pthread_setname_np>() internally writes to the thread-specific I<comm> "
5803 "file under the I</proc> filesystem: I</proc/self/task/[tid]/comm>. "
5804 "B<pthread_getname_np>() retrieves it from the same location."
5808 #: build/C/man3/pthread_setname_np.3:120
5810 "The program below demonstrates the use of B<pthread_setname_np>() and "
5811 "B<pthread_getname_np>()."
5815 #: build/C/man3/pthread_setname_np.3:122
5816 msgid "The following shell session shows a sample run of the program:"
5820 #: build/C/man3/pthread_setname_np.3:138
5824 "Created a thread. Default name is: a.out\n"
5825 "The thread name after setting it is THREADFOO.\n"
5826 "B<^Z> # Suspend the program\n"
5827 "[1]+ Stopped ./a.out\n"
5828 "$ B<ps H -C a.out -o 'pid tid cmd comm'>\n"
5829 " PID TID CMD COMMAND\n"
5830 " 5990 5990 ./a.out a.out\n"
5831 " 5990 5991 ./a.out THREADFOO\n"
5832 "$ B<cat /proc/5990/task/5990/comm>\n"
5834 "$ B<cat /proc/5990/task/5991/comm>\n"
5839 #: build/C/man3/pthread_setname_np.3:150
5842 "#define _GNU_SOURCE\n"
5843 "#include E<lt>pthread.hE<gt>\n"
5844 "#include E<lt>stdio.hE<gt>\n"
5845 "#include E<lt>string.hE<gt>\n"
5846 "#include E<lt>unistd.hE<gt>\n"
5847 "#include E<lt>errno.hE<gt>\n"
5848 "#include E<lt>stdlib.hE<gt>\n"
5852 #: build/C/man3/pthread_setname_np.3:152
5854 msgid "#define NAMELEN 16\n"
5858 #: build/C/man3/pthread_setname_np.3:156
5861 "#define errExitEN(en, msg) \\e\n"
5862 " do { errno = en; perror(msg); exit(EXIT_FAILURE); \\e\n"
5867 #: build/C/man3/pthread_setname_np.3:163
5871 "threadfunc(void *parm)\n"
5873 " sleep(5); // allow main program to set the thread name\n"
5879 #: build/C/man3/pthread_setname_np.3:170
5883 "main(int argc, char **argv)\n"
5885 " pthread_t thread;\n"
5887 " char thread_name[NAMELEN];\n"
5891 #: build/C/man3/pthread_setname_np.3:174
5894 " rc = pthread_create(&thread, NULL, threadfunc, NULL);\n"
5896 " errExitEN(rc, \"pthread_create\");\n"
5900 #: build/C/man3/pthread_setname_np.3:178
5903 " rc = pthread_getname_np(thread, thread_name, NAMELEN);\n"
5905 " errExitEN(rc, \"pthread_getname_np\");\n"
5909 #: build/C/man3/pthread_setname_np.3:183
5912 " printf(\"Created a thread. Default name is: %s\\en\", thread_name);\n"
5913 " rc = pthread_setname_np(thread, (argc E<gt> 1) ? argv[1] : "
5916 " errExitEN(rc, \"pthread_setname_np\");\n"
5920 #: build/C/man3/pthread_setname_np.3:185
5922 msgid " sleep(2);\n"
5926 #: build/C/man3/pthread_setname_np.3:191
5929 " rc = pthread_getname_np(thread, thread_name,\n"
5930 " (argc E<gt> 2) ? atoi(argv[1]) : NAMELEN);\n"
5932 " errExitEN(rc, \"pthread_getname_np\");\n"
5933 " printf(\"The thread name after setting it is %s.\\en\", thread_name);\n"
5937 #: build/C/man3/pthread_setname_np.3:195
5940 " rc = pthread_join(thread, NULL);\n"
5942 " errExitEN(rc, \"pthread_join\");\n"
5946 #: build/C/man3/pthread_setname_np.3:199
5949 " printf(\"Done\\en\");\n"
5950 " exit(EXIT_SUCCESS);\n"
5955 #: build/C/man3/pthread_setname_np.3:205
5956 msgid "B<prctl>(2), B<pthread_create>(3), B<pthreads>(7)"
5960 #: build/C/man3/pthread_setschedparam.3:26
5962 msgid "PTHREAD_SETSCHEDPARAM"
5966 #: build/C/man3/pthread_setschedparam.3:26
5972 #: build/C/man3/pthread_setschedparam.3:30
5974 "pthread_setschedparam, pthread_getschedparam - set/get scheduling policy and "
5975 "parameters of a thread"
5979 #: build/C/man3/pthread_setschedparam.3:38
5982 "B<int pthread_setschedparam(pthread_t >I<thread>B<, int >I<policy>B<,>\n"
5983 "B< const struct sched_param *>I<param>B<);>\n"
5984 "B<int pthread_getschedparam(pthread_t >I<thread>B<, int *>I<policy>B<,>\n"
5985 "B< struct sched_param *>I<param>B<);>\n"
5989 #: build/C/man3/pthread_setschedparam.3:46
5991 "The B<pthread_setschedparam>() function sets the scheduling policy and "
5992 "parameters of the thread I<thread>."
5995 #. FIXME . pthread_setschedparam() places no restriction on the policy,
5996 #. but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER
5997 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7013
5999 #: build/C/man3/pthread_setschedparam.3:57
6001 "I<policy> specifies the new scheduling policy for I<thread>. The supported "
6002 "values for I<policy>, and their semantics, are described in B<sched>(7)."
6006 #: build/C/man3/pthread_setschedparam.3:63
6008 "The structure pointed to by I<param> specifies the new scheduling parameters "
6009 "for I<thread>. Scheduling parameters are maintained in the following "
6013 #. FIXME . nptl/pthread_setschedparam.c has the following
6014 #. /* If the thread should have higher priority because of some
6015 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
6016 #. Eventually (perhaps after writing the mutexattr pages), we
6017 #. may want to add something on the topic to this page.
6019 #: build/C/man3/pthread_setschedparam.3:104
6021 "The B<pthread_getschedparam>() function returns the scheduling policy and "
6022 "parameters of the thread I<thread>, in the buffers pointed to by I<policy> "
6023 "and I<param>, respectively. The returned priority value is that set by the "
6024 "most recent B<pthread_setschedparam>(), B<pthread_setschedprio>(3), or "
6025 "B<pthread_create>(3) call that affected I<thread>. The returned priority "
6026 "does not reflect any temporary priority adjustments as a result of calls to "
6027 "any priority inheritance or priority ceiling functions (see, for example, "
6028 "B<pthread_mutexattr_setprioceiling>(3) and "
6029 "B<pthread_mutexattr_setprotocol>(3))."
6033 #: build/C/man3/pthread_setschedparam.3:112
6035 "On success, these functions return 0; on error, they return a nonzero error "
6036 "number. If B<pthread_setschedparam>() fails, the scheduling policy and "
6037 "parameters of I<thread> are not changed."
6041 #: build/C/man3/pthread_setschedparam.3:114
6042 msgid "Both of these functions can fail with the following error:"
6046 #: build/C/man3/pthread_setschedparam.3:122
6047 msgid "B<pthread_setschedparam>() may additionally fail with the following errors:"
6051 #: build/C/man3/pthread_setschedparam.3:129
6053 "I<policy> is not a recognized policy, or I<param> does not make sense for "
6058 #: build/C/man3/pthread_setschedparam.3:133
6060 "The caller does not have appropriate privileges to set the specified "
6061 "scheduling policy and parameters."
6065 #. Available since glibc 2.0
6067 #: build/C/man3/pthread_setschedparam.3:141
6069 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
6070 "policy or scheduling parameters to an unsupported value\") error for "
6071 "B<pthread_setschedparam>()."
6075 #: build/C/man3/pthread_setschedparam.3:148
6077 "The B<pthread_setschedparam>() and B<pthread_getschedparam>() functions "
6082 #: build/C/man3/pthread_setschedparam.3:156
6084 "For a description of the permissions required to, and the effect of, "
6085 "changing a thread's scheduling policy and priority, and details of the "
6086 "permitted ranges for priorities in each scheduling policy, see B<sched>(7)."
6090 #: build/C/man3/pthread_setschedparam.3:163
6092 "The program below demonstrates the use of B<pthread_setschedparam>() and "
6093 "B<pthread_getschedparam>(), as well as the use of a number of other "
6094 "scheduling-related pthreads functions."
6098 #: build/C/man3/pthread_setschedparam.3:179
6100 "In the following run, the main thread sets its scheduling policy to "
6101 "B<SCHED_FIFO> with a priority of 10, and initializes a thread attributes "
6102 "object with a scheduling policy attribute of B<SCHED_RR> and a scheduling "
6103 "priority attribute of 20. The program then sets (using "
6104 "B<pthread_attr_setinheritsched>(3)) the inherit scheduler attribute of the "
6105 "thread attributes object to B<PTHREAD_EXPLICIT_SCHED>, meaning that threads "
6106 "created using this attributes object should take their scheduling attributes "
6107 "from the thread attributes object. The program then creates a thread using "
6108 "the thread attributes object, and that thread displays its scheduling policy "
6113 #: build/C/man3/pthread_setschedparam.3:187
6116 "$ B<su> # Need privilege to set real-time scheduling policies\n"
6118 "# B<./a.out -mf10 -ar20 -i e>\n"
6119 "Scheduler settings of main thread\n"
6120 " policy=SCHED_FIFO, priority=10\n"
6124 #: build/C/man3/pthread_setschedparam.3:191
6127 "Scheduler settings in \\(aqattr\\(aq\n"
6128 " policy=SCHED_RR, priority=20\n"
6129 " inheritsched is EXPLICIT\n"
6133 #: build/C/man3/pthread_setschedparam.3:194
6136 "Scheduler attributes of new thread\n"
6137 " policy=SCHED_RR, priority=20\n"
6141 #: build/C/man3/pthread_setschedparam.3:199
6143 "In the above output, one can see that the scheduling policy and priority "
6144 "were taken from the values specified in the thread attributes object."
6148 #: build/C/man3/pthread_setschedparam.3:206
6150 "The next run is the same as the previous, except that the inherit scheduler "
6151 "attribute is set to B<PTHREAD_INHERIT_SCHED>, meaning that threads created "
6152 "using the thread attributes object should ignore the scheduling attributes "
6153 "specified in the attributes object and instead take their scheduling "
6154 "attributes from the creating thread."
6158 #: build/C/man3/pthread_setschedparam.3:212
6161 "# B<./a.out -mf10 -ar20 -i i>\n"
6162 "Scheduler settings of main thread\n"
6163 " policy=SCHED_FIFO, priority=10\n"
6167 #: build/C/man3/pthread_setschedparam.3:216
6170 "Scheduler settings in \\(aqattr\\(aq\n"
6171 " policy=SCHED_RR, priority=20\n"
6172 " inheritsched is INHERIT\n"
6176 #: build/C/man3/pthread_setschedparam.3:219
6179 "Scheduler attributes of new thread\n"
6180 " policy=SCHED_FIFO, priority=10\n"
6184 #: build/C/man3/pthread_setschedparam.3:225
6186 "In the above output, one can see that the scheduling policy and priority "
6187 "were taken from the creating thread, rather than the thread attributes "
6192 #: build/C/man3/pthread_setschedparam.3:231
6194 "Note that if we had omitted the I<-i\\ i> option, the output would have been "
6195 "the same, since B<PTHREAD_INHERIT_SCHED> is the default for the inherit "
6196 "scheduler attribute."
6200 #: build/C/man3/pthread_setschedparam.3:235
6202 msgid "/* pthreads_sched_test.c */\n"
6206 #: build/C/man3/pthread_setschedparam.3:241
6209 "#include E<lt>pthread.hE<gt>\n"
6210 "#include E<lt>stdio.hE<gt>\n"
6211 "#include E<lt>stdlib.hE<gt>\n"
6212 "#include E<lt>unistd.hE<gt>\n"
6213 "#include E<lt>errno.hE<gt>\n"
6217 #: build/C/man3/pthread_setschedparam.3:250
6221 "usage(char *prog_name, char *msg)\n"
6223 " if (msg != NULL)\n"
6224 " fputs(msg, stderr);\n"
6228 #: build/C/man3/pthread_setschedparam.3:267
6231 " fprintf(stderr, \"Usage: %s [options]\\en\", prog_name);\n"
6232 " fprintf(stderr, \"Options are:\\en\");\n"
6233 "#define fpe(msg) fprintf(stderr, \"\\et%s\", msg); /* Shorter */\n"
6234 " fpe(\"-aE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and "
6235 "priority in\\en\");\n"
6236 " fpe(\" thread attributes object\\en\");\n"
6237 " fpe(\" E<lt>policyE<gt> can be\\en\");\n"
6238 " fpe(\" f SCHED_FIFO\\en\");\n"
6239 " fpe(\" r SCHED_RR\\en\");\n"
6240 " fpe(\" o SCHED_OTHER\\en\");\n"
6241 " fpe(\"-A Use default thread attributes object\\en\");\n"
6242 " fpe(\"-i {e|i} Set inherit scheduler attribute to\\en\");\n"
6243 " fpe(\" \\(aqexplicit\\(aq or \\(aqinherit\\(aq\\en\");\n"
6244 " fpe(\"-mE<lt>policyE<gt>E<lt>prioE<gt> Set scheduling policy and "
6245 "priority on\\en\");\n"
6246 " fpe(\" main thread before pthread_create() "
6248 " exit(EXIT_FAILURE);\n"
6253 #: build/C/man3/pthread_setschedparam.3:278
6257 "get_policy(char p, int *policy)\n"
6260 " case \\(aqf\\(aq: *policy = SCHED_FIFO; return 1;\n"
6261 " case \\(aqr\\(aq: *policy = SCHED_RR; return 1;\n"
6262 " case \\(aqo\\(aq: *policy = SCHED_OTHER; return 1;\n"
6263 " default: return 0;\n"
6269 #: build/C/man3/pthread_setschedparam.3:289
6273 "display_sched_attr(int policy, struct sched_param *param)\n"
6275 " printf(\" policy=%s, priority=%d\\en\",\n"
6276 " (policy == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
6277 " (policy == SCHED_RR) ? \"SCHED_RR\" :\n"
6278 " (policy == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
6280 " param-E<gt>sched_priority);\n"
6285 #: build/C/man3/pthread_setschedparam.3:295
6289 "display_thread_sched_attr(char *msg)\n"
6292 " struct sched_param param;\n"
6296 #: build/C/man3/pthread_setschedparam.3:299
6299 " s = pthread_getschedparam(pthread_self(), &policy, ¶m);\n"
6301 " handle_error_en(s, \"pthread_getschedparam\");\n"
6305 #: build/C/man3/pthread_setschedparam.3:303
6308 " printf(\"%s\\en\", msg);\n"
6309 " display_sched_attr(policy, ¶m);\n"
6314 #: build/C/man3/pthread_setschedparam.3:308
6318 "thread_start(void *arg)\n"
6320 " display_thread_sched_attr(\"Scheduler attributes of new thread\");\n"
6324 #: build/C/man3/pthread_setschedparam.3:311
6332 #: build/C/man3/pthread_setschedparam.3:321
6336 "main(int argc, char *argv[])\n"
6338 " int s, opt, inheritsched, use_null_attrib, policy;\n"
6339 " pthread_t thread;\n"
6340 " pthread_attr_t attr;\n"
6341 " pthread_attr_t *attrp;\n"
6342 " char *attr_sched_str, *main_sched_str, *inheritsched_str;\n"
6343 " struct sched_param param;\n"
6347 #: build/C/man3/pthread_setschedparam.3:323
6349 msgid " /* Process command-line options */\n"
6353 #: build/C/man3/pthread_setschedparam.3:328
6356 " use_null_attrib = 0;\n"
6357 " attr_sched_str = NULL;\n"
6358 " main_sched_str = NULL;\n"
6359 " inheritsched_str = NULL;\n"
6363 #: build/C/man3/pthread_setschedparam.3:338
6366 " while ((opt = getopt(argc, argv, \"a:Ai:m:\")) != -1) {\n"
6368 " case \\(aqa\\(aq: attr_sched_str = optarg; break;\n"
6369 " case \\(aqA\\(aq: use_null_attrib = 1; break;\n"
6370 " case \\(aqi\\(aq: inheritsched_str = optarg; break;\n"
6371 " case \\(aqm\\(aq: main_sched_str = optarg; break;\n"
6372 " default: usage(argv[0], \"Unrecognized option\\en\");\n"
6378 #: build/C/man3/pthread_setschedparam.3:342
6381 " if (use_null_attrib &&\n"
6382 " (inheritsched_str != NULL || attr_sched_str != NULL))\n"
6383 " usage(argv[0], \"Can\\(aqt specify -A with -i or -a\\en\");\n"
6387 #: build/C/man3/pthread_setschedparam.3:345
6390 " /* Optionally set scheduling attributes of main thread,\n"
6391 " and display the attributes */\n"
6395 #: build/C/man3/pthread_setschedparam.3:350
6398 " if (main_sched_str != NULL) {\n"
6399 " if (!get_policy(main_sched_str[0], &policy))\n"
6400 " usage(argv[0], \"Bad policy for main thread (-m)\\en\");\n"
6401 " param.sched_priority = strtol(&main_sched_str[1], NULL, 0);\n"
6405 #: build/C/man3/pthread_setschedparam.3:355
6408 " s = pthread_setschedparam(pthread_self(), policy, ¶m);\n"
6410 " handle_error_en(s, \"pthread_setschedparam\");\n"
6415 #: build/C/man3/pthread_setschedparam.3:358
6418 " display_thread_sched_attr(\"Scheduler settings of main thread\");\n"
6419 " printf(\"\\en\");\n"
6423 #: build/C/man3/pthread_setschedparam.3:360
6425 msgid " /* Initialize thread attributes object according to options */\n"
6429 #: build/C/man3/pthread_setschedparam.3:369
6432 " if (!use_null_attrib) {\n"
6433 " s = pthread_attr_init(&attr);\n"
6435 " handle_error_en(s, \"pthread_attr_init\");\n"
6441 #: build/C/man3/pthread_setschedparam.3:377
6444 " if (inheritsched_str != NULL) {\n"
6445 " if (inheritsched_str[0] == \\(aqe\\(aq)\n"
6446 " inheritsched = PTHREAD_EXPLICIT_SCHED;\n"
6447 " else if (inheritsched_str[0] == \\(aqi\\(aq)\n"
6448 " inheritsched = PTHREAD_INHERIT_SCHED;\n"
6450 " usage(argv[0], \"Value for -i must be \\(aqe\\(aq or "
6451 "\\(aqi\\(aq\\en\");\n"
6455 #: build/C/man3/pthread_setschedparam.3:382
6458 " s = pthread_attr_setinheritsched(&attr, inheritsched);\n"
6460 " handle_error_en(s, \"pthread_attr_setinheritsched\");\n"
6465 #: build/C/man3/pthread_setschedparam.3:388
6468 " if (attr_sched_str != NULL) {\n"
6469 " if (!get_policy(attr_sched_str[0], &policy))\n"
6471 " \"Bad policy for \\(aqattr\\(aq (-a)\\en\");\n"
6472 " param.sched_priority = strtol(&attr_sched_str[1], NULL, 0);\n"
6476 #: build/C/man3/pthread_setschedparam.3:396
6479 " s = pthread_attr_setschedpolicy(&attr, policy);\n"
6481 " handle_error_en(s, \"pthread_attr_setschedpolicy\");\n"
6482 " s = pthread_attr_setschedparam(&attr, ¶m);\n"
6484 " handle_error_en(s, \"pthread_attr_setschedparam\");\n"
6489 #: build/C/man3/pthread_setschedparam.3:399
6492 " /* If we initialized a thread attributes object, display\n"
6493 " the scheduling attributes that were set in the object */\n"
6497 #: build/C/man3/pthread_setschedparam.3:407
6500 " if (attrp != NULL) {\n"
6501 " s = pthread_attr_getschedparam(&attr, ¶m);\n"
6503 " handle_error_en(s, \"pthread_attr_getschedparam\");\n"
6504 " s = pthread_attr_getschedpolicy(&attr, &policy);\n"
6506 " handle_error_en(s, \"pthread_attr_getschedpolicy\");\n"
6510 #: build/C/man3/pthread_setschedparam.3:410
6513 " printf(\"Scheduler settings in \\(aqattr\\(aq\\en\");\n"
6514 " display_sched_attr(policy, ¶m);\n"
6518 #: build/C/man3/pthread_setschedparam.3:418
6521 " s = pthread_attr_getinheritsched(&attr, &inheritsched);\n"
6522 " printf(\" inheritsched is %s\\en\",\n"
6523 " (inheritsched == PTHREAD_INHERIT_SCHED) ? \"INHERIT\" :\n"
6524 " (inheritsched == PTHREAD_EXPLICIT_SCHED) ? \"EXPLICIT\" :\n"
6526 " printf(\"\\en\");\n"
6531 #: build/C/man3/pthread_setschedparam.3:420
6533 msgid " /* Create a thread that will display its scheduling attributes */\n"
6537 #: build/C/man3/pthread_setschedparam.3:424
6540 " s = pthread_create(&thread, attrp, &thread_start, NULL);\n"
6542 " handle_error_en(s, \"pthread_create\");\n"
6546 #: build/C/man3/pthread_setschedparam.3:426
6548 msgid " /* Destroy unneeded thread attributes object */\n"
6552 #: build/C/man3/pthread_setschedparam.3:432
6555 " if (!use_null_attrib) {\n"
6556 " s = pthread_attr_destroy(&attr);\n"
6558 " handle_error_en(s, \"pthread_attr_destroy\");\n"
6563 #: build/C/man3/pthread_setschedparam.3:436
6566 " s = pthread_join(thread, NULL);\n"
6568 " handle_error_en(s, \"pthread_join\");\n"
6572 #: build/C/man3/pthread_setschedparam.3:453
6574 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<pthread_attr_init>(3), "
6575 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
6576 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), B<pthread_self>(3), "
6577 "B<pthread_setschedprio>(3), B<pthreads>(7), B<sched>(7)"
6581 #: build/C/man3/pthread_setschedprio.3:26
6583 msgid "PTHREAD_SETSCHEDPRIO"
6587 #: build/C/man3/pthread_setschedprio.3:29
6588 msgid "pthread_setschedprio - set scheduling priority of a thread"
6592 #: build/C/man3/pthread_setschedprio.3:34
6594 msgid "B<int pthread_setschedprio(pthread_t >I<thread>B<, int >I<prio>B<);>\n"
6597 #. FIXME . nptl/pthread_setschedprio.c has the following
6598 #. /* If the thread should have higher priority because of some
6599 #. PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
6600 #. Eventually (perhaps after writing the mutexattr pages), we
6601 #. may want to add something on the topic to this page.
6602 #. nptl/pthread_setschedparam.c has a similar case.
6604 #: build/C/man3/pthread_setschedprio.3:53
6606 "The B<pthread_setschedprio>() function sets the scheduling priority of the "
6607 "thread I<thread> to the value specified in I<prio>. (By contrast "
6608 "B<pthread_setschedparam>(3) changes both the scheduling policy and priority "
6613 #: build/C/man3/pthread_setschedprio.3:61
6615 "On success, this function returns 0; on error, it returns a nonzero error "
6616 "number. If B<pthread_setschedprio>() fails, the scheduling priority of "
6617 "I<thread> is not changed."
6621 #: build/C/man3/pthread_setschedprio.3:66
6622 msgid "I<prio> is not valid for the scheduling policy of the specified thread."
6626 #: build/C/man3/pthread_setschedprio.3:70
6628 "The caller does not have appropriate privileges to set the specified "
6633 #: build/C/man3/pthread_setschedprio.3:81
6635 "POSIX.1-2001 also documents an B<ENOTSUP> (\"attempt was made to set the "
6636 "priority to an unsupported value\") error for B<pthread_setschedparam>(3)."
6640 #: build/C/man3/pthread_setschedprio.3:83
6641 msgid "This function is available in glibc since version 2.3.4."
6645 #: build/C/man3/pthread_setschedprio.3:88
6646 msgid "The B<pthread_setschedprio>() function is thread-safe."
6650 #: build/C/man3/pthread_setschedprio.3:96
6652 "For a description of the permissions required to, and the effect of, "
6653 "changing a thread's scheduling priority, and details of the permitted ranges "
6654 "for priorities in each scheduling policy, see B<sched>(7)."
6658 #: build/C/man3/pthread_setschedprio.3:109
6660 "B<getrlimit>(2), B<sched_get_priority_min>(2), B<pthread_attr_init>(3), "
6661 "B<pthread_attr_setinheritsched>(3), B<pthread_attr_setschedparam>(3), "
6662 "B<pthread_attr_setschedpolicy>(3), B<pthread_create>(3), B<pthread_self>(3), "
6663 "B<pthread_setschedparam>(3), B<pthreads>(7), B<sched>(7)"
6667 #: build/C/man3/pthread_sigmask.3:26
6669 msgid "PTHREAD_SIGMASK"
6673 #: build/C/man3/pthread_sigmask.3:26 build/C/man3/pthread_testcancel.3:26
6679 #: build/C/man3/pthread_sigmask.3:29
6680 msgid "pthread_sigmask - examine and change mask of blocked signals"
6684 #: build/C/man3/pthread_sigmask.3:35
6687 "B<int pthread_sigmask(int >I<how>B<, const sigset_t *>I<set>B<, sigset_t "
6688 "*>I<oldset>B<);>\n"
6692 #: build/C/man3/pthread_sigmask.3:46
6693 msgid "B<pthread_sigmask>():"
6697 #: build/C/man3/pthread_sigmask.3:58
6699 "The B<pthread_sigmask>() function is just like B<sigprocmask>(2), with the "
6700 "difference that its use in multithreaded programs is explicitly specified by "
6701 "POSIX.1-2001. Other differences are noted in this page."
6705 #: build/C/man3/pthread_sigmask.3:61
6707 "For a description of the arguments and operation of this function, see "
6708 "B<sigprocmask>(2)."
6712 #: build/C/man3/pthread_sigmask.3:66
6714 "On success, B<pthread_sigmask>() returns 0; on error, it returns an error "
6719 #: build/C/man3/pthread_sigmask.3:69
6720 msgid "See B<sigprocmask>(2)."
6724 #: build/C/man3/pthread_sigmask.3:74
6725 msgid "The B<pthread_sigmask>() function is thread-safe."
6729 #: build/C/man3/pthread_sigmask.3:78
6730 msgid "A new thread inherits a copy of its creator's signal mask."
6734 #: build/C/man3/pthread_sigmask.3:83
6736 "The program below blocks some signals in the main thread, and then creates a "
6737 "dedicated thread to fetch those signals via B<sigwait>(3). The following "
6738 "shell session demonstrates its use:"
6742 #: build/C/man3/pthread_sigmask.3:94
6747 "$B< kill -QUIT %1>\n"
6748 "Signal handling thread got signal 3\n"
6749 "$B< kill -USR1 %1>\n"
6750 "Signal handling thread got signal 10\n"
6751 "$B< kill -TERM %1>\n"
6752 "[1]+ Terminated ./a.out\n"
6756 #: build/C/man3/pthread_sigmask.3:105
6759 "#include E<lt>pthread.hE<gt>\n"
6760 "#include E<lt>stdio.hE<gt>\n"
6761 "#include E<lt>stdlib.hE<gt>\n"
6762 "#include E<lt>unistd.hE<gt>\n"
6763 "#include E<lt>signal.hE<gt>\n"
6764 "#include E<lt>errno.hE<gt>\n"
6768 #: build/C/man3/pthread_sigmask.3:107
6770 msgid "/* Simple error handling functions */\n"
6774 #: build/C/man3/pthread_sigmask.3:116
6778 "sig_thread(void *arg)\n"
6780 " sigset_t *set = arg;\n"
6785 #: build/C/man3/pthread_sigmask.3:124
6789 " s = sigwait(set, &sig);\n"
6791 " handle_error_en(s, \"sigwait\");\n"
6792 " printf(\"Signal handling thread got signal %d\\en\", sig);\n"
6798 #: build/C/man3/pthread_sigmask.3:131
6802 "main(int argc, char *argv[])\n"
6804 " pthread_t thread;\n"
6810 #: build/C/man3/pthread_sigmask.3:134
6813 " /* Block SIGQUIT and SIGUSR1; other threads created by main()\n"
6814 " will inherit a copy of the signal mask. */\n"
6818 #: build/C/man3/pthread_sigmask.3:141
6821 " sigemptyset(&set);\n"
6822 " sigaddset(&set, SIGQUIT);\n"
6823 " sigaddset(&set, SIGUSR1);\n"
6824 " s = pthread_sigmask(SIG_BLOCK, &set, NULL);\n"
6826 " handle_error_en(s, \"pthread_sigmask\");\n"
6830 #: build/C/man3/pthread_sigmask.3:145
6833 " s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);\n"
6835 " handle_error_en(s, \"pthread_create\");\n"
6839 #: build/C/man3/pthread_sigmask.3:148
6842 " /* Main thread carries on to create other threads and/or do\n"
6847 #: build/C/man3/pthread_sigmask.3:151
6850 " pause(); /* Dummy pause so we can test program */\n"
6855 #: build/C/man3/pthread_sigmask.3:160
6857 "B<sigaction>(2), B<sigpending>(2), B<sigprocmask>(2), B<pthread_create>(3), "
6858 "B<pthread_kill>(3), B<sigsetops>(3), B<pthreads>(7), B<signal>(7)"
6862 #: build/C/man3/pthread_sigqueue.3:25
6864 msgid "PTHREAD_SIGQUEUE"
6868 #: build/C/man3/pthread_sigqueue.3:28
6869 msgid "pthread_sigqueue - queue a signal and data to a thread"
6873 #: build/C/man3/pthread_sigqueue.3:32
6876 "B<#include E<lt>signal.hE<gt>>\n"
6877 "B<#include E<lt>pthread.hE<gt>>\n"
6881 #: build/C/man3/pthread_sigqueue.3:35
6884 "B<int pthread_sigqueue(pthread_t >I<thread>B<, int >I<sig>B<,>\n"
6885 "B< const union sigval >I<value>B<);>\n"
6889 #: build/C/man3/pthread_sigqueue.3:46
6890 msgid "B<pthread_sigqueue>(): _GNU_SOURCE"
6894 #: build/C/man3/pthread_sigqueue.3:54
6896 "The B<pthread_sigqueue>() function performs a similar task to "
6897 "B<sigqueue>(3), but, rather than sending a signal to a process, it sends a "
6898 "signal to a thread in the same process as the calling thread."
6902 #: build/C/man3/pthread_sigqueue.3:66
6904 "The I<thread> argument is the ID of a thread in the same process as the "
6905 "caller. The I<sig> argument specifies the signal to be sent. The I<value> "
6906 "argument specifies data to accompany the signal; see B<sigqueue>(3) for "
6911 #: build/C/man3/pthread_sigqueue.3:71
6913 "On success, B<pthread_sigqueue>() returns 0; on error, it returns an error "
6918 #: build/C/man3/pthread_sigqueue.3:78
6920 "The limit of signals which may be queued has been reached. (See "
6921 "B<signal>(7) for further information.)"
6925 #: build/C/man3/pthread_sigqueue.3:82
6926 msgid "I<sig> was invalid."
6930 #: build/C/man3/pthread_sigqueue.3:82
6936 #: build/C/man3/pthread_sigqueue.3:86
6937 msgid "B<pthread_sigqueue>() is not supported on this system."
6941 #: build/C/man3/pthread_sigqueue.3:90
6942 msgid "I<thread> is not valid."
6946 #: build/C/man3/pthread_sigqueue.3:94
6947 msgid "The B<pthread_sigqueue>() function first appeared in glibc 2.11."
6951 #: build/C/man3/pthread_sigqueue.3:99
6952 msgid "The B<pthread_sigqueue>() function is thread-safe."
6956 #: build/C/man3/pthread_sigqueue.3:101
6957 msgid "This function is a GNU extension."
6961 #: build/C/man3/pthread_sigqueue.3:108
6963 "B<rt_tgsigqueueinfo>(2), B<sigaction>(2), B<pthread_sigmask>(3), "
6964 "B<sigqueue>(3), B<sigwait>(3), B<pthreads>(7), B<signal>(7)"
6968 #: build/C/man3/pthread_testcancel.3:26
6970 msgid "PTHREAD_TESTCANCEL"
6974 #: build/C/man3/pthread_testcancel.3:29
6975 msgid "pthread_testcancel - request delivery of any pending cancellation request"
6979 #: build/C/man3/pthread_testcancel.3:34
6981 msgid "B<void pthread_testcancel(void);>\n"
6985 #: build/C/man3/pthread_testcancel.3:43
6987 "Calling B<pthread_testcancel>() creates a cancellation point within the "
6988 "calling thread, so that a thread that is otherwise executing code that "
6989 "contains no cancellation points will respond to a cancellation request."
6993 #: build/C/man3/pthread_testcancel.3:50
6995 "If cancelability is disabled (using B<pthread_setcancelstate>(3)), or no "
6996 "cancellation request is pending, then a call to B<pthread_testcancel>() has "
7001 #: build/C/man3/pthread_testcancel.3:54
7003 "This function does not return a value. If the calling thread is canceled as "
7004 "a consequence of a call to this function, then the function does not return."
7008 #: build/C/man3/pthread_testcancel.3:63
7009 msgid "The B<pthread_testcancel>() function is thread-safe."
7013 #: build/C/man3/pthread_testcancel.3:68
7014 msgid "See B<pthread_cleanup_push>(3)."
7018 #: build/C/man3/pthread_testcancel.3:72
7020 "B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
7021 "B<pthread_setcancelstate>(3), B<pthreads>(7)"
7025 #: build/C/man3/pthread_tryjoin_np.3:26
7027 msgid "PTHREAD_TRYJOIN_NP"
7031 #: build/C/man3/pthread_tryjoin_np.3:26
7037 #: build/C/man3/pthread_tryjoin_np.3:30
7039 "pthread_tryjoin_np, pthread_timedjoin_np - try to join with a terminated "
7044 #: build/C/man3/pthread_tryjoin_np.3:36
7046 msgid "B<int pthread_tryjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<);>\n"
7050 #: build/C/man3/pthread_tryjoin_np.3:39
7053 "B<int pthread_timedjoin_np(pthread_t >I<thread>B<, void **>I<retval>B<,>\n"
7054 "B< const struct timespec *>I<abstime>B<);>\n"
7058 #: build/C/man3/pthread_tryjoin_np.3:46
7060 "These functions operate in the same way as B<pthread_join>(3), except for "
7061 "the differences described on this page."
7065 #: build/C/man3/pthread_tryjoin_np.3:58
7067 "The B<pthread_tryjoin_np>() function performs a nonblocking join with the "
7068 "thread I<thread>, returning the exit status of the thread in I<*retval>. If "
7069 "I<thread> has not yet terminated, then instead of blocking, as is done by "
7070 "B<pthread_join>(3), the call returns an error."
7074 #: build/C/man3/pthread_tryjoin_np.3:76
7076 "The B<pthread_timedjoin_np>() function performs a join-with-timeout. If "
7077 "I<thread> has not yet terminated, then the call blocks until a maximum time, "
7078 "specified in I<abstime>. If the timeout expires before I<thread> "
7079 "terminates, the call returns an error. The I<abstime> argument is a "
7080 "structure of the following form, specifying an absolute time measured since "
7081 "the Epoch (see B<time>(2)):"
7085 #: build/C/man3/pthread_tryjoin_np.3:83
7088 "struct timespec {\n"
7089 " time_t tv_sec; /* seconds */\n"
7090 " long tv_nsec; /* nanoseconds */\n"
7095 #: build/C/man3/pthread_tryjoin_np.3:89
7096 msgid "On success, these functions return 0; on error, they return an error number."
7100 #: build/C/man3/pthread_tryjoin_np.3:94
7102 "These functions can fail with the same errors as B<pthread_join>(3). "
7103 "B<pthread_tryjoin_np>() can in addition fail with the following error:"
7107 #: build/C/man3/pthread_tryjoin_np.3:94
7113 #: build/C/man3/pthread_tryjoin_np.3:98
7114 msgid "I<thread> had not yet terminated at the time of the call."
7118 #: build/C/man3/pthread_tryjoin_np.3:101
7119 msgid "B<pthread_timedjoin_np>() can in addition fail with the following errors:"
7123 #: build/C/man3/pthread_tryjoin_np.3:101
7125 msgid "B<ETIMEDOUT>"
7129 #: build/C/man3/pthread_tryjoin_np.3:106
7130 msgid "The call timed out before I<thread> terminated."
7134 #: build/C/man3/pthread_tryjoin_np.3:114
7136 "I<abstime> value is invalid (I<tv_sec> is less than 0 or I<tv_nsec> is "
7137 "greater than 1e9)."
7141 #: build/C/man3/pthread_tryjoin_np.3:118
7142 msgid "B<pthread_timedjoin_np>() never returns the error B<EINTR>."
7146 #: build/C/man3/pthread_tryjoin_np.3:120
7147 msgid "These functions first appeared in glibc in version 2.3.3."
7151 #: build/C/man3/pthread_tryjoin_np.3:125
7152 msgid "The following code waits to join for up to 5 seconds:"
7156 #: build/C/man3/pthread_tryjoin_np.3:129
7159 " struct timespec ts;\n"
7164 #: build/C/man3/pthread_tryjoin_np.3:131
7170 #: build/C/man3/pthread_tryjoin_np.3:135
7173 " if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {\n"
7174 "\t/* Handle error */\n"
7179 #: build/C/man3/pthread_tryjoin_np.3:137
7181 msgid " ts.tv_sec += 5;\n"
7185 #: build/C/man3/pthread_tryjoin_np.3:142
7188 " s = pthread_timedjoin_np(thread, NULL, &ts);\n"
7190 " /* Handle error */\n"
7195 #: build/C/man3/pthread_tryjoin_np.3:147
7196 msgid "B<clock_gettime>(2), B<pthread_exit>(3), B<pthread_join>(3), B<pthreads>(7)"
7200 #: build/C/man3/pthread_yield.3:25
7202 msgid "PTHREAD_YIELD"
7206 #: build/C/man3/pthread_yield.3:28
7207 msgid "pthread_yield - yield the processor"
7211 #: build/C/man3/pthread_yield.3:34
7213 msgid "B<int pthread_yield(void);>\n"
7217 #: build/C/man3/pthread_yield.3:44
7219 "B<pthread_yield>() causes the calling thread to relinquish the CPU. The "
7220 "thread is placed at the end of the run queue for its static priority and "
7221 "another thread is scheduled to run. For further details, see "
7226 #: build/C/man3/pthread_yield.3:49
7228 "On success, B<pthread_yield>() returns 0; on error, it returns an error "
7233 #: build/C/man3/pthread_yield.3:53
7235 "On Linux, this call always succeeds (but portable and future-proof "
7236 "applications should nevertheless handle a possible error return)."
7240 #: build/C/man3/pthread_yield.3:58
7241 msgid "The B<pthread_yield>() function is thread-safe."
7244 #. e.g., the BSDs, Tru64, AIX, and Irix.
7246 #: build/C/man3/pthread_yield.3:64
7248 "This call is nonstandard, but present on several other systems. Use the "
7249 "standardized B<sched_yield>(2) instead."
7253 #: build/C/man3/pthread_yield.3:67
7254 msgid "On Linux, this function is implemented as a call to B<sched_yield>(2)."
7258 #: build/C/man3/pthread_yield.3:70
7259 msgid "B<sched_yield>(2), B<pthreads>(7), B<sched>(7)"
7263 #: build/C/man7/pthreads.7:26
7269 #: build/C/man7/pthreads.7:29
7270 msgid "pthreads - POSIX threads"
7274 #: build/C/man7/pthreads.7:36
7276 "POSIX.1 specifies a set of interfaces (functions, header files) for threaded "
7277 "programming commonly known as POSIX threads, or Pthreads. A single process "
7278 "can contain multiple threads, all of which are executing the same program. "
7279 "These threads share the same global memory (data and heap segments), but "
7280 "each thread has its own stack (automatic variables)."
7284 #: build/C/man7/pthreads.7:39
7286 "POSIX.1 also requires that threads share a range of other attributes (i.e., "
7287 "these attributes are process-wide rather than per-thread):"
7291 #: 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:103 build/C/man7/pthreads.7:106 build/C/man7/pthreads.7:683 build/C/man7/pthreads.7:690 build/C/man7/pthreads.7:702 build/C/man7/pthreads.7:712 build/C/man7/pthreads.7:716 build/C/man7/pthreads.7:725 build/C/man7/pthreads.7:735 build/C/man7/pthreads.7:742 build/C/man7/pthreads.7:749 build/C/man7/pthreads.7:751 build/C/man7/pthreads.7:754 build/C/man7/pthreads.7:760 build/C/man7/pthreads.7:763 build/C/man7/pthreads.7:765 build/C/man7/pthreads.7:767 build/C/man7/pthreads.7:777 build/C/man7/pthreads.7:797 build/C/man7/pthreads.7:806 build/C/man7/pthreads.7:812 build/C/man7/pthreads.7:814 build/C/man7/pthreads.7:816 build/C/man7/pthreads.7:820 build/C/man7/pthreads.7:825 build/C/man7/pthreads.7:833
7297 #: build/C/man7/pthreads.7:41
7302 #: build/C/man7/pthreads.7:43
7303 msgid "parent process ID"
7307 #: build/C/man7/pthreads.7:45
7308 msgid "process group ID and session ID"
7312 #: build/C/man7/pthreads.7:47
7313 msgid "controlling terminal"
7317 #: build/C/man7/pthreads.7:49
7318 msgid "user and group IDs"
7322 #: build/C/man7/pthreads.7:51
7323 msgid "open file descriptors"
7327 #: build/C/man7/pthreads.7:54
7328 msgid "record locks (see B<fcntl>(2))"
7332 #: build/C/man7/pthreads.7:56
7333 msgid "signal dispositions"
7337 #: build/C/man7/pthreads.7:59
7338 msgid "file mode creation mask (B<umask>(2))"
7342 #: build/C/man7/pthreads.7:65
7343 msgid "current directory (B<chdir>(2)) and root directory (B<chroot>(2))"
7347 #: build/C/man7/pthreads.7:70
7348 msgid "interval timers (B<setitimer>(2)) and POSIX timers (B<timer_create>(2))"
7352 #: build/C/man7/pthreads.7:73
7353 msgid "nice value (B<setpriority>(2))"
7357 #: build/C/man7/pthreads.7:76
7358 msgid "resource limits (B<setrlimit>(2))"
7362 #: build/C/man7/pthreads.7:81
7364 "measurements of the consumption of CPU time (B<times>(2)) and resources "
7369 #: build/C/man7/pthreads.7:84
7371 "As well as the stack, POSIX.1 specifies that various other attributes are "
7372 "distinct for each thread, including:"
7376 #: build/C/man7/pthreads.7:88
7377 msgid "thread ID (the I<pthread_t> data type)"
7381 #: build/C/man7/pthreads.7:91
7382 msgid "signal mask (B<pthread_sigmask>(3))"
7386 #: build/C/man7/pthreads.7:95
7387 msgid "the I<errno> variable"
7391 #: build/C/man7/pthreads.7:98
7392 msgid "alternate signal stack (B<sigaltstack>(2))"
7396 #: build/C/man7/pthreads.7:101
7397 msgid "real-time scheduling policy and priority (B<sched>(7))"
7401 #: build/C/man7/pthreads.7:103
7402 msgid "The following Linux-specific features are also per-thread:"
7406 #: build/C/man7/pthreads.7:106
7407 msgid "capabilities (see B<capabilities>(7))"
7411 #: build/C/man7/pthreads.7:109
7412 msgid "CPU affinity (B<sched_setaffinity>(2))"
7416 #: build/C/man7/pthreads.7:109
7418 msgid "Pthreads function return values"
7422 #: build/C/man7/pthreads.7:116
7424 "Most pthreads functions return 0 on success, and an error number of "
7425 "failure. Note that the pthreads functions do not set I<errno>. For each of "
7426 "the pthreads functions that can return an error, POSIX.1-2001 specifies that "
7427 "the function can never fail with the error B<EINTR>."
7431 #: build/C/man7/pthreads.7:116
7437 #: build/C/man7/pthreads.7:130
7439 "Each of the threads in a process has a unique thread identifier (stored in "
7440 "the type I<pthread_t>). This identifier is returned to the caller of "
7441 "B<pthread_create>(3), and a thread can obtain its own thread identifier "
7442 "using B<pthread_self>(3). Thread IDs are guaranteed to be unique only "
7443 "within a process. A thread ID may be reused after a terminated thread has "
7444 "been joined, or a detached thread has terminated. In all pthreads functions "
7445 "that accept a thread ID as an argument, that ID by definition refers to a "
7446 "thread in the same process as the caller."
7450 #: build/C/man7/pthreads.7:130
7452 msgid "Thread-safe functions"
7456 #: build/C/man7/pthreads.7:134
7458 "A thread-safe function is one that can be safely (i.e., it will deliver the "
7459 "same results regardless of whether it is) called from multiple threads at "
7464 #: build/C/man7/pthreads.7:138
7466 "POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the "
7467 "standard shall be thread-safe, except for the following functions:"
7471 #: build/C/man7/pthreads.7:232
7478 "ctermid() if passed a non-NULL argument\n"
7492 "ecvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7497 "fcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7499 "gcvt() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7501 "getchar_unlocked()\n"
7507 "gethostbyaddr() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7508 "gethostbyname() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7515 "getprotobyname()\n"
7516 "getprotobynumber()\n"
7544 "putchar_unlocked()\n"
7555 "strsignal() [Added in POSIX.1-2008]\n"
7557 "system() [Added in POSIX.1-2008]\n"
7558 "tmpnam() if passed a non-NULL argument\n"
7561 "wcrtomb() if its final argument is NULL\n"
7562 "wcsrtombs() if its final argument is NULL\n"
7568 #: build/C/man7/pthreads.7:234
7570 msgid "Async-cancel-safe functions"
7574 #: build/C/man7/pthreads.7:238
7576 "An async-cancel-safe function is one that can be safely called in an "
7577 "application where asynchronous cancelability is enabled (see "
7578 "B<pthread_setcancelstate>(3))."
7582 #: build/C/man7/pthreads.7:241
7584 "Only the following functions are required to be async-cancel-safe by "
7585 "POSIX.1-2001 and POSIX.1-2008:"
7589 #: build/C/man7/pthreads.7:247
7592 "pthread_cancel()\n"
7593 "pthread_setcancelstate()\n"
7594 "pthread_setcanceltype()\n"
7598 #: build/C/man7/pthreads.7:249
7600 msgid "Cancellation points"
7604 #: build/C/man7/pthreads.7:256
7606 "POSIX.1 specifies that certain functions must, and certain other functions "
7607 "may, be cancellation points. If a thread is cancelable, its cancelability "
7608 "type is deferred, and a cancellation request is pending for the thread, then "
7609 "the thread is canceled when it calls a function that is a cancellation "
7614 #: build/C/man7/pthreads.7:259
7616 "The following functions are required to be cancellation points by "
7617 "POSIX.1-2001 and/or POSIX.1-2008:"
7621 #: build/C/man7/pthreads.7:322
7626 "clock_nanosleep()\n"
7630 "fcntl() F_SETLKW\n"
7638 "mq_timedreceive()\n"
7645 "openat() [Added in POSIX.1-2008]\n"
7650 "pthread_cond_timedwait()\n"
7651 "pthread_cond_wait()\n"
7653 "pthread_testcancel()\n"
7668 "sigpause() [POSIX.1-2001 only (moves to \"may\" list in POSIX.1-2008)]\n"
7676 "usleep() [POSIX.1-2001 only (function removed in POSIX.1-2008)]\n"
7685 #: build/C/man7/pthreads.7:327
7687 "The following functions may be cancellation points according to POSIX.1-2001 "
7688 "and/or POSIX.1-2008:"
7692 #: build/C/man7/pthreads.7:555
7701 "chmod() [Added in POSIX.1-2008]\n"
7702 "chown() [Added in POSIX.1-2008]\n"
7716 "dprintf() [Added in POSIX.1-2008]\n"
7724 "faccessat() [Added in POSIX.1-2008]\n"
7725 "fchmod() [Added in POSIX.1-2008]\n"
7726 "fchmodat() [Added in POSIX.1-2008]\n"
7727 "fchown() [Added in POSIX.1-2008]\n"
7728 "fchownat() [Added in POSIX.1-2008]\n"
7730 "fcntl() (for any value of cmd argument)\n"
7752 "fstatat() [Added in POSIX.1-2008]\n"
7756 "futimens() [Added in POSIX.1-2008]\n"
7764 "getchar_unlocked()\n"
7767 "getdelim() [Added in POSIX.1-2008]\n"
7773 "gethostbyaddr() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7774 "gethostbyname() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7778 "getline() [Added in POSIX.1-2008]\n"
7785 "getopt() (if opterr is nonzero)\n"
7786 "getprotobyname()\n"
7787 "getprotobynumber()\n"
7803 "getwd() [SUSv3 only (function removed in POSIX.1-2008)]\n"
7809 "linkat() [Added in POSIX.1-2008]\n"
7810 "lio_listio() [Added in POSIX.1-2008]\n"
7813 "lockf() [Added in POSIX.1-2008]\n"
7816 "mkdir() [Added in POSIX.1-2008]\n"
7817 "mkdirat() [Added in POSIX.1-2008]\n"
7818 "mkdtemp() [Added in POSIX.1-2008]\n"
7819 "mkfifo() [Added in POSIX.1-2008]\n"
7820 "mkfifoat() [Added in POSIX.1-2008]\n"
7821 "mknod() [Added in POSIX.1-2008]\n"
7822 "mknodat() [Added in POSIX.1-2008]\n"
7833 "posix_fallocate()\n"
7838 "posix_trace_clear()\n"
7839 "posix_trace_close()\n"
7840 "posix_trace_create()\n"
7841 "posix_trace_create_withlog()\n"
7842 "posix_trace_eventtypelist_getnext_id()\n"
7843 "posix_trace_eventtypelist_rewind()\n"
7844 "posix_trace_flush()\n"
7845 "posix_trace_get_attr()\n"
7846 "posix_trace_get_filter()\n"
7847 "posix_trace_get_status()\n"
7848 "posix_trace_getnext_event()\n"
7849 "posix_trace_open()\n"
7850 "posix_trace_rewind()\n"
7851 "posix_trace_set_filter()\n"
7852 "posix_trace_shutdown()\n"
7853 "posix_trace_timedgetnext_event()\n"
7854 "posix_typed_mem_open()\n"
7856 "psiginfo() [Added in POSIX.1-2008]\n"
7857 "psignal() [Added in POSIX.1-2008]\n"
7858 "pthread_rwlock_rdlock()\n"
7859 "pthread_rwlock_timedrdlock()\n"
7860 "pthread_rwlock_timedwrlock()\n"
7861 "pthread_rwlock_wrlock()\n"
7865 "putchar_unlocked()\n"
7872 "readlink() [Added in POSIX.1-2008]\n"
7873 "readlinkat() [Added in POSIX.1-2008]\n"
7876 "renameat() [Added in POSIX.1-2008]\n"
7879 "scandir() [Added in POSIX.1-2008]\n"
7890 "sigpause() [Added in POSIX.1-2008]\n"
7896 "symlinkat() [Added in POSIX.1-2008]\n"
7907 "unlinkat() [Added in POSIX.1-2008]\n"
7908 "utime() [Added in POSIX.1-2008]\n"
7909 "utimensat() [Added in POSIX.1-2008]\n"
7910 "utimes() [Added in POSIX.1-2008]\n"
7911 "vdprintf() [Added in POSIX.1-2008]\n"
7922 #. So, scanning "cancellation point" comments in the glibc 2.8 header
7923 #. files, it looks as though at least the following nonstandard
7924 #. functions are cancellation points:
7964 #. getprotobynumber_r
7979 #. getwchar_unlocked
7986 #. pthread_timedjoin_np
7992 #. putwchar_unlocked
8013 #: build/C/man7/pthreads.7:653
8015 "An implementation may also mark other functions not specified in the "
8016 "standard as cancellation points. In particular, an implementation is likely "
8017 "to mark any nonstandard function that may block as a cancellation point. "
8018 "(This includes most functions that can touch files.)"
8022 #: build/C/man7/pthreads.7:653
8024 msgid "Compiling on Linux"
8028 #: build/C/man7/pthreads.7:656
8030 "On Linux, programs that use the Pthreads API should be compiled using I<cc "
8035 #: build/C/man7/pthreads.7:656
8037 msgid "Linux implementations of POSIX threads"
8041 #: build/C/man7/pthreads.7:659
8043 "Over time, two threading implementations have been provided by the GNU C "
8048 #: build/C/man7/pthreads.7:659
8050 msgid "B<LinuxThreads>"
8054 #: build/C/man7/pthreads.7:663
8056 "This is the original Pthreads implementation. Since glibc 2.4, this "
8057 "implementation is no longer supported."
8061 #: build/C/man7/pthreads.7:663
8063 msgid "B<NPTL> (Native POSIX Threads Library)"
8067 #: build/C/man7/pthreads.7:671
8069 "This is the modern Pthreads implementation. By comparison with "
8070 "LinuxThreads, NPTL provides closer conformance to the requirements of the "
8071 "POSIX.1 specification and better performance when creating large numbers of "
8072 "threads. NPTL is available since glibc 2.3.2, and requires features that "
8073 "are present in the Linux 2.6 kernel."
8077 #: build/C/man7/pthreads.7:681
8079 "Both of these are so-called 1:1 implementations, meaning that each thread "
8080 "maps to a kernel scheduling entity. Both threading implementations employ "
8081 "the Linux B<clone>(2) system call. In NPTL, thread synchronization "
8082 "primitives (mutexes, thread joining, and so on) are implemented using the "
8083 "Linux B<futex>(2) system call."
8087 #: build/C/man7/pthreads.7:681
8089 msgid "LinuxThreads"
8093 #: build/C/man7/pthreads.7:683
8094 msgid "The notable features of this implementation are the following:"
8098 #: build/C/man7/pthreads.7:690
8100 "In addition to the main (initial) thread, and the threads that the program "
8101 "creates using B<pthread_create>(3), the implementation creates a \"manager\" "
8102 "thread. This thread handles thread creation and termination. (Problems can "
8103 "result if this thread is inadvertently killed.)"
8107 #: build/C/man7/pthreads.7:702
8109 "Signals are used internally by the implementation. On Linux 2.2 and later, "
8110 "the first three real-time signals are used (see also B<signal>(7)). On "
8111 "older Linux kernels, B<SIGUSR1> and B<SIGUSR2> are used. Applications must "
8112 "avoid the use of whichever set of signals is employed by the implementation."
8116 #: build/C/man7/pthreads.7:709
8118 "Threads do not share process IDs. (In effect, LinuxThreads threads are "
8119 "implemented as processes which share more information than usual, but which "
8120 "do not share a common process ID.) LinuxThreads threads (including the "
8121 "manager thread) are visible as separate processes using B<ps>(1)."
8125 #: build/C/man7/pthreads.7:712
8127 "The LinuxThreads implementation deviates from the POSIX.1 specification in a "
8128 "number of ways, including the following:"
8132 #: build/C/man7/pthreads.7:716
8133 msgid "Calls to B<getpid>(2) return a different value in each thread."
8137 #: build/C/man7/pthreads.7:725
8139 "Calls to B<getppid>(2) in threads other than the main thread return the "
8140 "process ID of the manager thread; instead B<getppid>(2) in these threads "
8141 "should return the same value as B<getppid>(2) in the main thread."
8145 #: build/C/man7/pthreads.7:735
8147 "When one thread creates a new child process using B<fork>(2), any thread "
8148 "should be able to B<wait>(2) on the child. However, the implementation "
8149 "only allows the thread that created the child to B<wait>(2) on it."
8153 #: build/C/man7/pthreads.7:742
8155 "When a thread calls B<execve>(2), all other threads are terminated (as "
8156 "required by POSIX.1). However, the resulting process has the same PID as "
8157 "the thread that called B<execve>(2): it should have the same PID as the main "
8162 #: build/C/man7/pthreads.7:749
8164 "Threads do not share user and group IDs. This can cause complications with "
8165 "set-user-ID programs and can cause failures in Pthreads functions if an "
8166 "application changes its credentials using B<seteuid>(2) or similar."
8170 #: build/C/man7/pthreads.7:751
8171 msgid "Threads do not share a common session ID and process group ID."
8175 #: build/C/man7/pthreads.7:754
8176 msgid "Threads do not share record locks created using B<fcntl>(2)."
8180 #: build/C/man7/pthreads.7:760
8182 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
8183 "rather than process-wide."
8187 #: build/C/man7/pthreads.7:763
8188 msgid "Threads do not share semaphore undo values (see B<semop>(2))."
8192 #: build/C/man7/pthreads.7:765
8193 msgid "Threads do not share interval timers."
8196 #. FIXME . bug report filed for NPTL nice nonconformance
8197 #. http://bugzilla.kernel.org/show_bug.cgi?id=6258
8198 #. Sep 08: there is a patch by Denys Vlasenko to address this
8199 #. "make setpriority POSIX compliant; introduce PRIO_THREAD extension"
8200 #. Monitor this to see if it makes it into mainline.
8202 #: build/C/man7/pthreads.7:767 build/C/man7/pthreads.7:804
8203 msgid "Threads do not share a common nice value."
8207 #: build/C/man7/pthreads.7:777
8209 "POSIX.1 distinguishes the notions of signals that are directed to the "
8210 "process as a whole and signals that are directed to individual threads. "
8211 "According to POSIX.1, a process-directed signal (sent using B<kill>(2), for "
8212 "example) should be handled by a single, arbitrarily selected thread within "
8213 "the process. LinuxThreads does not support the notion of process-directed "
8214 "signals: signals may be sent only to specific threads."
8218 #: build/C/man7/pthreads.7:786
8220 "Threads have distinct alternate signal stack settings. However, a new "
8221 "thread's alternate signal stack settings are copied from the thread that "
8222 "created it, so that the threads initially share an alternate signal stack. "
8223 "(A new thread should start with no alternate signal stack defined. If two "
8224 "threads handle signals on their shared alternate signal stack at the same "
8225 "time, unpredictable program failures are likely to occur.)"
8229 #: build/C/man7/pthreads.7:786
8235 #: build/C/man7/pthreads.7:795
8237 "With NPTL, all of the threads in a process are placed in the same thread "
8238 "group; all members of a thread group share the same PID. NPTL does not "
8239 "employ a manager thread. NPTL makes internal use of the first two real-time "
8240 "signals (see also B<signal>(7)); these signals cannot be used in "
8245 #: build/C/man7/pthreads.7:797
8246 msgid "NPTL still has at least one nonconformance with POSIX.1:"
8250 #: build/C/man7/pthreads.7:806
8251 msgid "Some NPTL nonconformances occur only with older kernels:"
8255 #: build/C/man7/pthreads.7:812
8257 "The information returned by B<times>(2) and B<getrusage>(2) is per-thread "
8258 "rather than process-wide (fixed in kernel 2.6.9)."
8262 #: build/C/man7/pthreads.7:814
8263 msgid "Threads do not share resource limits (fixed in kernel 2.6.10)."
8267 #: build/C/man7/pthreads.7:816
8268 msgid "Threads do not share interval timers (fixed in kernel 2.6.12)."
8272 #: build/C/man7/pthreads.7:820
8274 "Only the main thread is permitted to start a new session using B<setsid>(2) "
8275 "(fixed in kernel 2.6.16)."
8279 #: build/C/man7/pthreads.7:825
8281 "Only the main thread is permitted to make the process into a process group "
8282 "leader using B<setpgid>(2) (fixed in kernel 2.6.16)."
8286 #: build/C/man7/pthreads.7:831
8288 "Threads have distinct alternate signal stack settings. However, a new "
8289 "thread's alternate signal stack settings are copied from the thread that "
8290 "created it, so that the threads initially share an alternate signal stack "
8291 "(fixed in kernel 2.6.16)."
8295 #: build/C/man7/pthreads.7:833
8296 msgid "Note the following further points about the NPTL implementation:"
8300 #: build/C/man7/pthreads.7:847
8302 "If the stack size soft resource limit (see the description of "
8303 "B<RLIMIT_STACK> in B<setrlimit>(2)) is set to a value other than "
8304 "I<unlimited>, then this value defines the default stack size for new "
8305 "threads. To be effective, this limit must be set before the program is "
8306 "executed, perhaps using the I<ulimit -s> shell built-in command (I<limit "
8307 "stacksize> in the C shell)."
8311 #: build/C/man7/pthreads.7:847
8313 msgid "Determining the threading implementation"
8317 #: build/C/man7/pthreads.7:852
8319 "Since glibc 2.3.2, the B<getconf>(1) command can be used to determine the "
8320 "system's threading implementation, for example:"
8324 #: build/C/man7/pthreads.7:857
8327 "bash$ getconf GNU_LIBPTHREAD_VERSION\n"
8332 #: build/C/man7/pthreads.7:862
8334 "With older glibc versions, a command such as the following should be "
8335 "sufficient to determine the default threading implementation:"
8339 #: build/C/man7/pthreads.7:868
8342 "bash$ $( ldd /bin/ls | grep libc.so | awk \\(aq{print $3}\\(aq ) | \\e\n"
8343 " egrep -i \\(aqthreads|nptl\\(aq\n"
8344 " Native POSIX Threads Library by Ulrich Drepper et al\n"
8348 #: build/C/man7/pthreads.7:870
8350 msgid "Selecting the threading implementation: LD_ASSUME_KERNEL"
8354 #: build/C/man7/pthreads.7:885
8356 "On systems with a glibc that supports both LinuxThreads and NPTL (i.e., "
8357 "glibc 2.3.I<x>), the B<LD_ASSUME_KERNEL> environment variable can be used to "
8358 "override the dynamic linker's default choice of threading implementation. "
8359 "This variable tells the dynamic linker to assume that it is running on top "
8360 "of a particular kernel version. By specifying a kernel version that does "
8361 "not provide the support required by NPTL, we can force the use of "
8362 "LinuxThreads. (The most likely reason for doing this is to run a (broken) "
8363 "application that depends on some nonconformant behavior in LinuxThreads.) "
8368 #: build/C/man7/pthreads.7:891
8371 "bash$ $( LD_ASSUME_KERNEL=2.2.5 ldd /bin/ls | grep libc.so | \\e\n"
8372 " awk \\(aq{print $3}\\(aq ) | egrep -i "
8373 "\\(aqthreads|nptl\\(aq\n"
8374 " linuxthreads-0.10 by Xavier Leroy\n"
8378 #: build/C/man7/pthreads.7:903
8380 "B<clone>(2), B<futex>(2), B<gettid>(2), B<proc>(5), B<futex>(7), "
8381 "B<sigevent>(7), B<signal>(7),"
8385 #: build/C/man7/pthreads.7:926
8387 "Various Pthreads manual pages, for example: B<pthread_attr_init>(3), "
8388 "B<pthread_atfork>(3), B<pthread_cancel>(3), B<pthread_cleanup_push>(3), "
8389 "B<pthread_cond_signal>(3), B<pthread_cond_wait>(3), B<pthread_create>(3), "
8390 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
8391 "B<pthread_key_create>(3), B<pthread_kill>(3), B<pthread_mutex_lock>(3), "
8392 "B<pthread_mutex_unlock>(3), B<pthread_once>(3), "
8393 "B<pthread_setcancelstate>(3), B<pthread_setcanceltype>(3), "
8394 "B<pthread_setspecific>(3), B<pthread_sigmask>(3), B<pthread_sigqueue>(3), "
8395 "and B<pthread_testcancel>(3)"