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 For an explanation of the terms used in this section, see
99 Interface Attribute Value
101 .BR pthread_attr_setinheritsched (),
102 .BR pthread_attr_getinheritsched ()
103 T} Thread safety MT-Safe
114 As at glibc 2.8, if a thread attributes object is initialized using
115 .BR pthread_attr_init (3),
116 then the scheduling policy of the attributes object is set to
118 and the scheduling priority is set to 0.
119 However, if the inherit-scheduler attribute is then set to
120 .BR PTHREAD_EXPLICIT_SCHED ,
121 then a thread created using the attribute object
122 wrongly inherits its scheduling attributes from the creating thread.
123 This bug does not occur if either the scheduling policy or
124 scheduling priority attribute is explicitly set
125 in the thread attributes object before calling
126 .BR pthread_create (3).
127 .\" FIXME . Track status of the following bug:
128 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
131 .BR pthread_setschedparam (3).
135 .BR pthread_attr_init (3),
136 .BR pthread_attr_setschedparam (3),
137 .BR pthread_attr_setschedpolicy (3),
138 .BR pthread_attr_setscope (3),
139 .BR pthread_create (3),
140 .BR pthread_setschedparam (3),
141 .BR pthread_setschedprio (3),