be86f7388f95530143e6ec433f2682972ebf13a2
[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.5 2008/05/02 02:05:04 swildner 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 .St -p1003.1b-93
82 as a write-style operation.
83 .Pp
84 The scheduling policies are in
85 .In 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 .In sched.h :
99 .Bd -literal -offset indent
100 struct sched_param {
101         int sched_priority;     /* scheduling priority */
102 };
103 .Ed
104 .Pp
105 The
106 .Fn sched_getscheduler
107 function returns the scheduling policy of the process specified
108 by
109 .Fa pid .
110 .Pp
111 If a process specified by
112 .Fa pid
113 exists and if the calling process has permission,
114 the scheduling parameters for the process whose process ID is equal to
115 .Fa pid
116 are returned.
117 .Pp
118 In this implementation, the policy of when a process can obtain the
119 scheduling parameters of another process are detailed in
120 .St -p1003.1b-93
121 as a read-style operation.
122 .Pp
123 If
124 .Fa pid
125 is zero, the scheduling parameters for the calling process will be
126 returned.  In this implementation, the
127 .Fa sched_getscheduler
128 function will fail if
129 .Fa pid
130 is negative.
131 .Sh RETURN VALUES
132 .Rv -std
133 .Sh ERRORS
134 On failure
135 .Va errno
136 will be set to the corresponding value:
137 .Bl -tag -width Er
138 .It Bq Er ENOSYS
139 The system is not configured to support this functionality.
140 .It Bq Er EPERM
141 The requesting process doesn not have permission as detailed in
142 .St -p1003.1b-93 .
143 .It Bq Er ESRCH
144 No process can be found corresponding to that specified by
145 .Fa pid .
146 .It Bq Er EINVAL
147 The value of the
148 .Fa policy
149 parameter is invalid, or one or more of the parameters contained in
150 .Fa param
151 is outside the valid range for the specified scheduling policy.
152 .El
153 .Sh SEE ALSO
154 .Xr sched_getparam 2 ,
155 .Xr sched_get_priority_max 2 ,
156 .Xr sched_get_priority_min 2 ,
157 .Xr sched_rr_get_interval 2 ,
158 .Xr sched_setparam 2 ,
159 .Xr sched_yield 2
160 .Sh STANDARDS
161 The
162 .Fn sched_setscheduler
163 and
164 .Fn sched_getscheduler
165 functions conform to
166 .St -p1003.1b-93 .