This commit is contained in:
Michael Kerrisk 2007-06-20 22:11:14 +00:00
parent f25eaea8f3
commit 5917ad3d34
3 changed files with 39 additions and 39 deletions

View File

@ -45,11 +45,11 @@ returns the minimum priority value that can be used with the
scheduling algorithm identified by \fIpolicy\fR. scheduling algorithm identified by \fIpolicy\fR.
Supported \fIpolicy\fR Supported \fIpolicy\fR
values are values are
.IR SCHED_FIFO , .BR SCHED_FIFO ,
.IR SCHED_RR , .BR SCHED_RR ,
.IR SCHED_OTHER , .BR SCHED_OTHER ,
and and
.IR SCHED_BATCH . .BR SCHED_BATCH .
Further details about these policies can be found in Further details about these policies can be found in
.BR sched_setscheduler (2). .BR sched_setscheduler (2).
@ -63,8 +63,8 @@ value returned by
.BR sched_get_priority_min (). .BR sched_get_priority_min ().
Linux allows the static priority value range 1 to 99 for Linux allows the static priority value range 1 to 99 for
\fISCHED_FIFO\fR and \fISCHED_RR\fR and the priority 0 for \fBSCHED_FIFO\fR and \fBSCHED_RR\fR and the priority 0 for
\fISCHED_OTHER\fR and \fISCHED_BATCH\fP. \fBSCHED_OTHER\fR and \fBSCHED_BATCH\fP.
Scheduling priority ranges for the various policies Scheduling priority ranges for the various policies
are not alterable. are not alterable.
@ -75,7 +75,7 @@ priority range and map it to the interval given by
and and
.BR sched_get_priority_min (). .BR sched_get_priority_min ().
POSIX.1-2001 requires a spread of at least 32 between the maximum and the POSIX.1-2001 requires a spread of at least 32 between the maximum and the
minimum values for \fISCHED_FIFO\fR and \fISCHED_RR\fR. minimum values for \fBSCHED_FIFO\fR and \fBSCHED_RR\fR.
POSIX systems on which POSIX systems on which
.BR sched_get_priority_max () .BR sched_get_priority_max ()

View File

@ -54,7 +54,7 @@ If
\fIpid\fR is zero, the time quantum for the calling process is written \fIpid\fR is zero, the time quantum for the calling process is written
into *\fItp\fR. into *\fItp\fR.
The identified process should be running under the The identified process should be running under the
.I SCHED_RR .B SCHED_RR
scheduling policy. scheduling policy.
.\" The round-robin time quantum value is not alterable under Linux .\" The round-robin time quantum value is not alterable under Linux

View File

@ -64,13 +64,13 @@ The interpretation of
the parameter \fIparam\fP depends on the selected policy. the parameter \fIparam\fP depends on the selected policy.
Currently, the Currently, the
following three scheduling policies are supported under Linux: following three scheduling policies are supported under Linux:
.IR SCHED_FIFO , .BR SCHED_FIFO ,
.IR SCHED_RR , .BR SCHED_RR ,
.IR SCHED_OTHER , .BR SCHED_OTHER ,
.\" In the 2.6 kernel sources, SCHED_OTHER is actually called .\" In the 2.6 kernel sources, SCHED_OTHER is actually called
.\" SCHED_NORMAL. .\" SCHED_NORMAL.
and and
.IR SCHED_BATCH ; .BR SCHED_BATCH ;
their respective semantics are described below. their respective semantics are described below.
.BR sched_getscheduler () .BR sched_getscheduler ()
@ -98,18 +98,18 @@ The scheduling policy determines for
each process, where it will be inserted into the list of processes each process, where it will be inserted into the list of processes
with equal static priority and how it will move inside this list. with equal static priority and how it will move inside this list.
\fISCHED_OTHER\fP is the default universal time-sharing scheduler \fBSCHED_OTHER\fP is the default universal time-sharing scheduler
policy used by most processes. policy used by most processes.
\fISCHED_BATCH\fP is intended for "batch" style execution of processes. \fBSCHED_BATCH\fP is intended for "batch" style execution of processes.
\fISCHED_FIFO\fP and \fISCHED_RR\fP are \fBSCHED_FIFO\fP and \fBSCHED_RR\fP are
intended for special time-critical applications that need precise intended for special time-critical applications that need precise
control over the way in which runnable processes are selected for control over the way in which runnable processes are selected for
execution. execution.
Processes scheduled with \fISCHED_OTHER\fP or \fISCHED_BATCH\fP Processes scheduled with \fBSCHED_OTHER\fP or \fBSCHED_BATCH\fP
must be assigned the static priority 0. must be assigned the static priority 0.
Processes scheduled under \fISCHED_FIFO\fP or Processes scheduled under \fBSCHED_FIFO\fP or
\fISCHED_RR\fP can have a static priority in the range 1 to 99. \fBSCHED_RR\fP can have a static priority in the range 1 to 99.
The system calls The system calls
.BR sched_get_priority_min (2) .BR sched_get_priority_min (2)
and and
@ -125,26 +125,26 @@ The scheduling policy only determines the
ordering within the list of runnable processes with equal static ordering within the list of runnable processes with equal static
priority. priority.
.SS SCHED_FIFO: First In-First Out scheduling .SS SCHED_FIFO: First In-First Out scheduling
\fISCHED_FIFO\fP can only be used with static priorities higher than \fBSCHED_FIFO\fP can only be used with static priorities higher than
0, which means that when a \fISCHED_FIFO\fP processes becomes runnable, 0, which means that when a \fBSCHED_FIFO\fP processes becomes runnable,
it will always immediately preempt any currently running it will always immediately preempt any currently running
\fISCHED_OTHER\fP or \fISCHED_BATCH\fP process. \fBSCHED_OTHER\fP or \fBSCHED_BATCH\fP process.
\fISCHED_FIFO\fP is a simple scheduling \fBSCHED_FIFO\fP is a simple scheduling
algorithm without time slicing. algorithm without time slicing.
For processes scheduled under the For processes scheduled under the
\fISCHED_FIFO\fP policy, the following rules are applied: A \fBSCHED_FIFO\fP policy, the following rules are applied: A
\fISCHED_FIFO\fP process that has been preempted by another process of \fBSCHED_FIFO\fP process that has been preempted by another process of
higher priority will stay at the head of the list for its priority and higher priority will stay at the head of the list for its priority and
will resume execution as soon as all processes of higher priority are will resume execution as soon as all processes of higher priority are
blocked again. blocked again.
When a \fISCHED_FIFO\fP process becomes runnable, it When a \fBSCHED_FIFO\fP process becomes runnable, it
will be inserted at the end of the list for its priority. will be inserted at the end of the list for its priority.
A call to A call to
.BR sched_setscheduler () .BR sched_setscheduler ()
or or
.BR sched_setparam (2) .BR sched_setparam (2)
will put the will put the
\fISCHED_FIFO\fP (or \fISCHED_RR\fP) process identified by \fBSCHED_FIFO\fP (or \fBSCHED_RR\fP) process identified by
\fIpid\fP at the start of the list if it was runnable. \fIpid\fP at the start of the list if it was runnable.
As a consequence, it may preempt the currently running process if As a consequence, it may preempt the currently running process if
it has the same priority. it has the same priority.
@ -157,22 +157,22 @@ A process calling
will be will be
put at the end of the list. put at the end of the list.
No other events will move a process No other events will move a process
scheduled under the \fISCHED_FIFO\fP policy in the wait list of scheduled under the \fBSCHED_FIFO\fP policy in the wait list of
runnable processes with equal static priority. runnable processes with equal static priority.
A \fISCHED_FIFO\fP A \fBSCHED_FIFO\fP
process runs until either it is blocked by an I/O request, it is process runs until either it is blocked by an I/O request, it is
preempted by a higher priority process, or it calls preempted by a higher priority process, or it calls
.BR sched_yield (2). .BR sched_yield (2).
.SS SCHED_RR: Round Robin scheduling .SS SCHED_RR: Round Robin scheduling
\fISCHED_RR\fP is a simple enhancement of \fISCHED_FIFO\fP. \fBSCHED_RR\fP is a simple enhancement of \fBSCHED_FIFO\fP.
Everything Everything
described above for \fISCHED_FIFO\fP also applies to \fISCHED_RR\fP, described above for \fBSCHED_FIFO\fP also applies to \fBSCHED_RR\fP,
except that each process is only allowed to run for a maximum time except that each process is only allowed to run for a maximum time
quantum. quantum.
If a \fISCHED_RR\fP process has been running for a time If a \fBSCHED_RR\fP process has been running for a time
period equal to or longer than the time quantum, it will be put at the period equal to or longer than the time quantum, it will be put at the
end of the list for its priority. end of the list for its priority.
A \fISCHED_RR\fP process that has A \fBSCHED_RR\fP process that has
been preempted by a higher priority process and subsequently resumes been preempted by a higher priority process and subsequently resumes
execution as a running process will complete the unexpired portion of execution as a running process will complete the unexpired portion of
its round robin time quantum. its round robin time quantum.
@ -183,8 +183,8 @@ retrieved using
.\" by the process nice value -- MTK .\" by the process nice value -- MTK
.\" .\"
.SS SCHED_OTHER: Default Linux time-sharing scheduling .SS SCHED_OTHER: Default Linux time-sharing scheduling
\fISCHED_OTHER\fP can only be used at static priority 0. \fBSCHED_OTHER\fP can only be used at static priority 0.
\fISCHED_OTHER\fP is the standard Linux time-sharing scheduler that is \fBSCHED_OTHER\fP is the standard Linux time-sharing scheduler that is
intended for all processes that do not require special static priority intended for all processes that do not require special static priority
real-time mechanisms. real-time mechanisms.
The process to run is chosen from the static The process to run is chosen from the static
@ -198,12 +198,12 @@ or
and increased for and increased for
each time quantum the process is ready to run, but denied to run by each time quantum the process is ready to run, but denied to run by
the scheduler. the scheduler.
This ensures fair progress among all \fISCHED_OTHER\fP This ensures fair progress among all \fBSCHED_OTHER\fP
processes. processes.
.SS SCHED_BATCH: Scheduling batch processes .SS SCHED_BATCH: Scheduling batch processes
(Since Linux 2.6.16.) (Since Linux 2.6.16.)
\fISCHED_BATCH\fP can only be used at static priority 0. \fBSCHED_BATCH\fP can only be used at static priority 0.
This policy is similar to \fISCHED_OTHER\fP, except that This policy is similar to \fBSCHED_OTHER\fP, except that
this policy will cause the scheduler to always assume this policy will cause the scheduler to always assume
that the process is CPU-intensive. that the process is CPU-intensive.
Consequently, the scheduler will apply a small scheduling Consequently, the scheduler will apply a small scheduling
@ -280,7 +280,7 @@ or
.BR mlockall (2). .BR mlockall (2).
As a non-blocking end-less loop in a process scheduled under As a non-blocking end-less loop in a process scheduled under
\fISCHED_FIFO\fP or \fISCHED_RR\fP will block all processes with lower \fBSCHED_FIFO\fP or \fBSCHED_RR\fP will block all processes with lower
priority forever, a software developer should always keep available on priority forever, a software developer should always keep available on
the console a shell scheduled under a higher static priority than the the console a shell scheduled under a higher static priority than the
tested application. tested application.
@ -317,7 +317,7 @@ The calling process does not have appropriate privileges.
The process whose ID is \fIpid\fP could not be found. The process whose ID is \fIpid\fP could not be found.
.SH "CONFORMING TO" .SH "CONFORMING TO"
POSIX.1-2001. POSIX.1-2001.
The \fISCHED_BATCH\fP policy is Linux specific. The \fBSCHED_BATCH\fP policy is Linux specific.
.SH NOTES .SH NOTES
POSIX.1 does not detail the permissions that an unprivileged POSIX.1 does not detail the permissions that an unprivileged
process requires in order to call process requires in order to call