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