OSDN Git Service

8df336b44806342a3fc90ead0caf442c278fe0a9
[linuxjm/LDP_man-pages.git] / original / man2 / sched_setparam.2
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 2014-05-11 "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 .sp
37 .BI "int sched_setparam(pid_t " pid ", const struct sched_param *" param );
38 .sp
39 .BI "int sched_getparam(pid_t " pid ", struct sched_param *" param );
40 .sp
41 \fBstruct sched_param {
42     ...
43     int \fIsched_priority\fB;
44     ...
45 };
46 .fi
47 .SH DESCRIPTION
48 .BR sched_setparam ()
49 sets the scheduling parameters associated with the scheduling policy
50 for the process identified by \fIpid\fP.
51 If \fIpid\fP is zero, then
52 the parameters of the calling process are set.
53 The interpretation of
54 the argument \fIparam\fP depends on the scheduling
55 policy of the process identified by
56 .IR pid .
57 See
58 .BR sched (7)
59 for a description of the scheduling policies supported under Linux.
60
61 .BR sched_getparam ()
62 retrieves the scheduling parameters for the
63 process identified by \fIpid\fP.
64 If \fIpid\fP is zero, then the parameters
65 of the calling process are retrieved.
66
67 .BR sched_setparam ()
68 checks the validity of \fIparam\fP for the scheduling policy of the
69 thread.
70 The value \fIparam\->sched_priority\fP must lie within the
71 range given by
72 .BR sched_get_priority_min (2)
73 and
74 .BR sched_get_priority_max (2).
75
76 For a discussion of the privileges and resource limits related to
77 scheduling priority and policy, see
78 .BR sched (7).
79
80 POSIX systems on which
81 .BR sched_setparam ()
82 and
83 .BR sched_getparam ()
84 are available define
85 .B _POSIX_PRIORITY_SCHEDULING
86 in \fI<unistd.h>\fP.
87 .SH RETURN VALUE
88 On success,
89 .BR sched_setparam ()
90 and
91 .BR sched_getparam ()
92 return 0.
93 On error, \-1 is returned, and
94 .I errno
95 is set appropriately.
96 .SH ERRORS
97 .TP
98 .B EINVAL
99 Invalid arguments:
100 .I param
101 is NULL or
102 .I pid
103 is negative
104 .TP
105 .B EINVAL
106 .RB ( sched_setparam ())
107 The argument \fIparam\fP does not make sense for the current
108 scheduling policy.
109 .TP
110 .B EPERM
111 .RB ( sched_setparam ())
112 The calling process does not have appropriate privileges
113 (Linux: does not have the
114 .B CAP_SYS_NICE
115 capability).
116 .TP
117 .B ESRCH
118 The process whose ID is \fIpid\fP could not be found.
119 .SH CONFORMING TO
120 POSIX.1-2001.
121 .SH NOTES
122 .PP
123 Scheduling parameters are in fact per-thread
124 attributes on Linux;
125 see
126 .BR sched (7).
127 .SH SEE ALSO
128 .ad l
129 .nh
130 .BR getpriority (2),
131 .BR nice (2),
132 .BR sched_get_priority_max (2),
133 .BR sched_get_priority_min (2),
134 .BR sched_getaffinity (2),
135 .BR sched_getscheduler (2),
136 .BR sched_setaffinity (2),
137 .BR sched_setscheduler (2),
138 .BR sched_setattr (2),
139 .BR setpriority (2),
140 .BR capabilities (7),
141 .BR sched (7)
142 .SH COLOPHON
143 This page is part of release 3.67 of the Linux
144 .I man-pages
145 project.
146 A description of the project,
147 information about reporting bugs,
148 and the latest version of this page,
149 can be found at
150 \%http://www.kernel.org/doc/man\-pages/.