1 .\" Copyright (c) 2016 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"*******************************************************************
27 .\" This file was generated with po4a. Translate the source file.
29 .\"*******************************************************************
30 .TH PTHREAD_GETATTR_DEFAULT_NP 3 2020\-06\-09 Linux "Linux Programmer's Manual"
32 pthread_getattr_default_np, pthread_setattr_default_np, \- get or set default
33 thread\-creation attributes
36 \fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */
37 \fB#include <pthread.h>\fP
39 \fBint pthread_getattr_default_np(pthread_attr_t *\fP\fIattr\fP\fB);\fP
40 \fBint pthread_setattr_default_np(pthread_attr_t *\fP\fIattr\fP\fB);\fP
42 \fI\-pthread\fP でコンパイルしてリンクする。
45 The \fBpthread_setattr_default_np\fP() function sets the default attributes
46 used for creation of a new thread\(emthat is, the attributes that are used
47 when \fBpthread_create\fP(3) is called with a second argument that is NULL.
48 The default attributes are set using the attributes supplied in \fI*attr\fP, a
49 previously initialized thread attributes object. Note the following details
50 about the supplied attributes object:
52 The attribute settings in the object must be valid.
54 The \fIstack address\fP attribute must not be set in the object.
56 Setting the \fIstack size\fP attribute to zero means leave the default stack
59 The \fBpthread_getattr_default_np\fP() function initializes the thread
60 attributes object referred to by \fIattr\fP so that it contains the default
61 attributes used for thread creation.
65 (\fBpthread_setattr_default_np\fP()) One of the attribute settings in \fIattr\fP
66 is invalid, or the stack address attribute is set in \fIattr\fP.
69 .\" Can happen (but unlikely) while trying to allocate memory for cpuset
70 (\fBpthread_setattr_default_np\fP()) Insufficient memory.
72 これらの関数は glibc バージョン 2.18 以降で利用できる。
74 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
82 \fBpthread_getattr_default_np\fP(),
83 \fBpthread_setattr_default_np\fP()
84 T} Thread safety MT\-Safe
88 これらの関数は非標準の GNU による拡張である。そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が付いている。
90 The program below uses \fBpthread_getattr_default_np\fP() to fetch the default
91 thread\-creation attributes and then displays various settings from the
92 returned thread attributes object. When running the program, we see the
100 Scheduling policy: SCHED_OTHER
101 Scheduling priority: 0
102 Detach state: JOINABLE
103 Inherit scheduler: INHERIT
115 #define errExitEN(en, msg) \e
116 do { errno = en; perror(msg); \e
117 exit(EXIT_FAILURE); } while (0)
120 display_pthread_attr(pthread_attr_t *attr)
126 struct sched_param schedparam;
130 s = pthread_attr_getstacksize(attr, &stacksize);
132 errExitEN(s, "pthread_attr_getstacksize");
133 printf("Stack size: %zd\en", stacksize);
135 s = pthread_attr_getguardsize(attr, &guardsize);
137 errExitEN(s, "pthread_attr_getguardsize");
138 printf("Guard size: %zd\en", guardsize);
140 s = pthread_attr_getschedpolicy(attr, &policy);
142 errExitEN(s, "pthread_attr_getschedpolicy");
143 printf("Scheduling policy: %s\en",
144 (policy == SCHED_FIFO) ? "SCHED_FIFO" :
145 (policy == SCHED_RR) ? "SCHED_RR" :
146 (policy == SCHED_OTHER) ? "SCHED_OTHER" : "[unknown]");
148 s = pthread_attr_getschedparam(attr, &schedparam);
150 errExitEN(s, "pthread_attr_getschedparam");
151 printf("Scheduling priority: %d\en", schedparam.sched_priority);
153 s = pthread_attr_getdetachstate(attr, &detachstate);
155 errExitEN(s, "pthread_attr_getdetachstate");
156 printf("Detach state: %s\en",
157 (detachstate == PTHREAD_CREATE_DETACHED) ? "DETACHED" :
158 (detachstate == PTHREAD_CREATE_JOINABLE) ? "JOINABLE" :
161 s = pthread_attr_getinheritsched(attr, &inheritsched);
163 errExitEN(s, "pthread_attr_getinheritsched");
164 printf("Inherit scheduler: %s\en",
165 (inheritsched == PTHREAD_INHERIT_SCHED) ? "INHERIT" :
166 (inheritsched == PTHREAD_EXPLICIT_SCHED) ? "EXPLICIT" :
171 main(int argc, char *argv[])
176 s = pthread_getattr_default_np(&attr);
178 errExitEN(s, "pthread_getattr_default_np");
180 display_pthread_attr(&attr);
188 \fBpthread_attr_getaffinity_np\fP(3), \fBpthread_attr_getdetachstate\fP(3),
189 \fBpthread_attr_getguardsize\fP(3), \fBpthread_attr_getinheritsched\fP(3),
190 \fBpthread_attr_getschedparam\fP(3), \fBpthread_attr_getschedpolicy\fP(3),
191 \fBpthread_attr_getscope\fP(3), \fBpthread_attr_getstack\fP(3),
192 \fBpthread_attr_getstackaddr\fP(3), \fBpthread_attr_getstacksize\fP(3),
193 \fBpthread_attr_init\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7)
195 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
196 \%https://www.kernel.org/doc/man\-pages/ に書かれている。