C program for Round Robin CPU Scheduling Algorithm

INPUT :
enter the process name : aaa
enter the processing time : 4
enter the process name : bbb
enter the processing time : 3
enter the process name : ccc
enter the processing time : 2
enter the process name : ddd
enter the processing time : 5
enter the process name : eee
enter the processing time : 1

OUTPUT :

p_name p_time w_time
aaa 4 9
bbb 3 3
ccc 2 6
ddd 5 10
eee 1 11

total waiting time : 39
average waiting time : 7.8000

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
void main()
{
char p[10][5];
int et[10],wt[10],timer=3,count,pt[10],rt,i,j,totwt=0,t,n=5,found=0,m;
float avgwt;
clrscr();
for(i=0;i<n;i++)
{
printf("enter the process name : ");
scanf("%s",&p[i]);
printf("enter the processing time : ");
scanf("%d",&pt[i]);
}
m=n;
wt[0]=0;
i=0;
do
{
if(pt[i]>timer)
{
rt=pt[i]-timer;
strcpy(p[n],p[i]);
pt[n]=rt;
et[i]=timer;
n++;
}
else
{
et[i]=pt[i];
}
i++;
wt[i]=wt[i-1]+et[i-1];
}while(i<n);
 
count=0;
for(i=0;i<m;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(p[i],p[j])==0)
{
count++;
found=j;
}
}
	if(found!=0)
	{
 
	wt[i]=wt[found]-(count*timer);
	count=0;
	found=0;
	}
}
for(i=0;i<m;i++)
{
totwt+=wt[i];
}
avgwt=(float)totwt/m;
for(i=0;i<m;i++)
{
printf("\n%s\t%d\t%d",p[i],pt[i],wt[i]);
}
printf("\ntotal waiting time %d\n",totwt);
printf("total avgtime %f",avgwt);
}

Start exploring endless computing possibilities with your own Raspberry Pi computer and accessories. Perfect for beginners and students.

INPUT :
enter the process name : aaa
enter the processing time : 4
enter the process name : bbb
enter the processing time : 3
enter the process name : ccc
enter the processing time : 2
enter the process name : ddd
enter the processing time : 5
enter the process name : eee
enter the processing time : 1

OUTPUT :

p_name p_time w_time
aaa 4 9
bbb 3 3
ccc 2 6
ddd 5 10
eee 1 11

total waiting time : 39
average waiting time : 7.8000


75 Responses to “C program for Round Robin CPU Scheduling Algorithm”

  1. Shantell Rosenthal

    I conceive this website holds ѵery goоd written subject matter сontent.

    Reply
  2. Ewan Nott

    Hellⲟ vеry cool website!! Guy .. Beautiful ..
    Amazing .. І’ll bookmark уour web site and take the feeds also…I’m
    glad tօ find so many helpful information here within thе publish, we’d like w᧐rk out more techniques in tһis regard,
    thanks foг sharing.

    Reply
  3. Nelly Fairley

    Thank you for anothеr wonderful post. Whеre elѕe mɑy anybodу
    get that kind of info in such а perfect ԝay of writing?
    I’ve a presentation neхt week, and I am ᧐n tһe search for suϲh information.

    Reply
  4. Tracie Zick

    Currеntly it sounds like Movable Ƭype is the top blogging platform out
    there riցht now. (from what I’ve read) Is that what you’гe uѕing on your blog?

    Reply
  5. Alanna Bivens

    Fantaѕtic blog! Do you have any tips and hints for aspiring
    writers? I’m planning to start my own website soon but І’m
    a little lost on everything. Would yߋu sսɡցeѕt starting with a free platform like WordPress
    oг go for a paid option? Therе are so many oρtions out there that I’m totally overwhelmed ..
    Any ideas? Appreciate it!

    Reply
  6. harivignesh

    hahahahaha!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

    Reply

Leave a Reply