Sch-Examle

advertisement
There are four processes with following given data. Define waiting time and find the average
waiting time in case of First Come First Serve, Shortest Remaining Time First and Round Robin
Scheduling policy, depending upon your roll no.
(2,8)
Process
P1
P2
P3
P4
Arrival Time
0
11
22
44
CPU Burst Time
80
60
20
40
Waiting Time: The time during which a process waits for allocation of CPU.
Waiting Time = Completion Time – Arrival Time – CPU Burst Time
………………………………………………………….
First Come First Serve (FCFS)
Scheduling decision are taken according to the arrival time of the processes
Gantt chart: Time line of processes execution
P4(40)
P3(20)
P2(60)
P1(80)
P1
Processes
Queue
Executing
Time -> 0
P4(40)
P3(20)
P2(60)
P2
80
140
P4(40)
P3(20)
P3
160
P4(40)
P4
200
WT = CT – AT – CBT
Waiting Time for Process 1: W1 = 80 – 0 – 80 = 80
W2 = 140 – 11 – 60 = 69
W3 = 160 – 22 – 20 = 118
W4 = 200 – 44 – 40 = 116
Total waiting Time:
= 303
Average waiting Time:
= 303 / 4 = 75.75
………………………………………………………….
Shortest Remaining Time First (SRTF) or Preemptive Shortest Job First
Scheduling decision are taken at Arrival and Completion Time
Gantt chart: Time line of processes execution
Processes
Queue
P2(60)
P1(69)
P2(60)
P1(69)
P3(20)
P2(49)
P1(69)
Executing
Time 0
P1
P2
P3
11
22
42
P2(49)
P1(69)
P2
44
P4(40)
P2(47)
P1(69)
P2(47)
P1(69)
P1(69)
P4
P2
P1
84
131
200
WT = CT – AT – CBT
Instructor : Ikram ul Haq
5th Semester
Page 1 of 2
Waiting Time for Process 1: W1 = 200 – 0 – 80 = 120
W2 = 131 – 11 – 60 = 60
W3 = 42 – 22 – 20 = 0
W4 = 84 – 44 – 40 = 0
Total waiting Time:
= 180
Average waiting Time:
= 180 / 4 = 45
………………………………………………………….
Round Robin (RR)
Scheduling decision are taken at Time Quantum up Time
Gantt chart: Time line of processes execution
Processes
Queue
Executing
Time 0
P1(80)
P1
10
P3(20) P2(50)
P2(60) P1(60) P3(20)
P1(70) P2(60) P1(60)
P1
P2
P1
20
30
40
P4(40)
P1(50)
P2(50)
P3(20)
P3
50
P3(10)
P4(40)
P1(50)
P2(50)
P2
60
P2(40)
P3(10)
P4(40)
P1(50)
P1
70
P1(40)
P2(40)
P3(10)
P4(40)
P4
80
P4(30)
P1(40) P4(30)
P2(40) P1(40)
P3(10) P2(40)
P3
P2
90
100
Processes P2(30) P1(30) P4(20) P2(20) P1(20) P4(10) P2(10) P1(10)
Queue
P4(30) P2(30) P1(30) P4(20) P2(20) P1(20) P4(10) P2(10) P1(10)
Executing
Time
P1(40) P4(30) P2(30) P1(30) P4(20) P2(20) P1(20) P4(10) P2(10) P1(10)
P1
P4
P2
P1
P4
P2
P1
P4
P2
P1
110
120
130
140
150
160
170
180
190
200
WT = CT – AT – CBT
Waiting Time for Process 1: W1 = 200 – 0 – 80 = 120
W2 = 190 – 11 – 60 = 119
W3 = 90 – 22 – 20 = 48
W4 = 180 – 44 – 40 = 96
Total waiting Time:
= 383
Average waiting Time:
= 383 / 4 = 95.75
Instructor : Ikram ul Haq
5th Semester
Page 2 of 2
Download
Related flashcards
Create Flashcards