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