]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright (C) Tom Bjorkholm, Markus Kuhn & David A. Wheeler 1996-1999 | |
cf9c27a6 | 4 | .\" and Copyright (C) 2007 Carsten Emde <Carsten.Emde@osadl.org> |
a3a22b7f | 5 | .\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
6 | .\" |
7 | .\" This is free documentation; you can redistribute it and/or | |
8 | .\" modify it under the terms of the GNU General Public License as | |
9 | .\" published by the Free Software Foundation; either version 2 of | |
10 | .\" the License, or (at your option) any later version. | |
11 | .\" | |
12 | .\" The GNU General Public License's references to "object code" | |
13 | .\" and "executables" are to be interpreted as the output of any | |
14 | .\" document formatting or typesetting system, including | |
15 | .\" intermediate and printed output. | |
16 | .\" | |
17 | .\" This manual is distributed in the hope that it will be useful, | |
18 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | .\" GNU General Public License for more details. | |
21 | .\" | |
22 | .\" You should have received a copy of the GNU General Public | |
23 | .\" License along with this manual; if not, write to the Free | |
24 | .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, | |
25 | .\" USA. | |
26 | .\" | |
27 | .\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se> | |
28 | .\" First version written | |
29 | .\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de> | |
30 | .\" revision | |
31 | .\" 1999-08-18 David A. Wheeler <dwheeler@ida.org> added Note. | |
c11b1abf | 32 | .\" Modified, 25 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com> |
c13182ef | 33 | .\" Corrected description of queue placement by sched_setparam() and |
fea681da MK |
34 | .\" sched_setscheduler() |
35 | .\" A couple of grammar clean-ups | |
c11b1abf | 36 | .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com> |
92c37d8c | 37 | .\" 2005-03-23, mtk, Added description of SCHED_BATCH. |
cf9c27a6 MK |
38 | .\" 2007-07-10, Carsten Emde <Carsten.Emde@osadl.org> |
39 | .\" Add text on real-time features that are currently being | |
40 | .\" added to the mainline kernel. | |
a1d5601b | 41 | .\" 2008-05-07, mtk; Rewrote and restructured various parts of the page to |
a3a22b7f | 42 | .\" improve readability. |
fea681da | 43 | .\" |
9b6ba4d8 | 44 | .\" Worth looking at: http://rt.wiki.kernel.org/index.php |
3787794c | 45 | .\" |
9b6ba4d8 | 46 | .TH SCHED_SETSCHEDULER 2 2008-11-06 "Linux" "Linux Programmer's Manual" |
fea681da MK |
47 | .SH NAME |
48 | sched_setscheduler, sched_getscheduler \- | |
a3a22b7f | 49 | set and get scheduling policy/parameters |
fea681da | 50 | .SH SYNOPSIS |
92c37d8c | 51 | .nf |
fea681da MK |
52 | .B #include <sched.h> |
53 | .sp | |
54 | .BI "int sched_setscheduler(pid_t " pid ", int " policy , | |
92c37d8c MK |
55 | .br |
56 | .BI " const struct sched_param *" param ); | |
fea681da MK |
57 | .sp |
58 | .BI "int sched_getscheduler(pid_t " pid ); | |
59 | .sp | |
fea681da | 60 | \fBstruct sched_param { |
92c37d8c MK |
61 | ... |
62 | int \fIsched_priority\fB; | |
63 | ... | |
fea681da | 64 | }; |
fea681da MK |
65 | .fi |
66 | .SH DESCRIPTION | |
e511ffb6 | 67 | .BR sched_setscheduler () |
fea681da | 68 | sets both the scheduling policy and the associated parameters for the |
a3a22b7f | 69 | process whose ID is specified in \fIpid\fP. |
c13182ef | 70 | If \fIpid\fP equals zero, the |
a3a22b7f | 71 | scheduling policy and parameters of the calling process will be set. |
c13182ef | 72 | The interpretation of |
c126cfd6 | 73 | the argument \fIparam\fP depends on the selected policy. |
4e592516 MK |
74 | Currently, Linux supports the following "normal" |
75 | (i.e., non-real-time) scheduling policies: | |
a3a22b7f | 76 | .TP 14 |
a1d5601b MK |
77 | .BR SCHED_OTHER |
78 | the standard round-robin time-sharing policy; | |
c13182ef | 79 | .\" In the 2.6 kernel sources, SCHED_OTHER is actually called |
92c37d8c | 80 | .\" SCHED_NORMAL. |
a3a22b7f MK |
81 | .TP |
82 | .BR SCHED_BATCH | |
83 | for "batch" style execution of processes; and | |
84 | .TP | |
85 | .BR SCHED_IDLE | |
86 | for running | |
87 | .I very | |
88 | low priority background jobs. | |
89 | .PP | |
90 | The following "real-time" policies are also supported, | |
91 | for special time-critical applications that need precise control over | |
92 | the way in which runnable processes are selected for execution: | |
93 | .TP 14 | |
94 | .BR SCHED_FIFO | |
95 | a first-in, first-out policy; and | |
96 | .TP | |
97 | .BR SCHED_RR | |
98 | a round-robin policy. | |
99 | .PP | |
100 | The semantics of each of these policies are detailed below. | |
fea681da | 101 | |
e511ffb6 | 102 | .BR sched_getscheduler () |
fea681da | 103 | queries the scheduling policy currently applied to the process |
c13182ef MK |
104 | identified by \fIpid\fP. |
105 | If \fIpid\fP equals zero, the policy of the | |
fea681da | 106 | calling process will be retrieved. |
a3a22b7f | 107 | .\" |
fea681da | 108 | .SS Scheduling Policies |
a3a22b7f | 109 | The scheduler is the kernel component that decides which runnable process |
c13182ef | 110 | will be executed by the CPU next. |
a3a22b7f MK |
111 | Each process has an associated scheduling policy and a \fIstatic\fP |
112 | scheduling priority, \fIsched_priority\fP; these are the settings | |
113 | that are modified by | |
114 | .BR sched_setscheduler (). | |
115 | The scheduler makes it decisions based on knowledge of the scheduling | |
116 | policy and static priority of all processes on the system. | |
fea681da | 117 | |
a3a22b7f MK |
118 | For processes scheduled under one of the normal scheduling policies |
119 | (\fBSCHED_OTHER\fP, \fBSCHED_IDLE\fP, \fBSCHED_BATCH\fP), | |
120 | \fIsched_priority\fP is not used in scheduling | |
121 | decisions (it must be specified as 0). | |
92c37d8c | 122 | |
a1d5601b | 123 | Processes scheduled under one of the real-time policies |
a3a22b7f MK |
124 | (\fBSCHED_FIFO\fP, \fBSCHED_RR\fP) have a |
125 | \fIsched_priority\fP value in the range 1 (low) to 99 (high). | |
126 | (As the numbers imply, real-time processes always have higher priority | |
127 | than normal processes.) | |
128 | Note well: POSIX.1-2001 only requires an implementation to support a | |
129 | minimum 32 distinct priority levels for the real-time policies, | |
6c74a966 | 130 | and some systems supply just this minimum. |
a3a22b7f | 131 | Portable programs should use |
60a90ecd MK |
132 | .BR sched_get_priority_min (2) |
133 | and | |
134 | .BR sched_get_priority_max (2) | |
a3a22b7f | 135 | to find the range of priorities supported for a particular policy. |
fea681da | 136 | |
a3a22b7f MK |
137 | Conceptually, the scheduler maintains a list of runnable |
138 | processes for each possible \fIsched_priority\fP value. | |
139 | In order to determine which process runs next, the scheduler looks for | |
aa796481 | 140 | the nonempty list with the highest static priority and selects the |
a3a22b7f MK |
141 | process at the head of this list. |
142 | ||
143 | A process's scheduling policy determines | |
144 | where it will be inserted into the list of processes | |
145 | with equal static priority and how it will move inside this list. | |
146 | ||
147 | All scheduling is preemptive: if a process with a higher static | |
148 | priority becomes ready to run, the currently running process | |
149 | will be preempted and | |
150 | returned to the wait list for its static priority level. | |
c13182ef | 151 | The scheduling policy only determines the |
fea681da MK |
152 | ordering within the list of runnable processes with equal static |
153 | priority. | |
fea681da | 154 | .SS SCHED_FIFO: First In-First Out scheduling |
5917ad3d MK |
155 | \fBSCHED_FIFO\fP can only be used with static priorities higher than |
156 | 0, which means that when a \fBSCHED_FIFO\fP processes becomes runnable, | |
92c37d8c | 157 | it will always immediately preempt any currently running |
c00194ab | 158 | \fBSCHED_OTHER\fP, \fBSCHED_BATCH\fP, or \fBSCHED_IDLE\fP process. |
5917ad3d | 159 | \fBSCHED_FIFO\fP is a simple scheduling |
c13182ef MK |
160 | algorithm without time slicing. |
161 | For processes scheduled under the | |
a3a22b7f MK |
162 | \fBSCHED_FIFO\fP policy, the following rules apply: |
163 | .IP * 3 | |
164 | A \fBSCHED_FIFO\fP process that has been preempted by another process of | |
fea681da MK |
165 | higher priority will stay at the head of the list for its priority and |
166 | will resume execution as soon as all processes of higher priority are | |
c13182ef | 167 | blocked again. |
a3a22b7f | 168 | .IP * |
5917ad3d | 169 | When a \fBSCHED_FIFO\fP process becomes runnable, it |
c13182ef | 170 | will be inserted at the end of the list for its priority. |
a3a22b7f | 171 | .IP * |
c13182ef | 172 | A call to |
60a90ecd MK |
173 | .BR sched_setscheduler () |
174 | or | |
175 | .BR sched_setparam (2) | |
176 | will put the | |
5917ad3d | 177 | \fBSCHED_FIFO\fP (or \fBSCHED_RR\fP) process identified by |
fea681da MK |
178 | \fIpid\fP at the start of the list if it was runnable. |
179 | As a consequence, it may preempt the currently running process if | |
180 | it has the same priority. | |
a7fadb55 | 181 | (POSIX.1-2001 specifies that the process should go to the end |
fea681da MK |
182 | of the list.) |
183 | .\" In 2.2.x and 2.4.x, the process is placed at the front of the queue | |
184 | .\" In 2.0.x, the Right Thing happened: the process went to the back -- MTK | |
a3a22b7f | 185 | .IP * |
60a90ecd MK |
186 | A process calling |
187 | .BR sched_yield (2) | |
a3a22b7f MK |
188 | will be put at the end of the list. |
189 | .PP | |
c13182ef | 190 | No other events will move a process |
5917ad3d | 191 | scheduled under the \fBSCHED_FIFO\fP policy in the wait list of |
c13182ef | 192 | runnable processes with equal static priority. |
a3a22b7f | 193 | |
5917ad3d | 194 | A \fBSCHED_FIFO\fP |
fea681da | 195 | process runs until either it is blocked by an I/O request, it is |
60a90ecd MK |
196 | preempted by a higher priority process, or it calls |
197 | .BR sched_yield (2). | |
fea681da | 198 | .SS SCHED_RR: Round Robin scheduling |
5917ad3d | 199 | \fBSCHED_RR\fP is a simple enhancement of \fBSCHED_FIFO\fP. |
c13182ef | 200 | Everything |
5917ad3d | 201 | described above for \fBSCHED_FIFO\fP also applies to \fBSCHED_RR\fP, |
fea681da | 202 | except that each process is only allowed to run for a maximum time |
c13182ef | 203 | quantum. |
5917ad3d | 204 | If a \fBSCHED_RR\fP process has been running for a time |
fea681da | 205 | period equal to or longer than the time quantum, it will be put at the |
c13182ef | 206 | end of the list for its priority. |
5917ad3d | 207 | A \fBSCHED_RR\fP process that has |
fea681da MK |
208 | been preempted by a higher priority process and subsequently resumes |
209 | execution as a running process will complete the unexpired portion of | |
c13182ef MK |
210 | its round robin time quantum. |
211 | The length of the time quantum can be | |
60a90ecd MK |
212 | retrieved using |
213 | .BR sched_rr_get_interval (2). | |
fea681da MK |
214 | .\" On Linux 2.4, the length of the RR interval is influenced |
215 | .\" by the process nice value -- MTK | |
af800319 | 216 | .\" |
fea681da | 217 | .SS SCHED_OTHER: Default Linux time-sharing scheduling |
5917ad3d MK |
218 | \fBSCHED_OTHER\fP can only be used at static priority 0. |
219 | \fBSCHED_OTHER\fP is the standard Linux time-sharing scheduler that is | |
a3a22b7f | 220 | intended for all processes that do not require the special |
c13182ef MK |
221 | real-time mechanisms. |
222 | The process to run is chosen from the static | |
a3a22b7f | 223 | priority 0 list based on a \fIdynamic\fP priority that is determined only |
c13182ef | 224 | inside this list. |
a3a22b7f | 225 | The dynamic priority is based on the nice value (set by |
60a90ecd MK |
226 | .BR nice (2) |
227 | or | |
228 | .BR setpriority (2)) | |
a3a22b7f MK |
229 | and increased for each time quantum the process is ready to run, |
230 | but denied to run by the scheduler. | |
231 | This ensures fair progress among all \fBSCHED_OTHER\fP processes. | |
232 | .\" | |
92c37d8c MK |
233 | .SS SCHED_BATCH: Scheduling batch processes |
234 | (Since Linux 2.6.16.) | |
5917ad3d | 235 | \fBSCHED_BATCH\fP can only be used at static priority 0. |
6958017f MK |
236 | This policy is similar to \fBSCHED_OTHER\fP in that it schedules |
237 | the process according to its dynamic priority | |
238 | (based on the nice value). | |
239 | The difference is that this policy | |
240 | will cause the scheduler to always assume | |
92c37d8c MK |
241 | that the process is CPU-intensive. |
242 | Consequently, the scheduler will apply a small scheduling | |
c00194ab MK |
243 | penalty with respect to wakeup behaviour, |
244 | so that this process is mildly disfavored in scheduling decisions. | |
a3a22b7f | 245 | |
c13182ef MK |
246 | .\" The following paragraph is drawn largely from the text that |
247 | .\" accompanied Ingo Molnar's patch for the implementation of | |
92c37d8c MK |
248 | .\" SCHED_BATCH. |
249 | This policy is useful for workloads that are non-interactive, | |
c13182ef MK |
250 | but do not want to lower their nice value, |
251 | and for workloads that want a deterministic scheduling policy without | |
92c37d8c | 252 | interactivity causing extra preemptions (between the workload's tasks). |
c00194ab MK |
253 | .\" |
254 | .SS SCHED_IDLE: Scheduling very low priority jobs | |
255 | (Since Linux 2.6.23.) | |
256 | \fBSCHED_IDLE\fP can only be used at static priority 0; | |
257 | the process nice value has no influence for this policy. | |
a3a22b7f | 258 | |
c00194ab MK |
259 | This policy is intended for running jobs at extremely low |
260 | priority (lower even than a +19 nice value with the | |
261 | .B SCHED_OTHER | |
262 | or | |
263 | .B SCHED_BATCH | |
264 | policies). | |
265 | .\" | |
fd04afa8 | 266 | .SS Privileges and resource limits |
fd04afa8 MK |
267 | In Linux kernels before 2.6.12, only privileged |
268 | .RB ( CAP_SYS_NICE ) | |
c7094399 | 269 | processes can set a nonzero static priority (i.e., set a real-time |
a3a22b7f | 270 | scheduling policy). |
afdee10d MK |
271 | The only change that an unprivileged process can make is to set the |
272 | .B SCHED_OTHER | |
273 | policy, and this can only be done if the effective user ID of the caller of | |
e511ffb6 | 274 | .BR sched_setscheduler () |
c13182ef | 275 | matches the real or effective user ID of the target process |
afdee10d MK |
276 | (i.e., the process specified by |
277 | .IR pid ) | |
278 | whose policy is being changed. | |
279 | ||
fd04afa8 MK |
280 | Since Linux 2.6.12, the |
281 | .B RLIMIT_RTPRIO | |
afdee10d | 282 | resource limit defines a ceiling on an unprivileged process's |
a3a22b7f | 283 | static priority for the |
fd04afa8 MK |
284 | .B SCHED_RR |
285 | and | |
0daa9e92 | 286 | .B SCHED_FIFO |
fd04afa8 | 287 | policies. |
4e592516 MK |
288 | The rules for changing scheduling policy and priority are as follows: |
289 | .IP * 2 | |
c7094399 | 290 | If an unprivileged process has a nonzero |
afdee10d | 291 | .B RLIMIT_RTPRIO |
c13182ef MK |
292 | soft limit, then it can change its scheduling policy and priority, |
293 | subject to the restriction that the priority cannot be set to a | |
4e592516 | 294 | value higher than the maximum of its current priority and its |
afdee10d MK |
295 | .B RLIMIT_RTPRIO |
296 | soft limit. | |
4e592516 | 297 | .IP * |
c13182ef | 298 | If the |
afdee10d | 299 | .B RLIMIT_RTPRIO |
4e592516 MK |
300 | soft limit is 0, then the only permitted changes are to lower the priority, |
301 | or to switch to a non-real-time policy. | |
302 | .IP * | |
c13182ef MK |
303 | Subject to the same rules, |
304 | another unprivileged process can also make these changes, | |
305 | as long as the effective user ID of the process making the change | |
afdee10d | 306 | matches the real or effective user ID of the target process. |
4e592516 MK |
307 | .IP * |
308 | Special rules apply for the | |
309 | .BR SCHED_IDLE : | |
310 | an unprivileged process operating under this policy cannot | |
311 | change its policy, regardless of the value of its | |
312 | .BR RLIMIT_RTPRIO | |
313 | resource limit. | |
314 | .PP | |
315 | Privileged | |
316 | .RB ( CAP_SYS_NICE ) | |
317 | processes ignore the | |
318 | .B RLIMIT_RTPRIO | |
319 | limit; as with older kernels, | |
320 | they can make arbitrary changes to scheduling policy and priority. | |
fd04afa8 MK |
321 | See |
322 | .BR getrlimit (2) | |
323 | for further information on | |
324 | .BR RLIMIT_RTPRIO . | |
fea681da MK |
325 | .SS Response time |
326 | A blocked high priority process waiting for the I/O has a certain | |
c13182ef MK |
327 | response time before it is scheduled again. |
328 | The device driver writer | |
fea681da MK |
329 | can greatly reduce this response time by using a "slow interrupt" |
330 | interrupt handler. | |
331 | .\" as described in | |
332 | .\" .BR request_irq (9). | |
fea681da | 333 | .SS Miscellaneous |
a3a22b7f | 334 | Child processes inherit the scheduling policy and parameters across a |
0bfa087b | 335 | .BR fork (2). |
a3a22b7f | 336 | The scheduling policy and parameters are preserved across |
ddb51c37 | 337 | .BR execve (2). |
fea681da | 338 | |
c13182ef | 339 | Memory locking is usually needed for real-time processes to avoid |
a3a22b7f | 340 | paging delays; this can be done with |
0bfa087b | 341 | .BR mlock (2) |
c13182ef | 342 | or |
0bfa087b | 343 | .BR mlockall (2). |
fea681da | 344 | |
ff40dbb3 | 345 | Since a nonblocking infinite loop in a process scheduled under |
5917ad3d | 346 | \fBSCHED_FIFO\fP or \fBSCHED_RR\fP will block all processes with lower |
fea681da MK |
347 | priority forever, a software developer should always keep available on |
348 | the console a shell scheduled under a higher static priority than the | |
c13182ef MK |
349 | tested application. |
350 | This will allow an emergency kill of tested | |
afdee10d | 351 | real-time applications that do not block or terminate as expected. |
a3a22b7f MK |
352 | See also the description of the |
353 | .BR RLIMIT_RTTIME | |
354 | resource limit in | |
355 | .BR getrlimit (2). | |
fea681da MK |
356 | |
357 | POSIX systems on which | |
e511ffb6 | 358 | .BR sched_setscheduler () |
fea681da | 359 | and |
e511ffb6 | 360 | .BR sched_getscheduler () |
fea681da | 361 | are available define |
f25eaea8 | 362 | .B _POSIX_PRIORITY_SCHEDULING |
c84371c6 | 363 | in \fI<unistd.h>\fP. |
fea681da MK |
364 | .SH "RETURN VALUE" |
365 | On success, | |
e511ffb6 | 366 | .BR sched_setscheduler () |
c13182ef | 367 | returns zero. |
fea681da | 368 | On success, |
e511ffb6 | 369 | .BR sched_getscheduler () |
2fda57bd | 370 | returns the policy for the process (a nonnegative integer). |
92c37d8c | 371 | On error, \-1 is returned, and |
fea681da MK |
372 | .I errno |
373 | is set appropriately. | |
374 | .SH ERRORS | |
375 | .TP | |
376 | .B EINVAL | |
377 | The scheduling \fIpolicy\fP is not one of the recognized policies, | |
c126cfd6 | 378 | or \fIparam\fP does not make sense for the \fIpolicy\fP. |
fea681da MK |
379 | .TP |
380 | .B EPERM | |
afdee10d | 381 | The calling process does not have appropriate privileges. |
fea681da MK |
382 | .TP |
383 | .B ESRCH | |
384 | The process whose ID is \fIpid\fP could not be found. | |
385 | .SH "CONFORMING TO" | |
d61ff56a | 386 | POSIX.1-2001 (but see BUGS below). |
c00194ab | 387 | The \fBSCHED_BATCH\fP and \fBSCHED_IDLE\fP policies are Linux-specific. |
92c37d8c | 388 | .SH NOTES |
97bc0094 MK |
389 | POSIX.1 does not detail the permissions that an unprivileged |
390 | process requires in order to call | |
f902bebc | 391 | .BR sched_setscheduler (), |
97bc0094 MK |
392 | and details vary across systems. |
393 | For example, the Solaris 7 manual page says that | |
bfd91cc8 | 394 | the real or effective user ID of the calling process must |
97bc0094 | 395 | match the real user ID or the save set-user-ID of the target process. |
cf9c27a6 MK |
396 | .PP |
397 | Originally, Standard Linux was intended as a general-purpose operating | |
398 | system being able to handle background processes, interactive | |
399 | applications, and less demanding real-time applications (applications that | |
400 | need to usually meet timing deadlines). | |
401 | Although the Linux kernel 2.6 | |
402 | allowed for kernel preemption and the newly introduced O(1) scheduler | |
403 | ensures that the time needed to schedule is fixed and deterministic | |
404 | irrespective of the number of active tasks, true real-time computing | |
405 | was not possible up to kernel version 2.6.17. | |
406 | .SS Real-time features in the mainline Linux kernel | |
c5871a7d | 407 | .\" FIXME . Probably this text will need some minor tweaking |
435ecb8e | 408 | .\" by about the time of 2.6.30; ask Carsten Emde about this then. |
cf9c27a6 MK |
409 | From kernel version 2.6.18 onwards, however, Linux is gradually |
410 | becoming equipped with real-time capabilities, | |
411 | most of which are derived from the former | |
83ea1eee | 412 | .I realtime-preempt |
435ecb8e MK |
413 | patches developed by Ingo Molnar, Thomas Gleixner, |
414 | Steven Rostedt, and others. | |
bf1c0ede | 415 | Until the patches have been completely merged into the |
cf9c27a6 | 416 | mainline kernel |
9b6ba4d8 | 417 | (this is expected to be around kernel version 2.6.30), |
b77e081d | 418 | they must be installed to achieve the best real-time performance. |
cf9c27a6 | 419 | These patches are named: |
088a639b | 420 | .in +4n |
cf9c27a6 | 421 | .nf |
97bc0094 | 422 | |
cf9c27a6 MK |
423 | patch-\fIkernelversion\fP-rt\fIpatchversion\fP |
424 | .fi | |
425 | .in | |
fea681da | 426 | .PP |
cf9c27a6 | 427 | and can be downloaded from |
435ecb8e | 428 | .IR http://www.kernel.org/pub/linux/kernel/projects/rt/ . |
cf9c27a6 MK |
429 | |
430 | Without the patches and prior to their full inclusion into the mainline | |
431 | kernel, the kernel configuration offers only the three preemption classes | |
432 | .BR CONFIG_PREEMPT_NONE , | |
433 | .BR CONFIG_PREEMPT_VOLUNTARY , | |
434 | and | |
0daa9e92 | 435 | .B CONFIG_PREEMPT_DESKTOP |
cf9c27a6 MK |
436 | which respectively provide no, some, and considerable |
437 | reduction of the worst-case scheduling latency. | |
438 | ||
439 | With the patches applied or after their full inclusion into the mainline | |
440 | kernel, the additional configuration item | |
0daa9e92 | 441 | .B CONFIG_PREEMPT_RT |
cf9c27a6 MK |
442 | becomes available. |
443 | If this is selected, Linux is transformed into a regular | |
444 | real-time operating system. | |
445 | The FIFO and RR scheduling policies that can be selected using | |
446 | .BR sched_setscheduler () | |
447 | are then used to run a process | |
448 | with true real-time priority and a minimum worst-case scheduling latency. | |
d61ff56a MK |
449 | .SH BUGS |
450 | POSIX says that on success, | |
451 | .BR sched_setscheduler () | |
452 | should return the previous scheduling policy. | |
453 | Linux | |
454 | .BR sched_setscheduler () | |
455 | does not conform to this requirement, | |
456 | since it always returns 0 on success. | |
fea681da MK |
457 | .SH "SEE ALSO" |
458 | .BR getpriority (2), | |
459 | .BR mlock (2), | |
460 | .BR mlockall (2), | |
461 | .BR munlock (2), | |
462 | .BR munlockall (2), | |
463 | .BR nice (2), | |
464 | .BR sched_get_priority_max (2), | |
465 | .BR sched_get_priority_min (2), | |
466 | .BR sched_getaffinity (2), | |
467 | .BR sched_getparam (2), | |
468 | .BR sched_rr_get_interval (2), | |
469 | .BR sched_setaffinity (2), | |
470 | .BR sched_setparam (2), | |
471 | .BR sched_yield (2), | |
472 | .BR setpriority (2), | |
a18e2edb MK |
473 | .BR capabilities (7), |
474 | .BR cpuset (7) | |
fea681da MK |
475 | .PP |
476 | .I Programming for the real world \- POSIX.4 | |
477 | by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0 | |
ea6100ea MK |
478 | .PP |
479 | The kernel source file | |
480 | .I Documentation/scheduler/sched-rt-group.txt | |
481 | (since kernel 2.6.25). |