1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: GPL-2.0-or-later
.\"
.TH sched_setparam 2 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
sched_setparam, sched_getparam \- set and get scheduling parameters
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.B #include <sched.h>
.P
.BI "int sched_setparam(pid_t " pid ", const struct sched_param *" param );
.BI "int sched_getparam(pid_t " pid ", struct sched_param *" param );
.P
\f[B]struct sched_param {
...
int \f[I]sched_priority\f[];
...
};\f[]
.fi
.SH DESCRIPTION
.BR sched_setparam ()
sets the scheduling parameters associated with the scheduling policy
for the thread whose thread ID is specified in
.IR pid .
If
.I pid
is zero, then
the parameters of the calling thread are set.
The interpretation of
the argument
.I param
depends on the scheduling policy
of the thread identified by
.IR pid .
See
.BR sched (7)
for a description of the scheduling policies supported under Linux.
.P
.BR sched_getparam ()
retrieves the scheduling parameters for the
thread identified by
.IR pid .
If
.I pid
is zero, then the parameters
of the calling thread are retrieved.
.P
.BR sched_setparam ()
checks the validity of
.I param
for the scheduling policy of the thread.
The value
.I param\->sched_priority
must lie within the
range given by
.BR sched_get_priority_min (2)
and
.BR sched_get_priority_max (2).
.P
For a discussion of the privileges and resource limits related to
scheduling priority and policy, see
.BR sched (7).
.P
POSIX systems on which
.BR sched_setparam ()
and
.BR sched_getparam ()
are available define
.B _POSIX_PRIORITY_SCHEDULING
in
.IR <unistd.h> .
.SH RETURN VALUE
On success,
.BR sched_setparam ()
and
.BR sched_getparam ()
return 0.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EINVAL
Invalid arguments:
.I param
is NULL or
.I pid
is negative
.TP
.B EINVAL
.RB ( sched_setparam ())
The argument
.I param
does not make sense for the current
scheduling policy.
.TP
.B EPERM
.RB ( sched_setparam ())
The caller does not have appropriate privileges
(Linux: does not have the
.B CAP_SYS_NICE
capability).
.TP
.B ESRCH
The thread whose ID is
.I pid
could not be found.
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
POSIX.1-2001.
.SH SEE ALSO
.ad l
.nh
.BR getpriority (2),
.BR gettid (2),
.BR nice (2),
.BR sched_get_priority_max (2),
.BR sched_get_priority_min (2),
.BR sched_getaffinity (2),
.BR sched_getscheduler (2),
.BR sched_setaffinity (2),
.BR sched_setattr (2),
.BR sched_setscheduler (2),
.BR setpriority (2),
.BR capabilities (7),
.BR sched (7)
|