cout<<"************************模拟FIFO页面调度算法处理缺页中断************************"<<endl;
cout<<"页表初始长度为:"<<j<<endl;
cout<<"++++++++++++++++++++++++++++页表初始状态如下+++++++++++++++++++++++++++++++"<<endl;
list.print();
char a[12]={'+','+','*','I','O','-','M','+','I','O','+','I'};
int b[12]={70,50,15,21,56,40,53,23,37,78,1,84};
int m=0,n;
int k=0;
int c=0;
for(int i=0;i<12;i++)
{
int t;
cout<<"*************************"<<"第"<<i+1<<"步["<<a[i]<<"]操作!"<<"*************************"<<endl;
cout<<"请输入该操作对应的页号:";
cin>>n;
cout<<"*************************************************"<<endl;
m=list.check(n);
t=checkp(n);
if(t==1)
{
if(m==-1)
{
cout<<"*缺页中断,页号:"<<n<<endl;
cout<<"****************调用FIFO页面调度算法处理中断**************";
c=list.alternative(k,n);
k=(k+1)%j;
cout<<"该页所在的主存块号为:"<<c<<endl;
cout<<"该指令的物理地址为:"<<n<<b[i]<<endl;
cout<<"********************"<<"中断处理后页表的状态"<<"*******************"<<endl;
}
else
{
cout<<"该指令的物理地址为:"<<n<<b[i]<<endl;
}
}
if(m!=-1&&t==0)
{
cout<<"该页所在主存块号:"<<m<<endl;
m*=128+b[i];
//cout<<"+++++++++++++++++++++++++++++++"<<endl;
cout<<"该指令的物理地址为:"<<m<<endl;
//cout<<"+++++++++++++++++++++++++++++++"<<endl;
}
else if(m==-1&&t==0)
{
cout<<"*缺页中断,页号:"<<n<<endl;
//cout<<"++++++++++++++++++++++++++++++++++";
cout<<"****************调用FIFO页面调度算法处理中断**************";
c=list.alternative(k,n);
k=(k+1)%j;
cout<<"该页所在的主存块号为:"<<c<<endl;
//cout<<"++++++++++++++++++++++++++++++++++"<<endl;
cout<<"该指令的物理地址为:"<<c*128+b[i]<<endl;
//cout<<"++++++++++++++++++++++++++++++++++"<<endl;
cout<<"********************"<<"中断处理后页表的状态"<<"*******************"<<endl;
}
else
;
list.print();
//cout<<"-------------------------------------------------------------------"<<endl;
}
return 1;
}
int checkp(int n)
{
int a=0;
int k=1;
for(int c=(int)sqrt(double (n))+2;c>=1;c--)
{
if(n==k)
a=1;
else
k=k*2;
}
return a;
}上一页 [1] [2] [3]
操作系统课程设计-模拟FIFO页面调度算法处理缺页中断c++源码 第3页下载如图片无法显示或论文不完整,请联系qq752018766