Uploaded by magaxat

quiz-1-as-ch4

advertisement
Question 1
Given the following information:
Job number
A
B
C
D
a)
Table 1: Processes schedules
Arrival Time
0
1
2
3
CPU cycle
6
3
1
4
Draw a timeline for each of the following scheduling algorithm. (It may be helpful to first
compute a start and finish time for each job).




FCFS
SJN
SRT
Round Robin space(using time quantum 2, ignore context switching and natural wait)
(8 marks)
b)
Complete the chart by computing waiting time and turnaround time for every job using all
scheduling algorithm stated in (a).
(6 marks)
c)
Compute the average waiting time and average turnaround time.
(4 marks)
d)
State which algorithm given the best result.
(2 marks)
SOLUTION ANSWER
a)
FCFS
Job A
0
6
SJN
Job A
0
6
Job B
9
Job C
Job C
Job D
10
Job B
7
14
Job D
10
14
SRT
Preemptive
Job A Job B
0
1 2
Job C
3
Round Robin
Job A
Job B
0
2
b)
FCFS
Job number
A
B
C
D
SJN
Job number
A
B
C
D
Job B
4
CPU cycle
0
1
2
3
6
3
1
4
Arrival Time
CPU cycle
0
1
2
3
6
3
1
4
0
1
2
3
ROUND ROBIN
Job number
Arrival Time
A
B
C
D
0
1
2
3
Job A
14
Job C Job D
Job A
5
7
Arrival Time
SRT -preemptive
Job number
Arrival Time
A
B
C
D
Job D
5
9
CPU cycle
6
3
1
4
CPU cycle
6
3
1
4
Job B Job D
Job A
9
10
12
14
Completion
time
6
9
10
14
Turnaround
time
6
8
8
11
Waiting
time
0
5
7
7
Completion
time
6
10
7
14
Turnaround
time
6
9
5
11
Waiting
time
0
6
4
7
Completion
time
14
5
3
9
Turnaround
time
14
4
1
6
Waiting
time
8
1
0
2
Completion
time
14
10
5
12
Turnaround
time
14
9
3
9
Waiting
time
8
6
2
5
c)
FCFS
AverageTurnaroundTim e 
AverageWaitingTime 
6  8  8  11
 8.25s
4
0577
 4.75s
4
SJN
AverageTurnaroundTim e 
AverageWaitingTime 
6  9  5  11
 7.75s
4
0647
 4.25s
4
SRT
AverageTurnaroundTim e 
AverageWaitingTime 
14  4  1  6
 6.25s
4
8 1 0  2
 2.75s
4
ROUND ROBIN
AverageTurnaroundTim e 
AverageWaitingTime 
d)
14  9  3  9
 8.75s
4
8625
 5.25s
4
The best result is SRT
Download