In: Computer Science
Scheduling Algorithms
Part 1
First Come First Serve
Consider the following processes along with their burst time (in Calculate the average waiting time if the processes arrive in the following order
Process |
Burst Time in Ms |
P1 |
20 |
P2 |
10 |
P3 |
5 |
Calculate the average waiting time if the processes arrive in the following order
(i)P1, P2, P3
(ii)P2, P3, P1
(i) Case 1: Consider a case if processes P1, P2, P3 arrive at the same time say 0 ms in the system in the order P1, P2, P3. The arrival of processes is represented in the Gantt chart as shown below.
Gantt chart
P1 |
P2 |
P3 |
20 30 35
Process |
Waiting Time |
Turnaround Time |
P1 |
0 |
20 |
P2 |
20 |
30 |
P3 |
30 |
35 |
Therefore, average waiting time =
Turnaround Time =
Case 2: Processes arrive in order P1, P2, P3, let us assume at 0 ms, 2 ms and 4 ms, respectively.
Arrival Time: Time at which the process arrives in the ready queue.
Process |
Burst Time |
Arrival Time |
P1 |
20 |
0 |
P2 |
10 |
2 |
P3 |
5 |
4 |
Gantt chart: Draw the Gantt Chart
Waiting time for process P1 = 0 ms
Waiting time for process P2 = 20 ms – 2 ms = 18 ms
Waiting time for process P3 = 30 ms- 4 ms = 26 ms
Calculate the average waiting time
Calculate the Turnaround Time