A multithreaded web server uses a cache to avoid disk reads for frequently accessed pages. When a request is received, a worker thread first checks the cache and will perform a disk read only if the page is not found in the cache. Kernel-level threads should be used instead of user-level threads to allow preemption for better response times under heavy loads.
1. Lu J-J Tai ftcrf]-
sEMESTER rEsr )t*A br,, rqu $'t'
--f|J*'r lruttrttr
---T--i^/lclntL'store Itl
Ql.A multithreaded web server Uses'a cache to frequently acce s so as to avoid
fetching these pages from the disk. Whenever a request for a web page is received, a worker
thread will first check the cache. A disk read u,ill only be performed if the page is not in the
cache. You have been told that u5gllqv€Llhrygls are being used for the worker threads. Should
kernelJevel threads be used instead? Justi r answer. marks
,J.r, t mr[,-uql hvit{frftUrt C NaU0rk Qruk envt'rrfqq${) th^f r6{/iftl tld (grS**J,zpr
lflt6s
frrrntt -c*t 4rrtntr dbu$ bc d,Oofc', (r"-r t: L,wn in 0kvtfC;rrjanlt'rrdr. +l.Uko*
I1.r {lmalr q(( b W+e; 6 U,tatclci-$t f
NArl c{ prnat w{r-t19".
.
"l:1*..i::" kunal U t
oruS4d ti'i-iil,^'rX *f"":SBOtq,
inl r.rn r.r' /rr. <M
1@nr2!"trn,t ./"g,/{h,uf
thttak
^,hr^ (/ , '., r--.
er rrrl 1 vtw/ n kLT 'trgtrJ
6-1
nhch rr l5tattl as str'40 lbtair "u.dl L trrk'{{qry} ./
'lg uA^ tnOJt t'^d.Vridtbf trrshF o4rtn oAQ, {r"edis Li.zhrl h l/a eua+
Q2. You have been asked to look into an apprppriate CPU scheciuling policy fcr a new multipurpose operating
system. The system is to cater for interhctivq use in envinrnments with users comprising of different
categories such as prosamm rs, system administrators, end*users aud etc. You have decided to
implement rfon-pree-frFtive priority--F6liFt with system tasks given higher priority. l{owever, your
colleague believes that Multi-level Feedback Queue (MLFQ) policy is
Highlight TWO (2) features of MLFQ. In additigrrQvaluate the aS
preempti ve-pffi riffi c fiE-"-- when- cofr pared with /fut LBQ, w' th rcga rd
>r-
i
qervlce -. r
torl,r it L.r5
' *d' ttodg
l.[.ff'a ol t{Lt(J'
$n{',strh{ot J^'[!'ct"{ schdJ(Y
^f,od$t7
{ iE t"ol] 1'1ar[t( dhrn ff, l'<erjcr
- d
.6.q b( Cd,{q1ai z.l
(fil prrcn 16r. te mgraftl raunl qtrco(t , {hir 6erlJ
/*r'*rnl 0.,
v icc etitriVt 1*vt^l
6{Y {r ca' trocer!. tt E fnlilrI lnry trtrr L/ri' ,9
ly i"{rlt""'og t'h'd
iit i ortl krr.trnrt t c" N$d,l {o o ffo -le,cl qeu (- Q I -frYr.( I "Stnl
ndva^t^qe; n**1* yti*! lrr(tlt, 4[ (iNq prt0/
^[ .[r] (, oqI
uvi'{rul k*J T,n
a+cd
, *i> ro.l ltcrtfutt
roq'-t
uhttut, tr tr!,rcr cK hLtd wrll L,r
lnoo$tl c,nl itr
{..tft l.t,r{ht 4rr {lnr Sqril.
lrLpQ
lk Jqwfa,lpxs( Mn-filfttf {it,t fonS Trt/tr crulu"rI , s{srqa'{il Ca,lJ ot -[
lo*r lrirrrg fftfir t.o-( 6 crrc,{t roq'Qa ta ,5V fcori
W{rJ r
^$ lbt I'c^D Ir,tr
hgtr-
o1iot1 rht r'0. trwtl1 lFat(tlt
2. AACS5214 COMPUTER OPER]TTING SYSTEMS 2O1Oi2O11
Q3. A real-time system has 3 periodic tasks as shown in the table below:
I'ir 'i
at
Can each of the policies below pro{qce a feasible schedule? Justif, your answers with Gantt
charts s howin g thi sch edu le between (fl and/O?f .
r Rate-Monotonic schedvling (RMS)
o Earliest-Deadline-First scheduling (EDF) (8 marks)
Rate-Monotonic schgdullne
F,, otl uoo$t{tt i0 fnS 1
,f,
55 )Y tr 5s h5 '+5
0,r rr) hrC{9 Cr>tFc) tr,,Cro) Arr ( {01
t, Arr[(o)
Arrtus) $,,(L!) br, f Lo) Brr ( 6o)
Bnc 60> cs (-Ir) [rr [+s)
&"t['ut ,
LDr rs
q. ..n,ttU
3. jr
AACS5214 COMPUTER OPERATING SYSTEMS 2010/2011
Q4. Consider a solution to the prgduqer-copsuqrer problem with the use of semaphores as given
below. The variabl.g, semapho..r. ,(- *,
Q9*49are [nh.(
Producer Consumer
do{ do{
// produce an item wait (full);
wait (empty); wait (mutex);
wait (mutex); // remove an item from buffer
// insert item into a buffer of size N signal (rnutex);
signal (mutex); signal (empty);
qignal (full); // consume item
while (TRUE); while (TRUE):
(i) What should be the initial value of the empty semaphore? Explain the purpose of the S G
(empty) statement in thez.Producer process-jupport your answer by explaining the funciffi
of the wait ogeration)N{th the use of pseudocode. (6 marks)
Initial value of e
S, g,r{ ffilp$) 01{n&er lwtur rt fo, l^td u"tt'k
h{tr u {'tt or MI, t[. it FfU -fl.(,i,ra0l ol
is il r gnrr^ dl.t 4t'1e&ctr' Ptc tl'ug ffc) , l.l},od{
h .&dct U 1ff-,S,,utstr'1. c^r{i ${ hr
frn 1'l-uu't!,r,,tr q.f l*J
nt {lo v6p( z o . -{fitr{ie ytodttr {aa
0[[
'<O - nl br{dhr PloolJ
ntllo ltll
',rto
{il rlrcnff
ii) What shou the initial
signal (full) statement i
operation.
lnitial value of full: o
{f, nl [t rs oruknw,/ fi $ru
trrti,n{ untr er3nat CE ){
$ilbat C+tt1, { utur
"it L" irrrtrrvl tJ t l all cltrb vat* ++;
rtltnl{T'#*id*U rlCvarue < p)t
N+rn r{ i( lur a^2,2o, i I tgl, Yt.arl c ltrc{lr
!1, rl.r{ OttnvT(rucor, tllft-{ [fi(t) m $v,{ {tt cy$
lfoerf it ef {, ftwv(. +It i*c. yte lxV !
,FD
d/dc ft"urr'
{tY su( l&19 15 J,O{ {t"af Nt ifou hnr lW {o
{[ l',r[k,"
4. a
AACS5214 COMPUTER OPERr{TING SYSTEMS 2010/2011
(iii) Evaluate the use of semaphores to solve the producer-consumer problem. (5 marks)
t:$",*r ^r,ft
lr,,,t-hl.__rtr--ll'ryT" +tt k40','
fr t*y
6{qr tuiro. ,/l
(r t[ wo^'{Cwirttl --wni(["r{c{u t.Y nrrrt$(, {x vtlr o[ snapt/u,fr k''p "lt
dtccCrli [J ,on{i( qq/^{',f, VSk , alr $t Cur.hAtr /pr'rd,,^' 7*"t1-/t
tl[ L' Llc''l't[ ',, d e
@ uLut/ 4o ca{icat FCC{N^
(ivil dtrurrmo{cr; - 1$Cr.r{"/*t*.* be errya,1tl flr:r ordt,-, +.'{ vltut ot
-in
wt( f."crrost tn^j ]r,t4^ fnr(wsNai,r, lhc,{
#/
snenu / 1'r"1,cr1 wt(l q [ 'q(
+k lu.Pl, a{ il( 0fcar.
fesources A, B and The total
system is
depicted in the tables belowl
Maximum A,llocation 3)-t,
A B C ,{ B C
P1 2 I I I I 0 lbl 7e 7.
P2 3 2 3 0 I D' 51tr-
?.) P3
P4
2 I
I
0
2
,
0
0
0
0
0
2
11c
t atr o ro (),9 2-
P5 2 I 0 zr//
alo
By using Banker's algorithm, determine whether a request from F2 fcr can be granted
immediatelv. Give a detailed ion on how you reach this conclusion. 6 marks
{ ltoCAtln fIU+1"1", NsrC ry$s
ABC *ac Af3 c
Yt t t o 5 0
r- o tl 3:: 3)
lt. 0 oo f,t0 ) 0
[.{ 0g)t) o/'
PE D'a J 5 ) oh
-_- (/
5 2g
wr (tu{1 lelnrft 6 rd{ut^fU
1a,,L
tN(rlJ
{tnAo l6h rtat tof-{ tt tut lnt {,
I) ftllct{r, ao: ir) drtqct l: , -[o 4vrrt hql
kFordd n^
r 1J d,l -{o
'tk, +lt(
d^S PN/r6,