]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/pthread_attr_setinheritsched.3
98dc2eea1d2d1a8c37735b0a1aa90e2725e4e2d4
[thirdparty/man-pages.git] / man3 / pthread_attr_setinheritsched.3
1 '\" t
2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH pthread_attr_setinheritsched 3 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
10 inherit-scheduler attribute in thread attributes object
11 .SH LIBRARY
12 POSIX threads library
13 .RI ( libpthread ", " \-lpthread )
14 .SH SYNOPSIS
15 .nf
16 .B #include <pthread.h>
17 .PP
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 );
22 .fi
23 .SH DESCRIPTION
24 The
25 .BR pthread_attr_setinheritsched ()
26 function sets the inherit-scheduler attribute of the
27 thread attributes object referred to by
28 .I attr
29 to the value specified in
30 .IR inheritsched .
31 The inherit-scheduler attribute determines whether a thread created using
32 the thread attributes object
33 .I attr
34 will inherit its scheduling attributes from the calling thread
35 or whether it will take them from
36 .IR attr .
37 .PP
38 The following scheduling attributes are affected by the
39 inherit-scheduler attribute:
40 scheduling policy
41 .RB ( pthread_attr_setschedpolicy (3)),
42 scheduling priority
43 .RB ( pthread_attr_setschedparam (3)),
44 and contention scope
45 .RB ( pthread_attr_setscope (3)).
46 .PP
47 The following values may be specified in
48 .IR inheritsched :
49 .TP
50 .B PTHREAD_INHERIT_SCHED
51 Threads that are created using
52 .I attr
53 inherit scheduling attributes from the creating thread;
54 the scheduling attributes in
55 .I attr
56 are ignored.
57 .TP
58 .B PTHREAD_EXPLICIT_SCHED
59 Threads that are created using
60 .I attr
61 take their scheduling attributes from the values specified
62 by the attributes object.
63 .\" FIXME Document the defaults for scheduler settings
64 .PP
65 The default setting of the inherit-scheduler attribute in
66 a newly initialized thread attributes object is
67 .BR PTHREAD_INHERIT_SCHED .
68 .PP
69 The
70 .BR pthread_attr_getinheritsched ()
71 returns the inherit-scheduler attribute of the thread attributes object
72 .I attr
73 in the buffer pointed to by
74 .IR inheritsched .
75 .SH RETURN VALUE
76 On success, these functions return 0;
77 on error, they return a nonzero error number.
78 .SH ERRORS
79 .BR pthread_attr_setinheritsched ()
80 can fail with the following error:
81 .TP
82 .B EINVAL
83 Invalid value in
84 .IR inheritsched .
85 .PP
86 POSIX.1 also documents an optional
87 .B ENOTSUP
88 error ("attempt was made to set the attribute to an unsupported value") for
89 .BR pthread_attr_setinheritsched ().
90 .SH ATTRIBUTES
91 For an explanation of the terms used in this section, see
92 .BR attributes (7).
93 .ad l
94 .nh
95 .TS
96 allbox;
97 lbx lb lb
98 l l l.
99 Interface Attribute Value
100 T{
101 .BR pthread_attr_setinheritsched (),
102 .BR pthread_attr_getinheritsched ()
103 T} Thread safety MT-Safe
104 .TE
105 .hy
106 .ad
107 .sp 1
108 .SH STANDARDS
109 POSIX.1-2008.
110 .SH HISTORY
111 glibc 2.0.
112 POSIX.1-2001.
113 .SH BUGS
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
117 .B SCHED_OTHER
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
129 .SH EXAMPLES
130 See
131 .BR pthread_setschedparam (3).
132 .SH SEE ALSO
133 .ad l
134 .nh
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),
142 .BR pthreads (7),
143 .BR sched (7)