0% found this document useful (0 votes)
8 views

RoundRobin C

Uploaded by

akvakarthik2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

RoundRobin C

Uploaded by

akvakarthik2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

5/9/24, 7:26 AM RoundRobin.

RoundRobin.c

1 #include<stdio.h>
2
3 void main()
4 {
5 int n, i, qt, count = 0, sq = 0, bt[8], wt[8], tat[8], rem_bt[8];
6 float ttat = 0, twt = 0;
7
8 printf("Enter the no.of processes: ");
9 scanf("%d", &n);
10
11 printf("\nEnter the Quantum Time: ");
12 scanf("%d",&qt);
13
14 printf("\n");
15 for(i = 0; i<n; i++)
16 {
17 printf("Enter the Burst Time for process %d: ", i+1);
18 scanf("%d",&bt[i]);
19 rem_bt[i] = bt[i];
20 }
21
22 while(1)
23 {
24 for(i = 0, count = 1; i < n; i++)
25 {
26 if(rem_bt[i] > 0)
27 {
28 count = 0;
29
30 if(rem_bt[i] > qt)
31 {
32 sq += qt;
33 rem_bt[i] -= qt;
34 }
35 else
36 {
37 sq += rem_bt[i];
38 tat[i] = sq;
39 rem_bt[i] = 0;
40 }
41 }
42 }
43 if(count)
44 {
45 break;
46 }
47 }
48 printf("\nProcess\tBurst Time\tTurnAround Time\tWaiting Time\n");
49 for(i = 0; i < n; i++)
50 {
51 wt[i] = tat[i] - bt[i];
52 ttat += tat[i];
53 twt += wt[i];
54 printf("\nP%d\t%d\t\t%d\t\t%d\n", i+1, bt[i], tat[i], wt[i]);
55 }
56 printf("Average Turn Around Time: %.2f", ttat/n);
57 printf("\nAverage Waiting Time: %.2f", twt/n);
58 }

localhost:56984/80a6bc80-62d6-45d4-a01d-21113208192e/ 1/1

You might also like