2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH pthread_attr_setinheritsched 3 (date) "Linux man-pages (unreleased)"
9 pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
10 inherit-scheduler attribute in thread attributes object
13 .RI ( libpthread ", " \-lpthread )
16 .B #include <pthread.h>
18 .BI "int pthread_attr_setinheritsched(pthread_attr_t *" attr ,
19 .BI " int " inheritsched );
20 .BI "int pthread_attr_getinheritsched(const pthread_attr_t *restrict " attr ,
21 .BI " int *restrict " inheritsched );
25 .BR pthread_attr_setinheritsched ()
26 function sets the inherit-scheduler attribute of the
27 thread attributes object referred to by
29 to the value specified in
31 The inherit-scheduler attribute determines whether a thread created using
32 the thread attributes object
34 will inherit its scheduling attributes from the calling thread
35 or whether it will take them from
38 The following scheduling attributes are affected by the
39 inherit-scheduler attribute:
41 .RB ( pthread_attr_setschedpolicy (3)),
43 .RB ( pthread_attr_setschedparam (3)),
45 .RB ( pthread_attr_setscope (3)).
47 The following values may be specified in
50 .B PTHREAD_INHERIT_SCHED
51 Threads that are created using
53 inherit scheduling attributes from the creating thread;
54 the scheduling attributes in
58 .B PTHREAD_EXPLICIT_SCHED
59 Threads that are created using
61 take their scheduling attributes from the values specified
62 by the attributes object.
63 .\" FIXME Document the defaults for scheduler settings
65 The default setting of the inherit-scheduler attribute in
66 a newly initialized thread attributes object is
67 .BR PTHREAD_INHERIT_SCHED .
70 .BR pthread_attr_getinheritsched ()
71 returns the inherit-scheduler attribute of the thread attributes object
73 in the buffer pointed to by
76 On success, these functions return 0;
77 on error, they return a nonzero error number.
79 .BR pthread_attr_setinheritsched ()
80 can fail with the following error:
86 POSIX.1 also documents an optional
88 error ("attempt was made to set the attribute to an unsupported value") for
89 .BR pthread_attr_setinheritsched ().
91 .\" Available since glibc 2.0.
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
103 .BR pthread_attr_setinheritsched (),
104 .BR pthread_attr_getinheritsched ()
105 T} Thread safety MT-Safe
111 POSIX.1-2001, POSIX.1-2008.
113 As at glibc 2.8, if a thread attributes object is initialized using
114 .BR pthread_attr_init (3),
115 then the scheduling policy of the attributes object is set to
117 and the scheduling priority is set to 0.
118 However, if the inherit-scheduler attribute is then set to
119 .BR PTHREAD_EXPLICIT_SCHED ,
120 then a thread created using the attribute object
121 wrongly inherits its scheduling attributes from the creating thread.
122 This bug does not occur if either the scheduling policy or
123 scheduling priority attribute is explicitly set
124 in the thread attributes object before calling
125 .BR pthread_create (3).
126 .\" FIXME . Track status of the following bug:
127 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
130 .BR pthread_setschedparam (3).
134 .BR pthread_attr_init (3),
135 .BR pthread_attr_setschedparam (3),
136 .BR pthread_attr_setschedpolicy (3),
137 .BR pthread_attr_setscope (3),
138 .BR pthread_create (3),
139 .BR pthread_setschedparam (3),
140 .BR pthread_setschedprio (3),