summaryrefslogtreecommitdiffstats
path: root/man7/sched.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/sched.7')
-rw-r--r--man7/sched.7190
1 files changed, 95 insertions, 95 deletions
diff --git a/man7/sched.7 b/man7/sched.7
index 5640325a9..f4a7f9eb7 100644
--- a/man7/sched.7
+++ b/man7/sched.7
@@ -23,65 +23,65 @@ Linux provides the following system calls for controlling
the CPU scheduling behavior, policy, and priority of processes
(or, more precisely, threads).
.TP
-.BR nice (2)
+.MR nice 2
Set a new nice value for the calling thread,
and return the new nice value.
.TP
-.BR getpriority (2)
+.MR getpriority 2
Return the nice value of a thread, a process group,
or the set of threads owned by a specified user.
.TP
-.BR setpriority (2)
+.MR setpriority 2
Set the nice value of a thread, a process group,
or the set of threads owned by a specified user.
.TP
-.BR sched_setscheduler (2)
+.MR sched_setscheduler 2
Set the scheduling policy and parameters of a specified thread.
.TP
-.BR sched_getscheduler (2)
+.MR sched_getscheduler 2
Return the scheduling policy of a specified thread.
.TP
-.BR sched_setparam (2)
+.MR sched_setparam 2
Set the scheduling parameters of a specified thread.
.TP
-.BR sched_getparam (2)
+.MR sched_getparam 2
Fetch the scheduling parameters of a specified thread.
.TP
-.BR sched_get_priority_max (2)
+.MR sched_get_priority_max 2
Return the maximum priority available in a specified scheduling policy.
.TP
-.BR sched_get_priority_min (2)
+.MR sched_get_priority_min 2
Return the minimum priority available in a specified scheduling policy.
.TP
-.BR sched_rr_get_interval (2)
+.MR sched_rr_get_interval 2
Fetch the quantum used for threads that are scheduled under
the "round-robin" scheduling policy.
.TP
-.BR sched_yield (2)
+.MR sched_yield 2
Cause the caller to relinquish the CPU,
so that some other thread be executed.
.TP
-.BR sched_setaffinity (2)
+.MR sched_setaffinity 2
(Linux-specific)
Set the CPU affinity of a specified thread.
.TP
-.BR sched_getaffinity (2)
+.MR sched_getaffinity 2
(Linux-specific)
Get the CPU affinity of a specified thread.
.TP
-.BR sched_setattr (2)
+.MR sched_setattr 2
Set the scheduling policy and parameters of a specified thread.
This (Linux-specific) system call provides a superset of the functionality of
-.BR sched_setscheduler (2)
+.MR sched_setscheduler 2
and
-.BR sched_setparam (2).
+.MR sched_setparam 2 .
.TP
-.BR sched_getattr (2)
+.MR sched_getattr 2
Fetch the scheduling policy and parameters of a specified thread.
This (Linux-specific) system call provides a superset of the functionality of
-.BR sched_getscheduler (2)
+.MR sched_getscheduler 2
and
-.BR sched_getparam (2).
+.MR sched_getparam 2 .
.\"
.SS Scheduling policies
The scheduler is the kernel component that decides which runnable thread
@@ -106,9 +106,9 @@ Note well: POSIX.1 requires an implementation to support only a
minimum 32 distinct priority levels for the real-time policies,
and some systems supply just this minimum.
Portable programs should use
-.BR sched_get_priority_min (2)
+.MR sched_get_priority_min 2
and
-.BR sched_get_priority_max (2)
+.MR sched_get_priority_max 2
to find the range of priorities supported for a particular policy.
.P
Conceptually, the scheduler maintains a list of runnable
@@ -147,12 +147,12 @@ When a blocked \fBSCHED_FIFO\fP thread becomes runnable, it
will be inserted at the end of the list for its priority.
.IP \[bu]
If a call to
-.BR sched_setscheduler (2),
-.BR sched_setparam (2),
-.BR sched_setattr (2),
-.BR pthread_setschedparam (3),
+.MR sched_setscheduler 2 ,
+.MR sched_setparam 2 ,
+.MR sched_setattr 2 ,
+.MR pthread_setschedparam 3 ,
or
-.BR pthread_setschedprio (3)
+.MR pthread_setschedprio 3
changes the priority of the running or runnable
.B SCHED_FIFO
thread identified by
@@ -175,14 +175,14 @@ it is placed at the front of the list for its new priority.
.IP
According to POSIX.1-2008,
changes to a thread's priority (or policy) using any mechanism other than
-.BR pthread_setschedprio (3)
+.MR pthread_setschedprio 3
should result in the thread being placed at the end of
the list for its priority.
.\" In Linux 2.2.x and Linux 2.4.x, the thread is placed at the front of the queue
.\" In Linux 2.0.x, the Right Thing happened: the thread went to the back -- MTK
.IP \[bu]
A thread calling
-.BR sched_yield (2)
+.MR sched_yield 2
will be put at the end of the list.
.P
No other events will move a thread
@@ -192,7 +192,7 @@ runnable threads with equal static priority.
A \fBSCHED_FIFO\fP
thread runs until either it is blocked by an I/O request, it is
preempted by a higher priority thread, or it calls
-.BR sched_yield (2).
+.MR sched_yield 2 .
.SS SCHED_RR: Round-robin scheduling
\fBSCHED_RR\fP is a simple enhancement of \fBSCHED_FIFO\fP.
Everything
@@ -208,7 +208,7 @@ execution as a running thread will complete the unexpired portion of
its round-robin time quantum.
The length of the time quantum can be
retrieved using
-.BR sched_rr_get_interval (2).
+.MR sched_rr_get_interval 2 .
.\" On Linux 2.4, the length of the RR interval is influenced
.\" by the process nice value -- MTK
.\"
@@ -220,9 +220,9 @@ GEDF (Global Earliest Deadline First)
in conjunction with CBS (Constant Bandwidth Server).
To set and fetch this policy and associated attributes,
one must use the Linux-specific
-.BR sched_setattr (2)
+.MR sched_setattr 2
and
-.BR sched_getattr (2)
+.MR sched_getattr 2
system calls.
.P
A sporadic task is one that has a sequence of jobs, where each
@@ -261,7 +261,7 @@ arrival/wakeup absolute deadline
When setting a
.B SCHED_DEADLINE
policy for a thread using
-.BR sched_setattr (2),
+.MR sched_setattr 2 ,
one can specify three parameters:
.IR Runtime ,
.IR Deadline ,
@@ -296,7 +296,7 @@ and
fields of the
.I sched_attr
structure; see
-.BR sched_setattr (2).
+.MR sched_setattr 2 .
These fields express values in nanoseconds.
.\" FIXME It looks as though specifying sched_period as 0 means
.\" "make sched_period the same as sched_deadline".
@@ -320,7 +320,7 @@ all of the parameter values must be at least 1024
(i.e., just over one microsecond,
which is the resolution of the implementation), and less than 2\[ha]63.
If any of these checks fails,
-.BR sched_setattr (2)
+.MR sched_setattr 2
fails with the error
.BR EINVAL .
.P
@@ -336,7 +336,7 @@ The kernel thus performs an admittance test when setting or changing
policy and attributes.
This admission test calculates whether the change is feasible;
if it is not,
-.BR sched_setattr (2)
+.MR sched_setattr 2
fails with the error
.BR EBUSY .
.P
@@ -358,7 +358,7 @@ thread is runnable,
it will preempt any thread scheduled under one of the other policies.
.P
A call to
-.BR fork (2)
+.MR fork 2
by a thread scheduled under the
.B SCHED_DEADLINE
policy fails with the error
@@ -368,7 +368,7 @@ unless the thread has its reset-on-fork flag set (see below).
A
.B SCHED_DEADLINE
thread that calls
-.BR sched_yield (2)
+.MR sched_yield 2
will yield the current job and wait for a new period to begin.
.\"
.\" FIXME Calling sched_getparam() on a SCHED_DEADLINE thread
@@ -407,10 +407,10 @@ and
.B SCHED_BATCH
(see below) processes.
The nice value can be modified using
-.BR nice (2),
-.BR setpriority (2),
+.MR nice 2 ,
+.MR setpriority 2 ,
or
-.BR sched_setattr (2).
+.MR sched_setattr 2 .
.P
According to POSIX.1, the nice value is a per-process attribute;
that is, the threads in a process should share a nice value.
@@ -446,7 +446,7 @@ On Linux, the
.B RLIMIT_NICE
resource limit can be used to define a limit to which
an unprivileged process's nice value can be raised; see
-.BR setrlimit (2)
+.MR setrlimit 2
for details.
.P
For further details on the nice value, see the subsections on
@@ -489,7 +489,7 @@ policies).
.SS Resetting scheduling policy for child processes
Each thread has a reset-on-fork scheduling flag.
When this flag is set, children created by
-.BR fork (2)
+.MR fork 2
do not inherit privileged scheduling policies.
The reset-on-fork flag can be set by either:
.IP \[bu] 3
@@ -498,7 +498,7 @@ ORing the
flag into the
.I policy
argument when calling
-.BR sched_setscheduler (2)
+.MR sched_setscheduler 2
(since Linux 2.6.32);
or
.IP \[bu]
@@ -507,19 +507,19 @@ specifying the
flag in
.I attr.sched_flags
when calling
-.BR sched_setattr (2).
+.MR sched_setattr 2 .
.P
Note that the constants used with these two APIs have different names.
The state of the reset-on-fork flag can analogously be retrieved using
-.BR sched_getscheduler (2)
+.MR sched_getscheduler 2
and
-.BR sched_getattr (2).
+.MR sched_getattr 2 .
.P
The reset-on-fork feature is intended for media-playback applications,
and can be used to prevent applications evading the
.B RLIMIT_RTTIME
resource limit (see
-.BR getrlimit (2))
+.MR getrlimit 2 )
by creating multiple child processes.
.P
More precisely, if the reset-on-fork flag is set,
@@ -541,7 +541,7 @@ it can be reset only if the thread has the
.B CAP_SYS_NICE
capability.
This flag is disabled in child processes created by
-.BR fork (2).
+.MR fork 2 .
.\"
.SS Privileges and resource limits
Before Linux 2.6.12, only privileged
@@ -607,7 +607,7 @@ or the
policy so long as its nice value falls within the range permitted by its
.B RLIMIT_NICE
resource limit (see
-.BR getrlimit (2)).
+.MR getrlimit 2 ).
.P
Privileged
.RB ( CAP_SYS_NICE )
@@ -616,7 +616,7 @@ threads ignore the
limit; as with older kernels,
they can make arbitrary changes to scheduling policy and priority.
See
-.BR getrlimit (2)
+.MR getrlimit 2
for further information on
.BR RLIMIT_RTPRIO .
.SS Limiting the CPU usage of real-time and deadline processes
@@ -640,7 +640,7 @@ One of these is to use the
resource limit to set a ceiling on the CPU time that
a real-time process may consume.
See
-.BR getrlimit (2)
+.MR getrlimit 2
for details.
.P
Since Linux 2.6.25, Linux also provides two
@@ -681,15 +681,15 @@ interrupt handler.
.\" .BR request_irq (9).
.SS Miscellaneous
Child processes inherit the scheduling policy and parameters across a
-.BR fork (2).
+.MR fork 2 .
The scheduling policy and parameters are preserved across
-.BR execve (2).
+.MR execve 2 .
.P
Memory locking is usually needed for real-time processes to avoid
paging delays; this can be done with
-.BR mlock (2)
+.MR mlock 2
or
-.BR mlockall (2).
+.MR mlockall 2 .
.\"
.SS The autogroup feature
.\" commit 5091faa449ee0b7d73bc296a93bca9540fc51d0a
@@ -698,7 +698,7 @@ the kernel provides a feature known as autogrouping to improve interactive
desktop performance in the face of multiprocess, CPU-intensive
workloads such as building the Linux kernel with large numbers of
parallel build processes (i.e., the
-.BR make (1)
+.MR make 1
.B \-j
flag).
.P
@@ -713,10 +713,10 @@ The default value in this file is 1, unless the kernel was booted with the
parameter.
.P
A new autogroup is created when a new session is created via
-.BR setsid (2);
+.MR setsid 2 ;
this happens, for example, when a new terminal window is started.
A new process created by
-.BR fork (2)
+.MR fork 2
inherits its parent's autogroup membership.
Thus, all of the processes in a session are members of the same autogroup.
An autogroup is automatically destroyed when the last process
@@ -731,7 +731,7 @@ can be described via the following example.
.P
Suppose that there are two autogroups competing for the same CPU
(i.e., presume either a single CPU system or the use of
-.BR taskset (1)
+.MR taskset 1
to confine all the processes to the same CPU on an SMP system).
The first group contains ten CPU-bound processes from
a kernel build started with
@@ -776,7 +776,7 @@ This is done by writing a number in the "nice" range to the file
to set the autogroup's nice value.
The allowed range is from +19 (low priority) to \-20 (high priority).
(Writing values outside of this range causes
-.BR write (2)
+.MR write 2
to fail with the error
.BR EINVAL .)
.\" FIXME .
@@ -802,7 +802,7 @@ and the process's nice value
(compared to other processes in the same autogroup.
.P
The use of the
-.BR cgroups (7)
+.MR cgroups 7
CPU controller to place processes in cgroups other than the
root CPU cgroup overrides the effect of autogrouping.
.P
@@ -840,7 +840,7 @@ corresponding parent cgroup.
If autogrouping is enabled,
then all of the threads that are (implicitly) placed in an autogroup
(i.e., the same session, as created by
-.BR setsid (2))
+.MR setsid 2 )
form a task group.
Each new autogroup is thus a separate task group.
The root task group is the parent of all such autogroups.
@@ -864,9 +864,9 @@ This has some surprising consequences in terms of the traditional semantics
of the nice value on UNIX systems.
In particular, if autogrouping
is enabled (which is the default in various distributions), then employing
-.BR setpriority (2)
+.MR setpriority 2
or
-.BR nice (1)
+.MR nice 1
on a process has an effect only for scheduling relative
to other processes executed in the same session
(typically: the same terminal window).
@@ -934,7 +934,7 @@ The FIFO and RR scheduling policies are then used to run a thread
with true real-time priority and a minimum worst-case scheduling latency.
.SH NOTES
The
-.BR cgroups (7)
+.MR cgroups 7
CPU controller can be used to limit the CPU consumption of
groups of processes.
.P
@@ -950,35 +950,35 @@ was not possible up to Linux 2.6.17.
.SH SEE ALSO
.ad l
.nh
-.BR chcpu (1),
-.BR chrt (1),
-.BR lscpu (1),
-.BR ps (1),
-.BR taskset (1),
-.BR top (1),
-.BR getpriority (2),
-.BR mlock (2),
-.BR mlockall (2),
-.BR munlock (2),
-.BR munlockall (2),
-.BR nice (2),
-.BR sched_get_priority_max (2),
-.BR sched_get_priority_min (2),
-.BR sched_getaffinity (2),
-.BR sched_getparam (2),
-.BR sched_getscheduler (2),
-.BR sched_rr_get_interval (2),
-.BR sched_setaffinity (2),
-.BR sched_setparam (2),
-.BR sched_setscheduler (2),
-.BR sched_yield (2),
-.BR setpriority (2),
-.BR pthread_getaffinity_np (3),
-.BR pthread_getschedparam (3),
-.BR pthread_setaffinity_np (3),
-.BR sched_getcpu (3),
-.BR capabilities (7),
-.BR cpuset (7)
+.MR chcpu 1 ,
+.MR chrt 1 ,
+.MR lscpu 1 ,
+.MR ps 1 ,
+.MR taskset 1 ,
+.MR top 1 ,
+.MR getpriority 2 ,
+.MR mlock 2 ,
+.MR mlockall 2 ,
+.MR munlock 2 ,
+.MR munlockall 2 ,
+.MR nice 2 ,
+.MR sched_get_priority_max 2 ,
+.MR sched_get_priority_min 2 ,
+.MR sched_getaffinity 2 ,
+.MR sched_getparam 2 ,
+.MR sched_getscheduler 2 ,
+.MR sched_rr_get_interval 2 ,
+.MR sched_setaffinity 2 ,
+.MR sched_setparam 2 ,
+.MR sched_setscheduler 2 ,
+.MR sched_yield 2 ,
+.MR setpriority 2 ,
+.MR pthread_getaffinity_np 3 ,
+.MR pthread_getschedparam 3 ,
+.MR pthread_setaffinity_np 3 ,
+.MR sched_getcpu 3 ,
+.MR capabilities 7 ,
+.MR cpuset 7
.ad
.P
.I Programming for the real world \- POSIX.4