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