max=m;.....................................................................................................................................25
memery[max]=page[i];/*页面字符串数组插入到物理块数组中*/......................................25
flag[max]=0; /*记录该页进入物理块的时间*/.....................................................................25
for(j=0;j<mSIZE;j++)..............................................................................................................25
temp[i][j]=memery[j];/*物理块数组插入到辅助数组中*/...................................................25
}................................................................................................................................................25
else............................................................................................................................................25
{................................................................................................................................................25
for(j=0;j<mSIZE;j++)..............................................................................................................25
temp[i][j]=memery[j];/*物理块数组插入到辅助数组中*/...................................................25
}................................................................................................................................................25
}................................................................................................................................................25
compute();/*计算过程延迟输出*/..........................................................................................25
print(count,count1);/*输出结果函数*/...................................................................................25
}.................................................................................................................................................25
3.6 CLOCK 置换算法 模块.....................................................................................................25
3.6.1 功能..........................................................................................................................25
3.6.2 数据结构..................................................................................................................26
3.6.3 算法..........................................................................................................................26
//简单 Clock 置换算法.............................................................................................................26
void CLOCK(int num)..............................................................................................................26
{.................................................................................................................................................26
int j;............................................................................................................................................26
if(inblock(num)).......................................................................................................................26
{................................................................................................................................................26
//printf("命中!\n");...................................................................................................................26
lost++;/*记录命中的次数*/....................................................................................................26
for(int i=0;i<mSIZE;i++).........................................................................................................26
{if(memery [i]== -1)................................................................................................................26
{printf("| | ");}...........................................................................................................................26
else............................................................................................................................................26
printf("|%d| ",memery [i]); } printf("\t");.................................................................................26
}................................................................................................................................................26
else.............................................................................................................................................26
if(count == mSIZE)..................................................................................................................26
{................................................................................................................................................26
//lost++;....................................................................................................................................26
for(j=0;j<mSIZE; )...................................................................................................................26
{................................................................................................................................................26
if(state[j] == 0).........................................................................................................................26
{................................................................................................................................................26
break;.........................................................................................................................................26
}................................................................................................................................................26
else{..........................................................................................................................................26