SCSR2043 Operating Systems
T es t 2 | 1
SECTION A TRUE & FALSE QUESTIONS (10 MARKS)
(INSTRUCTION : Write your answer either TRUE (T) or FALSE (F) based on the o!!owing statements"#
$" % thread thread a!so a!so &nown as a !ight'we !ight'weight ight proess proess an be deined deined as the the sma!!est sma!!est unit o e)eution whih an be shedu!ed and e)euted 2" *t ta&es ta&es ar !ess time time to reate reate a new proess proess than than to reate reate a new new thread" thread"
7
T
8
7
5
8
3" +ro +roes esss that that ee eett or be ae aet ted ed by the the e)eu e)euti tion on o anot anothe herr proe proess ss is a!!ed an independent proess"
7
5
8
4" Rae Rae ondit onditio ion n ou ours rs when on!y on!y one one pro proes esss try try to aess aess the g!oba! g!oba! ,ariab!es"
7
5
8
7
T
8
7
5
8
7
T
8
7
T
8
-" *n onu onurr rren entt proe proess ssin ing g syst system ems. s. set set o inst instru rut tio ion n were were e)eu e)eute ted d in se/uene" " Semaphore Semaphore (S# is is an integer integer ,ariab!e ,ariab!e that that is aessed aessed on!y through through stop(# stop(# and and signa!(#" 1" Test Test and Set is is a hardware hardware support support mehanism mehanism to to perorm perorm synhroniati synhroniation on in OS" " *n order order to ontro! ontro! aess aess to shared shared resour resoures. es. semaph semaphore ore an be used or mutua! e)!usion imp!ementation" " *n Round Robin Robin shedu!in shedu!ing g i the time time /uantum is ,ery !arge !arge the the shedu!ing shedu!ing is the same as Shortest Remaining Time 5irst (SRT5#" (SRT5#" $0" Shortest 6ob 5irst (S65# shedu!ing a!gorithm ou!d resu!t an aging"
7
5
8
7
T 8
SECTION B
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 2
STRUCTURED QUESTIONS (50 MARKS)
(INSTRUCTION : +!ease answer a!! /uestions in the spae pro,ided#
QUESTION 1 7 ar&s8
a# Whih o the o!!owings are shared aross threads in a mu!tithreading proess; Ti& in the appropriate bo)es or your answer"
72
mar&s8
Component +rogram Counter %ddress Spae
S!"#e$
Not S!"#e$ 9
9 9
b# =isuss TWO (2# beneits o using threads"
9 74
ar&s8
QUESTION 2 7 $1 ar&s8
a# Why do we need shedu!ing in operating system;
7$
ar&s8
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | %
b# Consider the o!!owing set o proesses in Tab!e $. with the !ength o the C+>'burst9y!e9time gi,en in mi!!iseonds and the priority" T"'e 1 #oe
A##*+"' T*me
CU C,'e
#*o#*t,
A
0
-
3
B
2
4
4
C
3
2
D
4
$
i"=raw a time!ine hart to i!!ustrate the e)eution o the abo,e proesses using #*o#*t, !e$-'*n. (p#eempt*+e) (sma!!er number imp!ies higher priority#"
73 ar&s8
%?=C 0 - $3 $
ii"
Comp!ete Tab!e 2 or the #*o#*t, !e$-'*n. " Show your a!u!ation"
74
ar&s8 T"'e 2 #oe % B C D
/"*t*n. T*me
T-#n"#o-n$ T*me
%,erage Waiting Time (%WT#:
4 %,erage Turnaround Time (%TT#:"1-
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 |
iii"
=raw a time!ine hart to i!!ustrate the e)eution o the abo,e proesses using S!o#tet 73
Rem"*n*n. T*me (SRT)
ar&s8
i,"
Comp!ete Tab!e )) or the S!o#tet Rem"*n*n. T*me (SRT) shedu!ing" Show your a!u!ation"
74
ar&s8 T"'e % #oe A B C D
/"*t*n. T*me
T-#n"#o-n$ T*me
%,erage Waiting Time (%WT#:
%,erage Turnaround Time (%TT#:
,"
Compare and ana!yse the resu!ts between the abo,e shedu!ing"
72
ar&s8
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 5
QUESTION 2 7$3 ar&s8
a# Regarding the +roduer'Consumer prob!em. state the untion:
72
mar&s8 i"
+roduer proess +rodue inormation
ii"
Consumer proess Consume inormation
iii"
>nbounded' buer >n!imited buer sie
i,"
?ounded buer 5i)ed buer sie
# The buer an be in three states" =raw the buer states"
73 ar&s8
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 |
d# +eterson@s %!gorithm: Ai,en a ode or +roess 0 and +roess $ in Tab!e 4" 5i!! in !ags and turn ,ariab!es i +roess $ initiates the re/uest to enter the ritia! setion"
74 ar&s8
T"'e #oe 0
#oe 1
do B
do B
3'".40 TR>DE t-#n $E whi!e (3'".41 FF t-#n $# E 9G do nothing G9 ritia! setion 3'".40 5%HSDE remainder setion I whi!e (TR>D#E
3'".41 TR>DE t-#n 0E whi!e (3'".40 FF t-#n 0# E 9G do nothing G9 ritia! setion 3'".41 5%HSDE remainder setion I whi!e (TR>D#E
T"'e 5 t*m e
3'".40
3'".41
T-#n
t
FALSE
TR>D
0
0
E+ent
+ re/uest to enter CS $
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 6
t t t t t t
$ 2 3 4
t t
1
5%HSD
TR>D
0
+ enters CS $
TRUE
TR>D
$
+ re/uests to enter CS 0
TR>D
FALSE
$
+ e)eutes RS $
TR>D
5%HSD
$
+ enters CS 0
TR>D
5%HSD
$
+ e)eutes RS $
FALSE
5%HSD
$
+ e)eutes RS 0
5%HSD
5%HSD
$
+ e)eutes RS $
TRUE
5%HSD
$
+ re/uests to enter CS 0
e# 6ustiy your answer by showing: i# utua! e)!usion is preser,ed
7$ mar&s8
ii# The +rogress re/uirement is satisied
7$ mar&s8
iii) The bounded'waiting re/uirement is met
7$ mar&s8
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 7
QUESTION 7$ ar&s8
a# Tab!e shows the imp!ementation o +roduer and Consumer using Semaphore" Comp!ete the g!oba! ,ariab!e ,a!ues in Tab!e ))
*
In*t*"' +"'-e
N = 5 (size of buer) mutex =1 empty = 1 full = 0/4
#o$-e#
do { produce an item … ait(empty)! ait(mutex)! … add item to buer … si"nal(mutex)! si"nal(full)!
7 mar&s8 Con-me#
do { … ait(full)! ait(mutex)! …'' remoe an item from buer …' si"nal(mutex)! si"nal(empty)! } while (#$%&)!
} while (#$%&)! T"'e 6 #o$-e#
ait( ) empty mutex full
0 0
Con-me#
si"nal( ) $ $
ait( ) empty mutex full
0 0
si"nal( ) $ $
i# * the initia! ,a!ue o empty is 0. what happen on the +roduer side; D)p!ain" 72 ar&s8 +roduer annot enter the ritia! setion due to semaphore empty J0" wait ( # is not perorm"
ii# Sha!! Consumer onsumes the tas& i empty is 0; D)p!ain" When empty 0 means onsumer an proeed beause the buer is u!!9i!!ed"
72 ar&s8
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 8
b# ?ased on the o!!owing se/uene o statements or e)euting the three proesses. state the output or Tab!e to $$" %ssume that a!! !ags are initia!ied to 0"
74 ar&s8
T"'e 7 P0
wa i t ( B_fl a g) pr i nt f ( “ B“ ) ; s i gnal ( C_fl ag)
P1
pr i nt f ( “ A“ ) s i gna l ( B_fl ag)
P2
wa i t ( C_ fl ag ) pr i nt f ( “ C“ )
Output : % ? C T"'e 8 P0
P1
P2
wa i t ( C_ fl ag ) pr i nt f ( “ B“ ) ;
pr i nt f ( “ A“ )
s i g na l ( C_ fl ag )
s i g na l ( B_ fl ag )
pr i nt f ( “ C“ )
Output : ?C%9%?C9?%C T"'e 10 P0
P1
wai t ( B_flag)
wai t ( A_flag)
pr i nt f ( “ B“ ) ;
pr i nt f ( “ A“ )
s i gnal ( A_fl ag)
P2
pr i nt f ( “ C“ ) s i gnal ( B_fl ag)
Output : C?% T"'e 11 P0
wa i t ( B_fl a g) pr i nt f ( “ B“ ) ; wa i t ( C_ fl ag)
P1
pr i nt f ( “ A“ ) s i gna l ( B_fl ag)
P2
pr i nt f ( “ C“ ) s i gnal ( C_fl ag)
Output : %?C9C%?9%C?
20$3920$4'2
SCSR2043 Operating Systems
T es t 2 | 10
''''''''''''''''''''''''''''''''''''''''''''''''Dnd o Kuestion '''''''''''''''''''''''''''''''''''''''''''''''''
20$3920$4'2