实验
报告
软件系统测试报告下载sgs报告如何下载关于路面塌陷情况报告535n,sgs报告怎么下载竣工报告下载
三 内存页面置换算法的设计
实验报告三
——内存页面置换算法的设计
姓名:丛菲 学号:20100830205 班级:信息安全二班 一、实习内容
• 实现最近最久未使用(LRU)置换算法
二、实习目的
• LINUX中,为了提高内存利用率,提供了内外存进程对换机制,内存空间的分配和
回收均以页为单位进行,一个进程只需将其一部分调入内存便可运行,还支持请求
调页的存储管理方式。
• 本实习要求学生通过请求页式存储管理中页面置换算法模拟设计,了解虚拟存储技
术的特点,掌握请求页式存储管理的页面置换算法。
三、实习题目
1. 最近最久未使用(LRU)置换算法原理就是:当需要淘汰某页面时,选择当前一段时间内最久未使用过的页先淘汰,即淘汰距当前最远的上次使用的页。
• 例如: 分配给该进程的页块数为3,一个20位长的页面访问序列
为:12560,36536,56042,70435,
则缺页次数和缺页率按下图给出:
2. 假定分配给该进程的页块数为3,页面访问序列长度为20。本实验可以采用数组结构实现,首先随机产生页面序列,当发生请求调页时,若内存已满,则需要利用LRU算法,将当前一段时间内最久未使用过的页替换出去。
• 模拟程序的算法如下图:
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements
四、实现代码为:
#include
#define M 3
#define N 20
#define Myprintf printf("|---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|\n")
/*表格控制*/
typedef struct page
{
int num; /*记录页面号*/
int time; /*记录调入内存时间*/
}Page; /* 页面逻辑结构,结构为方便算法实现设计*/ Page b[M]; /*内存单元数*/
int c[M][N]; /*暂保存内存当前的状态:缓冲区*/ int queue[100]; /*记录调入队列*/
int K; /*调入队列计数变量*/
/*初始化内存单元、缓冲区*/
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements
void Init(Page *b,int c[M][N])
{
int i,j;
for(i=0;imax)
{
max=b[i].time;
tag=i;
}
}
return tag;
}
/*判断页面是否已在内存中*/
int Equation(int fold,Page *b)
{
int i;
for(i=0;i=0)
{
b[val].time=0;
for(i=0;i
分析
定性数据统计分析pdf销售业绩分析模板建筑结构震害分析销售进度分析表京东商城竞争战略分析
内
存页面数的变化对各种置换算法命中率的影响。
答: 内存页面数越多哦,命中率越高.
LRU算法可以减少页错误率,较易理解.
最优算法页错误最低,且没有Belady异常,但是较难实现
FIFO算法容易理解和实现,但是页错误率较高
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements
七、实验总结
明白LRU算法的原理,当内存页面中不存在当前页面时,且没有空闲页面,将替换近期最少使
用的页面,这种算法可以有效减少替换掉常用页面的次数,从而减少页错误率.
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements