]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - lib/libc/sys/sched_setscheduler.2
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / lib / libc / sys / sched_setscheduler.2
1 .\" $FreeBSD$
2 .\" Copyright (c) 1998 HD Associates, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .Dd March 12, 1998
27 .Dt SCHED_SETSCHEDULER 2
28 .Os
29 .Sh NAME
30 .Nm sched_setscheduler ,
31 .Nm sched_getscheduler
32 .Nd set/get scheduling policy and scheduler parameters
33 .Sh LIBRARY
34 .Lb libc
35 .Sh SYNOPSIS
36 .In sched.h
37 .Ft int
38 .Fn sched_setscheduler "pid_t pid" "int policy" "const struct sched_param *param"
39 .Ft int
40 .Fn sched_getscheduler "pid_t pid"
41 .Sh DESCRIPTION
42 The
43 .Fn sched_setscheduler
44 system call sets the scheduling policy and scheduling parameters
45 of the process specified by
46 .Fa pid
47 to
48 .Fa policy
49 and the parameters specified in the
50 .Vt sched_param
51 structure pointed to by
52 .Fa param ,
53 respectively.
54 The value of the
55 .Fa sched_priority
56 member in the
57 .Fa param
58 structure must be any integer within the inclusive priority range for
59 the scheduling policy specified by
60 .Fa policy .
61 .Pp
62 In this implementation, if the value of
63 .Fa pid
64 is negative the system call will fail.
65 .Pp
66 If a process specified by
67 .Fa pid
68 exists and if the calling process has permission, the scheduling
69 policy and scheduling parameters will be set for the process
70 whose process ID is equal to
71 .Fa pid .
72 .Pp
73 If
74 .Fa pid
75 is zero, the scheduling policy and scheduling
76 parameters are set for the calling process.
77 .Pp
78 In this implementation, the policy of when a process can affect
79 the scheduling parameters of another process is specified in
80 .St -p1003.1b-93
81 as a write-style operation.
82 .Pp
83 The scheduling policies are in
84 .Fa <sched.h> :
85 .Bl -tag -width [SCHED_OTHER]
86 .It Bq Er SCHED_FIFO
87 First-in-first-out fixed priority scheduling with no round robin scheduling;
88 .It Bq Er SCHED_OTHER
89 The standard time sharing scheduler;
90 .It Bq Er SCHED_RR
91 Round-robin scheduling across same priority processes.
92 .El
93 .Pp
94 The
95 .Vt sched_param
96 structure is defined in
97 .Fa <sched.h> :
98 .Pp
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 system call 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.
127 In this implementation, the
128 .Fa sched_getscheduler
129 system call 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 .St -p1003.1b-93 .
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 argument 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 system calls conform to
167 .St -p1003.1b-93 .