Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Al

l
ocat
ionoff
rames:

Animpor tantaspectofoperati
ngsyst
ems, v
irt
ualmemoryisimpl
ement edusi
ngdemand
paging.Demandpagi ngnecessi
tat
esthedevel
opmentofapage-r
eplacementalgor
ithm and
aframeal locat
ionalgorit
hm.Frameal
locat
ionalgori
thmsar
eusedifyouhav emult
iple
processes; i
thelpsdecidehowmanyframest oall
ocatet
oeachprocess.

Therearev ar
iousconst rai
ntstothest r
ategiesfortheal l
ocationoff rames:
 Youc annotal l
ocatemor ethant hetotalnumberofav ailableframes.
 Atl eastami nimum numberoff r
amesshoul dbeal l
ocat edt oeachpr ocess.Thi
s
constraintissupportedbyt woreasons.Thef i
rstreasoni s,
asl essnumberoff rames
areall
ocat ed,therei
sani ncreaseint hepagef aultrati
o, decreasingtheperfor
mance
oftheexecut ionoftheprocess.Secondl y,t
hereshoul dbeenoughf r
amest oholdall
thedifferentpagesthatanysi ngleinstr
ucti
oncanr eference.
Frameallocati
onal gorit
hms–
Thetwoal gori
thmscommonl yusedt oallocatefr
amest oapr ocessar e:

1.Equal allocat ion: Inasy st


em wi thxf ramesandypr ocesses,eachpr ocessgetsequal
numberoff rames, i.
e.x/ y.Forinstance, ifthesy stem has48f ramesand9
processes, eachpr ocesswi l
lget5f r
ames.Thet hreef r
ameswhi char enotallocat
ed
toanypr ocesscanbeusedasaf ree-framebuf f
erpool .
o Di sadv antage: Insy stemswi t
hpr ocessesofv aryi
ngsizes, i
tdoesnotmake
muchsenset ogi veeachpr ocessequal frames.Al l
ocationofal ar
genumber
off ramest oasmal lprocesswi llevent uallyleadt othewast ageofal arge
numberofal l
ocat edunusedf r
ames.
2.Pr oport
ional allocat i
on: Framesar eallocat edt oeachpr ocessaccor dingtothe
processsi ze.
Forapr ocesspiofsi zesi,thenumberofal locatedf ramesi sai=( si/
S)*m, whereSis
thesum oft hesi zesofal l t
hepr ocessesandm i st henumberoff ramesi nthe
sy stem.Fori nst ance, inasy stem wi th62f rames, ifthereisapr ocessof10KBand
anot herpr ocessof127KB, thent hefirstpr ocesswi l
l beall
ocated( 10/137)*62=4
framesandt heot herpr ocesswi llget( 127/ 137)* 62=57f r
ames.
o Adv ant age: Allthepr ocessesshar et heav ailableframesaccor dingtotheir
needs, rathert hanequal ly.

GlobalvsLocalAll
ocat
ion–
Thenumberoff ramesall
ocat
edtoaprocesscanalsodynami
cal
l
ychangedependi
ngon
whetheryouhaveusedglobalr
epl
acementorlocal
repl
acementf
orr
eplaci
ngpagesincase
ofapagef aul
t.

1.Localreplacement :Whenapr ocessneedsapagewhi chisnotint hememor y,itcan


bri
ngint henewpageandal l
ocateitaframef rom i
tsownsetofal locatedframes
only.
o Adv antage: Thepagesi nmemor yforaparti
cularprocessandt hepagef aul
t
r
at i
oisaf f
ect edbythepagi ngbehaviorofonlythatprocess.
o Di sadvantage: Alowpr i
orit
yprocessmayhi nderahi ghpriorityprocessbynot
makingi t
sf ramesav ail
abletothehighprior
ityprocess.
2.Globalreplacement : Whenapr ocessneedsapagewhi chisnotint hememor y,itcan
bri
ngint henewpageandal l
ocateitaframef rom t
hesetofal lfr
ames, evenifthat
fr
amei scur rentl
yallocatedtosomeot herprocess;t
hatis,onepr ocesscant akea
fr
amef rom anot her.
o Adv antage: Doesnothi ndertheperformanceofpr ocessesandhencer esults
i
ngr eatersyst em t
hroughput.
o Di sadvantage: Thepagef aultr
ati
oofapr ocesscannotbesol elycontrolled
bytheprocessit
sel
f.Thepagesinmemoryforapr
ocessdependsont
he
pagingbehavi
orofotherpr
ocessesaswel
l.

Ot
heri
mpor
tantt
opi
caskedi
npr
evi
ousy
earquest
ionpaper
(shor
tnot
es)
:

Q.
1wr
it
eshor
tnot
e“OSasResour
ceManger
”.

Whenacomput erhasmul t
ipl
euser s,t heneedformanagi ngandpr otectingthememory,I
/O
devicesandot herdevi
cesisev engr eater
.
Thepr imar ytaskofOSi stokeept rackofwhoi susingwhi chr esour ce,tograntr
esour
ce
requests,t
omedi ateconfli
cti
ngrequest sfrom di
ff
erentprogramset c.
Usersof tenneedt oshar
enotonl yhardwar e,buti
nfor
mat i
on(Fil
e,Database)aswel l.

Whi
chI
ncl
udesi
nResour
ceManager?

Resour
cemanagementi
ncl
udesmul
ti
plex
ingr
esour
cesi
n2way
s,t
heyar
e
1.I
nTime
2.I
nSpace

WhenResour
cei
sTi
meMul
ti
plexed

“Whogoesnextandf orhowl ong”-isthemaint askfortimeresour


cemanageri
nOS.
Dif
fer
entprogramsorusert aketurnsusingit
.
Multi
plepr
ogramswill r
unbyal l
ocatingtheCPUt hr
oughOS.
Whenanotherprogr
am get stouset heCPU, theOSwi l
lchoose.
Shari
ngthepri
nteri
st heidealexampl efort
imemul t
ipl
exing.

WhenResour
cei
sSpaceMul
ti
plexed

Mainmemor yisnormallydivi
dedupamongsev eralrunningpr
ograms
OSassumeenoughmemor ytoholdmulti
pleprograms
OSholdsev eralprogr
amsi nmemor yatonceinsteadofcompl et
ingonebyone.
Theissuesoff ai
rness,prot
ecti
onandsoonwi llsolv
ebyOS.
Harddiskisanot herr
esourcemanagerforspacemul ti
plexed
Q.
2wr
it
eshor
tnot
e“ker
nel
”.

AKer nel i
sacomput erpr
ogr am thatisthehear tandcor eofanOper ati
ngSy stem.Si
ncethe
Oper at i
ngSy stem hascontrol overthesystem so, t
heKer nelalsohascontrolover
everyt hinginthesy st
em.Itist hemosti mpor tantpartofanOper ati
ngSystem.Whenev era
system st arts,theKernel
isthef irstprogram thatisloadedafterthebootl
oaderbecausethe
Kernel hastohandl etherestoft hethingofthesy stem fortheOperati
ngSy stem.TheKernel
remai nsi nthememor yuntiltheOper ati
ngSy stem isshut-
down.

TheKernel
isresponsi
blef
orl
ow-level
taskssuchasdiskmanagement,memory
management,taskmanagement,
etc.I
tprovi
desani nt
erf
acebet
weentheuserandthe
har
dwarecomponent soft
hesystem.Whenapr ocessmakesarequestt
otheKernel
,theni
t
i
scall
edSystem Call
.

AKerneli
sprovi
dedwit
hapr ot
ectedKernelSpacewhichisaseparat
eareaofmemor yand
t
hisareai
snotaccessi
blebyotherappl
icat
ionprogr
ams.So,thecodeoftheKernel
is
l
oadedint
othisprot
ect
edKernelSpace.Apartf
rom thi
s,t
hememor yusedbyother
appl
i
cat
ionsiscal
ledtheUserSpace.Asthesear
etwodi
ff
erentspacesi
nthememor
y,so
communicat
ionbetweenthem i
sabitsl
ower .

Funct
ionsofaKer
nel

Fol
l
owi
ngar
ethef
unct
ionsofaKer
nel
:

 AccessComput
err
esour
ce:
AKer
nel
canaccessv
ari
ouscomput
err
esour
cesl
i
ket
he
CPU, I/
Odev icesandotherr esources.Itact
sasabr i
dgebetweentheuserandthe
resour cesoft hesyst
em.
 Re sour ceManagement :Itisthedut yofaKer nelt
osharetheresourcesbet
ween
variouspr ocessinsuchawayt hatthereisunif
orm accesstotheresour
cesbyever
y
process.
 Me mor yManagement :Everypr ocessneedssomememor yspace.So,memorymust
beal locatedanddeallocatedf orit
sexecut i
on.Allt
hesememor ymanagementis
donebyaKer nel.
 De viceManagement :Theper i
pheral devi
cesconnectedinthesystem ar
eusedbythe
processes.So, t
heall
ocat i
onoft hesedev i
cesismanagedbyt heKer nel
.

Q.3wri
teshor tnote“spooling”
.
SPOOLi sanacr onymf orsimultaneousper i
pheral
operationson-
li
ne.
 Iti
sakindofbuf
fer
ing
mechanism orapr ocessi nwhichdat aistemporari
lyheldtobeusedandexecutedbya
devi
ce,program orthesy stem.Datai ssenttoandst or
edi nmemoryorothervol
ati
l
e
stor
ageunt i
ltheprogram orcomput errequest
sitforexecuti
on.

I
nacomput ersystem per i
pheralequipments,suchaspr i
ntersandpunchcar dr eader setc
(batchpr ocessing),arev eryslow r el
ati
vetot heper for
manceoft herestoft hesy stem.
Gettinginputandout putf r
om thesy stem wasqui cklyseent obeabot tl
eneck.Her ecomes
theneedf orspool.Spoolingwor kslikeatypicalrequestqueuewher edata,instr
uct ionsand
processesf r om mul t
iplesourcesar eaccumul atedf orexecuti
onl at
eron.Gener all
y,itis
maint ai
nedoncomput er’
sphy sicalmemor y,buf fersort heI/O devi
ce-
speci f
ici nterrupt
s.
Thespooli spr ocessedi nFIFOmanneri .
e.what ev erfir
stinstr
ucti
onist hereint hequeue
will
bepoppedandexecut ed.

Appli
cati
ons/ I
mpl ementationsofSpool :
1)Themostcommoncanbef oundinI/Odev icesli
kekey boardprinter
sandmouse.For
example,Inpr i
nter,thedocument s/
fil
esthatar esenttot heprint
erar efirststor
edi nthe
memor yort hepr i
nterspool er
.Oncet heprinteri sr
eady,itfet
chest hedataf rom thespool
andprintsit
.
Evenexper i
encedasi tuationwhensuddenl yf orsomesecondsy ourmouseorkey board
stopswor ki
ng?Meanwhi le,weusuallycli
ckagai nandagai nher eandt her
eont hescreento
checkifitswor ki
ngornot .Wheni tactual
lyst artsworki
ng,whatandwher everwepr essed
duri
ngi t
shangst ategetsexecut edv er
yfastbecauseal ltheinstr
uctionsgotst or
edi nthe
r
espect
ivedev
ice’
sspool
.

2)Abatchprocessi
ngsy
stem usesspooli
ngt
omai ntai
naqueueofready
-to-
runj
obswhi
ch
canbestar
tedassoonasthesystem hast
heresour
cestopr
ocessthem.

3)Spooli
ngiscapabl
eofoverl
appingI
/Ooperat
ionf
oronej
obwi
thprocessoroper
ati
onsfor
anot
herjob.i.
e.mult
ipl
eprocessescanwrit
edocumentst
oaprintqueuewi t
houtwai
ti
ng
andresumewiththei
rwork.

4)E-
mail
:anemai
lisdeli
ver
edbyaMTA(Mai
lTransf
erAgent
)toat
empor
aryst
oragear
ea
wher
eitwai
tst
obepickedupbytheMA(
Mail
UserAgent
)

You might also like