0% found this document useful (0 votes)
267 views13 pages

CSC520 - Chapter 4 Exercise Solutions

This document contains multiple exercises involving scheduling algorithms like priority scheduling, round robin scheduling, shortest job next scheduling, and calculating metrics like turnaround time and waiting time. For each exercise, it provides process details and timing information, asks to draw Gantt charts for different algorithms, and calculate requested metrics.

Uploaded by

Al Firdauz
Copyright
© Attribution Non-Commercial (BY-NC)
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)
267 views13 pages

CSC520 - Chapter 4 Exercise Solutions

This document contains multiple exercises involving scheduling algorithms like priority scheduling, round robin scheduling, shortest job next scheduling, and calculating metrics like turnaround time and waiting time. For each exercise, it provides process details and timing information, asks to draw Gantt charts for different algorithms, and calculate requested metrics.

Uploaded by

Al Firdauz
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 13

Exercise

Suppose a system uses priority scheduling where a small integer means higher priority
Create a Gantt chart to illustrate the execution of these processes What is the turnaround time for process P2 under priority scheduling? What is the average waiting time for the processes?

P1 0 20

P4 70

P0

P2 150 160

P3 180

Turnaround time for P2 160 Waiting time


P0 70 P1 0 P2 150 P3 160 P4 20

Average waiting time 400/5 = 80

Exercise
Based on the information given below, draw a Gantt chart illustrating the execution of each process using the following algorithms
SJN RR (Quantum = 2)

Calculate the response time for process A and process E, for each of the algorithm

A
0 8

C
11

B
15 18

D
20

F
23

E
27

A
0 6

B
8

A
10 12

B
14

C
15 18

D
20

E
22

F
24

E
26

F
27

SJN Response time


PA 0 PE 4

RR Response Time
PA 0 PE 1

Exercise
Suppose a system uses SJN scheduling where a small integer means higher priority
Create a Gantt chart to illustrate the execution of these processes What is the turnaround time for process P3 under SJN scheduling? What is the average waiting time for the processes?

P0
0

P3
75 95

P2
120

P1
160

P4
205

P3 Turnaround time
95 55 = 40

Waiting Time
P0 0 P1 150 P2 85 P3 20 P4 65

Average waiting time 320/5 = 64

Exercise
Based on the information given below, draw a Gantt chart illustrating the execution of each process using the following algorithms
FCFS SJF Priority Scheduling

Calculate the waiting time for Process B and D for each of the scheduling algorithm

A
0

B
10 12

C
15

D
20

A
0

B
10 12

C
15

D
20

A
0 10

D
15

B
17

C
20

FCFS/SJF PB 9 FCFS/SJF PD 12 Priority PB 14 Priority PD 7

Exercise
Based on the information given below, draw a Gantt chart illustrating the execution of each process using the priority scheduling algorithm Calculate the average turnaround time for all processes Calculate the average waiting time for all processes

P0
0 20

P1
55

P2
75

P3
90

P4
115

P0 20 P1 45 P2 45 P3 50 P4 60 Average turnaround time 320/5 = 64 P0 0 P1 10 P2 25 P3 35 P4 35 Average waiting time 105/5 = 21

Exercise
Suppose a system uses RR (q =15) scheduling where a small integer means higher priority
Create a Gantt chart to illustrate the execution of these processes What is the turnaround time for process P2 under RR scheduling? What is the average waiting time for the processes?

P0
0 15

P1
30

P2
40

P0
55

P1
60

P3
75

P4
90

P0

P3
105 110

P4
125

P0
140

P4
140
155

P0

P4 P0
170 175

180

P2 turnaround time = 25 Waiting time


P0 25 + 35 + 20 + 15 + 5 = 100 P1 25 P2 15 P3 30 P4 10 + 20 + 15 + 15 = 60

Average waiting time 230/5 = 46

You might also like