Sie sind auf Seite 1von 11

In computer science, scheduling is the method by which threads, processes

or data fows are given access to system resources (e.g. processor time,
communications bandwidth). This is usually done to load balance and share
system resources efectively or achieve a target quality of service. The need
for a scheduling algorithm arises from the requirement for most modern
systems to perform multitasing (e!ecuting more than one process at a time)
and multiple!ing (transmit multiple data streams simultaneously across a
single physical channel).
The scheduler is concerned mainly with"
Throughput # The total number of processes that complete their e!ecution per
time unit.
$atency, speci%cally"
Turnaround time # total time between submission of a process and its
completion.
&esponse time # amount of time it taes from when a request was submitted
until the %rst response is produced.
'airness # (qual )*+ time to each process (or more generally appropriate
times according to each process, priority and worload).
-aiting Time # The time the process remains in the ready queue.
In practice, these goals often confict (e.g. throughput versus latency), thus a
scheduler will implement a suitable compromise. *reference is given to any
one of the above mentioned concerns depending upon the user,s needs and
ob.ectives.
In real#time environments, such as embedded systems for automatic control
in industry (for e!ample robotics), the scheduler also must ensure that
processes can meet deadlines/ this is crucial for eeping the system stable.
0cheduled tass can also be distributed to remote devices across a networ
and managed through an administrative bac end.1perating systems may
feature up to three distinct types of scheduler, a long#term scheduler (also
nown as an admission scheduler or high#level scheduler), a mid#term or
medium#term scheduler and a short#term scheduler. The names suggest the
relative frequency with which these functions are performed. The scheduler is
an operating system module that selects the ne!t .obs to be admitted into
the system and the ne!t process to run.
*rocess scheduler2edit3
$ong#term scheduling2edit3
The long#term, or admission scheduler, decides which .obs or processes are
to be admitted to the ready queue (in the 4ain 4emory)/ that is, when an
attempt is made to e!ecute a program, its admission to the set of currently
e!ecuting processes is either authori5ed or delayed by the long#term
scheduler . Thus, this scheduler dictates what processes are to run on a
system, and the degree of concurrency to be supported at any one time 6
whether a high or low amount of processes are to be e!ecuted concurrently,
and how the split between I71 intensive and )*+ intensive processes is to be
handled. The long term scheduler is responsible for controlling the degree of
multiprogramming . In modern operating systems, this is used to mae sure
that real time processes get enough )*+ time to %nish their tass. -ithout
proper real time scheduling, modern 8+Is would seem sluggish.
$ong#term scheduling is also important in large#scale systems such as batch
processing systems, computer clusters, supercomputers and render farms. In
these cases, special purpose .ob scheduler software is typically used to assist
these functions, in addition to any underlying admission scheduling support
in the operating system.
4edium term scheduling2edit3
0cheduler temporarily removes processes from main memory and places
them on secondary memory (such as a dis drive) or vice versa. This is
commonly referred to as 9swapping out9 or 9swapping in9 (also incorrectly as
9paging out9 or 9paging in9). The medium#term scheduler may decide to swap
out a process which has not been active for some time, or a process which
has a low priority, or a process which is page faulting frequently, or a process
which is taing up a large amount of memory in order to free up main
memory for other processes, swapping the process bac in later when more
memory is available, or when the process has been unbloced and is no
longer waiting for a resource. 20tallings, :;<3 20tallings, :=>3
In many systems today (those that support mapping virtual address space to
secondary storage other than the swap %le), the medium#term scheduler may
actually perform the role of the long#term scheduler, by treating binaries as
9swapped out processes9 upon their e!ecution. In this way, when a segment
of the binary is required it can be swapped in on demand, or 9la5y loaded9.
20tallings, :;?3
0hort#term scheduling2edit3
The short#term scheduler (also nown as the )*+ scheduler) decides which of
the ready, in#memory processes are to be e!ecuted (allocated a )*+) after a
cloc interrupt, an I71 interrupt, an operating system call or another form of
signal. Thus the short#term scheduler maes scheduling decisions much more
frequently than the long#term or mid#term schedulers # a scheduling decision
will at a minimum have to be made after every time slice, and these are very
short. This scheduler can be preemptive, implying that it is capable of forcibly
removing processes from a )*+ when it decides to allocate that )*+ to
another process, or non#preemptive (also nown as 9voluntary9 or 9co#
operative9), in which case the scheduler is unable to 9force9 processes of the
)*+.
@ preemptive scheduler relies upon a programmable interval timer which
invoes an interrupt handler that runs in ernel mode and implements the
scheduling function.
Aispatcher2edit3
@nother component that is involved in the )*+#scheduling function is the
dispatcher. The dispatcher is the module that gives control of the )*+ to the
process selected by the short#term scheduler. This function involves the
following"
0witching conte!t
0witching to user mode
Bumping to the proper location in the user program to restart that program.
Aispatcher analyses the values from *rogram counter and fetches
instructions, loads data into registers.
The dispatcher should be as fast as possible, since it is invoed during every
process switch. Auring the conte!t switches, the processor is idle for a
fraction of time. Cence, unnecessary conte!t switches should be avoided. The
time it taes for the dispatcher to stop one process and start another running
is nown as the dispatch latency. 28alvin, DEE3.
Fetwor scheduler2edit3
4ain article" Fetwor scheduler
Ais scheduler2edit3
4ain article" I71 scheduling
Bob scheduler2edit3
4ain article" Bob scheduler
(!amples are cron, at, systemd.
0cheduling disciplines2edit3
0cheduling disciplines are algorithms used for distributing resources among
parties which simultaneously and asynchronously request them. 0cheduling
disciplines are used in routers (to handle pacet traGc) as well as in
operating systems (to share )*+ time among both threads and processes),
dis drives (I71 scheduling), printers (print spooler), most embedded systems,
etc.
The main purposes of scheduling algorithms are to minimi5e resource
starvation and to ensure fairness amongst the parties utili5ing the resources.
0cheduling deals with the problem of deciding which of the outstanding
requests is to be allocated resources. There are many diferent scheduling
algorithms. In this section, we introduce several of them.
In pacet#switched computer networs and other statistical multiple!ing, the
notion of a scheduling algorithm is used as an alternative to %rst#come %rst#
served queuing of data pacets.
The simplest best#efort scheduling algorithms are round#robin, fair queuing
(a ma!#min fair scheduling algorithm), proportionally fair scheduling and
ma!imum throughput. If diferentiated or guaranteed quality of service is
ofered, as opposed to best#efort communication, weighted fair queuing may
be utili5ed.
In advanced pacet radio wireless networs such as C0A*@ (Cigh#0peed
Aownlin *acet @ccess ) :.E8 cellular system, channel#dependent
scheduling may be used to tae advantage of channel state information. If
the channel conditions are favourable, the throughput and system spectral
eGciency may be increased. In even more advanced systems such as $T(,
the scheduling is combined by channel#dependent pacet#by#pacet dynamic
channel allocation, or by assigning 1'A4@ multi#carriers or other frequency#
domain equali5ation components to the users that best can utili5e them.
'irst in %rst out2edit3
4ain article" 'irst In 'irst 1ut
@lso nown as 'irst )ome, 'irst 0erved (')'0), is the simplest scheduling
algorithm, 'I'1 simply queues processes in the order that they arrive in the
ready queue.
0ince conte!t switches only occur upon process termination, and no
reorgani5ation of the process queue is required, scheduling overhead is
minimal.
Throughput can be low, since long processes can hold the )*+
Turnaround time, waiting time and response time can be high for the same
reasons above
Fo prioriti5ation occurs, thus this system has trouble meeting process
deadlines.
The lac of prioriti5ation means that as long as every process eventually
completes, there is no starvation. In an environment where some processes
might not complete, there can be starvation.
It is based on Hueuing
Cere is the )#code for ')'0
0hortest remaining time2edit3
4ain article" 0hortest remaining time
0imilar to 0hortest Bob 'irst (0B'). -ith this strategy the scheduler arranges
processes with the least estimated processing time remaining to be ne!t in
the queue. This requires advanced nowledge or estimations about the time
required for a process to complete.
If a shorter process arrives during another process, e!ecution, the currently
running process may be interrupted (nown as preemption), dividing that
process into two separate computing blocs. This creates e!cess overhead
through additional conte!t switching. The scheduler must also place each
incoming process into a speci%c place in the queue, creating additional
overhead.
This algorithm is designed for ma!imum throughput in most scenarios.
-aiting time and response time increase as the process,s computational
requirements increase. 0ince turnaround time is based on waiting time plus
processing time, longer processes are signi%cantly afected by this. 1verall
waiting time is smaller than 'I'1, however since no process has to wait for
the termination of the longest process.
Fo particular attention is given to deadlines, the programmer can only
attempt to mae processes with deadlines as short as possible.
0tarvation is possible, especially in a busy system with many small processes
being run.
This policy is no more in use.
To use this policy we should have at least two processes of diferent priority
'i!ed priority pre#emptive scheduling2edit3
4ain article" 'i!ed priority pre#emptive scheduling
The 10 assigns a %!ed priority ran to every process, and the scheduler
arranges the processes in the ready queue in order of their priority. $ower
priority processes get interrupted by incoming higher priority processes.
1verhead is not minimal, nor is it signi%cant.
'**0 has no particular advantage in terms of throughput over 'I'1
scheduling.
If the number of ranings is limited it can be characteri5ed as a collection of
'I'1 queues, one for each priority raning. *rocesses in lower#priority queues
are selected only when all of the higher#priority queues are empty.
-aiting time and response time depend on the priority of the process. Cigher
priority processes have smaller waiting and response times.
Aeadlines can be met by giving processes with deadlines a higher priority.
0tarvation of lower priority processes is possible with large amounts of high
priority processes queuing for )*+ time.
&ound#robin scheduling2edit3
4ain article" &ound#robin scheduling
The scheduler assigns a %!ed time unit per process, and cycles through them.
&& scheduling involves e!tensive overhead, especially with a small time unit.
Ialanced throughput between ')'0 and 0B', shorter .obs are completed
faster than in ')'0 and longer processes are completed faster than in 0B'.
8ood average response time, waiting time is dependent on number of
processes, and not average process length.
Iecause of high waiting times, deadlines are rarely met in a pure && system.
0tarvation can never occur, since no priority is given. 1rder of time unit
allocation is based upon process arrival time, similar to ')'0.
4ultilevel queue scheduling2edit3
4ain article" 4ultilevel queue
This is used for situations in which processes are easily divided into diferent
groups. 'or e!ample, a common division is made between foreground
(interactive) processes and bacground (batch) processes. These two types of
processes have diferent response#time requirements and so may have
diferent scheduling needs. It is very useful for shared memory problems.
0cheduling optimi5ation problems2edit3
1pen#shop scheduling
Bob 0hop 0cheduling
'low 0hop 0cheduling *roblem
4anual scheduling2edit3
4ain article" 4anual scheduling
@ very common method in embedded systems is to manually schedule .obs.
This can for e!ample be done in a time#multiple!ed fashion. 0ometimes the
ernel is divided in three or more parts" 4anual scheduling, preemptive and
interrupt level. (!act methods for scheduling .obs are often proprietary.
Fo resource starvation problems.
Jery high predictability/ allows implementation of hard real#time systems.
@lmost no overhead.
4ay not be optimal for all applications.
(fectiveness is completely dependent on the implementation.
Cow to choose a scheduling algorithm2edit3
-hen designing an operating system, a programmer must consider which
scheduling algorithm will perform best for the use the system is going to see.
There is no universal KbestL scheduling algorithm, and many operating
systems use e!tended or combinations of the scheduling algorithms above.
'or e!ample, -indows FT7M*7Jista uses a multilevel feedbac queue, a
combination of %!ed priority preemptive scheduling, round#robin, and %rst in
%rst out. In this system, threads can dynamically increase or decrease in
priority depending on if it has been serviced already, or if it has been waiting
e!tensively. (very priority level is represented by its own queue, with round#
robin scheduling amongst the high priority threads and 'I'1 among the lower
ones. In this sense, response time is short for most threads, and short but
critical system threads get completed very quicly. 0ince threads can only
use one time unit of the round robin in the highest priority queue, starvation
can be a problem for longer high priority threads.
1perating system process scheduler implementations2edit3
The algorithm used may be as simple as round#robin in which each process is
given equal time (for instance D ms, usually between D ms and D>> ms) in a
cycling list. 0o, process @ e!ecutes for D ms, then process I, then process ),
then bac to process @.
4ore advanced algorithms tae into account process priority, or the
importance of the process. This allows some processes to use more time than
other processes. The ernel always uses whatever resources it needs to
ensure proper functioning of the system, and so can be said to have in%nite
priority. In 04*(symmetric multiprocessing) systems, processor aGnity is
considered to increase overall system performance, even if it may cause a
process itself to run more slowly. This generally improves performance by
reducing cache thrashing.
107:<> and successors2edit3
II4 107:<> was available with three diferent schedulers. The diferences
were such that the variants were often considered three diferent operating
systems"
The 0ingle 0equential 0cheduler option, also nown as the *rimary )ontrol
*rogram (*)*) provided sequential e!ecution of a single stream of .obs.
The 4ultiple 0equential 0cheduler option, nown as 4ultiprogramming with a
'i!ed Fumber of Tass (4'T) provided e!ecution of multiple concurrent .obs.
(!ecution was governed by a priority which had a default for each stream or
could be requested separately for each .ob. 4'T version II added subtass
(threads), which e!ecuted. at a priority based on that of the parent .ob. (ach
.ob stream de%ned the ma!imum amount of memory which could be used by
any .ob in that stream.
The 4ultiple *riority 0chedulers option, or 4ultiprogramming with a Jariable
Fumber of Tass (4JT), featured subtass from the start/ each .ob requested
the priority and memory it required before e!ecution.
$ater virtual storage versions of 4J0 added a -orload 4anager feature to
the scheduler, which schedules processor resources according to an
elaborate scheme de%ned by the installation.
-indows2edit3
Jery early 40#A10 and 4icrosoft -indows systems were non#multitasing,
and as such did not feature a scheduler. -indows :.D! used a non#
preemptive scheduler, meaning that it did not interrupt programs. It relied on
the program to end or tell the 10 that it didn,t need the processor so that it
could move on to another process. This is usually called cooperative
multitasing. -indows ;E introduced a rudimentary preemptive scheduler/
however, for legacy support opted to let D< bit applications run without
preemption.2D3
-indows FT#based operating systems use a multilevel feedbac queue. :N
priority levels are de%ned, > through to :D, with priorities > through DE being
9normal9 priorities and priorities D< through :D being soft real#time priorities,
requiring privileges to assign. > is reserved for the 1perating 0ystem. +sers
can select E of these priorities to assign to a running application from the
Tas 4anager application, or through thread management @*Is. The ernel
may change the priority level of a thread depending on its I71 and )*+ usage
and whether it is interactive (i.e. accepts and responds to input from
humans), raising the priority of interactive and I71 bounded processes and
lowering that of )*+ bound processes, to increase the responsiveness of
interactive applications.2N3 The scheduler was modi%ed in -indows Jista to
use the cycle counter register of modern processors to eep trac of e!actly
how many )*+ cycles a thread has e!ecuted, rather than .ust using an
interval#timer interrupt routine.2:3 Jista also uses a priority scheduler for the
I71 queue so that dis defragmenters and other such programs don,t interfere
with foreground operations.2?3
4ac 102edit3
4ac 10 ; uses cooperative scheduling for threads, where one process
controls multiple cooperative threads, and also provides preemptive
scheduling for 4* tass. The ernel schedules 4* tass using a preemptive
scheduling algorithm. @ll *rocess 4anager processes run within a special 4*
tas, called the 9blue tas9. Those processes are scheduled cooperatively,
using a round#robin scheduling algorithm/ a process yields control of the
processor to another process by e!plicitly calling a blocing function such as
-aitFe!t(vent. (ach process has its own copy of the Thread 4anager that
schedules that process,s threads cooperatively/ a thread yields control of the
processor to another thread by calling OieldTo@nyThread or OieldToThread.2E3
4ac 10 M uses a multilevel feedbac queue, with four priority bands for
threads # normal, system high priority, ernel mode only, and real#time.2<3
Threads are scheduled preemptively/ 4ac 10 M also supports cooperatively
scheduled threads in its implementation of the Thread 4anager in )arbon.2E3
@IM2edit3
In @IM Jersion ? there are three possible values for thread scheduling policy "
'irst In, 'irst 1ut" 1nce a thread with this policy is scheduled, it runs to
completion unless it is bloced, it voluntarily yields control of the )*+, or a
higher#priority thread becomes dispatchable. 1nly %!ed#priority threads can
have a 'I'1 scheduling policy.
&ound &obin" This is similar to the @IM Jersion : scheduler round#robin
scheme based on D>ms time slices. -hen a && thread has control at the end
of the time slice, it moves to the tail of the queue of dispatchable threads of
its priority. 1nly %!ed#priority threads can have a &ound &obin scheduling
policy.
1TC(&" This policy is de%ned by *10IMD>>:.?a as implementation#de%ned. In
@IM Jersion ?, this policy is de%ned to be equivalent to &&, e!cept that it
applies to threads with non#%!ed priority. The recalculation of the running
thread,s priority value at each cloc interrupt means that a thread may lose
control because its priority value has risen above that of another
dispatchable thread. This is the @IM Jersion : behavior.
Threads are primarily of interest for applications that currently consist of
several asynchronous processes. These applications might impose a lighter
load on the system if converted to a multithreaded structure.
@IM E implements the following scheduling policies" 'I'1, round robin, and a
fair round robin. The 'I'1 policy has three diferent implementations" 'I'1,
'I'1N, and 'I'1:. The round robin policy is named 0)C(AP&& in @IM, and the
fair round robin is called 0)C(AP1TC(&.2=3
$inu!2edit3
$inu! N.?2edit3
In $inu! N.?, an 1(n) scheduler with a multilevel feedbac queue with priority
levels ranging from > to D?> was used/ >6;; are reserved for real#time tass
and D>>6D?> are considered nice tas levels. 'or real#time tass, the time
quantum for switching processes was appro!imately N>> ms, and for nice
tass appro!imately D> ms.2citation needed3 The scheduler ran through the
run queue of all ready processes, letting the highest priority processes go
%rst and run through their time slices, after which they will be placed in an
e!pired queue. -hen the active queue is empty the e!pired queue will
become the active queue and vice versa.
Cowever, some (nterprise $inu! distributions such as 0+0( $inu! (nterprise
0erver replaced this scheduler with a bacport of the 1(D) scheduler (which
was maintained by @lan )o! in his $inu! N.?#ac Qernel series) to the $inu! N.?
ernel used by the distribution.
$inu! N.<.> to $inu! N.<.NN2edit3
'rom versions N.< to N.<.NN, the ernel used an 1(D) scheduler developed by
Ingo 4olnar and many other ernel developers during the $inu! N.E
development. 'or many ernel in time frame, )on Qolivas developed patch
sets which improved interactivity with this scheduler or even replaced it with
his own schedulers.
0ince $inu! N.<.N:2edit3
)on Qolivas,s wor, most signi%cantly his implementation of 9fair scheduling9
named 9&otating 0taircase Aeadline9, inspired Ingo 4olnRr to develop the
)ompletely 'air 0cheduler as a replacement for the earlier 1(D) scheduler,
crediting Qolivas in his announcement.2S3
The )ompletely 'air 0cheduler ()'0) uses a well#studied, classic scheduling
algorithm called fair queuing originally invented for pacet networs. 'air
queuing had been previously applied to )*+ scheduling under the name
stride scheduling.
The fair queuing )'0 scheduler has a scheduling comple!ity of 1(log F),
where F is the number of tass in the runqueue. )hoosing a tas can be done
in constant time, but reinserting a tas after it has run requires 1(log F)
operations, because the run queue is implemented as a red#blac tree.
)'0 is the %rst implementation of a fair queuing process scheduler widely
used in a general#purpose operating system.2;3
The Irain 'uc 0cheduler (I'0) is an alternative to the )'0.
'reeI0A2edit3
'reeI0A uses a multilevel feedbac queue with priorities ranging from >#NEE.
>#<: are reserved for interrupts, <?#DN= for the top half of the ernel, DNS#
DE; for real#time user threads, D<>#NN: for time#shared user threads, and
NN?#NEE for idle user threads. @lso, lie $inu!, it uses the active queue setup,
but it also has an idle queue.2D>3
FetI0A2edit3
FetI0A uses a multilevel feedbac queue with priorities ranging from >#NN:.
>#<: are reserved for time#shared threads (default, 0)C(AP1TC(& policy),
<?#;E for user threads which entered ernel space, ;<#DNS for ernel threads,
DNS#D;D for user real#time threads (0)C(AP'I'1 and 0)C(AP&& policies), and
D;N#NN: for software interrupts.
0olaris2edit3
0olaris uses a multilevel feedbac queue with priorities ranging from >#D<;.
>#E; are reserved for time#shared threads, <>#;; for system threads, D>>#DE;
for real#time threads, and D<>#D<; for low priority interrupts. +nlie $inu!,
when a process is done using its time quantum, it,s given a new priority and
put bac in the queue.

Das könnte Ihnen auch gefallen