#include<stdio.h>
#include<conio.h>
void main()
{
int prs,n,ps[10],i,j=0,k;
clrscr();
printf("\nEnter the number of partitions:");
scanf("%d",&n);
printf("\nEnter the size of each parition:");
for(i=0;i<n;i++)
scanf("%d",&ps[i]);
printf("\nEnter the size of the process:");
scanf("%d",&prs);
printf("\nEnter the index of last allocated matrix:");
scanf("%d",&k);
printf("\nLast allocated block:%d",ps[k]);
for(i=k+1;i<n;i++)
{
if(ps[i]>=prs)
{
printf("\nThe index value to which process is allocated:%d",i);
printf("\nThe size of the partition to which process is allocated:%d",ps[i]);
printf("\n\nExternal fragmentation:%d",ps[i]-prs);
j=1;
break;
}
}
if(j==0)
printf("\nThe process size is greater than each of the partition");
getch();
}
/*OUTPUT FOR NEXT-FIT*/
1st CONCEPT IMPLEMENTATION:
INPUT:
Enter the number of partitions: 4
Enter the size of each partition:
14
16
20
18
Enter the size of the process: 10
Enter the last allocated matrix: 2
OUTPUT:
Last allocated block: 20
The index value to which process is allocated: 3
The size of the partition to which process is allocated: 18
External fragmentation: 8
2nd CONCEPT IMPLEMENTATION
INPUT:
Enter the number of partitions: 3
Enter the size of each partition:
20
22
18
Enter the size of process: 24
Enter the index of last allocated matrix: 1
OUTPUT:
Last allocated block: 22
The process size is greater than each of the partition.
If you like this please Link Back to this article...
0 comments:
Post a Comment