Homework 2 –  Process Management and CPU Scheduling

advertisement
Homework 2 – Process Management and CPU Scheduling
COP 4610/CGS5765, Introduction to Operating Systems, Fall 2003, Florida State University

Points: 100 points
Due: Week 7, Tuesday, October 7, 2003
1. (10 pnts) Problem 5 in the textbook on page 229.
a.
b.
c.
d.
e.
f.
User name – process
Stack bottom – thread
Resources blocking me – thread
Primary memory allocated to me – process
Files allocated to me – process
Execution state – thread
2. (15 pnts) Problem 7 in the textbook on page 230.
request
done
request
Running
interrupt
Blocked
For Interrupt
preempt
request
schedule/dispatch
request
allocate
Blocked
forReuseable
Ready
allocate
Blocked for
Consumable
3. (15 pnts) Problem 4 in the textbook on page 281.
a. Gantt chart
0
10
p2
30
p1
50
p3
100
p4
b. Turnaround time for p4 = 100
c. Average wait time
W(p_0) = 100
W(p_1) = 10
W(p_2) = 0
180
p0
W(p_3) = 30
W(p_4) = 50
Average = (100+10+0+30+50)/5 = 38
4. (15 pnts) Problem 5 in the textbook on page 281.
a. Gantt chart
0
20
70
p1
p4
p0
150 160 180
p2 p3
b. Turnaround time for p2 = 160
c. Average wait time
W(p_0) = 70
W(p_1) = 0
W(p_2) = 150
W(p_3) = 160
W(p_4) = 20
Average = (70+0+150+160+20)/5 = 80
5. (15 pnts) Problem 7 in the textbook on page 281.
SJN scheduling with variable arrival times
0
10
P0
35
p2
75
p1
105
p3
150
P4
215
p0
6. (15 pnts) Problem 6 in the textbook on page 281.
Note that this is one solution. Other solutions are possible, depending on how you handle newly
arrived processes.
RR scheduling with a time quantum of 15
a. Gantt chart
0
15 30 45 60 75 85 100 115 130 140 145 160 175 190 205
p 0 p1 p2 p0 p1 p2 p3 p4 p0 p1 p3 p4
p0 p4 p0
b. Turnaround time for p3 = 65
c. Average wait time
W(p_0) = 0
W(p_1) = 5
W(p_2) = 20
W(p_3) = 5
W(p_4) = 15
Average = (0+5+20+5+15)/5 = 9
7. (15 pnts) Problem 8 in the textbook on page 282 Here we assume the same system given in
Problem 6 on Page 281.
Note that this is one solution. Other solutions are possible, depending on how you handle newly
arrived processes.
RR scheduling with a time quantum of 15 & switch time of 5
a. Gantt chart
0
15 20 35 40 55 60 75 80 95 100 110 115 130 135 150
p 0 C p1 C p2 C p 0 C p1 C p2
C
p3 C
p4
150 155 170 175 185 190 195 200
C
p0 C
p1 C
p3 C
p4
b. Turnaround time for p3 = 115
c. Average wait time
W(p_0) = 0
W(p_1) = 10
W(p_2) = 30
W(p_3) = 35
W(p_4) = 50
Average = (0+10+30+35+50)/5 = 25
215 220 235 240 255 260 275
C
p0 C
p4 C
p0
Download