0% found this document useful (0 votes)
17 views18 pages

OS QNS With ANS

OS practice

Uploaded by

Boniface Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views18 pages

OS QNS With ANS

OS practice

Uploaded by

Boniface Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Operati

ng Sy st
em:Quest
ions andt
hei
r answer
s :
Processes andDeadl
ock ( Par
t 1)

Q1:Defi
ne:Operati
ngsystem, Pr
ocess,Processstat
e,PCB,Dispatcher
,Dispat
chl
atency
,
I
nter
rupt,pr
otect
ion,Deadlockstat
e,Safestate,
Resourceal
locati
onstate?

Answer

Oper
ati
ngsyst
em i
sasetofpr
ogramst
hatcont
rolt
heexecut
ionofappl
i
cati
onprograms
andactasani
nter
medi
arybet
weenauserofacomput
erandthecomputerhar
dware.

Pr
ocessi
sapr
ogr
am i
nexecut
ion.I
tist
heuni
tofwor
kinmostsy
stem.

Pr
ocessst
atei
sthecur
rentact
ivi
tyoft
hatpr
ocess.

ThePCBisadatast
ruct
ure.Ituseasthereposi
tor
yforanyi
nfor
mat
iont
hatmayv
ary
fr
om pr
ocesst
oprocess.Eachprocesshasit
sPCB.

Thedi
spat
cheri
sthemodul
ethatgi
vescont
rol
oft
heCPUt
othepr
ocesssel
ect
edbyt
he
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

shortt
erm schedul
er.
Dispatchlat
encyisthet
imet
akesf
ort
hedi
spat
chert
ost
oponepr
ocessandst
art
anotherrunni
ng.

I
nter
rupti
sanev
entt
hatal
ter
sthesequencei
nwhi
cht
hepr
ocessorexecut
esi
nst
ruct
ions.

Pr
otect
ionrefer
stomechani
sm t
hatcont
rol
theaccessofpr
ogr
amsoruser
stot
hebot
h
sy
stem andresour
ces

Deadl
ockstat
e:Asetofprocessesi
sinadeadl
ockst
atewhenev er
yprocessint
heset
i
swaiti
ngforanev
entthatcanbecausedonl
ybyanot
herprocessintheset.

Saf
estat
e:Ast
at ssaf
ei eift
hesyst
em canal
l
ocat er
esour
cest
oeachpr
ocess(
upt
oit
s
maximum)i
nsomeorderandst
il
lavoi
dadeadlock.

Resourceal
l
ocati
onst
ate:
Iti
sdef
inedast
henumberofav ai
l
abl
eandal
l
ocat
ed
resour
cesandthemaxi
mum demandsoft
heprocesses.

Q2:Whyar et heprogramsanddat anotresi


dedinmainmemor yper
manentl
y?
Answer
Therearetwor easons:
1)Mai nmemor yisusuall
yt oosmal lt
ost or
eallneededprogramsand.Dat
a
permanentl
y .Mainmemor yisav ol
ati
lestoragedevi
cethatl
osesitscont
ent
swhen
poweristurnedof forother
wiselost

Q3:Whatar et heacti
vi
ti
esoft heoper ati
ngsystem inr egardtoprocessmanagement?
Answer
Theoperati
ngsy st
em isresponsibleforthefoll
owingact i
vi
ti
esinregardt
oprocess
management :
1) Creatinganddeletingbot huserandsy st
em pr ocesses
2) Suspendi ngandresumi ngpr ocesses
3) Providingmechanismsf orprocesssynchronization
4) Providingmechanismsf orprocesscommuni cat ion
5) Providingmechanismsf ordeadlockhandli
ng

Q4:
Whatar
etheact
ivi
ti
esoft
heoper
ati
ngsy
stem i
nregar
dtof
il
emanagement
?

Answer
Theoperati
ngsy stem i
sresponsibleforthefoll
owi ngact
ivi
ti
esi nr
egar
dtof
il
e
management :
1)Creati
nganddel eti
ngfil
es
2)Creati
nganddel eti
ngdirectori
estoor ganizefil
es
3)Suppor t
ingprimi
tiv
esformani pulati
ngf i
l
esanddi rector
ies
4)Mappi ngfil
esontosecondar ystorage
5)Backingupf il
esonstable(nonv ol
atil
e)storagemedi a

Dr
.Qasi
m MohammedHussei
n Page1
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Q5:
Expl
ainwi
thdi
agr
am t
hepr
ocessst
ates?

Answer

Eachprocessmaybei noneofthefollowi
ngst at
es:
1.New.Thepr ocessisbeingcr
eated.
2.Running.Instr
uct i
onsarebei
ngexecuted.
3.Wai t
ing.Thepr ocessiswai
ti
ngforsomeev enttooccur(suchasanI
/Ocompl
eti
on
orr
eceptionofasi gnal
).
4.Ready .Theprocessi swai
ti
ngtobeassi gnedt oaprocessor.
5.Termi nat
ed.Thepr ocesshasfi
nishedexecution.

Q6:Whatisinformat ioni nt hePCB?


Answer
PCBcont ai
nst hef ollowingi nformation
• Pr ocessst ate.Thest atemaybenew, r
eady ,runni
ng,wai
ti
ng,
halt
ed,andsoon.
• Pr ogram count er.Thecount erindi catestheaddr essofthenexti
nstruct
iont
o
beexecut edf ort hispr ocess.
• CPU r egisters.They i nclude accumul ators,index
regi
sters, st ack poi nters, and gener al-pur
pose
regi
sters,plusanycondi ti
on-codei nformat ion.
• CPU- schedul ing i nf ormat i
on. Thi s i nformati
on
i
ncludes a pr ocess pr i
orit
y,poi nterst o schedul i
ng
queues, andanyot herschedul i
ngpar amet ers.
• Memor y -
managementi nformat i
on.Thi si nformati
on
mayi ncludesuchi nfor mationast hev al
ueoft hebase
andl i
mi tregist ers,t hepaget ables,ort hesegment
tabl
es,dependi ngont hememor ysy stem usedbyt he
operati
ngsy stem.

Dr
.Qasi
m MohammedHussei
n Page2
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

• Accounti
nginfor
mat ion.Thisinf
ormati
oni ncludestheamountofCPUandr eal
ti
meused, t
imeli
mi ts,accountnumbers,joborpr ocessnumbers,andsoon.
• I
/Ostatusinf
ormation.Thisinformat
ionincludest heli
stof
I/
Odev i
cesall
ocatedt otheprocess,ali
stofopenf i
les,andsoon.
Q7:
WhataretheOperati
onsonPr ocesses?

Answer

Theoperati
onsonpr ocessesareprocesscr eat
ionandt erminati
on.
1. ProcessCreation:Apr ocessmaycr eateseveralnewpr ocesses, vi
aacr eate-
processsystem call,duri
ngthecourseofexecut i
on.Thecr eatingpr ocessis
caledapar
l entprocess, andthenewpr ocessesarecalledchildrenoft hatprocess.
2. ProcessTerminat i
on: Aprocesster
mi nateswheni tfi
nishesexecut i
ngi t
sfinal
stat
ementandaskst heoperati
ngsy st
em todeleteitorbyanot herprocessv i
aan
appropri
atesystem cal l
.

Q8:I
nprocesscr
eati
on,whatarethepossi bi
li
ti
esinconcerned(1)Parentexecut
ion
(
2)Addr
essspaceofthenewpr ocess(child)
?Answer
(
1)Ther
earetwopossibi
li
ti
esofexecution:
a)Theparentcont
inuestoexecuteconcur r
entl
ywithi
tschildr
en.
b)Theparentwait
suntilsomeorall ofit
schil
drenhaveterminat
ed.

(
2)Ther
ear
ealsot
wopossibi
l
iti
esintermsoftheaddressspaceoft
henewpr
ocess:
a)Thechi
l
dprocessi
saduplicat
eoft hepar
entpr
ocess.
b)Thechi
l
dprocesshasanewpr ogram l
oadedi
ntoit.

Q9:Aparentmayt er
mi natet
heexecuti
onofoneofi t
schil
dren.Whatarethereasons?
Answer
a)Thechil
dhasexceededi t
susageofsomeoft heresourcesthati
thasbeen
al
locat
ed.
b)Thetaskassignedt othechi
ldi
snol ongerr
equir
ed.
c)Theparentisexiti
ng,andtheoperat
ingsyst
em doesnotallowachildt
ocont i
nuei
f
i
tsparentterminates.

Q10:
Whatar
etheev
ent
soccurwhent
hepr
ocessal
l
ocat
etot
heCPUandi
sexecut
ing?

Answer

Oneoft
hef
oll
owi
ngev
ent
smayoccur
:

a)Thepr
ocesscoul
dissueanI
/Or
equestandpl
acesi
nanI
/Oqueue.

b)Thepr
ocesscoul
dcr
eat
eanewsubpr
ocessandwai
tfori
tst
ermi
nat
ion.

c)Thepr
ocesscoul
dremov
efor
cibl
yfr
om t
heCPUasar
esul
tofani
nter
ruptandbe

Dr
.Qasi
m MohammedHussei
n Page3
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

putbacki
nther
eadyqueue.

Exi
t

Q11:
Whatar
ethedi
ff
erencesbet
ween?

(
1)Long-t
erm schedulerandshort
-t
erm scheduler
?
(
2)Preempti
veandnon- pr
eempti
vescheduling?
(
3)CPU-boundpr ocessandI/O-
boundpr ocess?
(
4)Timeshari
ngsy st
em andbatchsyst
em?

Answer

(
1) Thedi
ff
erencesbet
weenl
ongt
erm schedul
erandshor
tter
m schedul
er

Longt
erm schedul
er shor
tter
m schedul
er
1 I
tcal
l
edjobschedul
er I
tcal
l
edCPUschedul
er

I
tselects pr
ocesses fr
om the I
tsel ect
sf rom among theprocesses
2 pool and loads t hem intot hatarereadytoexecut
eandal l
ocates
memoryforexecut
ion. theCPUt ooneofthem.
I
t takes many mi nut
es forItt akes(
10-100)
msf ort
akingt
henew
3 l
oadi
ngthenewpr ocess. process.

2)Pr
eempt
iveandnon-
preempt
iveschedul
i
ng?

Dr
.Qasi
m MohammedHussei
n Page4
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Non-preemptivescheduling Preempti
veschedul
ing
Whent heCPUhasbeen Schedul
ingall
owsapr ocesstobei nt
err
upt
edi
n
all
ocatedt oaprocess,the themidstofitsexecuti
on,t
akingtheCPUaway
processkeepst heCPUunt i
li
t andall
ocati
ngitt
oanotherprocess.
rel
easest heCPUei t
herby
terminati
ngorbyswi tchingto
thewai t
ingstat
e

3)CPU-
boundpr
ocessandI
/O-
boundpr
ocess

I
/Obound
Processusesmoreofit
sti
me Processisonethatspendsmoreofi
tsti
me
doingcomputat
ions. doingI/
Ot hani
tspendsdoingcomputat
ions.

4)Ti
meshar
ingsy
stem andbat
chsy
stem?

Batchsyst
em Ti
meshar i
ngsy stem
1.Theusersubmi t
sjobsinregular 1.Onli
necommuni cati
on.
scheduletooperat
or. 2.Thereisi
nter
act
ionbet weenuserand
2.Noi nt
eract
ionbetweenusersand syst
em.
systems. 3.Manyuserssimult
aneousl yusethe
3.Itusesbysingl
euserattime. syst
em.
4.Thedesignandimpl ementat
ionis 4.Desi
gnandi mpl
ement ati
onar e
simple complex

Q12:Whatar etheCPUschedul i
ngalgorit
hm cri
teri
a?
AnswerQ
Thecri
teriaincludethefollowing:
1.CPUut il
izat
ion.Keept heCPUasbusyaspossi ble.I
nar ealsystem,i
tshouldrange
from 40per cent( f
oral ightl
yloadedsy st
em)t o90per cent(foraheavil
yused
sy stem).
2.Thr oughput.Thenumberofpr ocessesthatar ecompl etedpertimeunit
.
3.Tur naroundt i
me( TAT) .Theintervalf
rom thet i
meofsubmi ssionofaprocessto
thet imeofcompl eti
on.TAT=execut i
ontime+wai t
ingt i
me.
4.Wai tingtime.Iti
st hesum oft heper i
odsspentwai t
ingi nthereadyqueue.
5.Responset i
me.I tisthet i
mei ttakestostartresponding, notthetimeitt
akesto
out puttheresponse.

Q13:
Whatar
etheadv
ant
agesof
: (
A)Agi
ngt
echni
ques (
B)RAG (
C)PCB

Dr
.Qasi
m MohammedHussei
n Page5
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

(
D)cooper
ati
ngprocesses (E)Sy
stem cal
li
nOS.
AnswerQ(
A)Advant
agesofagingtechni
ques

Agingisatechniquetosol
vethest
arv
ati
onprobl
em,
iti
ncr
easesthepriori
tyof
processesthatwaiti
nthesyst
em f
oralongt
ime. Answer(B) AdvantagesofRAG

Itshowst hepossi bi
lit
yofdeadl ockoccurs.IfRAGdoesnothav eacy cle,t
henthe
syst snoti
em i nadeadl ockedst at
e.Ift
hereisacy cl
e, t
hent hesy stem mayormaynot
beinadeadl ockedst ate.
Answer( C) Adv antagesofPCB
PCBusesast her eposi toryforanyprocessinformation.
Answer( D) Adv ant agesofcooper at
ingprocesses:
1)Inf or
mat i
onshar ing:All
owconcur r
entaccesst osamei nf ormati
on.
2)Comput ationspeedup:Br eaktaskintosubtasks, eachofwhi chwillbeexecuti
ngin
paral
lel witht heot hersthatspeedupt heexecution.
3)Modul arit
y :candi vi
dingt hesystem f
uncti
onsi ntosepar ateprocessesorthreads.
4)Conv enience: Manyt askswor katthesamet i
me.
Answer( E) Adv ant agesofsy stem call
.
System callprovidest heinterf
acebet weenar unningpr ogram andt heoperati
ngsystem.

Q14:Whatar et hedeadl ockcondi ti


ons?
Answer
1)Mut ual exclusion.Atleastoner esour cemustbehel dinanon- sharabl
emode; t
hat
i
s, onlyonepr ocessatat i
mecanuset her esource.I fanotherpr ocessrequests
thatresour ce, t
her equesti
ngpr ocessmustbedel ayedunt ilt
her esourcehasbeen
rel
eased.
2)Hol dandwai t
.Apr ocessmustbehol dingatleastoner esour ceandwai ti
ngt o
acqui readdi ti
onalresourcesthatar ecur rentl
ybei nghel dbyot herprocesses.
3)Nopr eempt ion.Resour cescannotbepr eempted; thatis,aresour cecanbe
rel
easedonl yvoluntar
il
ybyt hepr ocesshol dingit,afterthatpr ocesshascompl et
ed
i
tst ask.
1)Circularwai t.Aset{P1, •
••rPn}ofwai t
ingprocessesmustexi stsuchthatPoi s
wai t
ingf orar esourcehel dbyPI ,
PIi swai ti
ngforar esourcehel dbyP2, .
..,Pn-1i
s
wai t
ingf orar esourcehel dbyPn, andPni swaitingf orar esourceheldbyPo.

Q15:Whataret hemet hodsf orHandlingDeadlocksstates?


AnswerQ
wecandeal witht hedeadlockpr obl
em inoneoft hr
eeway s:
1)Wecanuseapr otocol t
opr eventoravoiddeadlocks.ensur
ingthatthesyst
em wil
l
neverent eradeadlockst ate.
2)Wecanal lowthesy stem toenteradeadlockst at
e,detecti
t,andrecover
.
3)Wecani gnorethepr obl
em altogetherandpretendthatdeadlocksneveroccuri
n
thesystem.

Dr
.Qasi
m MohammedHussei
n Page6
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Q16:Howcanwepreventtheoccur
renceofadeadl
ockoccurs?
AnswerQ
Byensur
ingt
hatatl
eastoneofdeadlockcondi
ti
onscannothol
d.Asf
oll
ow:

1)Mut ualExclusion:Themut ual-exclusionconditi


onmusthol dfornon-sharabl
e
resources.
2)Hol dandwai t:wemustguar anteet hat,whenev eraprocessrequestsar esource,
i
tdoesnothol danyot herresour ces.
3)NoPr eempt ion: wecanuset hef ollowingpr ot
ocol.I
fapr ocessisholdingsome
resourcesandr equest
sanot herr esourcethatcannotbei mmedi atel
yal l
ocat
edt o
i
t( t
hepr ocessmustwai t)
,thenal l r
esourcescur r
entl
ybeingheldar epreempted.
4)Circul
arWai t:Byi mposeat otalor deri
ngofal lr
esourcetypesandt or equi
rethat
eachpr ocessr equestsresourcesi nani ncreasi
ngor derofenumer ati
on.

Q17:Howcanweav oi
dingdeadl ocksoccur ?
Answer
Foravoidi
ngdeadl ocksist orequi readditi
onal inf
or mati
onabouthowr esourcesaretobe
request
ed.
Eachrequestrequiresthef oll
owi ng:
1)Ther esourcecurr entl
yav ailable.
2)Ther esourcecurr entl
yallocat edtoeachpr ocess.
3)Thef utur
er equest sandr eleasesofeachpr ocess.
Theabov einf
ormat ionisusedt odeci dewhet herthecur rentrequestcanbesat i
sfi
edor
mustwai ttoavoidapossi bl
efut uredeadl ock.
Adeadlock-avoi
danceal gor i
thm dy namicall
yexami nesther esource-
all
ocationstat
eto
ensurethatacircularwai tconditioncannev erexist.Ther esource-al
l
ocationstatei
s
defi
nedbyt henumberofav ail
abl eandal l
ocat edresourcesandt hemaxi mum demandsof
theprocesses.

Q18:Explai
nt hedeadl
ockdet ecti
on?
AnswerQ
I
fasy st
em doesnotempl oyeitheradeadlock-
prevent
ionoradeadl ockav oi
dance
al
gorit
hm thenadeadl ocksituati
onmayoccur .Thesy stem mustprovide:
1. Analgorit
hm thatexami nesthestateofthesystem todeter
mi newhethera
deadlockhasoccur r
ed.
2. Analgorit
hm torecoverf r
om thedeadlock.

Adet
ecti
onandr ecover
ywilli
ncuraconsiderabl
eoverheadi
ncomput
ati
ont
imet
hat
i
ncl
udes:
1) Runtimecostofmaintaini
ngthenecessaryi
nformati
on.
2) Executi
ngthedetect
ionalgori
thm.
3) Thepotent
iall
ossesinherenti
nrecoveryf
rom adeadlock.

Q19:Howcanr
ecov
eryf
rom deadl
ockst
ate?
Answer

Dr
.Qasi
m MohammedHussei
n Page7
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Whenadeadl ockexi sts,sev eralalt


ernati
vesar eav ailable.
1.Onepossi bil
ityist oinformt heoper atorthatadeadl ockhasoccur redandt olet
theoper atordeal witht hedeadlockmanual l
y .
2.Thesy stem r ecov ersf r
om t hedeadlockaut omat ically.Therearetwoopt i
onsf or
breakingadeadl ock.
A) ProcessTer mi nat i
on: Aborti
ngpr ocessest oel i
mi natethedeadlock.Thereare
twomet hods:
1) Ab ortall deadlockedpr ocesses.
2) Ab ortonepr ocessatat i
meunt ilthedeadl ockcy cl
eiseliminat
ed.
B) Re sour cePr eempt i
on: pr
eempt :somer esour cesf rom processesandgi vethese
resour cest oot herpr ocessesunt i
lthedeadl ockcy cl
eisbroken.threeissues
needt obeaddr essed:
1) Se lect i
ngav icti
m.Whi chresour cesandwhi chpr ocessesaretobe
preempt ed?
2) Rol lback.I fwepr eemptar esour cef rom apr ocess,whatshouldbedone
witht hatpr ocess?
3) St arvat i
on.Howdoweensur et hatst arvationwi ll
notoccur,guaranteethat
resour ceswi llnotal waysbepr eempt edf rom t hesamepr ocess?

Q20:
Choset
hesui
tabl
ewor
d(s)t
ofi
l
lthef
oll
owi
ngbl
anks?

a) Apr ogr am inexecut i


oni scal l
ed---
--
--
---
-.
(Process, Instr
uction,Pr ocedure,Functi
on).
b) Intervalbetweent het i
meofsubmi ssionandcompl eti
onoft hejobiscall
ed
( Waitingtime, Turnaroundt i
me,Throughput ,Responset i
me. )
c) Aschedul erwhi chselect sprocessesf r
om secondar ystoragedev i
ceiscall
ed(Short
term schedul er,Longt erm scheduler,Medium term scheduler,Processschedul
er).
d) In---
--
-----
--
-sev er
alprogr amsar ekepti nmai nmemor yatt hesamet ime.
(Mul t
iprocessor ,multi
pr ogrammi ng,buffer
ing,on-lineoperation)
.
e) The- -
- -
---
--
--isusedast her eposi
toryforanyinformat i
onoft heprocess. (Process
state,deadl ock,CPU, PCB) .
f) Ast atei s- -
----
---
--
--ifthesy stem canal locater esourcesf oreachpr ocessinsome
orderandst illavoidadeadl ock.
(Star vation, mut ual exclusi
on, RAG, safest ate)
g) Eachpr ocessi nasy stem hasasegmentofcode, call
ed- -
--
--
---
--
---
,i
nwhi cht he
processmaybechangi ngcommonv ari
ables, updatingat able,writ
ingaf i
le.(Cri
ti
cal
section, semaphor e, r
acecondi ti
on,segmentt able).
h) Inov erlayal locationmet hod, t
hepr ogram si zecanbe- -
----
--
--
---
-thantheamountof
memor yal l
ocat edt oi t
.( Less, equal,greater,equal orl
ess) .
i
) - -
--
--
-----
--ist hemodul ethatgi vescont r
ol oftheCPUt otheprocesssel ectedbyt he
shortt erm schedul er .( Di
spat cher,LTS, pr
ocessor ,
aging).
j
) - -
--
--
--Sy stem isusedwhent her earer i
gidtimer equi
rement sont heoper ationof
processor .(Bat ch,Ti meshar ing,Real ti
me, none) .
k) In--
----sy stem, t
hepr ocessorscommuni catewi thoneandot hert hr
oughv ar i
ous

Dr
.Qasi
m MohammedHussei
n Page8
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

communi cat ionsl ines.( Par al


lel,distr
ibuted, ov erlay,spool i
ng)
l
) I n---
--
--schedul i
ngal gor it
hm, t
hepr ocesst hatr equest stheCPUf irsti
sallocatedthe
CPUf irst.( RR, FCFS, SJF, Priority)
.
m)I nacomput er ,tost artr unning-forinst ance,wheni tispower eduporr eboot ed,i
t
needst ohav ean- -
---
----
-pr ogram t orun( Boot st r
ap, Compi l
er ,Editor,Word).
n) The- -
-----
----
--memor yi sat echni quet hatallowst heexecut i
onofpr ocessest hatmay
notbecompl etelyinmemor y.(Cache, Register ,Secondar y,Virtual)
o) In---
--
--st or agemanagement , Theuserhascont rolovertheent irememor yspace.
(Baremachi ne, Over l
ay ,Swappi ng,Fixedpar t
ition) .
p) Deadlock- ---
-----prov idesasetofmet hodsf orensur i
ngt hatatl eastoneoft he
necessar ycondi tionscannothol d.(Prevention, Av oidance, Handl ing,Recov ery)
.
q) --
--
---
--
---ref erst omechani sm thatcont roltheaccessofpr ogr amsoruser st othe
bothsy stem andr esour ces.(Secur i
ty,CPU, Pr otect i
on, I/
O).
r) In---
--
--schedul i
ngal gor it
hm, asmal lunitoft i
me, calledt i
mequant um, f
oreach
process.( RR, FCFS, SJF, Priori
ty ).
s) --
--
---
--
----ist hesum oft heper i
odsspentwai t
ingi nt her eadyqueue.( r
esponset ime,
turnaroundt ime, wai tingt i
me, execut iontime)
t) Inpagi ng, thel ogical addr essspacei sbr eakingi ntof i
xed–si zedbl ockscal l
ed---
--
--
--
-
--
--
---
.(f rame, page, segment ,register)

Dr
.Qasi
m MohammedHussei
n Page9
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

u) --
---
------
---
----Schedul ersel ectpr ocesst hepr ocesst hati sreadyqueuet oexecut e
andal locat et heCPUt oit.(LTS, STS,MTS, dispatcher )
.
v)I n------
---
----fitplacementst rat egy,Allocat ethesmal lestholet hatisbi genough.
(f i
rstf it
, bestf it
,wor stfi
t,demand)
w)Agi ngi sat echni quet ohandl e---
----
---
----
--
---
--problem.( starvation,sy nchronizat
ion,
fragment ation,segment ation)
x) Eachpr ocessi nasy stem hasasegmentofcode, cal l
ed- --
--
--
----
--
-,i
nwhi chthe
processmaybechangi ngcommonv ariables,updat ingat able, wri
tingaf i
l
e.
(Critical sect ion,semaphor e, racecondi ti
on, segmentt able).
y) Theboot strappr ogr am isst oredi n( ROM, RAM, regi ster,cache)
z) Wepr otectt he---
---
-----
--
--
---
---topr eventauserpr ogr am f rom ani nfinit
el oop.(I
/O
dev ice, memor y,CPU, demand) .
aa)Ast atei s------
---
--
--i
ft hesy st em canal l
ocat eresour cesf oreachpr ocessi nsome
orderandst illavoidadeadl ock.( starvat i
on,mut ual exclusion,RAG, safestate)
ab)Possi blesi deef fectsof --
---
-----
--
--
--deadl ocksar elowdev iceut i
li
zationand
reducedsy stem t hroughput .( Prev enting,av oidi
ng, RAG, recov eri
ng) .
ac)- ----i sasegmentofcodei nsy stem pr ocessi nwhi cht hepr ocess
maybechangi
ngcommonv ari
abl
es,updati
ngatabl
e,wr
it
ingaf
il
e,
andsoon.
(
semaphor
e,Cr
it
ical
sect
ion,
Racecondit
ion,PCB)
ad)-----i
sthesum oft
heper
iodsspentwait
ingi
nther
eadyqueue.(
responset
ime,
tur
naroundt
ime,wai
ti
ngti
me, execut
iont
ime

AnswerQ20

(
a)Process (b)t urnaroundti
me (c)longt erm schedul
er
(d)Mult
iprogramming (e)PCB (f
)saf est at
e
(g)Cri
ti
calsecti
on (
h)gr eaterthan (i)dispatch
(j
)Real ti
me (
k)distributed (l)FIFO
(m)Boot str
ap (
n)v i
rtual (
o)bar emachi ne
(p)Preventi
on (
q)pr otecti
on. (
r)RR
(s)Wai t
ingtime (
t)page (
u)STS
(v)best-fit (w)st arvati
on (
x)cr i
tical
section (y)ROM (z)CPU (
aa)safe
state.
(bb)preventi
ng (cc)cr i
ti
calsect
ion (
dd)wai ti
ngtime.

Pr
ocessschedul
i
ngexampl
es

Q21:Fi
ndt
heav
eragewait
ingtimeandaveraget
urnaroundtimeforexecuti
ngt
he
f
oll
owi
ngpr
ocessesusingFCFS(f
ir
st-
comefirst
-servi
ce)schedul
ing?

Pr
ocess Bur
stt
ime

Dr
.Qasi
m MohammedHussei
n Page10
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

P0 7
P1 5
P2 2
P3 9
AnswerQ21
Thefir
stst
epoft
hesol
uti
oni
sfoundi
ngt
heGant
tchar
t.

Thewai
ti
ngti
meofP0=0
Thewai
ti
ngti
meofP1=7
Thewai
ti
ngti
meofP2=12
Thewai
ti
ngti
meofP3=14
Theav
eragewai
ti
ngt
ime=(
0+7+12+14)/
4=33/
4=8.
25

Thetur
naroundtimeofp0=7
Thetur
naroundtimeofp1=12
Thetur
naroundtimeofp2=14
Thetur
naroundtimeofp3=23
Theaveragetur
naroundt
ime=(7+12+14+23)
/4= 56/
4=14

Q22:Findt
heaveragewai
ti
ngti
me(A.W.T)andav
eragetur
naroundt
ime(A.
T.A.T)f
or
execut
ingt
hefoll
owingpr
ocessusi
ng(1)Pr
eempti
veshort
-j
obfir
st(
2)Non-
preemptiv
e
short
-j
obfi
rst
?

Pr
ocess P1 P2 P3 P4 P5
Bur
stt
ime 5 13 8 4 10
Ar
ri
val
time 2 3 0 5 1
Answer

(
1)Usi
ngpreempt
iveshor
t-
jobf
ir
st
Gant
tchart

P3 P1 P4 P3 P5 P2
0 2 7 11 17 27 40

W.
T.ofp1=2-
2=0 T.
A.T.ofP1=7–2=5
W.
T.ofp2=27–3=24 T.
A.T.ofP2=40–3=37
W.
T.ofp3=0+(
11-
2)=9 T.
A.T.ofP3=17–0=17

Dr
.Qasi
m MohammedHussei
n Page11
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

W.
T.ofp4=7–5=2 T.
A.T.ofP4=11–5=6
W.
T.ofp5=17–1=16 T.
A.T.ofP5=27-
1=26

A.
W.T.=(0+24+9+2+16)
/5=51/
5=10.2
A.
T.A.
T=(5+37+17+6+26)/
5=91/5=18.
2

2)Usi
ngnon-pr
eempt
iveshor
t-
jobf
ir
st

Gant
tchar
t

P3 P4 P1 P5 P2
0 8 12 17 27 40

W.
T.ofp1=12-
2=10 T.
A.T.ofP1=17–2=15
W.
T.ofp2=27–3=24 T.
A.T.ofP2=40–3=37
W.
T.ofp3=0 T.
A.T.ofP3=8–0=8
W.
T.ofp4=8–5=3 T.
A.T.ofP4=12–5=7
W.
T.ofp5=17–1=16 T.
A.T.ofP5=27-
1=26

A.
W.T.=(10+24+0+3+16)
/5=53/
5=10.
6
A.
T.A.
T=(15+37+8+7+26)
/5=93/
5=18.
6

Q23:Fi
ndtheaveragewaiti
ngti
meandtur
nar
oundt
imef
orexecut
ingt
hef
oll
owi
ng
pr
ocessusingpri
ori
tyschedul
i
ngal
gori
thm?
Pr
ocess P1 P2 P3 P4 P5
Bur
stt
ime 5 13 8 6 12
Pr
ior
it
y 1 3 0 4 2

Answer

Gant
tchar
t
P3 P1 P5 P2 P4
0 8 13 25 38 44
W.
T.ofp1=8 T.
A.T.ofP1=13

Dr
.Qasi
m MohammedHussei
n Page12
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

W.
T.ofp2=25 T.
A.T.ofP2=38
W.
T.ofp3=0 T.
A.T.ofP3=8
W.
T.ofp4=38 T.
A.T.ofP4=44
W.
T.ofp5=13 T.
A.T.ofP5=25

A.
W.T.=(
8+25+0+38+13)
/5=84/
5=16.
8
A.
T.A.
T=(
13+38+8+44+25)
/5=128/
5=25.
6

Q24:Fi
ndt heav
eragewait
ingti
me( A.
W.T.)andtheaveraget
urnar
oundti
me(A.
T.A.
T.)
f
orexecut
ingthefol
lowi
ngprocessesusi
ngr ound-
robi
nalgor
it
hm,wheret
imequant
um
i
s5?

Pr
ocess P1 P2 P3 P4 P5

Bur
stt
ime 11 4 14 9 21

Ar
ri
val
time 5 0 0 1 2

Answer

P2=4 0
P3=14 94 0
P4=9 4 0
P5=21 16 11 6 1 0
P1=11 6 1 0

Gant
tchar
t
P2 P3 P4 P5 P1 P3 P4 P5 P1 P3 P5 P1 P5 P5
0 4 9 14 19 24 29 33 38 43 47 52 53 58 59

W.
T.ofP1=(19- 5)
+(38-
24)+(52-
43)=14+14+9=37
W.
T.ofP2=0
W.
T.ofP3=(4-0)+( 24-
9)+( 43-
29)=4+15+14=33
W.T.ofP4=(9-1)+(29-14)=8+15=23
W.T.ofP5=(14-2)+(33-19)+(47-
38)+(
53-
52)=12+14+9+1=36
A.
W. T.=(
37+0+33+23+36)/ 5=129/5=25.8

T.
A.TofP1=(
53-5)
=48
T.
A.TofP2=(4-
0)=4

Dr
.Qasi
m MohammedHussei
n Page13
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

T.
A.TofP3=(
47–0)=47
T.
A.TofP4=(
33-
1)=32
T.
A.TofP5=(
59-
2)=57
A.
T.A.
T.=(
48+4+47+32+57)/
5=188/
5=37.
6

Q25:Consi deramul ti
lev elfeedbackqueueschedul i
ng(MLFBQ)wi t
ht hreequeuesq1,
q2,andq3.q1andq2user ound-robinalgorit
hm wi t
ht i
mequantum ( TQ)=5,and4
respectivel
y.q3usef i
r st-
comef i
rst-ser
vicealgorit
hm.Fi ndtheaveragewai t
ingti
me
(A.W.T)andav er
aget urnar oundtime( A.T.A.T)forexecut
ingt
hefoll
owingpr ocess?
Processes P1 P2 P3 P4
Burstti
me 8 22 4 12
Answer
I
nMLFBQschedul i
ngal gorithm,thepr ocessmov ebetweenqueues.Ifapr ocessuses
toomuchCPUt i
me, i
twi llbemov edt oal ower -
pri
ori
tyqueue.

q1 q2 q3
P1: 8 3 -
P2:22 17 13 P4,
P3,
P2,
P1
q1
P4,
P2,
P1
P3:4 - - q2

P4:
12 7 3
P4,
P2

q3

Gant
tchar
t

P1 P2 P3 P4 P1 P2 P4 P2 P4
1 5 10 14 19 22 26 30
43 46

W.
T.ofp1=0+(
19-
5)=14 T.
A.T.ofP1=22
W.
T.ofp2=5+(
22-
10)+(
30-
26)=5+12+4=21 T.
A.T.ofP2=43
W.
T.ofp3=10 T.
A.T.ofP3=14
W.
T.ofp4=14+(
26-
19)+(
43-
30)=14+7+13=34 T.
A.T.ofP4=46

Dr
.Qasi
m MohammedHussei
n Page14
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

A.
W.T.=(
14+21+10+34)
/4=79/
4=19.
75
A.
T.A.
T=(
22+43+14+46)=125/
4=31.
25

Deadlockexamples
Q26:Supposewehavetworesour
ces, A,andB.Ahas6i nst
ancesandBhas3 i
nst
ances.Can
thesyst
em execut
ethef
oll
owingprocesseswi t
houtdeadl
ockoccurr
ing?

Al
locat
e Maxi
mum need
Pr
ocess A B A B
P1 1 1 2 2
P2 1 0 4 2
P3 1 0 3 2
P4 0 1 1 1
P5 2 1 6 3

Answer

Need
Pr
ocess A B
Av
ail
abl
e:A=1;
B=0 P1 1 1
P2 3 2
P3 2 2
P4 1 0
2 0 11 22 3 2
P5 4 2
01 11 10 1 0
P4 P1 P3 P2 P5
1 1 2 2 3 2 4 2
Wecanexecut
ethepr
ocessesi
nthesequence<P4,P1,
P3,
P2,
P5>wi
thoutdeadl
ock.

Q27:
Consi
derwehav
efi
vepr
ocessesP0,
P1,
...P5andt
hreer
esour
cesA,
B,andC.I
sthe

Dr
.Qasi
m MohammedHussei
n Page15
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Answer
Wef i
ndther
esourcest
hatneedf
oreachpr
ocess
Process Need
P0 1 0 2
P1 0 1 0
P2 0 3 2
P3 1 0 0
P4 1 2 1
P5 0 5 1

110 110 12 1 122 242


200 011 00 1 120 111
110 121 12 2 24 2 353
P1 p3 p4 p0 p2 p5

Thepr
ocessi
nsaf
est
atei
ftheyar
eexecut
edi
nthesequence<P1,
P3,
P4,
P0,
P2,
P5>

Q28:
Supposewehav
efi
vepr
ocessesandt
hreer
esour
ces,
A,B,
andC.Ahas2i
nst
ances,
B
has5instancesandChas4i nst
ances.Canthesyst
em execut
ethef
oll
owi
ngpr
ocesses
wit
houtdeadlockoccur
ri
ng,
wherewehav ethefol
l
owing?

Maxi
mum need Al
l
ocati
on
Pr
ocess A B C A B C
P1 1 2 3 0 1 1
P2 2 2 0 0 1 0
P3 0 1 1 0 0 1
P4 3 5 3 1 2 1
P5 1 1 2 1 0 1

Answer
Theavail
abl
eisA=0,
B=1,
C=0.
Thecur
rentneedi
s

Cur
rentneed

Dr
.Qasi
m MohammedHussei
n Page16
Oper
ati
ngSy
stem Quest
ionsandt
hei
ranswer
s

Pr
ocess A B C
P1 1 1 2
P2 2 1 0
P3 0 1 0
P4 2 3 2
P5 0 1 1

010 011 112


001 101 011
P3 P5 P1 ?
011 112 123

Thedeadl
ocki
soccur
redsi
ncet
heav
ail
abl
eresour
cesi
slesst
hant
heneedsofP2and
P4.

Ref
erence
Operat
ingsy
stem concept
s
By:Abr
aham Si
lber
schatz,
Pet
erBaerGal
vi
n,Gr
egGang

Dr
.Qasi
m MohammedHussei
n Page17

You might also like