Friday, March 4, 2011

PRIORITY SCHEDULING PROGRAM


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,r,s,t,x,d=0,p[20],b[20],pr[20];
clrscr();
printf("enter the no. of process");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("enter burst time %d:",i);
scanf("%d",b[i]);
}
for(i=1;i<=n;i++)
{
printf("priority %d",i);
scanf("%d",pr[i]);
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(pr[i]>pr[j])
{
r=p[j];
s=b[j];
t=pr[j];
p[j]=p[i];
b[j]=b[i];
pr[j]=pr[i];
p[i]=r;
b[i]=s;
pr[i]=t;
}
}
}
for(i=1;i<=n;i++)
{
x=x+b[i];
printf("process %d interval is from %d to %d",p[i],d,x);
d=x;
}
getch();
}





No comments:

Post a Comment