Debian Codegraph @

upstream/debian-unstable/man3/pthread_attr_setinheritsched.3

raw
1 '\" t
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH pthread_attr_setinheritsched 3 2025-05-17 "Linux man-pages 6.18"
7 .SH NAME
8 pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
9 inherit-scheduler attribute in thread attributes object
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ,\~ \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <pthread.h>
16 .P
17 .BI "int pthread_attr_setinheritsched(pthread_attr_t *" attr ,
18 .BI " int " inheritsched );
19 .BI "int pthread_attr_getinheritsched(const pthread_attr_t *restrict " attr ,
20 .BI " int *restrict " inheritsched );
21 .fi
22 .SH DESCRIPTION
23 The
24 .BR pthread_attr_setinheritsched ()
25 function sets the inherit-scheduler attribute of the
26 thread attributes object referred to by
27 .I attr
28 to the value specified in
29 .IR inheritsched .
30 The inherit-scheduler attribute determines whether a thread created using
31 the thread attributes object
32 .I attr
33 will inherit its scheduling attributes from the calling thread
34 or whether it will take them from
35 .IR attr .
36 .P
37 The following scheduling attributes are affected by the
38 inherit-scheduler attribute:
39 scheduling policy
40 .RB ( pthread_attr_setschedpolicy (3)),
41 scheduling priority
42 .RB ( pthread_attr_setschedparam (3)),
43 and contention scope
44 .RB ( pthread_attr_setscope (3)).
45 .P
46 The following values may be specified in
47 .IR inheritsched :
48 .TP
49 .B PTHREAD_INHERIT_SCHED
50 Threads that are created using
51 .I attr
52 inherit scheduling attributes from the creating thread;
53 the scheduling attributes in
54 .I attr
55 are ignored.
56 .TP
57 .B PTHREAD_EXPLICIT_SCHED
58 Threads that are created using
59 .I attr
60 take their scheduling attributes from the values specified
61 by the attributes object.
62 .\" FIXME Document the defaults for scheduler settings
63 .P
64 The default setting of the inherit-scheduler attribute in
65 a newly initialized thread attributes object is
66 .BR PTHREAD_INHERIT_SCHED .
67 .P
68 The
69 .BR pthread_attr_getinheritsched ()
70 returns the inherit-scheduler attribute of the thread attributes object
71 .I attr
72 in the buffer pointed to by
73 .IR inheritsched .
74 .SH RETURN VALUE
75 On success, these functions return 0;
76 on error, they return a nonzero error number.
77 .SH ERRORS
78 .BR pthread_attr_setinheritsched ()
79 can fail with the following error:
80 .TP
81 .B EINVAL
82 Invalid value in
83 .IR inheritsched .
84 .P
85 POSIX.1 also documents an optional
86 .B ENOTSUP
87 error ("attempt was made to set the attribute to an unsupported value") for
88 .BR pthread_attr_setinheritsched ().
89 .SH ATTRIBUTES
90 For an explanation of the terms used in this section, see
91 .BR attributes (7).
92 .TS
93 allbox;
94 lbx lb lb
95 l l l.
96 Interface Attribute Value
97 T{
98 .na
99 .nh
100 .BR pthread_attr_setinheritsched (),
101 .BR pthread_attr_getinheritsched ()
102 T} Thread safety MT-Safe
103 .TE
104 .SH STANDARDS
105 POSIX.1-2008.
106 .SH HISTORY
107 glibc 2.0.
108 POSIX.1-2001.
109 .SH BUGS
110 As at glibc 2.8, if a thread attributes object is initialized using
111 .BR pthread_attr_init (3),
112 then the scheduling policy of the attributes object is set to
113 .B SCHED_OTHER
114 and the scheduling priority is set to 0.
115 However, if the inherit-scheduler attribute is then set to
116 .BR PTHREAD_EXPLICIT_SCHED ,
117 then a thread created using the attribute object
118 wrongly inherits its scheduling attributes from the creating thread.
119 This bug does not occur if either the scheduling policy or
120 scheduling priority attribute is explicitly set
121 in the thread attributes object before calling
122 .BR pthread_create (3).
123 .\" FIXME . Track status of the following bug:
124 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
125 .SH EXAMPLES
126 See
127 .BR pthread_setschedparam (3).
128 .SH SEE ALSO
129 .ad l
130 .nh
131 .BR pthread_attr_init (3),
132 .BR pthread_attr_setschedparam (3),
133 .BR pthread_attr_setschedpolicy (3),
134 .BR pthread_attr_setscope (3),
135 .BR pthread_create (3),
136 .BR pthread_setschedparam (3),
137 .BR pthread_setschedprio (3),
138 .BR pthreads (7),
139 .BR sched (7)