資源簡介
c語言寫的用與頁面置換的代碼,其中包括FIFO算法,LRU算法,LFU算法和NUR算法
代碼片段和文件信息
#include
#include
//#include
#define?true?1
#define?false?0
#define?invalid?-1
#define?nul?0
#define?total_instruction?320 /*指令流長*/
#define?total_vp?32 /*虛頁長*/
#define?clear_period?50 /*清零周期*/
typedef?struct /*頁面結構*/
{
int?pn//頁面序號
pfn//頁面所在內存區的幀號
counter//一個周期內訪問該頁面的次數
time;//上次訪問的時間
}pl_type;
pl_type?pl[total_vp];//頁面結構數組
struct?pfc_struct /*頁面控制結構*/
{
int?pnpfn;
struct?pfc_struct?*next;//頁面指針,用于維護內存緩沖區的鏈式結構
};
typedef?struct?pfc_struct?pfc_type;//主存區頁面控制結構別名
pfc_type?pfc[total_vp]//主存區頁面控制結構數組
*freepf_head //主存區頁面控制結構的空閑頁面頭指針
*busypf_head //為忙頁面頭的指針
*busypf_tail; //為忙頁面尾的指針
int?diseffect //頁錯誤計數器,初次把頁面載入主存時也當做頁錯誤
a[total_instruction];?//隨即指令流數組
int?page[total_instruction]?//指令對應的頁面號
offset[total_instru
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5887??2016-01-12?22:38??頁面置換.c
評論
共有 條評論