Blame man2/sched_setparam.2

Packit 7cfc04
.\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
Packit 7cfc04
.\" This is free documentation; you can redistribute it and/or
Packit 7cfc04
.\" modify it under the terms of the GNU General Public License as
Packit 7cfc04
.\" published by the Free Software Foundation; either version 2 of
Packit 7cfc04
.\" the License, or (at your option) any later version.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The GNU General Public License's references to "object code"
Packit 7cfc04
.\" and "executables" are to be interpreted as the output of any
Packit 7cfc04
.\" document formatting or typesetting system, including
Packit 7cfc04
.\" intermediate and printed output.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This manual is distributed in the hope that it will be useful,
Packit 7cfc04
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
.\" GNU General Public License for more details.
Packit 7cfc04
.\"
Packit 7cfc04
.\" You should have received a copy of the GNU General Public
Packit 7cfc04
.\" License along with this manual; if not, see
Packit 7cfc04
.\" <http://www.gnu.org/licenses/>.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
Packit 7cfc04
.\"            First version written
Packit 7cfc04
.\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
Packit 7cfc04
.\"            revision
Packit 7cfc04
.\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\"
Packit 7cfc04
.TH SCHED_SETPARAM 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
sched_setparam, sched_getparam \- set and get scheduling parameters
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <sched.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int sched_setparam(pid_t " pid ", const struct sched_param *" param );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int sched_getparam(pid_t " pid ", struct sched_param *" param );
Packit 7cfc04
.PP
Packit 7cfc04
\fBstruct sched_param {
Packit 7cfc04
    ...
Packit 7cfc04
    int \fIsched_priority\fB;
Packit 7cfc04
    ...
Packit 7cfc04
};
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR sched_setparam ()
Packit 7cfc04
sets the scheduling parameters associated with the scheduling policy
Packit 7cfc04
for the process identified by \fIpid\fP.
Packit 7cfc04
If \fIpid\fP is zero, then
Packit 7cfc04
the parameters of the calling process are set.
Packit 7cfc04
The interpretation of
Packit 7cfc04
the argument \fIparam\fP depends on the scheduling
Packit 7cfc04
policy of the process identified by
Packit 7cfc04
.IR pid .
Packit 7cfc04
See
Packit 7cfc04
.BR sched (7)
Packit 7cfc04
for a description of the scheduling policies supported under Linux.
Packit 7cfc04
.PP
Packit 7cfc04
.BR sched_getparam ()
Packit 7cfc04
retrieves the scheduling parameters for the
Packit 7cfc04
process identified by \fIpid\fP.
Packit 7cfc04
If \fIpid\fP is zero, then the parameters
Packit 7cfc04
of the calling process are retrieved.
Packit 7cfc04
.PP
Packit 7cfc04
.BR sched_setparam ()
Packit 7cfc04
checks the validity of \fIparam\fP for the scheduling policy of the
Packit 7cfc04
thread.
Packit 7cfc04
The value \fIparam\->sched_priority\fP must lie within the
Packit 7cfc04
range given by
Packit 7cfc04
.BR sched_get_priority_min (2)
Packit 7cfc04
and
Packit 7cfc04
.BR sched_get_priority_max (2).
Packit 7cfc04
.PP
Packit 7cfc04
For a discussion of the privileges and resource limits related to
Packit 7cfc04
scheduling priority and policy, see
Packit 7cfc04
.BR sched (7).
Packit 7cfc04
.PP
Packit 7cfc04
POSIX systems on which
Packit 7cfc04
.BR sched_setparam ()
Packit 7cfc04
and
Packit 7cfc04
.BR sched_getparam ()
Packit 7cfc04
are available define
Packit 7cfc04
.B _POSIX_PRIORITY_SCHEDULING
Packit 7cfc04
in \fI<unistd.h>\fP.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR sched_setparam ()
Packit 7cfc04
and
Packit 7cfc04
.BR sched_getparam ()
Packit 7cfc04
return 0.
Packit 7cfc04
On error, \-1 is returned, and
Packit 7cfc04
.I errno
Packit 7cfc04
is set appropriately.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
Invalid arguments:
Packit 7cfc04
.I param
Packit 7cfc04
is NULL or
Packit 7cfc04
.I pid
Packit 7cfc04
is negative
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.RB ( sched_setparam ())
Packit 7cfc04
The argument \fIparam\fP does not make sense for the current
Packit 7cfc04
scheduling policy.
Packit 7cfc04
.TP
Packit 7cfc04
.B EPERM
Packit 7cfc04
.RB ( sched_setparam ())
Packit 7cfc04
The calling process does not have appropriate privileges
Packit 7cfc04
(Linux: does not have the
Packit 7cfc04
.B CAP_SYS_NICE
Packit 7cfc04
capability).
Packit 7cfc04
.TP
Packit 7cfc04
.B ESRCH
Packit 7cfc04
The process whose ID is \fIpid\fP could not be found.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
.PP
Packit 7cfc04
Scheduling parameters are in fact per-thread
Packit 7cfc04
attributes on Linux;
Packit 7cfc04
see
Packit 7cfc04
.BR sched (7).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.ad l
Packit 7cfc04
.nh
Packit 7cfc04
.BR getpriority (2),
Packit 7cfc04
.BR nice (2),
Packit 7cfc04
.BR sched_get_priority_max (2),
Packit 7cfc04
.BR sched_get_priority_min (2),
Packit 7cfc04
.BR sched_getaffinity (2),
Packit 7cfc04
.BR sched_getscheduler (2),
Packit 7cfc04
.BR sched_setaffinity (2),
Packit 7cfc04
.BR sched_setattr (2),
Packit 7cfc04
.BR sched_setscheduler (2),
Packit 7cfc04
.BR setpriority (2),
Packit 7cfc04
.BR capabilities (7),
Packit 7cfc04
.BR sched (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.