xref: /freebsd/lib/libsys/sched_setparam.2 (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
1.\" Copyright (c) 1998 HD Associates, Inc.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd March 12, 1998
26.Dt SCHED_SETPARAM 2
27.Os
28.Sh NAME
29.Nm sched_setparam ,
30.Nm sched_getparam
31.Nd set/get scheduling parameters
32.Sh LIBRARY
33.Lb libc
34.Sh SYNOPSIS
35.In sched.h
36.Ft int
37.Fn sched_setparam "pid_t pid" "const struct sched_param *param"
38.Ft int
39.Fn sched_getparam "pid_t pid" "struct sched_param *param"
40.Sh DESCRIPTION
41The
42.Fn sched_setparam
43system call sets the scheduling parameters of the process specified by
44.Fa pid
45to the values specified by the
46.Fa sched_param
47structure pointed to by
48.Fa param .
49The value of the
50.Fa sched_priority
51member in the
52.Fa param
53structure must be any integer within the inclusive priority range for
54the current scheduling policy of the process specified by
55.Fa pid .
56Higher numerical values for the priority represent higher priorities.
57.Pp
58In this implementation, if the value of
59.Fa pid
60is negative the system call will fail.
61.Pp
62If a process specified by
63.Fa pid
64exists and if the calling process has permission, the scheduling
65parameters are set for the process whose process ID is equal to
66.Fa pid .
67.Pp
68If
69.Fa pid
70is zero, the scheduling parameters are set for the calling process.
71.Pp
72In this implementation, the policy of when a process can affect
73the scheduling parameters of another process is specified in
74.St -p1003.1b-93
75as a write-style operation.
76.Pp
77The target process, whether it is running or not running, will resume
78execution after all other runnable processes of equal or greater
79priority have been scheduled to run.
80.Pp
81If the priority of the process specified by the
82.Fa pid
83argument is set higher than that of the lowest priority running process
84and if the specified process is ready to run, the process specified by
85the
86.Fa pid
87argument will preempt a lowest priority running process.
88Similarly, if
89the process calling
90.Fn sched_setparam
91sets its own priority lower than that of one or more other nonempty
92process lists, then the process that is the head of the highest priority
93list will also preempt the calling process.
94Thus, in either case, the
95originating process might not receive notification of the completion of
96the requested priority change until the higher priority process has
97executed.
98.Pp
99In this implementation, when the current scheduling policy for the
100process specified by
101.Fa pid
102is normal timesharing (SCHED_OTHER, aka SCHED_NORMAL when not POSIX-source)
103or the idle policy (SCHED_IDLE when not POSIX-source) then the behavior
104is as if the process had been running under SCHED_RR with a priority
105lower than any actual realtime priority.
106.Pp
107The
108.Fn sched_getparam
109system call will return the scheduling parameters of a process specified
110by
111.Fa pid
112in the
113.Fa sched_param
114structure pointed to by
115.Fa param .
116.Pp
117If a process specified by
118.Fa pid
119exists and if the calling process has permission,
120the scheduling parameters for the process whose process ID is equal to
121.Fa pid
122are returned.
123.Pp
124In this implementation, the policy of when a process can obtain the
125scheduling parameters of another process are detailed in
126.St -p1003.1b-93
127as a read-style operation.
128.Pp
129If
130.Fa pid
131is zero, the scheduling parameters for the calling process will be
132returned.
133In this implementation, the
134.Fa sched_getparam
135system call will fail if
136.Fa pid
137is negative.
138.Sh RETURN VALUES
139.Rv -std
140.Sh ERRORS
141On failure
142.Va errno
143will be set to the corresponding value:
144.Bl -tag -width Er
145.It Bq Er ENOSYS
146The system is not configured to support this functionality.
147.It Bq Er EPERM
148The requesting process doesn not have permission as detailed in
149.St -p1003.1b-93 .
150.It Bq Er ESRCH
151No process can be found corresponding to that specified by
152.Fa pid .
153.It Bq Er EINVAL
154For
155.Fn sched_setparam :
156one or more of the requested scheduling parameters
157is outside the range defined for the scheduling policy of the specified
158.Fa pid .
159.El
160.Sh SEE ALSO
161.Xr sched_get_priority_max 2 ,
162.Xr sched_get_priority_min 2 ,
163.Xr sched_getscheduler 2 ,
164.Xr sched_rr_get_interval 2 ,
165.Xr sched_setscheduler 2 ,
166.Xr sched_yield 2
167.Sh STANDARDS
168The
169.Fn sched_setparam
170and
171.Fn sched_getparam
172system calls conform to
173.St -p1003.1b-93 .
174