close_range.2: Glibc added a wrapper recently
[man-pages.git] / man2 / sched_setparam.2
blob3974645ff5d61ecef6be84f76a8145e4984c8d2b
1 .\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
25 .\"            First version written
26 .\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
27 .\"            revision
28 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\"
30 .TH SCHED_SETPARAM 2 2021-03-22 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 sched_setparam, sched_getparam \- set and get scheduling parameters
33 .SH SYNOPSIS
34 .nf
35 .B #include <sched.h>
36 .PP
37 .BI "int sched_setparam(pid_t " pid ", const struct sched_param *" param );
38 .BI "int sched_getparam(pid_t " pid ", struct sched_param *" param );
39 .PP
40 \fBstruct sched_param {
41     ...
42     int \fIsched_priority\fB;
43     ...
45 .fi
46 .SH DESCRIPTION
47 .BR sched_setparam ()
48 sets the scheduling parameters associated with the scheduling policy
49 for the thread whose thread ID is specified in \fIpid\fP.
50 If \fIpid\fP is zero, then
51 the parameters of the calling thread are set.
52 The interpretation of
53 the argument \fIparam\fP depends on the scheduling
54 policy of the thread identified by
55 .IR pid .
56 See
57 .BR sched (7)
58 for a description of the scheduling policies supported under Linux.
59 .PP
60 .BR sched_getparam ()
61 retrieves the scheduling parameters for the
62 thread identified by \fIpid\fP.
63 If \fIpid\fP is zero, then the parameters
64 of the calling thread are retrieved.
65 .PP
66 .BR sched_setparam ()
67 checks the validity of \fIparam\fP for the scheduling policy of the
68 thread.
69 The value \fIparam\->sched_priority\fP must lie within the
70 range given by
71 .BR sched_get_priority_min (2)
72 and
73 .BR sched_get_priority_max (2).
74 .PP
75 For a discussion of the privileges and resource limits related to
76 scheduling priority and policy, see
77 .BR sched (7).
78 .PP
79 POSIX systems on which
80 .BR sched_setparam ()
81 and
82 .BR sched_getparam ()
83 are available define
84 .B _POSIX_PRIORITY_SCHEDULING
85 in \fI<unistd.h>\fP.
86 .SH RETURN VALUE
87 On success,
88 .BR sched_setparam ()
89 and
90 .BR sched_getparam ()
91 return 0.
92 On error, \-1 is returned, and
93 .I errno
94 is set to indicate the error.
95 .SH ERRORS
96 .TP
97 .B EINVAL
98 Invalid arguments:
99 .I param
100 is NULL or
101 .I pid
102 is negative
104 .B EINVAL
105 .RB ( sched_setparam ())
106 The argument \fIparam\fP does not make sense for the current
107 scheduling policy.
109 .B EPERM
110 .RB ( sched_setparam ())
111 The caller does not have appropriate privileges
112 (Linux: does not have the
113 .B CAP_SYS_NICE
114 capability).
116 .B ESRCH
117 The thread whose ID is \fIpid\fP could not be found.
118 .SH CONFORMING TO
119 POSIX.1-2001, POSIX.1-2008.
120 .SH SEE ALSO
121 .ad l
123 .BR getpriority (2),
124 .BR gettid (2),
125 .BR nice (2),
126 .BR sched_get_priority_max (2),
127 .BR sched_get_priority_min (2),
128 .BR sched_getaffinity (2),
129 .BR sched_getscheduler (2),
130 .BR sched_setaffinity (2),
131 .BR sched_setattr (2),
132 .BR sched_setscheduler (2),
133 .BR setpriority (2),
134 .BR capabilities (7),
135 .BR sched (7)