下载此文档

请求页式存储管理模拟实验源代码及实验报告.doc


文档分类:IT计算机 | 页数:约17页 举报非法文档有奖
1/17
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/17 下载此文档
文档列表 文档介绍
请求页式存储管理模拟实验源代码及实验报告
2

———————————————————————————————— 作者:
———————————————————————————————— 日期:

个人收集 仅供参考学习 勿做商业用途
//请求页式存储管理模拟实验源代码及实验报告
//自己写的,程序写得比拟简单,只为方便学弟学妹们 呵呵^ ^
//dlnu.
#include<iostream>
#include<>
#include<>
#include <ctime>
#include <cstdlib>
using namespace std;
int yemianliu[32]={0};//全局变量数组,地址流
int p; //全局变量p是一共有多少地址流
void chushihua()//初始化函数
{
int t;
srand(time(0));//随机产生指令序列
p=12+rand()%32;
cout<<"地址流序列:";
for(int i=0;i<p;i++)
{
t=1+rand()%9;
yemianliu[i]=t;//将随机产生的指令数存入页面流
cout<<t<<" ";
}
cout<<endl;
}
void FIFO(int n) //FIFO算法,n是M的值
{
int i;
int q=p;
int e;
int queye=0;
int flag;
int fifo[32]={0};
while(q--)
{
flag=0;
e=q;
for(i=0;i<n;i++)
{
if(fifo[i]==yemianliu[q])
{
flag=1;
break;
3

个人收集 仅供参考学习 勿做商业用途
}
}
if(flag==0)
{
int m=n-1;
int k=m;
while(m--)
{
fifo[k]=fifo[k-1];
k--;
}
fifo[0]=yemianliu[e];
queye++;
}
}
cout<<"M="<<n<<"时FIFO的命中率为:"<<(1-((double)queye/p))*100<<"%"<<" ";
}
void LRU(int n)//LRU算法
{
int i;
int q=p;
int e;
int queye=0;
int flag;
int flag1,;
int y;
int lru[32]={0};
while(q--)
{
flag=0;
e=q;
for(i=0;i<n;i++)
{
if(lru[i]==yemianliu[q])
{
flag=1;
flag1=i;
break;
}
}
if(flag==0)
{
int m=n-1;
4

个人收集 仅供参考学习 勿做商业用途
int k=m;
while(m--)
{
lru[k]=lru[k-1];
k--;
}
lru[0]=yemianliu[e];
queye++;
}
else if(flag==1)
{
y=flag1;
while(y--)
{
lru[fl

请求页式存储管理模拟实验源代码及实验报告 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数17
  • 收藏数0 收藏
  • 顶次数0
  • 上传人luciferios06
  • 文件大小370 KB
  • 时间2021-08-28
最近更新