]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_attr_setinheritsched.3
pthread_attr_setscope.3: wfix
[thirdparty/man-pages.git] / man3 / pthread_attr_setinheritsched.3
CommitLineData
b6a82811
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
b6a82811
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
b6a82811 25.\"
c59c89b3 26.TH PTHREAD_ATTR_SETINHERITSCHED 3 2013-04-19 "Linux" "Linux Programmer's Manual"
b6a82811
MK
27.SH NAME
28pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
29inherit scheduler attribute in thread attributes object
30.SH SYNOPSIS
31.nf
32.B #include <pthread.h>
33
34.BI "int pthread_attr_setinheritsched(pthread_attr_t *" attr ,
35.BI " int " inheritsched );
36.BI "int pthread_attr_getinheritsched(pthread_attr_t *" attr ,
37.BI " int *" inheritsched );
38.sp
39Compile and link with \fI\-pthread\fP.
6030f2d8 40.fi
b6a82811
MK
41.SH DESCRIPTION
42The
43.BR pthread_attr_setinheritsched ()
44function sets the inherit scheduler attribute of the
45thread attributes object referred to by
5b99d426 46.IR attr
b6a82811
MK
47to the value specified in
48.IR inheritsched .
49The inherit scheduler attribute determines whether a thread created using
50the thread attributes object
51.I attr
52will inherit its scheduling attributes from the calling thread
53or whether it will take them from
54.IR attr .
55
c59c89b3
MK
56The following scheduling attributes are affected by the
57inherit-scheduler attribute:
58scheduling policy
59.RB ( pthread_attr_setschedpolicy (3)),
60scheduling priority
61.RB ( pthread_attr_setschedparam (3)),
62and contention scope
63.RB ( pthread_attr_setscope (3)).
64
b6a82811
MK
65The following values may be specified in
66.IR inheritsched :
67.TP
68.B PTHREAD_INHERIT_SCHED
69Threads that are created using
70.I attr
71inherit scheduling attributes from the creating thread;
72the scheduling attributes in
73.I attr
74are ignored.
75.TP
76.B PTHREAD_EXPLICIT_SCHED
77Threads that are created using
78.I attr
79take their scheduling attributes from the values specified
80by the attributes object.
81.\" FIXME what are the defaults for scheduler settings?
82.PP
83The default setting of the inherit scheduler attribute in
84a newly initialized thread attributes object is
85.BR PTHREAD_INHERIT_SCHED .
86
87The
88.BR pthread_attr_getinheritsched ()
89returns the inherit scheduler attribute of the thread attributes object
90.IR attr
91in the buffer pointed to by
92.IR inheritsched .
93.SH RETURN VALUE
94On success, these functions return 0;
c7094399 95on error, they return a nonzero error number.
b6a82811
MK
96.SH ERRORS
97.BR pthread_attr_setinheritsched ()
98can fail with the following error:
99.TP
100.B EINVAL
101Invalid value in
102.IR inheritsched .
103.PP
104POSIX.1-2001 also documents an optional
105.B ENOTSUP
106error ("attempt was made to set the attribute to an unsupported value") for
107.BR pthread_attr_setinheritsched ().
108.\" .SH VERSIONS
109.\" Available since glibc 2.0.
110.SH CONFORMING TO
111POSIX.1-2001.
b6a82811
MK
112.SH BUGS
113As at glibc 2.8, if a thread attributes object is initialized using
114.BR pthread_attr_init (3),
115then the scheduling policy of the attributes object is set to
116.BR SCHED_OTHER
117and the scheduling priority is set to 0.
118However, if the inherit scheduler attribute is then set to
119.BR PTHREAD_EXPLICIT_SCHED ,
120then a thread created using the attribute object
121wrongly inherits its scheduling attributes from the creating thread.
122This bug does not occur if either the scheduling policy or
123scheduling priority attribute is explicitly set
124in 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
22cb459d
MK
128.SH EXAMPLE
129See
130.BR pthread_setschedparam (3).
b6a82811 131.SH SEE ALSO
ca8a0bd2
MK
132.ad l
133.nh
b6a82811
MK
134.BR sched_setscheduler (2),
135.BR pthread_attr_init (3),
136.BR pthread_attr_setschedparam (3),
137.BR pthread_attr_setschedpolicy (3),
c59c89b3 138.BR pthread_attr_setscope (3),
b6a82811
MK
139.BR pthread_create (3),
140.BR pthread_setschedparam (3),
141.BR pthread_setschedprio (3),
142.BR pthreads (7)