Robin
Robin
#include <stdio.h>
struct Process {
int id, a_time, w_time, c_time, b_time, t_time, r_time;
};
int main() {
int n, tq;
printf("Enter the time quantum: ");
scanf("%d", &tq);
printf("Enter the number of processes: ");
scanf("%d", &n);
struct Process proc[n];
printf("Enter the process Burst time:-\n");
for (int i = 0; i < n; i++) {
proc[i].id = i + 1;
printf("Process %d: ", i + 1);
scanf("%d", &proc[i].b_time);
proc[i].a_time = 0; // Set arrival time to zero for all processes
proc[i].r_time = proc[i].b_time;
}
round_robin(proc, n, tq);
}
Output
Enter the time quantum: 4
Enter the number of processes: 3
Enter the process Burst time:-
Process 1: 20
Process 2: 4
Process 3: 6
Gant Chart
|P1(4)|P2(8)|P3(12)|P1(16)|P3(18)|P1(22)|P1(26)|P1(30)|
Process id Arrival time Burst time Waiting time Completion time Turn Around time
1 0 20 10 30 30
2 0 4 4 8 8
3 0 6 12 18 18
Average Waiting Time: 8.666667
Average Turn Around Time: 18.666666