![](https://csdnimg.cn/release/download_crawler_static/87560546/bg3.jpg)
(完整 word 版)页面置换算法实验报告
2.页帧控制结构
struct pfc_struct{
int pn, pfn;
struct pfc_struct *next;};
typedef struct pfc_struct pfc_type;
pfc_type pfc[total_vp], *freepf_head, *busypf_head, *busypf_tail;
其中 pfc[total_vp]定义用户进程的页帧控制结构数组,在该实验中,用户内存工作区是动态变化的,最
多可达到用户进程的虚页数目,即 32 个物理块。
*freepf_head 为空闲页帧头的指针
*busypf_head 为忙页帧头的指针
*busypf_tail 忙页帧尾的指针
讲此结构封装到 PageControl。h 头文件中。
3。主要函数
(1) void initialize(int): 初始化函数
该函数主要对页面结构数组 pl 和页帧结构数组 pfc 进行初始化,如置页面结构中的页面号 pn,初始化
页帧号 pfn 为空,访问次数 counter 为 0,访问时间 time 为-1;同样对页帧数组进行初始化,形成一个空闲
页帧队列.
(2) void OPT(int): 计算使用最佳页面算法时的命中率
(3) void FIFO(int): 计算使用先进先出页面置换算法时的命中率
(4) void LRU(int): 计算使用最近最久未使用页面置换算法时的命中率
(5) void LFU(int): 计算使用最少使用置换算法时的命中率
void FIFO(int total_pf) /*先进先出页面置换算法*/
{
河南师范大学软件学院