Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
525 B
1
Indexable
Never
#include<stdio.h>
#include<conio.h>
main()
{
int i,m,n,tot,s[20];
printf("Enter total memory size :");
scanf("%d",&tot);
printf("Enter no of pages :");
scanf("%d",&n);
printf("Enter memory for OS :");
scanf("%d",&m);
for(i=0;i<n;i++)
{
printf("Enter size of page %d :",i+1);
scanf("%d",&s[i]);
}
tot=tot-m;
for(i=0;i<n;i++)
{
if(tot>=s[i])
{
printf("Allocate page %d\n ",i+1);
tot=tot-s[i];
}
else
printf("process p%d is Blocked\n",i+1);
}
printf("External fragmentation is=%d",tot);
getch();
}
Leave a Comment