Wednesday, 21 November 2012

OS MVT PROGRAM


#include<stdio.h>
 #include<stdlib.h>
void main()
{
int m=0,m1=0,m2=0,p,count=0,i;
 printf("\n enter the memory capacity:");
 scanf("%d",&m);
printf("\n enter the no of processes:");
 scanf("%d",&p);
for(i=0;i<p;i++)
{
 printf("\n Enter memory required for process%d: ",i+1);
scanf("%d",&m1);
 count=count+m1;
 if(m1<=m)
{
if(count==m)
printf("\n there is no further memory remaining:");
printf(" \n the memory allocated for process%d is: %d \n ",i+1,m);
 m2=m-m1;
printf("\n remaining memory is: %d",m2);
m=m2;
}
else
{
printf("\n memory is not allocated for process%d",i+1);
 }
printf("\n external fragmentation for this process is:%d \n",m2);
}
}

No comments:

Post a Comment