Add os/round-robin: Round Robin scheduler in C++ and C with Gantt chart, quantum sweep and captured output

This commit is contained in:
ankurm
2026-11-26 00:42:10 +05:30
parent f784f9b6ee
commit 9ed8479cec
24 changed files with 513 additions and 0 deletions
@@ -0,0 +1,15 @@
Round Robin, time quantum = 10
PID AT BT CT TAT WT
P1 0 10 10 10 0
P2 0 29 61 61 32
P3 0 3 23 23 20
P4 0 7 30 30 23
P5 0 12 52 52 40
Average waiting time : 23.00
Average turnaround time : 35.20
Gantt chart:
| P1 | P2 | P3 | P4 | P5 | P2 | P5 | P2 |
0 10 20 23 30 40 50 52 61
@@ -0,0 +1,13 @@
Round Robin, time quantum = 4
PID AT BT CT TAT WT
P1 0 24 30 30 6
P2 0 3 7 7 4
P3 0 3 10 10 7
Average waiting time : 5.67
Average turnaround time : 15.67
Gantt chart:
| P1 | P2 | P3 | P1 |
0 4 7 10 30
@@ -0,0 +1,14 @@
Round Robin, time quantum = 2
PID AT BT CT TAT WT
P1 0 5 12 12 7
P2 1 4 11 10 6
P3 2 2 6 4 2
P4 4 1 9 5 4
Average waiting time : 4.75
Average turnaround time : 7.75
Gantt chart:
| P1 | P2 | P3 | P1 | P4 | P2 | P1 |
0 2 4 6 8 9 11 12
@@ -0,0 +1,13 @@
Round Robin, time quantum = 3
PID AT BT CT TAT WT
P1 0 4 4 4 0
P2 10 3 13 3 0
P3 11 2 15 4 2
Average waiting time : 0.67
Average turnaround time : 3.67
Gantt chart:
| P1 | idle | P2 | P3 |
0 4 10 13 15
+13
View File
@@ -0,0 +1,13 @@
Round Robin, time quantum = 1
PID AT BT CT TAT WT
P1 0 6 12 12 6
P2 0 4 10 10 6
P3 0 2 6 6 4
Average waiting time : 5.33
Average turnaround time : 9.33
Gantt chart:
| P1 | P2 | P3 | P1 | P2 | P3 | P1 | P2 | P1 | P2 | P1 |
0 1 2 3 4 5 6 7 8 9 10 12
@@ -0,0 +1,14 @@
Round Robin, time quantum = 100
PID AT BT CT TAT WT
P1 0 8 8 8 0
P2 0 8 16 16 8
P3 0 8 24 24 16
P4 0 8 32 32 24
Average waiting time : 12.00
Average turnaround time : 20.00
Gantt chart:
| P1 | P2 | P3 | P4 |
0 8 16 24 32
@@ -0,0 +1,26 @@
Enter No of Processes:
Enter Burst Time of Process 1:
Enter Burst Time of Process 2:
Enter Burst Time of Process 3:
Enter Burst Time of Process 4:
Enter Burst Time of Process 5:
Enter Time Quantum:
Entered Data
ProcesstBurst Time
1 10
2 29
3 3
4 7
5 12
Result of Round Robin Scheduling
PNo BT WT TT
1 10 0 10
2 29 32 61
3 3 20 23
4 7 23 30
5 12 40 52
Average Waiting Time : 23
Average Turnaround Time : 35.2
@@ -0,0 +1,12 @@
Q avg-WT avg-TAT gantt-boxes
1 25.00 37.20 45
2 25.40 37.60 24
3 25.00 37.20 17
5 24.60 36.80 12
7 24.20 36.40 9
10 23.00 35.20 8
12 22.20 34.40 6
15 24.00 36.20 6
20 27.00 39.20 6
29 28.00 40.20 5
40 28.00 40.20 5
+6
View File
@@ -0,0 +1,6 @@
identical input/classic-q4.txt
identical input/idle-gap-q3.txt
identical input/large-quantum.txt
identical input/legacy-5proc-q10.txt
identical input/quantum-1.txt
identical input/staggered-q2.txt
@@ -0,0 +1,2 @@
random workloads (all arrivals at 0, seed 2015): 500
waiting-time mismatches, legacy vs rr.cpp : 0