Debian Codegraph @

templates/man3/pthread_attr_init.3.pot

raw
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.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:38+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "pthread_attr_init"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2025-09-21"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid ""
50 "pthread_attr_init, pthread_attr_destroy - initialize and destroy thread "
51 "attributes object"
52 msgstr ""
53
54 #. type: SH
55 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
56 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
57 #, no-wrap
58 msgid "LIBRARY"
59 msgstr ""
60
61 #. type: Plain text
62 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
63 #: opensuse-leap-16-1 opensuse-tumbleweed
64 msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)"
65 msgstr ""
66
67 #. type: SH
68 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
69 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
70 #, no-wrap
71 msgid "SYNOPSIS"
72 msgstr ""
73
74 #. type: Plain text
75 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
76 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
77 #, no-wrap
78 msgid "B<#include E<lt>pthread.hE<gt>>\n"
79 msgstr ""
80
81 #. type: Plain text
82 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
83 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
84 #, no-wrap
85 msgid ""
86 "B<int pthread_attr_init(pthread_attr_t *>I<attr>B<);>\n"
87 "B<int pthread_attr_destroy(pthread_attr_t *>I<attr>B<);>\n"
88 msgstr ""
89
90 #. type: SH
91 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
92 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
93 #, no-wrap
94 msgid "DESCRIPTION"
95 msgstr ""
96
97 #. type: Plain text
98 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
99 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
100 msgid ""
101 "The B<pthread_attr_init>() function initializes the thread attributes "
102 "object pointed to by I<attr> with default attribute values. After this "
103 "call, individual attributes of the object can be set using various related "
104 "functions (listed under SEE ALSO), and then the object can be used in one or "
105 "more B<pthread_create>(3) calls that create threads."
106 msgstr ""
107
108 #. type: Plain text
109 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
110 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
111 msgid ""
112 "Calling B<pthread_attr_init>() on a thread attributes object that has "
113 "already been initialized results in undefined behavior."
114 msgstr ""
115
116 #. type: Plain text
117 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
118 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
119 msgid ""
120 "When a thread attributes object is no longer required, it should be "
121 "destroyed using the B<pthread_attr_destroy>() function. Destroying a "
122 "thread attributes object has no effect on threads that were created using "
123 "that object."
124 msgstr ""
125
126 #. type: Plain text
127 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
128 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
129 msgid ""
130 "Once a thread attributes object has been destroyed, it can be reinitialized "
131 "using B<pthread_attr_init>(). Any other use of a destroyed thread "
132 "attributes object has undefined results."
133 msgstr ""
134
135 #. type: SH
136 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
137 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
138 #, no-wrap
139 msgid "RETURN VALUE"
140 msgstr ""
141
142 #. type: Plain text
143 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
144 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
145 msgid ""
146 "On success, these functions return 0; on error, they return a nonzero error "
147 "number."
148 msgstr ""
149
150 #. type: SH
151 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
152 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
153 #, no-wrap
154 msgid "ERRORS"
155 msgstr ""
156
157 #. type: Plain text
158 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
159 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
160 msgid ""
161 "POSIX.1 documents an B<ENOMEM> error for B<pthread_attr_init>(); on Linux "
162 "these functions always succeed (but portable and future-proof applications "
163 "should nevertheless handle a possible error return)."
164 msgstr ""
165
166 #. type: SH
167 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
168 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
169 #, no-wrap
170 msgid "ATTRIBUTES"
171 msgstr ""
172
173 #. type: Plain text
174 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
175 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
176 msgid ""
177 "For an explanation of the terms used in this section, see B<attributes>(7)."
178 msgstr ""
179
180 #. type: tbl table
181 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
182 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
183 #, no-wrap
184 msgid "Interface"
185 msgstr ""
186
187 #. type: tbl table
188 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
189 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
190 #, no-wrap
191 msgid "Attribute"
192 msgstr ""
193
194 #. type: tbl table
195 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
196 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
197 #, no-wrap
198 msgid "Value"
199 msgstr ""
200
201 #. type: tbl table
202 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
203 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
204 #, no-wrap
205 msgid ".na\n"
206 msgstr ""
207
208 #. type: tbl table
209 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
210 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
211 #, no-wrap
212 msgid ".nh\n"
213 msgstr ""
214
215 #. type: tbl table
216 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
217 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
218 #, no-wrap
219 msgid ""
220 "B<pthread_attr_init>(),\n"
221 "B<pthread_attr_destroy>()"
222 msgstr ""
223
224 #. type: tbl table
225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
227 #, no-wrap
228 msgid "Thread safety"
229 msgstr ""
230
231 #. type: tbl table
232 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
233 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
234 #, no-wrap
235 msgid "MT-Safe"
236 msgstr ""
237
238 #. type: SH
239 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
240 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
241 #, no-wrap
242 msgid "STANDARDS"
243 msgstr ""
244
245 #. type: Plain text
246 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
247 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
248 msgid "POSIX.1-2008."
249 msgstr ""
250
251 #. type: SH
252 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
253 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
254 #, no-wrap
255 msgid "HISTORY"
256 msgstr ""
257
258 #. type: Plain text
259 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
260 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
261 msgid "POSIX.1-2001."
262 msgstr ""
263
264 #. type: SH
265 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
266 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
267 #, no-wrap
268 msgid "NOTES"
269 msgstr ""
270
271 #. type: Plain text
272 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
273 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
274 msgid ""
275 "The I<pthread_attr_t> type should be treated as opaque: any access to the "
276 "object other than via pthreads functions is nonportable and produces "
277 "undefined results."
278 msgstr ""
279
280 #. type: SH
281 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
282 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
283 #, no-wrap
284 msgid "EXAMPLES"
285 msgstr ""
286
287 #. type: Plain text
288 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
289 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
290 msgid ""
291 "The program below optionally makes use of B<pthread_attr_init>() and "
292 "various related functions to initialize a thread attributes object that is "
293 "used to create a single thread. Once created, the thread uses the "
294 "B<pthread_getattr_np>(3) function (a nonstandard GNU extension) to retrieve "
295 "the thread's attributes, and then displays those attributes."
296 msgstr ""
297
298 #. type: Plain text
299 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
300 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
301 msgid ""
302 "If the program is run with no command-line argument, then it passes NULL as "
303 "the I<attr> argument of B<pthread_create>(3), so that the thread is created "
304 "with default attributes. Running the program on Linux/x86-32 with the NPTL "
305 "threading implementation, we see the following:"
306 msgstr ""
307
308 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
309 #. type: Plain text
310 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
311 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
312 #, no-wrap
313 msgid ""
314 "$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2 MB\n"
315 "unlimited\n"
316 "$B< ./a.out>\n"
317 "Thread attributes:\n"
318 " Detach state = PTHREAD_CREATE_JOINABLE\n"
319 " Scope = PTHREAD_SCOPE_SYSTEM\n"
320 " Inherit scheduler = PTHREAD_INHERIT_SCHED\n"
321 " Scheduling policy = SCHED_OTHER\n"
322 " Scheduling priority = 0\n"
323 " Guard size = 4096 bytes\n"
324 " Stack address = 0x40196000\n"
325 " Stack size = 0x201000 bytes\n"
326 msgstr ""
327
328 #. type: Plain text
329 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
330 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
331 msgid ""
332 "When we supply a stack size as a command-line argument, the program "
333 "initializes a thread attributes object, sets various attributes in that "
334 "object, and passes a pointer to the object in the call to "
335 "B<pthread_create>(3). Running the program on Linux/x86-32 with the NPTL "
336 "threading implementation, we see the following:"
337 msgstr ""
338
339 #. Results from glibc 2.8, SUSE 11.0; Oct 2008
340 #. type: Plain text
341 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
342 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
343 #, no-wrap
344 msgid ""
345 "$B< ./a.out 0x3000000>\n"
346 "posix_memalign() allocated at 0x40197000\n"
347 "Thread attributes:\n"
348 " Detach state = PTHREAD_CREATE_DETACHED\n"
349 " Scope = PTHREAD_SCOPE_SYSTEM\n"
350 " Inherit scheduler = PTHREAD_EXPLICIT_SCHED\n"
351 " Scheduling policy = SCHED_OTHER\n"
352 " Scheduling priority = 0\n"
353 " Guard size = 0 bytes\n"
354 " Stack address = 0x40197000\n"
355 " Stack size = 0x3000000 bytes\n"
356 msgstr ""
357
358 #. type: SS
359 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
360 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
361 #, no-wrap
362 msgid "Program source"
363 msgstr ""
364
365 #. type: Plain text
366 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
367 #: opensuse-tumbleweed
368 #, no-wrap
369 msgid ""
370 "#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n"
371 "#include E<lt>err.hE<gt>\n"
372 "#include E<lt>errno.hE<gt>\n"
373 "#include E<lt>pthread.hE<gt>\n"
374 "#include E<lt>stdio.hE<gt>\n"
375 "#include E<lt>stdlib.hE<gt>\n"
376 "#include E<lt>unistd.hE<gt>\n"
377 "\\&\n"
378 "static void\n"
379 "display_pthread_attr(pthread_attr_t *attr, char *prefix)\n"
380 "{\n"
381 " int s, i;\n"
382 " size_t v;\n"
383 " void *stkaddr;\n"
384 " struct sched_param sp;\n"
385 "\\&\n"
386 " s = pthread_attr_getdetachstate(attr, &i);\n"
387 " if (s != 0)\n"
388 " errc(EXIT_FAILURE, s, \"pthread_attr_getdetachstate\");\n"
389 " printf(\"%sDetach state = %s\\[rs]n\", prefix,\n"
390 " (i == PTHREAD_CREATE_DETACHED) ? \"PTHREAD_CREATE_DETACHED\" :\n"
391 " (i == PTHREAD_CREATE_JOINABLE) ? \"PTHREAD_CREATE_JOINABLE\" :\n"
392 " \"???\");\n"
393 "\\&\n"
394 " s = pthread_attr_getscope(attr, &i);\n"
395 " if (s != 0)\n"
396 " errc(EXIT_FAILURE, s, \"pthread_attr_getscope\");\n"
397 " printf(\"%sScope = %s\\[rs]n\", prefix,\n"
398 " (i == PTHREAD_SCOPE_SYSTEM) ? \"PTHREAD_SCOPE_SYSTEM\" :\n"
399 " (i == PTHREAD_SCOPE_PROCESS) ? \"PTHREAD_SCOPE_PROCESS\" :\n"
400 " \"???\");\n"
401 "\\&\n"
402 " s = pthread_attr_getinheritsched(attr, &i);\n"
403 " if (s != 0)\n"
404 " errc(EXIT_FAILURE, s, \"pthread_attr_getinheritsched\");\n"
405 " printf(\"%sInherit scheduler = %s\\[rs]n\", prefix,\n"
406 " (i == PTHREAD_INHERIT_SCHED) ? \"PTHREAD_INHERIT_SCHED\" :\n"
407 " (i == PTHREAD_EXPLICIT_SCHED) ? \"PTHREAD_EXPLICIT_SCHED\" :\n"
408 " \"???\");\n"
409 "\\&\n"
410 " s = pthread_attr_getschedpolicy(attr, &i);\n"
411 " if (s != 0)\n"
412 " errc(EXIT_FAILURE, s, \"pthread_attr_getschedpolicy\");\n"
413 " printf(\"%sScheduling policy = %s\\[rs]n\", prefix,\n"
414 " (i == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
415 " (i == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
416 " (i == SCHED_RR) ? \"SCHED_RR\" :\n"
417 " \"???\");\n"
418 "\\&\n"
419 " s = pthread_attr_getschedparam(attr, &sp);\n"
420 " if (s != 0)\n"
421 " errc(EXIT_FAILURE, s, \"pthread_attr_getschedparam\");\n"
422 " printf(\"%sScheduling priority = %d\\[rs]n\", prefix, sp.sched_priority);\n"
423 "\\&\n"
424 " s = pthread_attr_getguardsize(attr, &v);\n"
425 " if (s != 0)\n"
426 " errc(EXIT_FAILURE, s, \"pthread_attr_getguardsize\");\n"
427 " printf(\"%sGuard size = %zu bytes\\[rs]n\", prefix, v);\n"
428 "\\&\n"
429 " s = pthread_attr_getstack(attr, &stkaddr, &v);\n"
430 " if (s != 0)\n"
431 " errc(EXIT_FAILURE, s, \"pthread_attr_getstack\");\n"
432 " printf(\"%sStack address = %p\\[rs]n\", prefix, stkaddr);\n"
433 " printf(\"%sStack size = %#zx bytes\\[rs]n\", prefix, v);\n"
434 "}\n"
435 "\\&\n"
436 "static void *\n"
437 "thread_start(void *arg)\n"
438 "{\n"
439 " int s;\n"
440 " pthread_attr_t gattr;\n"
441 "\\&\n"
442 " /* pthread_getattr_np() is a non-standard GNU extension that\n"
443 " retrieves the attributes of the thread specified in its\n"
444 " first argument. */\n"
445 "\\&\n"
446 " s = pthread_getattr_np(pthread_self(), &gattr);\n"
447 " if (s != 0)\n"
448 " errc(EXIT_FAILURE, s, \"pthread_getattr_np\");\n"
449 "\\&\n"
450 " printf(\"Thread attributes:\\[rs]n\");\n"
451 " display_pthread_attr(&gattr, \"\\[rs]t\");\n"
452 "\\&\n"
453 " exit(EXIT_SUCCESS); /* Terminate all threads */\n"
454 "}\n"
455 "\\&\n"
456 "int\n"
457 "main(int argc, char *argv[])\n"
458 "{\n"
459 " pthread_t thr;\n"
460 " pthread_attr_t attr;\n"
461 " pthread_attr_t *attrp; /* NULL or &attr */\n"
462 " int s;\n"
463 "\\&\n"
464 " attrp = NULL;\n"
465 "\\&\n"
466 " /* If a command-line argument was supplied, use it to set the\n"
467 " stack-size attribute and set a few other thread attributes,\n"
468 " and set attrp pointing to thread attributes object. */\n"
469 "\\&\n"
470 " if (argc E<gt> 1) {\n"
471 " size_t stack_size;\n"
472 " void *sp;\n"
473 "\\&\n"
474 " attrp = &attr;\n"
475 "\\&\n"
476 " s = pthread_attr_init(&attr);\n"
477 " if (s != 0)\n"
478 " errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n"
479 "\\&\n"
480 " s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n"
481 " if (s != 0)\n"
482 " errc(EXIT_FAILURE, s, \"pthread_attr_setdetachstate\");\n"
483 "\\&\n"
484 " s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n"
485 " if (s != 0)\n"
486 " errc(EXIT_FAILURE, s, \"pthread_attr_setinheritsched\");\n"
487 "\\&\n"
488 " stack_size = strtoul(argv[1], NULL, 0);\n"
489 "\\&\n"
490 " s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);\n"
491 " if (s != 0)\n"
492 " errc(EXIT_FAILURE, s, \"posix_memalign\");\n"
493 "\\&\n"
494 " printf(\"posix_memalign() allocated at %p\\[rs]n\", sp);\n"
495 "\\&\n"
496 " s = pthread_attr_setstack(&attr, sp, stack_size);\n"
497 " if (s != 0)\n"
498 " errc(EXIT_FAILURE, s, \"pthread_attr_setstack\");\n"
499 " }\n"
500 "\\&\n"
501 " s = pthread_create(&thr, attrp, &thread_start, NULL);\n"
502 " if (s != 0)\n"
503 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
504 "\\&\n"
505 " if (attrp != NULL) {\n"
506 " s = pthread_attr_destroy(attrp);\n"
507 " if (s != 0)\n"
508 " errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n"
509 " }\n"
510 "\\&\n"
511 " pause(); /* Terminates when other thread calls exit() */\n"
512 "}\n"
513 msgstr ""
514
515 #. SRC END
516 #. type: SH
517 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
518 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
519 #, no-wrap
520 msgid "SEE ALSO"
521 msgstr ""
522
523 #. type: Plain text
524 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
525 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
526 msgid ""
527 "B<pthread_attr_setaffinity_np>(3), B<pthread_attr_setdetachstate>(3), "
528 "B<pthread_attr_setguardsize>(3), B<pthread_attr_setinheritsched>(3), "
529 "B<pthread_attr_setschedparam>(3), B<pthread_attr_setschedpolicy>(3), "
530 "B<pthread_attr_setscope>(3), B<pthread_attr_setsigmask_np>(3), "
531 "B<pthread_attr_setstack>(3), B<pthread_attr_setstackaddr>(3), "
532 "B<pthread_attr_setstacksize>(3), B<pthread_create>(3), "
533 "B<pthread_getattr_np>(3), B<pthread_setattr_default_np>(3), B<pthreads>(7)"
534 msgstr ""
535
536 #. type: TH
537 #: debian-trixie
538 #, no-wrap
539 msgid "2024-06-15"
540 msgstr ""
541
542 #. type: TH
543 #: debian-trixie
544 #, no-wrap
545 msgid "Linux man-pages 6.9.1"
546 msgstr ""
547
548 #. type: Plain text
549 #: debian-trixie
550 msgid "POSIX threads library (I<libpthread>, I<-lpthread>)"
551 msgstr ""
552
553 #. type: Plain text
554 #: debian-trixie fedora-44 fedora-rawhide
555 #, no-wrap
556 msgid ""
557 "#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n"
558 "#include E<lt>err.hE<gt>\n"
559 "#include E<lt>errno.hE<gt>\n"
560 "#include E<lt>pthread.hE<gt>\n"
561 "#include E<lt>stdio.hE<gt>\n"
562 "#include E<lt>stdlib.hE<gt>\n"
563 "#include E<lt>unistd.hE<gt>\n"
564 "\\&\n"
565 "static void\n"
566 "display_pthread_attr(pthread_attr_t *attr, char *prefix)\n"
567 "{\n"
568 " int s, i;\n"
569 " size_t v;\n"
570 " void *stkaddr;\n"
571 " struct sched_param sp;\n"
572 "\\&\n"
573 " s = pthread_attr_getdetachstate(attr, &i);\n"
574 " if (s != 0)\n"
575 " errc(EXIT_FAILURE, s, \"pthread_attr_getdetachstate\");\n"
576 " printf(\"%sDetach state = %s\\[rs]n\", prefix,\n"
577 " (i == PTHREAD_CREATE_DETACHED) ? \"PTHREAD_CREATE_DETACHED\" :\n"
578 " (i == PTHREAD_CREATE_JOINABLE) ? \"PTHREAD_CREATE_JOINABLE\" :\n"
579 " \"???\");\n"
580 "\\&\n"
581 " s = pthread_attr_getscope(attr, &i);\n"
582 " if (s != 0)\n"
583 " errc(EXIT_FAILURE, s, \"pthread_attr_getscope\");\n"
584 " printf(\"%sScope = %s\\[rs]n\", prefix,\n"
585 " (i == PTHREAD_SCOPE_SYSTEM) ? \"PTHREAD_SCOPE_SYSTEM\" :\n"
586 " (i == PTHREAD_SCOPE_PROCESS) ? \"PTHREAD_SCOPE_PROCESS\" :\n"
587 " \"???\");\n"
588 "\\&\n"
589 " s = pthread_attr_getinheritsched(attr, &i);\n"
590 " if (s != 0)\n"
591 " errc(EXIT_FAILURE, s, \"pthread_attr_getinheritsched\");\n"
592 " printf(\"%sInherit scheduler = %s\\[rs]n\", prefix,\n"
593 " (i == PTHREAD_INHERIT_SCHED) ? \"PTHREAD_INHERIT_SCHED\" :\n"
594 " (i == PTHREAD_EXPLICIT_SCHED) ? \"PTHREAD_EXPLICIT_SCHED\" :\n"
595 " \"???\");\n"
596 "\\&\n"
597 " s = pthread_attr_getschedpolicy(attr, &i);\n"
598 " if (s != 0)\n"
599 " errc(EXIT_FAILURE, s, \"pthread_attr_getschedpolicy\");\n"
600 " printf(\"%sScheduling policy = %s\\[rs]n\", prefix,\n"
601 " (i == SCHED_OTHER) ? \"SCHED_OTHER\" :\n"
602 " (i == SCHED_FIFO) ? \"SCHED_FIFO\" :\n"
603 " (i == SCHED_RR) ? \"SCHED_RR\" :\n"
604 " \"???\");\n"
605 "\\&\n"
606 " s = pthread_attr_getschedparam(attr, &sp);\n"
607 " if (s != 0)\n"
608 " errc(EXIT_FAILURE, s, \"pthread_attr_getschedparam\");\n"
609 " printf(\"%sScheduling priority = %d\\[rs]n\", prefix, sp.sched_priority);\n"
610 "\\&\n"
611 " s = pthread_attr_getguardsize(attr, &v);\n"
612 " if (s != 0)\n"
613 " errc(EXIT_FAILURE, s, \"pthread_attr_getguardsize\");\n"
614 " printf(\"%sGuard size = %zu bytes\\[rs]n\", prefix, v);\n"
615 "\\&\n"
616 " s = pthread_attr_getstack(attr, &stkaddr, &v);\n"
617 " if (s != 0)\n"
618 " errc(EXIT_FAILURE, s, \"pthread_attr_getstack\");\n"
619 " printf(\"%sStack address = %p\\[rs]n\", prefix, stkaddr);\n"
620 " printf(\"%sStack size = %#zx bytes\\[rs]n\", prefix, v);\n"
621 "}\n"
622 "\\&\n"
623 "static void *\n"
624 "thread_start(void *arg)\n"
625 "{\n"
626 " int s;\n"
627 " pthread_attr_t gattr;\n"
628 "\\&\n"
629 " /* pthread_getattr_np() is a non-standard GNU extension that\n"
630 " retrieves the attributes of the thread specified in its\n"
631 " first argument. */\n"
632 "\\&\n"
633 " s = pthread_getattr_np(pthread_self(), &gattr);\n"
634 " if (s != 0)\n"
635 " errc(EXIT_FAILURE, s, \"pthread_getattr_np\");\n"
636 "\\&\n"
637 " printf(\"Thread attributes:\\[rs]n\");\n"
638 " display_pthread_attr(&gattr, \"\\[rs]t\");\n"
639 "\\&\n"
640 " exit(EXIT_SUCCESS); /* Terminate all threads */\n"
641 "}\n"
642 "\\&\n"
643 "int\n"
644 "main(int argc, char *argv[])\n"
645 "{\n"
646 " pthread_t thr;\n"
647 " pthread_attr_t attr;\n"
648 " pthread_attr_t *attrp; /* NULL or &attr */\n"
649 " int s;\n"
650 "\\&\n"
651 " attrp = NULL;\n"
652 "\\&\n"
653 " /* If a command-line argument was supplied, use it to set the\n"
654 " stack-size attribute and set a few other thread attributes,\n"
655 " and set attrp pointing to thread attributes object. */\n"
656 "\\&\n"
657 " if (argc E<gt> 1) {\n"
658 " size_t stack_size;\n"
659 " void *sp;\n"
660 "\\&\n"
661 " attrp = &attr;\n"
662 "\\&\n"
663 " s = pthread_attr_init(&attr);\n"
664 " if (s != 0)\n"
665 " errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n"
666 "\\&\n"
667 " s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n"
668 " if (s != 0)\n"
669 " errc(EXIT_FAILURE, s, \"pthread_attr_setdetachstate\");\n"
670 "\\&\n"
671 " s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n"
672 " if (s != 0)\n"
673 " errc(EXIT_FAILURE, s, \"pthread_attr_setinheritsched\");\n"
674 "\\&\n"
675 " stack_size = strtoul(argv[1], NULL, 0);\n"
676 "\\&\n"
677 " s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);\n"
678 " if (s != 0)\n"
679 " errc(EXIT_FAILURE, s, \"posix_memalign\");\n"
680 "\\&\n"
681 " printf(\"posix_memalign() allocated at %p\\[rs]n\", sp);\n"
682 "\\&\n"
683 " s = pthread_attr_setstack(&attr, sp, stack_size);\n"
684 " if (s != 0)\n"
685 " errc(EXIT_FAILURE, s, \"pthread_attr_setstack\");\n"
686 " }\n"
687 "\\&\n"
688 " s = pthread_create(&thr, attrp, &thread_start, NULL);\n"
689 " if (s != 0)\n"
690 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
691 "\\&\n"
692 " if (attrp != NULL) {\n"
693 " s = pthread_attr_destroy(attrp);\n"
694 " if (s != 0)\n"
695 " errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n"
696 " }\n"
697 "\\&\n"
698 " pause(); /* Terminates when other thread calls exit() */\n"
699 "}\n"
700 msgstr ""
701
702 #. type: TH
703 #: fedora-44 fedora-rawhide
704 #, no-wrap
705 msgid "2024-07-23"
706 msgstr ""
707
708 #. type: TH
709 #: fedora-44 fedora-rawhide
710 #, no-wrap
711 msgid "Linux man-pages 6.13"
712 msgstr ""
713
714 #. type: TH
715 #: mageia-cauldron
716 #, no-wrap
717 msgid "Linux man-pages 6.17"
718 msgstr ""
719
720 #. type: TH
721 #: opensuse-leap-16-1 opensuse-tumbleweed
722 #, no-wrap
723 msgid "Linux man-pages (unreleased)"
724 msgstr ""