資源簡介
opt、FIFO、LRU/LFU、簡單clock、改進型clock等算法實現頁面置換
代碼片段和文件信息
#include
#include
#include
typedef?struct?item
{
int?num;?????????//頁號
int?time;????????//等待時間,LRU算法會用到這個屬性
int?M?;?????????//修改位
}Pro;
int?curmemory;?????????//調入主存中的頁面個數
int?missNum;???????????//缺頁次數
float?missRate;????????//缺頁率
int?pageNum;???????????//系統分配給作業的主存中的頁面數
int?memoryNum;?????????//可用內存頁面數
int?nru[200]?=?{?0?};????????????????//表示?物理塊?i?最近時候被訪問過?
Pro??page[100];?????????????//作業頁面集
Pro??memory[10];??????????//內存頁面集
void?handInput();
void?chooseInput();
void?fileInput();
void?print(Pro?*page1);????????//打印當前主存中的頁面
int??Search(int?num1?Pro?*memory1);????//在頁面集memory1中查找num1,如果找到,返回其在memory1中的下標,否則返回-1
int?Max(Pro?*memory1);?????????//尋找最近最長未使用的頁面
int?optimal(int?num?int?tag?Pro?*memory1?Pro?*page1);//最佳置換算法
void?Cl
- 上一篇:用C++做的霍夫曼編碼
- 下一篇:VC6.0改變按鈕的背景顏色
評論
共有 條評論