AIM: To Implement MVT.
#include<iostream.h>
int main()
{
int tm,rm,os,n,i,c=0,ps;
cout<<"Enter Total Memory: ";
cin>>tm;
cout<<"Enter Memory Given to OS: ";
cin>>os;
rm=tm-os;
cout<<"Enter No of Processes: ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter Size of Process"<<i+1<<": ";
cin>>ps;
c+=ps;
if(ps<=rm)
{
cout<<"Memory Allocated for Process"<<i+1<<" is="<<rm<<endl;
rm=rm-ps;
cout<<"Remaining Memory="<<rm<<endl;
}
else
{
cout<<"Memory Not Allocated for Process"<<i+1<<endl;
}
}
cout<<"External Fragmentation="<<rm<<endl;
}
No comments:
Post a Comment