文档介绍:计算机科学与技术系
实验报告
专业名称 网络工程
课程名称 操作系统原理
项目名称 FIFO 页面调度算法处理缺页中断
lick(object sender, EventArgs e)// 定义一个事件响应, 即对输入
进行操作
{
if (())
(" 请输入页号! ");
else if (() > 6 || () < 0) (" 输入页号不合法,请重新输入! ");
//判断输入是否合法
else
{
int page = ();
int i=0;
if (page !=
mainstore[0]
&&
page != mainstore[1]
&&
page !=
mainstore[2] && page != mainstore[3])
//插入页内存中不存在,进行
FIFO
算法
{
int lll;
lll = mainstore[0];
if (flag[mainstore[0]] == 0)// 修改标志位为 0,直接覆盖
{
mainstore[0] = page;
flag[lll] = 1;
}
Else// 修改标志位为 1,数组执行 FIFO
{
for (i = 0; i < 3; i++)
mainstore[i] = mainstore[i + 1];
mainstore[3] = page;
}
(" 当前调走页号 "+ ()+"\n 存入页号
为"+ ());
= "0";
= "0";
= "0";
= "0";
= "0";
= "0";
= "0";
//标志位初始化;
for (int j = 0; j < 4; j++)
{
if (mainstore[j] == 0)
= "1";
if (mainstore[j] == 1)
= "1";
if (mainstore[j] == 2)
= "1";
if (mainstore[j] == 3)
= "1";
if (mainstore[j] == 4)
= "1";
if (mainstore[j] == 5)
= "1";
if (mainstore[j] == 6)
= "1";
} //根据插入页号,将标志位置 1
for (int k = 0;k < 7; k++)
{
if (lll == 0)
= "1";
if (lll == 1)
= "1";
if (lll == 2)
= "1";
if (lll == 3)
= "1";
if (lll == 4)
= "1";
if (lll == 5)
= "1";
if (lll == 6)
= "1";
} //根据情况,将修改标志位置 1
}
else
{
(" 该页已在主存中! " );
}
blo++;
if(blo==1){
= mainstore[0].ToString();
= mainstore[1].ToString();
t