]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/sched.7
sched.7: tfix
[thirdparty/man-pages.git] / man7 / sched.7
CommitLineData
59c06be3 1.\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
7a0d1838
PZ
2.\" and Copyright (C) 2014 Peter Zijlstra <peterz@infradead.org>
3.\" and Copyright (C) 2014 Juri Lelli <juri.lelli@gmail.com>
59c06be3
MK
4.\" Various pieces from the old sched_setscheduler(2) page
5.\" Copyright (C) Tom Bjorkholm, Markus Kuhn & David A. Wheeler 1996-1999
6.\" and Copyright (C) 2007 Carsten Emde <Carsten.Emde@osadl.org>
7.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
8.\"
9.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
10.\" This is free documentation; you can redistribute it and/or
11.\" modify it under the terms of the GNU General Public License as
12.\" published by the Free Software Foundation; either version 2 of
13.\" the License, or (at your option) any later version.
14.\"
15.\" The GNU General Public License's references to "object code"
16.\" and "executables" are to be interpreted as the output of any
17.\" document formatting or typesetting system, including
18.\" intermediate and printed output.
19.\"
20.\" This manual is distributed in the hope that it will be useful,
21.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
22.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.\" GNU General Public License for more details.
24.\"
25.\" You should have received a copy of the GNU General Public
26.\" License along with this manual; if not, see
27.\" <http://www.gnu.org/licenses/>.
28.\" %%%LICENSE_END
29.\"
30.\" Worth looking at: http://rt.wiki.kernel.org/index.php
31.\"
bc65e772 32.TH SCHED 7 2014-10-02 "Linux" "Linux Programmer's Manual"
59c06be3
MK
33.SH NAME
34sched \- overview of scheduling APIs
35.SH DESCRIPTION
b16695a3
MK
36.SS API summary
37The Linux scheduling APIs are as follows:
38.TP
39.BR sched_setscheduler (2)
40Set the scheduling policy and parameters of a specified thread.
41.TP
42.BR sched_getscheduler (2)
43Return the scheduling policy of a specified thread.
44.TP
45.BR sched_setparam (2)
46Set the scheduling parameters of a specified thread.
47.TP
48.BR sched_getparam (2)
49Fetch the scheduling parameters of a specified thread.
50.TP
51.BR sched_get_priority_max (2)
52Return the minimum priority available in a specified scheduling policy.
53.TP
54.BR sched_get_priority_min (2)
55Return the maximum priority available in a specified scheduling policy.
56.TP
5813ff92 57.BR sched_rr_get_interval (2)
b16695a3
MK
58Fetch the quantum used for threads that are scheduled under
59the "round-robin" scheduling policy.
60.TP
61.BR sched_yield (2)
62Cause the caller to relinquish the CPU,
63so that some other thread be executed.
64.TP
65.BR sched_setaffinity (2)
66(Linux-specific)
67Set the CPU affinity of a specified thread.
68.TP
69.BR sched_getaffinity (2)
70(Linux-specific)
91f5e870 71Get the CPU affinity of a specified thread.
b16695a3
MK
72.TP
73.BR sched_setattr (2)
77dab50a
MK
74Set the scheduling policy and parameters of a specified thread.
75This (Linux-specific) system call provides a superset of the functionality of
76.BR sched_setscheduler (2)
77and
78.BR sched_setparam (2).
b16695a3
MK
79.TP
80.BR sched_getattr (2)
77dab50a
MK
81Fetch the scheduling policy and parameters of a specified thread.
82This (Linux-specific) system call provides a superset of the functionality of
83.BR sched_getscheduler (2)
84and
85.BR sched_getparam (2).
b16695a3 86.\"
59c06be3
MK
87.SS Scheduling policies
88The scheduler is the kernel component that decides which runnable thread
89will be executed by the CPU next.
90Each thread has an associated scheduling policy and a \fIstatic\fP
2e868ccc
MK
91scheduling priority,
92.IR sched_priority .
961df2a8 93The scheduler makes its decisions based on knowledge of the scheduling
59c06be3
MK
94policy and static priority of all threads on the system.
95
96For threads scheduled under one of the normal scheduling policies
97(\fBSCHED_OTHER\fP, \fBSCHED_IDLE\fP, \fBSCHED_BATCH\fP),
98\fIsched_priority\fP is not used in scheduling
99decisions (it must be specified as 0).
100
101Processes scheduled under one of the real-time policies
102(\fBSCHED_FIFO\fP, \fBSCHED_RR\fP) have a
103\fIsched_priority\fP value in the range 1 (low) to 99 (high).
104(As the numbers imply, real-time threads always have higher priority
105than normal threads.)
106Note well: POSIX.1-2001 requires an implementation to support only a
107minimum 32 distinct priority levels for the real-time policies,
108and some systems supply just this minimum.
109Portable programs should use
110.BR sched_get_priority_min (2)
111and
112.BR sched_get_priority_max (2)
113to find the range of priorities supported for a particular policy.
114
115Conceptually, the scheduler maintains a list of runnable
116threads for each possible \fIsched_priority\fP value.
117In order to determine which thread runs next, the scheduler looks for
118the nonempty list with the highest static priority and selects the
119thread at the head of this list.
120
121A thread's scheduling policy determines
122where it will be inserted into the list of threads
123with equal static priority and how it will move inside this list.
124
125All scheduling is preemptive: if a thread with a higher static
126priority becomes ready to run, the currently running thread
127will be preempted and
128returned to the wait list for its static priority level.
129The scheduling policy determines the
130ordering only within the list of runnable threads with equal static
131priority.
132.SS SCHED_FIFO: First in-first out scheduling
133\fBSCHED_FIFO\fP can be used only with static priorities higher than
1340, which means that when a \fBSCHED_FIFO\fP threads becomes runnable,
135it will always immediately preempt any currently running
136\fBSCHED_OTHER\fP, \fBSCHED_BATCH\fP, or \fBSCHED_IDLE\fP thread.
137\fBSCHED_FIFO\fP is a simple scheduling
138algorithm without time slicing.
139For threads scheduled under the
140\fBSCHED_FIFO\fP policy, the following rules apply:
141.IP * 3
142A \fBSCHED_FIFO\fP thread that has been preempted by another thread of
143higher priority will stay at the head of the list for its priority and
144will resume execution as soon as all threads of higher priority are
145blocked again.
146.IP *
147When a \fBSCHED_FIFO\fP thread becomes runnable, it
148will be inserted at the end of the list for its priority.
149.IP *
150A call to
4c2eb0c2
MK
151.BR sched_setscheduler (2),
152.BR sched_setparam (2),
59c06be3 153or
4c2eb0c2 154.BR sched_setattr (2)
59c06be3
MK
155will put the
156\fBSCHED_FIFO\fP (or \fBSCHED_RR\fP) thread identified by
157\fIpid\fP at the start of the list if it was runnable.
158As a consequence, it may preempt the currently running thread if
159it has the same priority.
160(POSIX.1-2001 specifies that the thread should go to the end
161of the list.)
162.\" In 2.2.x and 2.4.x, the thread is placed at the front of the queue
163.\" In 2.0.x, the Right Thing happened: the thread went to the back -- MTK
164.IP *
165A thread calling
166.BR sched_yield (2)
167will be put at the end of the list.
168.PP
169No other events will move a thread
170scheduled under the \fBSCHED_FIFO\fP policy in the wait list of
171runnable threads with equal static priority.
172
173A \fBSCHED_FIFO\fP
174thread runs until either it is blocked by an I/O request, it is
175preempted by a higher priority thread, or it calls
176.BR sched_yield (2).
177.SS SCHED_RR: Round-robin scheduling
178\fBSCHED_RR\fP is a simple enhancement of \fBSCHED_FIFO\fP.
179Everything
180described above for \fBSCHED_FIFO\fP also applies to \fBSCHED_RR\fP,
181except that each thread is allowed to run only for a maximum time
182quantum.
183If a \fBSCHED_RR\fP thread has been running for a time
184period equal to or longer than the time quantum, it will be put at the
185end of the list for its priority.
186A \fBSCHED_RR\fP thread that has
187been preempted by a higher priority thread and subsequently resumes
188execution as a running thread will complete the unexpired portion of
189its round-robin time quantum.
190The length of the time quantum can be
191retrieved using
192.BR sched_rr_get_interval (2).
193.\" On Linux 2.4, the length of the RR interval is influenced
194.\" by the process nice value -- MTK
195.\"
7a0d1838 196.SS SCHED_DEADLINE: Sporadic task model deadline scheduling
9cc1fa25
MK
197Since version 3.14, Linux provides a deadline scheduling policy
198.RB ( SCHED_DEADLINE ).
199This policy is currently implemented using
200GEDF (Global Earliest Deadline First)
201in conjunction with CBS (Constant Bandwidth Server).
202To set and fetch this policy and associated attributes,
203one must use the Linux-specific
204.BR sched_setattr (2)
205and
206.BR sched_getattr (2)
207system calls.
7a0d1838
PZ
208
209A sporadic task is one that has a sequence of jobs, where each
91c98da6 210job is activated at most once per period.
9cc1fa25
MK
211Each job also has a
212.IR "relative deadline" ,
91c98da6 213before which it should finish execution, and a
9cc1fa25
MK
214.IR "computation time" ,
215which is the CPU time necessary for executing the job.
216The moment when a task wakes up
217because a new job has to be executed is called the
218.IR "arrival time"
219(also referred to as the request time or release time).
220The
221.IR "start time"
222is the time at which a task starts its execution.
223The
0da5e58a 224.I "absolute deadline"
9cc1fa25 225is thus obtained by adding the relative deadline to the arrival time.
7a0d1838
PZ
226
227The following diagram clarifies these terms:
228
91c98da6 229.in +4n
7a0d1838 230.nf
7bd7f43e
MK
231arrival/wakeup absolute deadline
232 | start time |
233 | | |
234 v v v
235-----x--------xooooooooooooooooo--------x--------x---
0756f58f 236 |<- comp. time ->|
7bd7f43e
MK
237 |<------- relative deadline ------>|
238 |<-------------- period ------------------->|
7a0d1838 239.fi
91c98da6 240.in
7a0d1838 241
9cc1fa25 242When setting a
91c98da6 243.B SCHED_DEADLINE
9cc1fa25
MK
244policy for a thread using
245.BR sched_setattr (2),
246one can specify three parameters:
247.IR Runtime ,
248.IR Deadline ,
249and
250.IR Period .
251These parameters do not necessarily correspond to the aforementioned terms:
252usual practice is to set Runtime to something bigger than the average
253computation time (or worst-case execution time for hard real-time tasks),
254Deadline to the relative deadline, and Period to the period of the task.
255Thus, for
256.BR SCHED_DEADLINE
257scheduling, we have:
7a0d1838 258
91c98da6 259.in +4n
7a0d1838 260.nf
7bd7f43e
MK
261arrival/wakeup absolute deadline
262 | start time |
263 | | |
264 v v v
265-----x--------xooooooooooooooooo--------x--------x---
266 |<-- Runtime ------->|
267 |<----------- Deadline ----------->|
268 |<-------------- Period ------------------->|
7a0d1838 269.fi
91c98da6 270.in
7a0d1838 271
9cc1fa25
MK
272The three deadline-scheduling parameters correspond to the
273.IR sched_runtime ,
274.IR sched_deadline ,
275and
276.IR sched_period
277fields of the
278.I sched_attr
279structure; see
280.BR sched_setattr (2).
281These fields express value in nanoseconds.
282.\" FIXME It looks as though specifying sched_period as 0 means
bea08fec 283.\" "make sched_period the same as sched_deadline".
9cc1fa25
MK
284.\" This needs to be documented.
285If
286.IR sched_period
287is specified as 0, then it is made the same as
288.IR sched_deadline .
289
290The kernel requires that:
291
292 sched_runtime <= sched_deadline <= sched_period
293
294.\" See __checkparam_dl in kernel/sched/core.c
295In addition, under the current implementation,
296all of the parameter values must be at least 1024
297(i.e., just over one microsecond,
7bd7f43e 298which is the resolution of the implementation), and less than 2^63.
9cc1fa25
MK
299If any of these checks fails,
300.BR sched_setattr (2)
301fails with the error
302.BR EINVAL .
7a0d1838
PZ
303
304The CBS guarantees non-interference between tasks, by throttling
9cc1fa25 305threads that attempt to over-run their specified Runtime.
7a0d1838 306
9cc1fa25 307To ensure deadline scheduling guarantees,
0da5e58a 308the kernel must prevent situations where the set of
91c98da6 309.B SCHED_DEADLINE
9cc1fa25
MK
310threads is not feasible (schedulable) within the given constraints.
311The kernel thus performs an admittance test when setting or changing
91c98da6 312.B SCHED_DEADLINE
9cc1fa25
MK
313policy and attributes.
314This admission test calculates whether the change is feasible;
8e8cd193 315if it is not,
91c98da6 316.BR sched_setattr (2)
9cc1fa25
MK
317fails with the error
318.BR EBUSY .
7a0d1838
PZ
319
320For example, it is required (but not necessarily sufficient) for
9cc1fa25
MK
321the total utilization to be less than or equal to the total number of
322CPUs available, where, since each thread can maximally run for
323Runtime per Period, that thread's utilization is its
324Runtime divided by its Period.
7a0d1838 325
9cc1fa25
MK
326In order to fulfil the guarantees that are made when
327a thread is admitted to the
328.BR SCHED_DEADLINE
329policy,
91c98da6 330.BR SCHED_DEADLINE
9cc1fa25
MK
331threads are the highest priority (user controllable) threads in the
332system; if any
91c98da6 333.BR SCHED_DEADLINE
9cc1fa25
MK
334thread is runnable,
335it will preempt any thread scheduled under one of the other policies.
7a0d1838 336
9cc1fa25 337A call to
91c98da6 338.BR fork (2)
9cc1fa25
MK
339by a thread scheduled under the
340.B SCHED_DEADLINE
341policy will fail with the error
342.BR EAGAIN ,
343unless the thread has its reset-on-fork flag set (see below).
7a0d1838 344
91c98da6
MK
345A
346.B SCHED_DEADLINE
9cc1fa25 347thread that calls
91c98da6 348.BR sched_yield (2)
9cc1fa25
MK
349will yield the current job and wait for a new period to begin.
350.\"
351.\" FIXME Calling sched_getparam() on a SCHED_DEADLINE thread
352.\" fails with EINVAL, but sched_getscheduler() succeeds.
353.\" Is that intended? (Why?)
91c98da6 354.\"
59c06be3
MK
355.SS SCHED_OTHER: Default Linux time-sharing scheduling
356\fBSCHED_OTHER\fP can be used at only static priority 0.
357\fBSCHED_OTHER\fP is the standard Linux time-sharing scheduler that is
358intended for all threads that do not require the special
359real-time mechanisms.
360The thread to run is chosen from the static
361priority 0 list based on a \fIdynamic\fP priority that is determined only
362inside this list.
363The dynamic priority is based on the nice value (set by
1608b671
MK
364.BR nice (2),
365.BR setpriority (2),
59c06be3 366or
1608b671 367.BR sched_setattr (2))
59c06be3
MK
368and increased for each time quantum the thread is ready to run,
369but denied to run by the scheduler.
370This ensures fair progress among all \fBSCHED_OTHER\fP threads.
371.\"
372.SS SCHED_BATCH: Scheduling batch processes
373(Since Linux 2.6.16.)
374\fBSCHED_BATCH\fP can be used only at static priority 0.
375This policy is similar to \fBSCHED_OTHER\fP in that it schedules
376the thread according to its dynamic priority
377(based on the nice value).
378The difference is that this policy
379will cause the scheduler to always assume
380that the thread is CPU-intensive.
381Consequently, the scheduler will apply a small scheduling
a1fa36af 382penalty with respect to wakeup behavior,
59c06be3
MK
383so that this thread is mildly disfavored in scheduling decisions.
384
385.\" The following paragraph is drawn largely from the text that
386.\" accompanied Ingo Molnar's patch for the implementation of
387.\" SCHED_BATCH.
388.\" commit b0a9499c3dd50d333e2aedb7e894873c58da3785
389This policy is useful for workloads that are noninteractive,
390but do not want to lower their nice value,
391and for workloads that want a deterministic scheduling policy without
392interactivity causing extra preemptions (between the workload's tasks).
393.\"
394.SS SCHED_IDLE: Scheduling very low priority jobs
395(Since Linux 2.6.23.)
396\fBSCHED_IDLE\fP can be used only at static priority 0;
397the process nice value has no influence for this policy.
398
399This policy is intended for running jobs at extremely low
400priority (lower even than a +19 nice value with the
401.B SCHED_OTHER
402or
403.B SCHED_BATCH
404policies).
405.\"
406.SS Resetting scheduling policy for child processes
005eaa8f
MK
407Each thread has a reset-on-fork scheduling flag.
408When this flag is set, children created by
409.BR fork (2)
410do not inherit privileged scheduling policies.
411The reset-on-fork flag can be set by either:
412.IP * 3
413ORing the
59c06be3 414.B SCHED_RESET_ON_FORK
005eaa8f 415flag into the
59c06be3 416.I policy
005eaa8f
MK
417argument when calling
418.BR sched_setscheduler (2)
419(since Linux 2.6.32);
420or
421.IP *
422specifying the
423.B SCHED_FLAG_RESET_ON_FORK
424flag in
425.IR attr.sched_flags
59c06be3 426when calling
005eaa8f
MK
427.BR sched_setattr (2).
428.PP
429Note that the constants used with these two APIs have different names.
430The state of the reset-on-fork flag can analogously be retrieved using
431.BR sched_getscheduler (2)
432and
433.BR sched_getattr (2).
434
435The reset-on-fork feature is intended for media-playback applications,
59c06be3
MK
436and can be used to prevent applications evading the
437.BR RLIMIT_RTTIME
438resource limit (see
439.BR getrlimit (2))
440by creating multiple child processes.
441
005eaa8f 442More precisely, if the reset-on-fork flag is set,
59c06be3
MK
443the following rules apply for subsequently created children:
444.IP * 3
445If the calling thread has a scheduling policy of
446.B SCHED_FIFO
447or
448.BR SCHED_RR ,
449the policy is reset to
450.BR SCHED_OTHER
451in child processes.
452.IP *
453If the calling process has a negative nice value,
454the nice value is reset to zero in child processes.
455.PP
005eaa8f 456After the reset-on-fork flag has been enabled,
59c06be3
MK
457it can be reset only if the thread has the
458.BR CAP_SYS_NICE
459capability.
460This flag is disabled in child processes created by
461.BR fork (2).
59c06be3
MK
462.\"
463.SS Privileges and resource limits
464In Linux kernels before 2.6.12, only privileged
465.RB ( CAP_SYS_NICE )
466threads can set a nonzero static priority (i.e., set a real-time
467scheduling policy).
468The only change that an unprivileged thread can make is to set the
469.B SCHED_OTHER
759e1210 470policy, and this can be done only if the effective user ID of the caller
59c06be3
MK
471matches the real or effective user ID of the target thread
472(i.e., the thread specified by
473.IR pid )
474whose policy is being changed.
475
9cc1fa25
MK
476A thread must be privileged
477.RB ( CAP_SYS_NICE )
0da5e58a 478in order to set or modify a
9cc1fa25
MK
479.BR SCHED_DEADLINE
480policy.
481
59c06be3
MK
482Since Linux 2.6.12, the
483.B RLIMIT_RTPRIO
484resource limit defines a ceiling on an unprivileged thread's
485static priority for the
486.B SCHED_RR
487and
488.B SCHED_FIFO
489policies.
490The rules for changing scheduling policy and priority are as follows:
491.IP * 3
492If an unprivileged thread has a nonzero
493.B RLIMIT_RTPRIO
494soft limit, then it can change its scheduling policy and priority,
495subject to the restriction that the priority cannot be set to a
496value higher than the maximum of its current priority and its
497.B RLIMIT_RTPRIO
498soft limit.
499.IP *
500If the
501.B RLIMIT_RTPRIO
502soft limit is 0, then the only permitted changes are to lower the priority,
503or to switch to a non-real-time policy.
504.IP *
505Subject to the same rules,
506another unprivileged thread can also make these changes,
507as long as the effective user ID of the thread making the change
508matches the real or effective user ID of the target thread.
509.IP *
510Special rules apply for the
f7a858b4
MK
511.BR SCHED_IDLE
512policy.
59c06be3
MK
513In Linux kernels before 2.6.39,
514an unprivileged thread operating under this policy cannot
515change its policy, regardless of the value of its
516.BR RLIMIT_RTPRIO
517resource limit.
518In Linux kernels since 2.6.39,
519.\" commit c02aa73b1d18e43cfd79c2f193b225e84ca497c8
520an unprivileged thread can switch to either the
521.BR SCHED_BATCH
522or the
523.BR SCHED_NORMAL
524policy so long as its nice value falls within the range permitted by its
525.BR RLIMIT_NICE
526resource limit (see
527.BR getrlimit (2)).
528.PP
529Privileged
530.RB ( CAP_SYS_NICE )
531threads ignore the
532.B RLIMIT_RTPRIO
533limit; as with older kernels,
534they can make arbitrary changes to scheduling policy and priority.
535See
536.BR getrlimit (2)
537for further information on
538.BR RLIMIT_RTPRIO .
0c055c75
MK
539.SS Limiting the CPU usage of real-time and deadline processes
540A nonblocking infinite loop in a thread scheduled under the
541.BR SCHED_FIFO ,
542.BR SCHED_RR ,
543or
544.BR SCHED_DEADLINE
545policy will block all threads with lower
546priority forever.
547Prior to Linux 2.6.25, the only way of preventing a runaway real-time
548process from freezing the system was to run (at the console)
549a shell scheduled under a higher static priority than the tested application.
550This allows an emergency kill of tested
551real-time applications that do not block or terminate as expected.
552
553Since Linux 2.6.25, there are other techniques for dealing with runaway
554real-time and deadline processes.
555One of these is to use the
556.BR RLIMIT_RTTIME
557resource limit to set a ceiling on the CPU time that
558a real-time process may consume.
559See
560.BR getrlimit (2)
561for details.
562
563Since version 2.6.25, Linux also provides two
564.I /proc
565files that can be used to reserve a certain amount of CPU time
566to be used by non-real-time processes.
567Reserving some CPU time in this fashion allows some CPU time to be
568allocated to (say) a root shell that can be used to kill a runaway process.
569Both of these files specify time values in microseconds:
570.TP
571.IR /proc/sys/kernel/sched_rt_period_us
572This file specifies a scheduling period that is equivalent to
573100% CPU bandwidth.
574The value in this file can range from 1 to
575.BR INT_MAX ,
576giving an operating range of 1 microsecond to around 35 minutes.
577The default value in this file is 1,000,000 (1 second).
578.TP
579.IR /proc/sys/kernel/sched_rt_runtime_us
580The value in this file specifies how much of the "period" time
581can be used by all real-time and deadline scheduled processes
582on the system.
583The value in this file can range from \-1 to
584.BR INT_MAX \-1.
585Specifying \-1 makes the runtime the same as the period;
586that is, no CPU time is set aside for non-real-time processes
587(which was the Linux behavior before kernel 2.6.25).
588The default value in this file is 950,000 (0.95 seconds),
589meaning that 5% of the CPU time is reserved for processes that
590don't run under a real-time or deadline scheduling policy.
591.PP
59c06be3 592.SS Response time
1154a064 593A blocked high priority thread waiting for I/O has a certain
59c06be3
MK
594response time before it is scheduled again.
595The device driver writer
596can greatly reduce this response time by using a "slow interrupt"
597interrupt handler.
598.\" as described in
599.\" .BR request_irq (9).
600.SS Miscellaneous
601Child processes inherit the scheduling policy and parameters across a
602.BR fork (2).
603The scheduling policy and parameters are preserved across
604.BR execve (2).
605
606Memory locking is usually needed for real-time processes to avoid
607paging delays; this can be done with
608.BR mlock (2)
609or
610.BR mlockall (2).
59c06be3 611.SH NOTES
59c06be3
MK
612.PP
613Originally, Standard Linux was intended as a general-purpose operating
614system being able to handle background processes, interactive
615applications, and less demanding real-time applications (applications that
616need to usually meet timing deadlines).
617Although the Linux kernel 2.6
618allowed for kernel preemption and the newly introduced O(1) scheduler
619ensures that the time needed to schedule is fixed and deterministic
620irrespective of the number of active tasks, true real-time computing
621was not possible up to kernel version 2.6.17.
622.SS Real-time features in the mainline Linux kernel
623.\" FIXME . Probably this text will need some minor tweaking
624.\" by about the time of 2.6.30; ask Carsten Emde about this then.
625From kernel version 2.6.18 onward, however, Linux is gradually
626becoming equipped with real-time capabilities,
627most of which are derived from the former
628.I realtime-preempt
629patches developed by Ingo Molnar, Thomas Gleixner,
630Steven Rostedt, and others.
631Until the patches have been completely merged into the
632mainline kernel
633(this is expected to be around kernel version 2.6.30),
634they must be installed to achieve the best real-time performance.
635These patches are named:
636.in +4n
637.nf
638
639patch-\fIkernelversion\fP-rt\fIpatchversion\fP
640.fi
641.in
642.PP
643and can be downloaded from
644.UR http://www.kernel.org\:/pub\:/linux\:/kernel\:/projects\:/rt/
645.UE .
646
647Without the patches and prior to their full inclusion into the mainline
648kernel, the kernel configuration offers only the three preemption classes
649.BR CONFIG_PREEMPT_NONE ,
650.BR CONFIG_PREEMPT_VOLUNTARY ,
651and
652.B CONFIG_PREEMPT_DESKTOP
653which respectively provide no, some, and considerable
654reduction of the worst-case scheduling latency.
655
656With the patches applied or after their full inclusion into the mainline
657kernel, the additional configuration item
658.B CONFIG_PREEMPT_RT
659becomes available.
660If this is selected, Linux is transformed into a regular
661real-time operating system.
759e1210 662The FIFO and RR scheduling policies are then used to run a thread
59c06be3 663with true real-time priority and a minimum worst-case scheduling latency.
59c06be3
MK
664.SH SEE ALSO
665.ad l
666.nh
667.BR chrt (1),
f19db853 668.BR taskset (1),
59c06be3
MK
669.BR getpriority (2),
670.BR mlock (2),
671.BR mlockall (2),
672.BR munlock (2),
673.BR munlockall (2),
674.BR nice (2),
675.BR sched_get_priority_max (2),
676.BR sched_get_priority_min (2),
720a5280 677.BR sched_getscheduler (2),
59c06be3
MK
678.BR sched_getaffinity (2),
679.BR sched_getparam (2),
680.BR sched_rr_get_interval (2),
681.BR sched_setaffinity (2),
720a5280 682.BR sched_setscheduler (2),
59c06be3
MK
683.BR sched_setparam (2),
684.BR sched_yield (2),
685.BR setpriority (2),
720a5280
MK
686.BR pthread_getaffinity_np (3),
687.BR pthread_setaffinity_np (3),
688.BR sched_getcpu (3),
59c06be3
MK
689.BR capabilities (7),
690.BR cpuset (7)
691.ad
692.PP
693.I Programming for the real world \- POSIX.4
694by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0.
695.PP
b963d0e3
MK
696The Linux kernel source files
697.IR Documentation/scheduler/sched-deadline.txt ,
698.IR Documentation/scheduler/sched-rt-group.txt ,
458689ed 699.IR Documentation/scheduler/sched-design-CFS.txt ,
b963d0e3 700and
d630434e 701.IR Documentation/scheduler/sched-nice-design.txt