]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libc/sys/sched_setscheduler.2
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 .Bd -literal -offset indent
99 struct sched_param {
100         int sched_priority;     /* scheduling priority */
101 };
102 .Ed
103 .Pp
104 The
105 .Fn sched_getscheduler
106 system call returns the scheduling policy of the process specified
107 by
108 .Fa pid .
109 .Pp
110 If a process specified by
111 .Fa pid
112 exists and if the calling process has permission,
113 the scheduling parameters for the process whose process ID is equal to
114 .Fa pid
115 are returned.
116 .Pp
117 In this implementation, the policy of when a process can obtain the
118 scheduling parameters of another process are detailed in
119 .St -p1003.1b-93
120 as a read-style operation.
121 .Pp
122 If
123 .Fa pid
124 is zero, the scheduling parameters for the calling process will be
125 returned.
126 In this implementation, the
127 .Fa sched_getscheduler
128 system call 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 argument 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 system calls conform to
166 .St -p1003.1b-93 .