Friday, March 4, 2011

ROUND ROBIN


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t=0,s=1;
int a,q,x,*b;
clrscr();
printf("enter number of processes");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("process %d",i);
scanf("%d",&b[i]);
}
printf("enter time quantum");
scanf("%d",&q);
x=0;
for(i=1;i<=n;i++)
  t=t+b[i];
printf("total time is = %d\n",t);
for(i=0;i<=n;i++)
{
for(a=1;a<=n;a++)
{
if(b[a]>0)
{
if(b[a]<q && b[a]>0)
   x=x+b[a];
else
   x=x+q;
printf("current program is p %d...%d \n",a,x);
b[a]=b[a]-q;
s++;
}
}
}
getch();
}

No comments:

Post a Comment