Step-1:
First, sort the processes in increasing order of their Arrival Time.
Step-2:
Choose the process having highest Burst Time among all the processes that have arrived till that time. Then process it for its burst time. Check if any other process arrives until this process completes execution.
Step-3:
Repeat the above both steps until all the processes are executed.
Note:
If two processes have the same burst time then the tie is broken using FCFS i.e., the process that arrived first is processed first.
Consider the following table of arrival time and burst time for four processes P1, P2, P3 and P4.
Process Name | Arrival Time | Burst time |
---|---|---|
P1 | 1 | 2 |
P2 | 2 | 4 |
P3 | 3 | 6 |
P4 | 4 | 8 |
1. At t = 1, Available Process : P1. So, select P1 and execute 2 ms.
2. At t = 3 i.e. after P1 gets executed, Available Process : P2, P3. So, select P3 and execute 6 ms (since BT(P3)=6 which is higher than BT(P2) = 4)
3. At t = 9 i.e. after execution of P3, Available Process : P2, P4. So, select P4 and execute 8 ms (since, BT(P4) = 8, BT(P2) = 4)
4. Finally execute the process P2 for 4 ms.
CPU will be idle for 0 to 1 unit time since there is no process available in the given interval.
CPU-Idle | P1 | P3 | P4 | P2 |
---|---|---|---|---|
0-1 | 1-3 | 3-9 | 9-17 | 17-21 |
Process Name | Arrival Time | Burst time | Completion time | Turn Around Time | Response Time | Waiting Time |
---|---|---|---|---|---|---|
P1 | 1 | 2 | 3 | 2 | 0 | 0 |
P2 | 2 | 4 | 21 | 19 | 15 | 15 |
P3 | 3 | 6 | 9 | 6 | 0 | 0 |
P4 | 4 | 8 | 17 | 13 | 5 | 5 |