实验编号4名称页面置换算法模拟实验目的通过请求页式存储管理中页面置换算法模拟设计,以便:1、了解虚拟存储技术的特点2、掌握请求页式存储管理中页面置换算法实验内容与步骤设计一个虚拟存储区和内存工作区,并使用FIFO 和 LRU算法计算访问命中率
先用 srand() 函数和 rand() 函数定义和产生指令序列,然后将指令序列变换成相应的页地址流,并针对不同的算法计算相应的命中率
#include
32 块时的命中率printf("%2d page frames",i);FIFO(i);n=i;fn=INVALID;ounter=0;ime=-1; ext=&pfc[i+1];pfc[i]
pfn=i;}pfc[total_pf-1]
next=NULL;pfc[total_pf-1]
pfn=total_pf-1;freepf_head=&pfc[0];fn==INVALID){fn=INVALID;freepf_head=busypf_head;fn=freepf_head->pfn;if(busypf_tail==NULL) busypf_head=busypf_tail=freepf_head;else{busypf_tail->next=freepf_head;6
4ffn==INVALID){ime&&pmt[j]
=INVALID){min=pmt[j]
time;minj=j;}freepf_head=&pfc[pmt[minj]
pfn];fn=INVALID;pmt[minj]
time=-1;freepf_head->next=NULL;}pmt[page[i]]
pfn=freepf_head->pfn;ime=present_time;freepf_head=freepf_head->next;ime=present_time;6