Operating Systems - CS604 Power Point Slides Lecture 18
Transcript of Operating Systems - CS604 Power Point Slides Lecture 18
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
1/30
perating
Systems
Lecture 18
Syed Mansoor Sarwar
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
2/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Agenda for Today
&e"iew o# pre"ious ecture
!'() Syste* V scheduing
+gorith* e"auation
$rocess synchroniation
&ecap o# ecture
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
3/30
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
4/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
"ery second, the priority nu*/er o# a
those processes that are in the *ain
*e*ory and ready to run is updated /yusing the #oowing #or*ua
Priority# = (RecentCPU Usage)/2 + Thr. Pri.+ nice
hreshod priority and nice "aues areaways positi"e to pre"ent a user #ro*
*igrating out o# its assigned group
UNIX System
Sc!edu"ing A"gorit!m
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
5/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
i*e
0
1
2
3
4
5
$riority
60
75
67
63
76
68
C$!Count
0160
30
30
1
!"6!33
16
$+
$riority
60
60
75
67
63
76
C$!Count
0
0
1
60
30
30
1
!"6!
33
$
$riority
60
60
60
75
67
63
C$!Count
0
0
01
60
30
30
1
!
$C
UNIX System #$amp"e
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
6/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Round Ro%in Sc!edu"ing
and &rocess &riorities
+
7ig
her$riority
60
+
+
+
+ + runs #irst
1
4
2 3
5 6
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
7/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
A"gorit!m #va"uation
+naytic "auationhe agorith* and so*e syste*
wor%oad are used to produce a
#or*ua or nu*/er which gi"es theper#or*ance o# the agorith* #or that
wor%oad
9eter*inistic *odeing
:ueuing *odes
(*pe*entation
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
8/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
'eterministic (ode"ing
$redeter*ined wor%oad andper#or*ance o# each agorith* #or
that wor%oad !se o# ;antt charts
Si*pe and #ast
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
9/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
$rocess +rri"a i*e urst i*eP
1 00 7
P2
20 4
P3 40 1
P4
50 4
;antt chart
+"erage waiting ti*e = >? @ 1 @ 0 @2AB4 = 3
P3
P2
42 110
P4
5 7
P2
P1
16
P1
'eterministic (ode"ing
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
10/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
)ueuing (ode"ing
Co*puter syste* "iewed as anetwor% o# .ueues and ser"ersready .ueue, (B .ueue, e"ent
.ueues, C$!s, (B de"icecontroers, etc
n$%t&+rri"a and ser"ice rates
'%t$%t&C$! utiiation, a"erage
.ueue ength, a"erage
waiting ti*e, D
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
11/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
)ueuing (ode"ing
itte*s or,%an = EF G
wheren= a"erage .ueue ength
-= a"erage arri"a rate
= a"erage waiting ti*e in a
.ueue
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
12/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
)ueuing (ode"ing
Let the a"erage Ho/ arri"a rate /e 05+gorith* +"erage Gait
i*e
G=tw
+"erage :ueueLength>nA
ICIS 46 23
SJI 36 18
S&I 32 16
&& >.=1A 70 35
&& >.=4A 60 30
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
13/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
)ueuing (ode"ing
Co*picated *athe*atics9istri/utions >$oisson, uni#or*,
e
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
14/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Simu"ation
$rogra**ing *ode #or theco*puter syste*
Gor%oad generated /yassu*ing so*e distri/ution and
a rando* nu*/er generator, or
/y coecting data #ro* the
actua syste*
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
15/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Simu"ation
Characteristics
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
16/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Simu"ation
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
17/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Imp"ementation
est
Most e
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
18/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
&rocess
Sync!roni*ationConcurrent access to shared
data *ay resut in data
inconsistencyMaintaining data consistency
re.uires *echanis*s to ensurethat cooperating processesaccess shared data
se.uentiay
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
19/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
+ounded,+uffer &ro%"em
hare atade#ine !II&KS( 10
typede# struct
N ite*O
ite* /u##erP!II&KS(QOint in= 0, o%t= 0O
int co%nter= 0O
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
20/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Pro%cer $rocessite* ne1A whie >counter == !II&KS(A O
/u##erPinQ = nein @ 1A R !II&KS(O
counter@@ON
+ounded,+uffer &ro%"em
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
21/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
ite* ne1A
whie >counter == 0A O
neout @ 1A R !II&KS(O counter--O
N
+ounded,+uffer &ro%"em
Cons%,er $rocess
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
22/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
counter++T in asse*/y anguage
' R1 co%nter
4C R1
' co%nter R1
counter--T in asse*/y anguage' R2 co%nter
5C R2
+ounded,+uffer &ro%"em
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
23/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
(# /oth the producer and consu*eratte*pt to update the /u##er
concurrenty, the *achine anguage
state*ents *ay get interea"ed
(nterea"ing depends upon how the
producer and consu*er processes
are schedued
+ounded,+uffer &ro%"em
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
24/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
7ss%,e counteris initiay . 'neinterea8ing o9 state,ents is&
$ro%cer& ' R1 co%nter (R1 = ) 4C R1 (R1 = 6)cons%,er& ' R2 co%nter (R2 = ) 5C R2 (R2 = :)$ro%cer& ' co%nter R1 (co%nter = 6)
cons%,er&' co%nter R2 (co%nter = :)
The 8a%e o9 co%nt ,ay ;e either : or 6
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
25/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Race Conition he situation
where se"era processes access
and *anipuate shared data
concurrenty, the #ina "aue o# the
data depends on which process#inishes ast
&rocess
Sync!roni*ation
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
26/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Critica ection + piece o# code
in a cooperating process in which
the process *ay updates shareddata >"aria/e, #ie, data/ase, etcA
Critica ection Pro;e,Seriaie e
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
27/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
o9t
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
28/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
o >
critica section
re,iner section
?
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
29/30
January 27, 2016 Copyright Virtua !ni"ersity o# $a%istan
Recap of Lecture
!'() Syste* V scheduing
+gorith* e"auation
$rocess synchroniation
&ecap o# ecture
-
7/25/2019 Operating Systems - CS604 Power Point Slides Lecture 18
30/30
perating
Systems
Lecture 18
Syed Mansoor Sarwar