xref: /freebsd-src/lib/libsys/sched_setscheduler.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\" Copyright (c) 1998 HD Associates, Inc.
2*8269e767SBrooks Davis.\" All rights reserved.
3*8269e767SBrooks Davis.\"
4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
6*8269e767SBrooks Davis.\" are met:
7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
8*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
10*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
11*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
12*8269e767SBrooks Davis.\"
13*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*8269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*8269e767SBrooks Davis.\" SUCH DAMAGE.
24*8269e767SBrooks Davis.\"
25*8269e767SBrooks Davis.Dd March 12, 1998
26*8269e767SBrooks Davis.Dt SCHED_SETSCHEDULER 2
27*8269e767SBrooks Davis.Os
28*8269e767SBrooks Davis.Sh NAME
29*8269e767SBrooks Davis.Nm sched_setscheduler ,
30*8269e767SBrooks Davis.Nm sched_getscheduler
31*8269e767SBrooks Davis.Nd set/get scheduling policy and scheduler parameters
32*8269e767SBrooks Davis.Sh LIBRARY
33*8269e767SBrooks Davis.Lb libc
34*8269e767SBrooks Davis.Sh SYNOPSIS
35*8269e767SBrooks Davis.In sched.h
36*8269e767SBrooks Davis.Ft int
37*8269e767SBrooks Davis.Fn sched_setscheduler "pid_t pid" "int policy" "const struct sched_param *param"
38*8269e767SBrooks Davis.Ft int
39*8269e767SBrooks Davis.Fn sched_getscheduler "pid_t pid"
40*8269e767SBrooks Davis.Sh DESCRIPTION
41*8269e767SBrooks DavisThe
42*8269e767SBrooks Davis.Fn sched_setscheduler
43*8269e767SBrooks Davissystem call sets the scheduling policy and scheduling parameters
44*8269e767SBrooks Davisof the process specified by
45*8269e767SBrooks Davis.Fa pid
46*8269e767SBrooks Davisto
47*8269e767SBrooks Davis.Fa policy
48*8269e767SBrooks Davisand the parameters specified in the
49*8269e767SBrooks Davis.Vt sched_param
50*8269e767SBrooks Davisstructure pointed to by
51*8269e767SBrooks Davis.Fa param ,
52*8269e767SBrooks Davisrespectively.
53*8269e767SBrooks DavisThe value of the
54*8269e767SBrooks Davis.Fa sched_priority
55*8269e767SBrooks Davismember in the
56*8269e767SBrooks Davis.Fa param
57*8269e767SBrooks Davisstructure must be any integer within the inclusive priority range for
58*8269e767SBrooks Davisthe scheduling policy specified by
59*8269e767SBrooks Davis.Fa policy .
60*8269e767SBrooks Davis.Pp
61*8269e767SBrooks DavisIn this implementation, if the value of
62*8269e767SBrooks Davis.Fa pid
63*8269e767SBrooks Davisis negative the system call will fail.
64*8269e767SBrooks Davis.Pp
65*8269e767SBrooks DavisIf a process specified by
66*8269e767SBrooks Davis.Fa pid
67*8269e767SBrooks Davisexists and if the calling process has permission, the scheduling
68*8269e767SBrooks Davispolicy and scheduling parameters will be set for the process
69*8269e767SBrooks Daviswhose process ID is equal to
70*8269e767SBrooks Davis.Fa pid .
71*8269e767SBrooks Davis.Pp
72*8269e767SBrooks DavisIf
73*8269e767SBrooks Davis.Fa pid
74*8269e767SBrooks Davisis zero, the scheduling policy and scheduling
75*8269e767SBrooks Davisparameters are set for the calling process.
76*8269e767SBrooks Davis.Pp
77*8269e767SBrooks DavisIn this implementation, the policy of when a process can affect
78*8269e767SBrooks Davisthe scheduling parameters of another process is specified in
79*8269e767SBrooks Davis.St -p1003.1b-93
80*8269e767SBrooks Davisas a write-style operation.
81*8269e767SBrooks Davis.Pp
82*8269e767SBrooks DavisThe scheduling policies are in
83*8269e767SBrooks Davis.Fa <sched.h> :
84*8269e767SBrooks Davis.Bl -tag -width [SCHED_OTHER]
85*8269e767SBrooks Davis.It Bq Er SCHED_FIFO
86*8269e767SBrooks DavisFirst-in-first-out fixed priority scheduling with no round robin scheduling;
87*8269e767SBrooks Davis.It Bq Er SCHED_OTHER
88*8269e767SBrooks DavisThe standard time sharing scheduler;
89*8269e767SBrooks Davis.It Bq Er SCHED_RR
90*8269e767SBrooks DavisRound-robin scheduling across same priority processes.
91*8269e767SBrooks Davis.El
92*8269e767SBrooks Davis.Pp
93*8269e767SBrooks DavisThe
94*8269e767SBrooks Davis.Vt sched_param
95*8269e767SBrooks Davisstructure is defined in
96*8269e767SBrooks Davis.Fa <sched.h> :
97*8269e767SBrooks Davis.Bd -literal -offset indent
98*8269e767SBrooks Davisstruct sched_param {
99*8269e767SBrooks Davis	int sched_priority;	/* scheduling priority */
100*8269e767SBrooks Davis};
101*8269e767SBrooks Davis.Ed
102*8269e767SBrooks Davis.Pp
103*8269e767SBrooks DavisThe
104*8269e767SBrooks Davis.Fn sched_getscheduler
105*8269e767SBrooks Davissystem call returns the scheduling policy of the process specified
106*8269e767SBrooks Davisby
107*8269e767SBrooks Davis.Fa pid .
108*8269e767SBrooks Davis.Pp
109*8269e767SBrooks DavisIf a process specified by
110*8269e767SBrooks Davis.Fa pid
111*8269e767SBrooks Davisexists and if the calling process has permission,
112*8269e767SBrooks Davisthe scheduling parameters for the process whose process ID is equal to
113*8269e767SBrooks Davis.Fa pid
114*8269e767SBrooks Davisare returned.
115*8269e767SBrooks Davis.Pp
116*8269e767SBrooks DavisIn this implementation, the policy of when a process can obtain the
117*8269e767SBrooks Davisscheduling parameters of another process are detailed in
118*8269e767SBrooks Davis.St -p1003.1b-93
119*8269e767SBrooks Davisas a read-style operation.
120*8269e767SBrooks Davis.Pp
121*8269e767SBrooks DavisIf
122*8269e767SBrooks Davis.Fa pid
123*8269e767SBrooks Davisis zero, the scheduling parameters for the calling process will be
124*8269e767SBrooks Davisreturned.
125*8269e767SBrooks DavisIn this implementation, the
126*8269e767SBrooks Davis.Fa sched_getscheduler
127*8269e767SBrooks Davissystem call will fail if
128*8269e767SBrooks Davis.Fa pid
129*8269e767SBrooks Davisis negative.
130*8269e767SBrooks Davis.Sh RETURN VALUES
131*8269e767SBrooks Davis.Rv -std
132*8269e767SBrooks Davis.Sh ERRORS
133*8269e767SBrooks DavisOn failure
134*8269e767SBrooks Davis.Va errno
135*8269e767SBrooks Daviswill be set to the corresponding value:
136*8269e767SBrooks Davis.Bl -tag -width Er
137*8269e767SBrooks Davis.It Bq Er ENOSYS
138*8269e767SBrooks DavisThe system is not configured to support this functionality.
139*8269e767SBrooks Davis.It Bq Er EPERM
140*8269e767SBrooks DavisThe requesting process doesn not have permission as detailed in
141*8269e767SBrooks Davis.St -p1003.1b-93 .
142*8269e767SBrooks Davis.It Bq Er ESRCH
143*8269e767SBrooks DavisNo process can be found corresponding to that specified by
144*8269e767SBrooks Davis.Fa pid .
145*8269e767SBrooks Davis.It Bq Er EINVAL
146*8269e767SBrooks DavisThe value of the
147*8269e767SBrooks Davis.Fa policy
148*8269e767SBrooks Davisargument is invalid, or one or more of the parameters contained in
149*8269e767SBrooks Davis.Fa param
150*8269e767SBrooks Davisis outside the valid range for the specified scheduling policy.
151*8269e767SBrooks Davis.El
152*8269e767SBrooks Davis.Sh SEE ALSO
153*8269e767SBrooks Davis.Xr sched_get_priority_max 2 ,
154*8269e767SBrooks Davis.Xr sched_get_priority_min 2 ,
155*8269e767SBrooks Davis.Xr sched_getparam 2 ,
156*8269e767SBrooks Davis.Xr sched_rr_get_interval 2 ,
157*8269e767SBrooks Davis.Xr sched_setparam 2 ,
158*8269e767SBrooks Davis.Xr sched_yield 2
159*8269e767SBrooks Davis.Sh STANDARDS
160*8269e767SBrooks DavisThe
161*8269e767SBrooks Davis.Fn sched_setscheduler
162*8269e767SBrooks Davisand
163*8269e767SBrooks Davis.Fn sched_getscheduler
164*8269e767SBrooks Davissystem calls conform to
165*8269e767SBrooks Davis.St -p1003.1b-93 .
166