8/20/2019 CPU Scheduling.ppt
1/57
CPU Scheduling
8/20/2019 CPU Scheduling.ppt
2/57
PROCESS SCHEDULERS
• Processes travel various scheduling queues throughout itsentire lifetime.
• Its ourne! from one queue to another corres"ondingl!changes its "rocess state.
• #t this "oint consider that in a multi"rogramming s!stemthere are multi"le "rograms running around the s!stemuntil it e$hausts its lifetime.
• #ssuming that several o%s reside inside a queue in order toaddress the selection "rocess s!stematicall! a "art of the
o"erating s!stem& 'no(n as scheduler & "erforms this tas'.• )he scheduler has three t!"es* )he long-term scheduler
or job scheduler selects "rocesses from the secondarystorage and loads them into memor! for e$ecution.
8/20/2019 CPU Scheduling.ppt
3/57
PROCESS SCHEDULERS
• )he short-term scheduler or dispatcher selects"rocess from among the "rocesses that are read!to e$ecute& and allocates the CPU to one of them.
• Hence& it is also called CPU scheduler .
• +inall!& the mediumterm scheduler or swapper s(a"s "rocesses in and out of the memor!.
• )he long,term scheduler e$ecutes the least amongthe three schedulers.
• )he o% scheduler is in charge of the admission of o%s into the s!stem.
8/20/2019 CPU Scheduling.ppt
4/57
PROCESS SCHEDULERS
• It must %e noted that "rocess creation in the s!stemma! ta'e a (hile (hich means that the long term
scheduler is commonl! "rone to a lot of (ait or %eingidle most of the time.
• )he long,term scheduler controls the degree ofmultiprogramming ,the num%er of "rocesses that (illget in memor!.
• )he long interval in e$ecutions ena%le the long,term
scheduler to ta'e more time selecting a "rocess for
e$ecution.• )he long,term scheduler must select a good com%ination
of I-O,%ound and CPU,%ound "rocesses in order to
ma$imie the& CPU and I-O devices.
8/20/2019 CPU Scheduling.ppt
5/57
PROCESS SCHEDULERS
• Some s!stems have a medium,term scheduler.
• )his scheduler in quite in contrast (ith the long,termscheduler.
• )he s(a""er sus"ends a "rocess in memor! %!
tem"oraril! removing /s(a"s out 0 it from memor!and transferring it into a %ac'ing store.
• It then re"laces the s(a""ed out "rocess (ith another o% from the secondar! storage.
• )his "ractice im"roves the "erformance of thes!stem.
• )he short,term scheduler must select a ne( "rocessfrom memor! to %e fed into the CPU.
8/20/2019 CPU Scheduling.ppt
6/57
8/20/2019 CPU Scheduling.ppt
7/57
CPU SCHEDULERS
• 1henever the CPU %ecomes idle& the o"erating s!stem/"articularl! the CPU scheduler0 must select one of the"rocesses in the read! queue for e$ecution.
• CPU scheduling decisions ma! ta'e "lace under the
follo(ing four circumstances*2. 1hen a "rocess s(itches from the running state to the
(aiting state for e$am"le& I-O request invocation of(ait for the termination of one of the child "rocesses0.
3. 1hen a "rocess s(itches from the running state to the
read! state /for e$am"le& (hen an interru"t occurs0.4. 1hen a "rocess s(itches from the (aiting state to the
read! state /for e$am"le& com"letion of I-O0.
5. 1hen a "rocess terminates.
8/20/2019 CPU Scheduling.ppt
8/57
CPU SCHEDULERS
• +or circumstances 2 and 5& there is no choice in terms ofscheduling.
• # ne( "rocess /if one e$ists in the read! queue0 must %eselected for e$ecution.
• )here is a choice& ho(ever& for circumstances 3 and 4.• 1hen scheduling ta'es "lace onl! under circumstances 2
and 5& the scheduling scheme is non-preemptive6other(ise& the scheduling scheme is preemptive.
• Under non-preemptive scheduling& once the CPU has
%een allocated to a "rocess& the "rocess 'ee"s the CPUuntil it releases the CPU either %! terminating or s(itchingstates.
• Preemptive scheduling incurs a cost.
8/20/2019 CPU Scheduling.ppt
9/57
8/20/2019 CPU Scheduling.ppt
10/57
CPU SCHEDULI78#L8ORI)H9S
• Di:erent CPU,scheduling algorithms have di:erent"ro"erties and ma! favor one class of "rocesses overanother.
• 9an! criteria have %een suggested for com"aring CPU,scheduling algorithms.
• )he characteristics used for com"arison can ma'e asu%stantial di:erence in the determination of the %estalgorithm.
• )he criteria should include the follo(ing*
1. CPU Utilization. )his measures ho( %us! is the CPU.CPU utiliation ma! range from ; to 2;; "ercent. In areal s!stem& it should range from 5;< /for a lightl!loaded s!stem0 to =;< /for a heavil! loaded s!stem0.
8/20/2019 CPU Scheduling.ppt
11/57
8/20/2019 CPU Scheduling.ppt
12/57
CPU SCHEDULI78#L8ORI)H9S
$. %aiting !ime. CPU scheduling algorithm does nota:ect the amount of time during (hich a "rocesse$ecutes or does I-O6 it a:ects onl! the amount oftime a "rocess s"ends (aiting in the read! queue.1aiting time is the total amount of time a "rocess
s"ends (aiting in the read! queue.
&. 'esponse !ime. )he time from the su%mission of arequest until the s!stem ma'es the >rst res"onse. Itis the amount of time it ta'es to start res"onding%ut not the time that it ta'es to out"ut thatres"onse. )he turnaround time is generall! limited%! the s"eed of the out"ut device.
8/20/2019 CPU Scheduling.ppt
13/57
CPU SCHEDULI78#L8ORI)H9S• # good CPU scheduling algorithm ma$imies CPU utiliation
and through"ut and minimies turnaround time& (aiting timeand res"onse time.
• In most cases& the average measure is o"timied.
• Ho(ever& in some cases& it is desired to o"timie the minimumor ma$imum values& rather than the average.
• +or e$am"le& to guarantee that all users get good service& itma! %e %etter to minimie the ma$imum res"onse time.
• +or interactive s!stems /time,sharing s!stems0& some anal!stssuggests that minimiing the variance in the res"onse time ismore im"ortant than averaging res"onse time.
• # s!stem (ith a reasona%le and "redicta%le res"onse ma! %econsidered more desira%le than a s!stem that is faster on theaverage & %ut is highl! varia%le.
8/20/2019 CPU Scheduling.ppt
14/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )his is the sim"lest CPU,scheduling algorithm. )he "rocess that requests the CPU >rst gets theCPU >rst.
E$am"le *
Consider the follo(ing set of "rocesses that arriveat time ;& (ith the length of the CPU %urst givenin milliseconds*
PROCESS BURST TIME
P2 35
P3 4
P4 4
8/20/2019 CPU Scheduling.ppt
15/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• If the "rocesses arrive in the order P2& P3& P4 andare served in +C+S order& the s!stem gets theresult sho(n in the follo(ing 8antt chart*
P1 P2 P30 24 27 30
i i d
8/20/2019 CPU Scheduling.ppt
16/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )herefore& the (aiting time for each "rocess is*
#verage (aiting time ? /; @ 35 @ 3A0 - 4
? 2Ams
WT for P1 0 - 0 0
1) for P3 35 , ; 35
1) for P4 3A , ; 3A
i C i S d
8/20/2019 CPU Scheduling.ppt
17/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )he turnaround time for each "rocess (ould %e*
#verage turnaround time ? /35 @ 3A @ 4;0 - 4
? 3Ams
TT for P1 24 – 0 24
)) for P3 3A B ; 3A
)) for P4 4; , ; 4;
+i C +i S d
8/20/2019 CPU Scheduling.ppt
18/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• Ho(ever& if the "rocesses arrive in the order P4&P3& P2& ho(ever& the results (ill %e*
P3 P2 P10 3 6 30
+i C +i S d
8/20/2019 CPU Scheduling.ppt
19/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )herefore& the (aiting time for each "rocess(ould %e*
#verage (aiting time ? / @ 4 @ ;0 - 4 ? 4ms
WT for P1 6 – 0 6
1) for P3 4 B ; 4
1) for P4 ; , ; ;
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
20/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• 1ith this ne( o% sequence& (hat (ill %e the value ofthe turnaround time
• Com"arison of the t(o com"utations of the (aitingtime reveal that if the smaller %urst o%s get
"rocessed >rst that the large %urst "rocess then theaverage (ait %! each o% is lessened.
• ut %ecause +C+S is a non,"reem"tive algorithm& thecom"utation in the given e$am"le must %e done
using the sequence P2& P3& P4& and not P4& P3& P2.• If o%s (ith smaller %urst have to (ait for a long o%to >nish its long %urst then Convo! E:ect e$ists.
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
21/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )his is something that is quite anno!ing (hensmaller o%s are of higher "riorities than the %ig,%urst o% that is occu"!ing the "rocessor.
• Since& the CPU is tied to the o% (ith a ver! long
%urst& o%s (ith smaller have no choice %ut to(ait.
• # real life "arallelism (ould ta'e the form of a(aiting line for a "hotoco"!ing machine.
• 1e can see that it is not nice for a one,"agememo to (ait for the ver! long "rocess of co"!inga length! thesis and a moderatel! length! re"ort.
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
22/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithm
• )his ma! seem unust. #nother clear analog!involves a tric!cle (hich must (ait for a hugeconvo! to >nish a rigid chec'"oint.
• )hus& +C+S algorithm is "articularl! trou%lesome
for time,sharing s!stems (hich require frequentinteraction (ith di:erent "rocesses.
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
23/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithmE$am"le 2 *
JOB BURST TIME
F2 3O
F3 G F4 5
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
24/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithmE$am"le 3 *
JOB ARRIVALTIME
BURST TIME
F2 O
F3 3 G
F4 5
F5 =
+i t C +i t S d
8/20/2019 CPU Scheduling.ppt
25/57
+irst,Come +irst,Served/+C+S0 Scheduling #lgorithmE$am"le 4 *
JOB ARRIVALTIME
BURST TIME
F2 O 5
F3 22
F4 A G
F5 2 32
Sh t t F % +i t /SF+0
8/20/2019 CPU Scheduling.ppt
26/57
Shortest,Fo%,+irst /SF+0Scheduling #lgorithm
• )his algorithm is ver! much in "articular (ith thelength of CPU %urst "articular "rocess maintains.
• 1hen the CPU is availa%le& it is assigned to the"rocess that has the smallest CPU %urst.
• If t(o "rocesses have the same length of CPU%urst& +C+S scheduling is used to %rea' the tie %!considering (hich o% arrived >rst.
Sh t t F % +i t /SF+0
8/20/2019 CPU Scheduling.ppt
27/57
Shortest,Fo%,+irst /SF+0Scheduling #lgorithm
E$am"le *
Consider the follo(ing set of "rocesses that arriveat time O. (ith the length of the CPU %urst givenin milliseconds*
PROCESS BURST TIME
P2
P3
P4 A
P5 4
Sh t t F % +i t /SF+0
8/20/2019 CPU Scheduling.ppt
28/57
Shortest,Fo%,+irst /SF+0Scheduling #lgorithm
Using SF+& the s!stem (ould schedule these "rocessesaccording to the follo(ing 8antt chart*
)herefore& the (aiting time for each "rocess is*
#verage (aiting time ? /4 @ 2 @ = @ ;0 - 5
? Ams
P4 P1 P3 P2
0 3 9 16 24
WT for P1 3 - 0 3
1) for P3 2 , ; 2
1) for P4 = , ; =
1) for P5 ; , ; ;
Shortest Fo% +irst /SF+0
8/20/2019 CPU Scheduling.ppt
29/57
Shortest,Fo%,+irst /SF+0Scheduling #lgorithm
)he turnaround time for each "rocess is*
#verage turnaround time ? /= @ 35 @ 2 @ 40 - 5
? 24ms
TT for P1 9 - 0 9
)) for P3 35 , ; 35 )) for P4 2 , ; 2
)) for P5 4 , ; 4
8/20/2019 CPU Scheduling.ppt
30/57
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
31/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
• )he SF+ algorithm has a "reem"tive versioncommonl! referred to as shortest,remaining,time,>rst.
• # ne( "rocess arriving ma! have a shorter ne$tCPU %urst than (hat is left of the currentl!e$ecuting "rocess.
• # "reem"tive SF+ or,SR)+ algorithm (ill "reem"tthe currentl! e$ecuting "rocess.
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
32/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
E$am"le *
Consider the follo(ing set of "rocesses (ith thelength of the CPU %urst given in milliseconds*
PROCESS ARRIVALTIME
BURST TIME
P2 O
P3 2 5
P4 3 2
P5 4 G
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
33/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
If the "rocess arrive at the read! queue at the times sho(nand need the indicated %urst times& then the resulting"reem"tive SF+ schedule is as de"icted in the follo(ing 8antt*chart*
)herefore& the (aiting time for each "rocess is*
#verage (aiting time ? /2; @ 2 @ ; @ 40 - 5
? 4.Gms
P1 P2 P3 P2 P4 P1
0 1 2 3 6 11 18
WT for P1 11 – 0 – (1) 10
1) for P3 4 B 2 B /20 21) for P4 3 , 3 ;
1) for P5 , 4 4
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
34/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
PROCESS ARRIVALTIME BURST TIME
P2 O
P3 2 5
P4 3 2
P5 4 G
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
P1 P2 P3 P4
P1
P1 = 7
P2 = 4
P2
P1 = 7
P2 = 4
P3 = 1
P3
P1 = 7
P2 = 4P4 = 5
P2
P1 = 7
P4 = 5
P4
P1 = 7
P1
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
35/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
On the other hand& the turnaround time for each"rocess is*
)herefore& the turnaround time for each "rocess is*
#verage turnaround time ? /2 @ G @ 2 @ 0 - 5
? ms
TT for P1 1 - 0 1
)) for P3 B 2 G
)) for P4 4 , 3 2
)) for P5 22 , 4
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
36/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
7on"reem"tive SF+ scheduling (ould result in thefollo(ing schedule*
)herefore& the (aiting time for each "rocess is*
#verage (aiting time ? /; @ @ @ 2;0 - 5
? ms
P1 P3 P2 P4
0 8 9 13 18
WT for P1 0 – 0 0
1) for P3 = B 2
1) for P4 B 3
1) for P5 24 , 4 2;
Shortest Remaining )ime
8/20/2019 CPU Scheduling.ppt
37/57
Shortest Remaining )ime+irst /SR)+0 #lgorithm
Su%sequentl!& the turnaround time for each "rocessis*
)herefore& the turnaround time for each "rocess is*
#verage turnaround time ? / @ 23 @ A @ 2G0 - 5
? .AG ms
TT for P1 - 0
)) for P3 24 B 2 23
)) for P4 = , 3 A
)) for P5 2 , 4 2G
Priorit! /Prio0 Scheduling
8/20/2019 CPU Scheduling.ppt
38/57
Priorit! /Prio0 Scheduling#lgorithm
• # "riorit! is associated (ith each "rocess& and theCPU is allocated to the "rocess (ith the highest"riorit!.
• Equal,"riorit! "rocesses are scheduled in +C+S
order.
• #n SF+ algorithm is sim"l! a "riorit! algorithm(here the "riorit! /0 is the inverse of the ne$tCPU %urst /J0.
• ? 2 - J
• )he larger the CPU %urst& the lo(er the "riorit!&and vice versa.
Priorit! /Prio0 Scheduling
8/20/2019 CPU Scheduling.ppt
39/57
Priorit! /Prio0 Scheduling#lgorithm
E$am"le
Pro!"## Pr$or$%& B'r#% T$"
P2 4 2;
P3 2 2P4 5 3
P5 G 2
PG 3 G
Priorit! /Prio0 Scheduling
8/20/2019 CPU Scheduling.ppt
40/57
Priorit! /Prio0 Scheduling#lgorithm
Using "riorit! algorithm& the schedule (ill follo( the
8antt chart %elo(*
)herefore& the (aiting time for each "rocess is*
#verage (aiting time ? / @ ; @ 2 @ 2 @ 20-G
? .3 ms
P2 P P1 P3 P4
0 1 6 16 18
19
WT for P1 6 – 0 6
1) for P3 ; B ; ;
1) for P4 2 B ; 2
1) for P5 2 B ; 2
1) for PG 2 , ; 2
Priorit! /Prio0 Scheduling
8/20/2019 CPU Scheduling.ppt
41/57
Priorit! /Prio0 Scheduling#lgorithm
)he turnaround time for each "rocess is*
#verage turnaround time ? /2 @ 2 @ 2 @ 2= @
0-G ? 23 ms
TT for P1 16 – 0 16
)) for P3 2 B ; 2
)) for P4 2 B ; 2
)) for P5 2= B ; 2=
)) for PG , ;
Preem"tive Priorit! /P Prio0
8/20/2019 CPU Scheduling.ppt
42/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
• Priorit! scheduling can either %e "reem"tive ornon"reem"tive.
• 1hen a "rocess arrives at the read! queue& its"riorit! is com"ared (ith the "riorit! of the "rocess
(hich is currentl! e$ecuting at the CPU.• # "reem"tive "riorit! scheduling algorithm (ill
"reem"t the CPU if the "riorit! of the ne(l! arrived"rocess is higher than the currentl! running "rocess.
• # maor "ro%lem (ith the "riorit! schedulingalgorithms& (hether "reem"tive or non,"reem"tiveis inde(nite bloc)ing or starvation.
Preem"tive Priorit! /P Prio0
8/20/2019 CPU Scheduling.ppt
43/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
• In a heavil! loaded com"uter s!stem& a stead!stream of higher,"riorit! "rocesses can "revent alo(,"riorit! "rocess from ever getting the CPU.
• # solution to the "ro%lem of inde>nite %loc'age is
aging.• *ging is the technique of graduall! increasing
the "riorit! of "rocess that (ait in the s!stem fora long time.
Preem"tive Priorit! /P Prio0
8/20/2019 CPU Scheduling.ppt
44/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
E$am"le*
Consider the follo(ing set of "rocesses that arriveat time ;& (ith the length of the CPU %urst givenin milliseconds*
Pro!"## Arr$*+,T$"
B'r#%T$"
Pr$or$%&
P2 2 G G
P3 3 2; 5
P4 4 2 4P5 5 A 3
PG G 4 2
Preem"tive Priorit! /P,Prio0
8/20/2019 CPU Scheduling.ppt
45/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
E$am"le*
Using "reem"tive "riorit! algorithm& the schedule(ill result to the 8antt chart %elo(*
I P1 P2 P3 P4 P P4 P3 P2 P1
0 1 2 3 4 5 8 14 31 40 44
Preem"tive Priorit! /P,Prio0
8/20/2019 CPU Scheduling.ppt
46/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
)herefore& the (aiting time for each "rocess is*
#verage (aiting time ? /4 @ 3 @ 2; @ 4 @ ;0-G
? 2G. ms
WT for P1 40 – 1 – (1) 3
1) for P3 42 B 3 B /20 3
1) for P4 25 B 4 B /20 2;
1) for P5 B 5 B /20 4
1) for PG G B G ;
Preem"tive Priorit! /P,Prio0
8/20/2019 CPU Scheduling.ppt
47/57
Preem"tive Priorit! /P,Prio0Scheduling #lgorithm
)he turnaround time for each "rocess is*
#verage turnaround time ? /54 @ 4 @ 3 @ 2; @40-G
? 35.5 ms
TT for P1 44 – 1 43
)) for P3 5; B 3 4
)) for P4 42 B 4 3
)) for P5 25 B 5 2;
)) for PG B G 4
Round,Ro%in /RR0
8/20/2019 CPU Scheduling.ppt
48/57
Round,Ro%in /RR0Scheduling #lgorithm
• )his algorithm is s"eci>call! for time,sharings!stems.
• # small unit of time& called a time +uantum ortime slice& is de>ned.
• )he read! queue is treated as a circular queue.
• )he CPU scheduler goes around the read! queue&allocating the CPU to each "rocess for a timeinterval of u" to 2 time quantum.
• )he RR algorithm is therefore "reem"tive.
Round,Ro%in /RR0
8/20/2019 CPU Scheduling.ppt
49/57
Round,Ro%in /RR0Scheduling #lgorithm
E$am"le*
Consider the follo(ing set of "rocesses that arriveat time ;& (ith the length of the CPU %urst givenin milliseconds*
Pro!"## B'r#%T$"
P2 35
P3 4
P4 4
8/20/2019 CPU Scheduling.ppt
50/57
Round,Ro%in /RR0
8/20/2019 CPU Scheduling.ppt
51/57
Round Ro%in /RR0Scheduling #lgorithm
• )he "erformance of the RR algorithm de"endsheavil! on the sie of the time quantum.
• If the time quantum is too large& the RR "olic!degenerates into +C+S "olic!.
• If the time quantum is too small on the otherhand& then the e:ect of the conte$t,s(itch time%ecomes a signi>cant overhead.
• #s a general rule& ; < of the CPU %urst should
%e shorter than the time quantum.
9ultilevel Kueue Scheduling
8/20/2019 CPU Scheduling.ppt
52/57
9ultilevel Kueue Scheduling#lgorithm
• )his algorithm "artitions the read! queue intose"arate queues.
• Processes are "ermanentl! assigned to onequeue& generall! %ased on some "ro"ert! of the
"rocess& such as memor! sie or "rocess t!"e.• Each queue has its o(n scheduling algorithm&
and there must %e scheduling %et(een queues.
• In this e$am"le& no "rocess in the %atch queue
could run unless the queues for s!stem"rocesses& interactive "rocesses& and interactiveediting "rocesses (ere all em"t!.
8/20/2019 CPU Scheduling.ppt
53/57
9ultilevel +eed%ac' Kueue
8/20/2019 CPU Scheduling.ppt
54/57
9ultilevel +eed%ac' KueueScheduling #lgorithm
• )his algorithm is similar to the multilevel schedulingalgorithm e$ce"t that it allo(s "rocesses to move%et(een queues.
• )he idea is to se"arate "rocesses (ith di:erent CPU,
%urst characteristics.• If a "rocess uses too much CPU time& it (ill %e
moved to a lo(er,"riorit! queue.
• )his schemes leaves I-O,%ound and interactive
"rocesses in the high "riorit! queues.• Similarl!& a "rocess that (aits too long in a lo(er,
"riorit! queue ma! %e moved to a higher,"riorit!queue.
9ultilevel +eed%ac' Kueue
8/20/2019 CPU Scheduling.ppt
55/57
9ultilevel +eed%ac' KueueScheduling #lgorithm
($nt$m = 8ms
($nt$m = 16ms
')'S
9ultilevel +eed%ac' Kueue
8/20/2019 CPU Scheduling.ppt
56/57
9ultilevel +eed%ac' KueueScheduling #lgorithm
• In this e$am"le& the scheduler (ill >rst e$ecute all"rocesses in the >rst queue.
• Onl! (hen this queue is em"t! (ill the CPU e$ecute"rocesses in the second queue.
• If a "rocess in the >rst queue does not >nish in ms&it is moved to the tail end of the second queue.
• If a "rocess in the second queue did not >nish in 2ms& it is "reem"ted also and is "ut into the thirdqueue.
• Processes in the third queue are run on an +C+S%asis& onl! (hen the >rst and second queues areem"t!.
9ultilevel +eed%ac' Kueue
8/20/2019 CPU Scheduling.ppt
57/57
9ultilevel +eed%ac' KueueScheduling #lgorithm
• In general& the follo(ing "arameters de>ne a multilevelqueue schedule*
2. )he num%er of queues.
3. )he scheduling algorithm for each queue.
4. )he method used to determine (hen to u"grade a"rocess to 4 higher,"riorit! queue.
5. )he method used to determine (hen to demote a"rocess to a lo(er,"riorit! queue.
G. )he method used to determine (hich queue a"rocess (ill enter (hen that "rocess needs service
• #lthough the multilevel feed%ac' queue is the mostgeneral scheme& it is also the most com"le$ .