? Step-by-Step Execution of Round Robin
? Step-by-Step Execution of Round Robin
✅ Step-by-Step Execution
⏳ At Time = 0 min
🟢 Queue: P1
🎮 P1 plays for 5 min → Needs 2 more min
📢 Updated Queue: P2 → P3 → P4 → P5 → P6 → P1
⏳ At Time = 5 min
🟢 Queue: P2 → P3 → P4 → P5 → P6 → P1
🎮 P2 plays for 4 min → FINISHED ✅
📢 Updated Queue: P3 → P4 → P5 → P6 → P1
⏳ At Time = 9 min
🟢 Queue: P3 → P4 → P5 → P6 → P1
🎮 P3 plays for 5 min → Needs 10 more min
📢 Updated Queue: P4 → P5 → P6 → P1 → P3
⏳ At Time = 14 min
🟢 Queue: P4 → P5 → P6 → P1 → P3
🎮 P4 plays for 5 min → Needs 6 more min
📢 Updated Queue: P5 → P6 → P1 → P3 → P4
⏳ At Time = 19 min
🟢 Queue: P5 → P6 → P1 → P3 → P4
🎮 P5 plays for 5 min → Needs 15 more min
📢 Updated Queue: P6 → P1 → P3 → P4 → P5
⏳ At Time = 24 min
🟢 Queue: P6 → P1 → P3 → P4 → P5
🎮 P6 plays for 5 min → Needs 4 more min
📢 Updated Queue: P1 → P3 → P4 → P5 → P6
⏳ At Time = 29 min
🟢 Queue: P1 → P3 → P4 → P5 → P6
🎮 P1 plays for 2 min → FINISHED ✅
📢 Updated Queue: P3 → P4 → P5 → P6
⏳ At Time = 31 min
🟢 Queue: P3 → P4 → P5 → P6
🎮 P3 plays for 5 min → Needs 5 more min
📢 Updated Queue: P4 → P5 → P6 → P3
⏳ At Time = 36 min
🟢 Queue: P4 → P5 → P6 → P3
🎮 P4 plays for 5 min → Needs 1 more min
📢 Updated Queue: P5 → P6 → P3 → P4
⏳ At Time = 41 min
🟢 Queue: P5 → P6 → P3 → P4
🎮 P5 plays for 5 min → Needs 10 more min
📢 Updated Queue: P6 → P3 → P4 → P5
⏳ At Time = 46 min
🟢 Queue: P6 → P3 → P4 → P5
🎮 P6 plays for 4 min → FINISHED ✅
📢 Updated Queue: P3 → P4 → P5
⏳ At Time = 50 min
🟢 Queue: P3 → P4 → P5
🎮 P3 plays for 5 min → FINISHED ✅
📢 Updated Queue: P4 → P5
⏳ At Time = 55 min
🟢 Queue: P4 → P5
🎮 P4 plays for 1 min → FINISHED ✅
📢 Updated Queue: P5
⏳ At Time = 56 min
🟢 Queue: P5
🎮 P5 plays for 5 min → Needs 5 more min
📢 Updated Queue: P5
⏳ At Time = 61 min
🟢 Queue: P5
🎮 P5 plays for 5 min → FINISHED ✅
🎉 All processes completed at Time = 66 min 🎉
📊 Step-wise Gantt Chart Representation
Scheduling
Round Robin CPU
5-9 P2 (4 min) ✅ P3 → P4 → P5 → P6 → P1 P1 → P2
29 - 31 P1 (2 min) ✅ P3 → P4 → P5 → P6 P1 → P2 → P3 → P4 → P5 → P6 → P1
50 - 55 P3 (5 min) ✅ P4 → P5 P1 → P2 → P3 → P4 → P5 → P6 → P1 → P3
→ P4 → P5 → P6 → P3
55 - 56 P4 (1 min) ✅ P5 P1 → P2 → P3 → P4 → P5 → P6 → P1 → P3
→ P4 → P5 → P6 → P3 → P4
P1 0 31 31 - 0 = 31 31 - 7 = 24
P2 1 6 6-1=5 5-4=1
P3 2 50 50 - 2 = 48 48 - 15 = 33
P4 3 56 56 - 3 = 53 53 - 11 = 42
P5 4 66 66 - 4 = 62 62 - 20 = 42
P6 4 46 46 - 4 = 42 42 - 9 = 33
Key Characteristics:
2. Example Problem
Example: Consider the following set of processes with their arrival and burst times:
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Gantt Chart: A Gantt chart visually represents the execution order of processes over time.
Here's a hypothetical illustration of how SRTF would execute the above example:
Time 0 1 2 3 4 5 6 7 8 9 10 11 12 13
P P1 P2 P2 P1 P1 P4 P4 P4 P1 P1 P3 P3 P3 P3
Given Data:
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Step-by-Step Calculation:
1. Completion Time (CT) is the time when a process finishes execution.
2. Turnaround Time (TAT) is calculated as TAT=CT−AT\text{TAT} = \text{CT} -
\text{AT}TAT=CT−AT.
3. Waiting Time (WT) is calculated as WT=TAT−BT\text{WT} = \text{TAT} -
\text{BT}WT=TAT−BT.
Based on the arrival times and burst times, here is how the processes are executed in the
SRTF scheduling order (from the previous Gantt chart):
Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
(AT) (BT) (CT) (TAT) (WT)
P1 0 8 9 9-0=9 9-8=1
P2 1 4 5 5-1=4 4-4=0
P3 2 9 15 15 - 2 = 13 13 - 9 = 4
P4 3 5 13 13 - 3 = 10 10 - 5 = 5
Process Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
(AT) (BT) (CT) (TAT) (WT)
P1 0 8 9 9 1
P2 1 4 5 4 0
P3 2 9 15 13 4
P4 3 5 13 10 5
Final Metrics:
Performance Metrics:
1. Turnaround Time (TAT): The total time taken from the arrival of the process to its
completion.
2. Waiting Time (WT): The total time a process spends waiting in the ready queue.
3. Average Waiting Time: The sum of waiting times for all processes divided by the
number of processes.
Visual Enhancements:
● Icons & Graphics: Use icons representing processes, CPU time, and preemptions.
● Colors: Use different colors for processes running, waiting, and preempted states to
enhance clarity.
● Charts/Graphs: Include bar charts for performance metrics like average waiting
time and turnaround time for comparison.
Applications:
● SRTF is ideal for systems where job lengths are highly variable and where
minimizing waiting time is a critical factor. It is typically used in:
○ Real-Time Operating Systems (RTOS) where responsiveness is crucial.
○ Process Scheduling in batch systems for minimizing latency.
❌ Disadvantages:
● May cause starvation for longer processes.
● High CPU overhead due to frequent preemptions.
4. Conclusion
SRTF is an optimal scheduling algorithm for minimizing turnaround time. However, its
preemptive nature can lead to starvation for longer processes. It is best suited for
environments where short processes arrive frequently and require quick execution.