You are on page 1of 23

CPU Schedulina

CP Sheduling 3 the manage men CPU


t
cgouve

CP &cheduling a ODcess dehermimrng


J
Lohich
Ohich Process i 0 o n cPu ccuHon
ecutHon
Olc another ocesS on hold.
The Purpose o CP Schedulina d
mproye he fiency heAm
amd make the m
Jasand fai
* CP
Schedling 3 bas o mulA -

Oarqmmed
operaina em
*CPO&heduling 3 utd + incea
CP U3a Hon

PestCPo Scheduligg

CP &chedulina

re emptue Non-emptue|
re.emptue Sehedui
JA d hen procesS
cemp¥ue Schedulin
Switchs om nhin9 Sta eaa
S Aate om the Oaitin S
ready Sak
*I Jmpsa +orun a ak th

gne rie bo ancther cwer

asK
EXample:
rocesS Arival CPu ur+Tim
Time Cin mhe )

B Po
16
Non- e emplue Sheduli

kNon- reemNe Sheduli d hen a

a SotchcS
oce SC erminmahes ,Or ProceS

Jom unni he ili 9

*Tn his Schc dulinq Once


h cSouccS

he p occss
anc loeated o C P>ocess

holde he erminahd or
eacmes
Oatims Stqe.
I he >oce $s uinq, Ahen no Anenru
A oullotocd an betudecn the Cxecy-Hon the

oceSS

amplos

oces S Ariual time CPo Bur+ Time

6
16
* CPU
Schedulipa Citeriq'-

Schedulin Criteriq

Maximize Min'im ze
CP lizahon
*Tun around Tme
hrough put a Timc
Res ponSc Timc
CPU UHlizaHon -

*CP Hlization the main atk in shch


he opeaia
ddom nccds
make2yrt
cP emains
* +
buAy o oRsilc
can
ant rom Oto loo fercent
F o r he RToS,it Ca
ran 40 30 feray.
Toughput,
The numbes o Proce SeS tha inish
the Cec i o Per unit time JA knoa
as
Throughpu
The igner he numbes ne more
OorK 3A done ho 3m.
Oaitina Time

LOating timc Cn amoymt that


Specihic POce S s nccds 4o LOart in he
rca ueue.

*
Respon se Time'
*T+A qmoun + me n Ohieh

he rEquest Submi tted util+he

eponse produ-d.
urnaroun imo
Trunanrounda ime i an qmoum o

time xecute a
Speciic OceSS.
tho colcula Hon ot tho otal
ime Spent Loaiting to
3e intothe
memo , oaitng n he ucde qmd
Cecui on

The Period cocn he Hm o


ocess umission+o theCompleion time
the harnaN Dund ms
ees of Sche duliga Alaorithms -
Fivst Comc, Fist Serut
(FCFs)
*Shots ob Fist STF) She dal
Shor 4t
Rcmain Tint
iovit Schedulin
Round Robin Sche dul
lul4ileuc Sucue Sehedulip

Fit Come Firt Serve CFCFS

Fist Come, FiSt Serue&the l l form


ofFcFS . + Ja the easi cst and most
Simple
CPU Scheduling algovith In his
m.
Pc of
agoithm ,thc PocesSS hich
rtqu+Ahc CP
3tsthe cPU all ocqtion firs+ The Sche dullirg
metho d Can be manaacd oith a
FIFO ueue.

Exampl oeaut aSCumed aiual +imes as 0, So


+urn around and Gompletion imes qrc
Samc

ProceSSs Dyration
Ariva Time
24

8
Chantt chart

24 31

PLatipa time 0
Oating time 24
ating time 24

The Avevsa LSating time P,+4


Ho of fers

0+24 +29
14
3

ShorHest Job First

*S3F is afull4om othors job firs


n ohieh
ischcdulina algrithm he oceS
oiththe &hovhes exceution time should

Selecdfor exceu ton nex.


* This hedulina
mcthod Can be
Prcemiue
r non- prcem ptHue.

Exampe Consider the olleusing«ble o ariwal hme


qnd burst time PYoce SI6S
, , , Ps, Pq gnd s.
s
roces.S burst ime
Aiual Time

9mS

Sms
&ms
ms
3ms
fs Oms
4-mS
4-mS

nantt+chavt.

Pa Ps
IS

o
LOatina me Sta Aecution tim- (Arinal Tme
O

3-2
Pa -S: 4
Pa1S -L: 14

ANea3 LOaing PytPat Pa +Ps

i++194t 0+*
S
S
Shordest RomainpaTime

*Theull Horm o} SAT is Shortest Remgining


Aime
also Knoon aS STF
Pramtiue Seheduli5
Inhis netthod,the Proces oill be allocarcd
tothe ask ,ahich elotest o its
Compleion.

Example ConSider the olog able o aual


Hme and burst ime oY ue roce sseer

roceSS Burst Time Ariual Timc

ms
ms
Sms
S ms
ms
8ms
O mS
4-ms
4 ms

Chat+ Chat-

PP s
S
6Ymylq
S 98

o
Turn Around TimeCTAT) = Compeion ime - qrrivai Aime
oaitina Tine T) TAT bust Time
occsS Completion 4ime TAT atingTme

1S IS-2 13 13-6-

7-S 2 2-2-0

93 23-1- 22 22 8- 14
3
3-0-3 3 - 3
1o-4 6 -42

13t2+22 +3+6 =
Auerage
Auevage TAT 3.2

Auerag OT + 0 t 1440+2 46

i o t y Bascd Schedalina

ior
iori bAcd
Bcheduli a method
of Scheduli Proce SSes on priori In
his omeihodihe Scheduler Selechs the
he Jatk
LOerK o Per he

cr rs}hme Arrruo 4ime


4 0

12
hant chaa

Ps
13 14 16

A r u a lt 1 m

LOating Tme Ster fim Loat Aim or not barSt


brS

R O-0 =0
4 - 0+7=11

f4 16-1-S
's 14 2t+o

Auerag LSaiting time= (o+1+0+S +2)


S

Round Robin Sehcdulling


Round Robin s the cldest,SimplestScheduhg
algorithm. The name of his algorithm Comes
om theround-robin
the principle, ohe
Oqch per Son gcs an equal Shae o

in tun. Someig
H A mostl d Aor che dulig algovithm
n
mulaitaskiKing
Etampe Considor the
ollo toing alle o aa
time and buSt
ime
ue
PL,P3 and for and
wen Time quanhum
qantum 2

oce sS Gurt Timc Arual Tim

Sms OmS

-ms ms
2mS

mS
4ms

Cyant chat -

11

Compleion Timc Time at rocess Compleb iH


Cccuhom

Tun Anroun Timc . Compleion Tim - A a e l Tome


Tum
Tme as Around Timo
atn But Time
Comple 4ion Time
nd
CT)
Ym Around Time
12
CTAT)
P12-o-12
fa: 9 l-Iz10
3 -2-4
49-4S
aitina lime
CwT)

12-S+

1o o 4 6

4-2-2 2
R S\: 4

Average TAT = 12tlot+tS 3-4

Averagt LoT 1+6t2t+


4
4-7

X Leuel QueuesS
Multiple -

Schedulin
In ths method
PcosSes qssianec
uoue batel on o
he &peitic opa
oce ss like he Pro ces
i i y , Size of the
memoy, c.
Erampes Con sideY th ou
our Pdoces6S under
mylhleuel qucuc Rehedulin

Aual Time CPU urst Timc Queue tlo.

ur then
ioi ot 9ucu

Round Robin
Timc 9uantum-2) and qucue 2 s FCFS.

Cantt chart ',

P,P Pa
1S
4
cesS aes'.
OCeSSoy i n he ogeqhng m Can be n aj

o he ollousia Shates

Nes The ProceSS being CTCated.

The
he Heo Sta às he nea Crcatcd ram
tonich stored in thc
Secondar SAoraae
Sovage.
Kead The ProceSS s
9aitina4o be
assianed o proce SSY

*Kanning Tn aun Stqt the cP Sclect


the oo cess
c ess 6 Cxecution and xecutes

the ingtmcion ith ån he o c e SS.

Ne
amitted Tevmingted
Tnteruret

Read Scheduler Ranina


Cxit

Dis pateh

cucn Tl0 o
Comple tio waitfina cyent Na14
LOaiting!-The occSS Lattna-Jor Some
euent
o occUY Such as an T|o Completion
oY
ece pion ofa Synal)
1the poocesS is in un Sate andhe
rocess needs Some &outs r Cxecution.
b the oure A eld bx Some othus
hocess han he PocesS enhers nto the
blocKed
satia
ermingtd- The roccss as Jinished
CecutAon

rocess Conhro| Block Pc8)-

Pce i s a daa Sucture Uscd +o tore


he anfovmation qbout he ProcesS es.
+ js qlso Knon as he task control
bloc
Thhe informaion o the Pso cess

CP qt he untime,

PcB daha S*ucue can Hains


lloding3
oce sS State' +can bc unin9 ting ede.
soceSS 10 nd he
he Parcnt
CP 0
CPU
Taisr and m Counte. 0 m

Counttr holds he adde ss of the n


instuctioh be eAccutcd o hat
that Poces sS.
COCEs s.
Cpu
Schedulina Irfor mation &uch a rhori
intarmaHon amnd pointe 4o
Schedulig que.
emor lanagcment intoYmation " For
For eAqmple
eiqmp
aaeables, r Scgmentabler

*Accountina 1ntormation, The uY and Kerne


CP me Comsumcd account number, limi.

* Ilo Statys informaHon.- Devices qlocatcd Open


ile Aables ete
roces s 1D

Pointer
Piorit
gem couner

CPU aisteYS
inormation
Aecounh n9 inrmahon
et
-
iocess Schcdulexs

he prOCcSS Schedu lanq k the actiui


he pocc8S man hat andles he

rmotal of he uning oce&S o th


CP gnd -}he Selecion o anothY
e s
On he basis o a
Pax iculoar &vas
oceSs Schedulina J an cssenial Par
par o
a
mulhprogrqmmi operatina Aems.
There
here ore thrce tpes o Psocers Seheduler.
Long Term 0Yob Scheduler
hhe
T e Long term Lona Seheduler rcaulaBes the

'yogamn qne Select PoceSS OYm the qucuc


qna oads hem anto
erExec ukion.
mmo
aloaulakr the dae ofmulti-prgromm7
n a timeShari Sy8he the lona
Hem Sehedulcr docs mot exis

Mediumn erm ehedulex


Medium Jerm Scheauling iS an
inporan
ov o SLnp pira1 enabler ou oo
andlc Soapped out Psocesse
I n this Scne duler, a
uina oce &S Can bcomc
Suspended , hich makes an Tlocques
i s dust Ke a Part o
Timnc
Shani Sstem.
*14 i help tosc'inBroduec the pyocess n

the memo So hat he r o ce ss cxecuhon


can be continued agam

Snort Term Sehedulr.-


* Shot Texm Scheduldng J aSo Knouon aS
CPU Scheduler.

*The Short- Tem Schtduler Choose Sthosc


oceS Scs ha arc eac o ecut
14 s ess exist àn me time - sharing
ms.
The Poima aim o this Schedulev
to en hance
cP.Pesko mqnce and incea
occSS ccuhon rat

Thread -

*A 4hrcad is apath of ecution othin a


rocess. A occSS Can cantain multiple
threds
ThYeads PYBent Sofloae appoqch
Amprouimg
peofomance o opeat9 m

educi the cad o procesSs Sovt ch

* A
A thyead is qlo called a a Pcof .
liahtuwcight pca
Thrcad Soichig docs not nced+o intcract
Loith
oponqt Atm.
Onc hread Can c a d , Lorie ox Change

qnothcr thead's data

Counter istrReaister(Reu
COunde| Counkr Coynte
Fles
Code Date Filcs
Code
Single thread
Plihread

Auandage
E{fieient Communication.
Thread minimige Contot Soitdhins me
EfcctHc tiathon o multi poc e
SSor
systm.
Rezoure Sharn
Enhanccd thoughput he m
Threads
Thore ast pes o threadAc
-USoY Leuel Thxcad
Kerne cuel Thread

User Luel Thead


a uso Lsuc thread,all o the oorh
9 thvcad Managemen+ JA done b tho

Agplicaton
*Opcatia docsn'tvocogn2e A r

cvelthrcad.
Condext Soitch rcqustS ho narduoare
Suppov
USGrthread are implcmente b uSGY.

ST thmread

uSer paceThread
Libyanry
KernsSpace
CPU
Advantag e-
*
o Kevnel modifications needed o Sappo
hsadc
Scheduling Can be oPplicalion peci fie.
UScs
euelthvoads ad far} Create
Create qnd
qnd
managc
Oisadvatage
* I n a ypical opeqhi9Sem, mostS
m
Calls are blocking.

pocs not+qkG aduanHage o multiprOcCSs oY

Kemel Leuel Thread

* nIn Komel louelthcad, thrcad moqnagemen


JA donc the Kernc . Thc A no

+hrcad Codc in he
manaaemcn application
are

Kexnel thweed a implemented 0s.


14 isecegniged oS.

Contex Sai deh cquircS Ha-dLae Support


Sehodulina bythe Kes ne å do
thrcad basis
USSSpace
Pces-
Pocess-22

Thread Chad Tad ibar

Koancl &pace

CPu CP) (CPU CP

Aduan
*Kernel cam Senedule mulipe hrcad om h
Same PrOceSS
different Ps ceor.
on

i a thead blocked Konc) Can Ahedule another


thread ofthe Samc pro ce SS.
*kexncl routinc itself Can bMaltithreaded.

pisadvaniea
kncl hreadc ast
8enorally Sloo
Ccat and
+hre ads.
mana than the uML

You might also like