Process | P1 | P2 | P3 | P4 |
CPU Burst | 10 | 8 | 4 | 6 |
Answer
Let’s assume that all processes arrive at time 0 for simplicity.
(i) Round Robin (RR) Scheduling (q = 2):
Step 1: Execute processes in a round-robin fashion with a time quantum (q) of 2 until all processes complete.
Time Quantum = 2
Time | P1 | P2 | P3 | P4 | P1 | P2 | P4 | P1 |
---|
2 | 2 | 2 | 2 | 2 | 2 | 2 | 4 | |
---|---|---|---|---|---|---|---|---|
WT | 0 | 8 | 6 | 10 | 14 | 16 | 16 | 18 |
Step 2: Calculate the waiting time (WT) for each process.
- WT(P1) = 0
- WT(P2) = 8
- WT(P3) = 6
- WT(P4) = 10
Step 3: Calculate the average waiting time (AWT):
AWT = (WT(P1) + WT(P2) + WT(P3) + WT(P4)) / Number of processes
AWT = (0 + 8 + 6 + 10) / 4
AWT = 24 / 4
AWT = 6
(ii) Shortest Job First (SJF) Scheduling:
Step 1: Execute processes in ascending order of burst time (shortest first) until all processes complete.
Time | P3 | P4 | P2 | P1 |
---|
4 | 6 | 8 | 18 | |
---|---|---|---|---|
WT | 0 | 4 | 14 | 16 |
Step 2: Calculate the waiting time (WT) for each process.
- WT(P1) = 16
- WT(P2) = 14
- WT(P3) = 0
- WT(P4) = 4
Step 3: Calculate the average waiting time (AWT):
AWT = (WT(P1) + WT(P2) + WT(P3) + WT(P4)) / Number of processes
AWT = (16 + 14 + 0 + 4) / 4
AWT = 34 / 4
AWT = 8.5