You are on page 1of 1

#include<stdio.

h>
#include<conio.h>
int main()
{
int c=1,i=0,j=0,a[10],b[10],m,n;
printf("Enter the no. of hole ");
scanf("%d",&m);
printf("Enter the hole sizes");
for(i=0;i<m;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the no. of processes ");
scanf("%d",&n);
printf("Enter the process sizes");
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<n;i++)
{
if(c==0)
break;
for(j=0;j<m;j++)
{
if(b[i]<=a[j])
{
printf("process %d is allocated to %d kb hole\n",i,a[j]);
a[j]=a[j]-b[i];
break;
}
}
if(j==5)
{
printf("process %d got stuck",i);
c=0;
}
}
getch();
}

You might also like