在内存划出一块区域,并进行页面划分;设计请求页表;模拟页面分配;分别模拟“先进先出页面淘汰算法FIFO”、“最近最少使用页面淘汰算法LRU”和“理想型淘汰算法OPT” 本程序随机产生请求序列,分别模拟FIFO,LRU,OPT 三种算法
将结果保存在FIFO
txt,LRU
txt,OPT
txt 三个文件中
程序代码: #include #include #include #define N 20 #define P 3 struct DuLNode{ int data; struct DuLNode *prior; struct DuLNode *next; }; int pageFIFO[N+1]; int front=0,rear=0; int pageing[N+1],pmem[P+1]; int memcount=1; void init(int a[],int T) { int i; for(i=0;iprior->next=add; add->next=p; p->prior=add; } int getI(struct DuLNode *p,int e) { int i; struct DuLNode *cd=p; for(i=1;;i++) { cd=cd->next; if(cd->data==e) return i; if(cd==p) return -1; } } void deleLink(struct DuLNode *p,int i,int *e) { int n; struct DuLNode *cd=p; for(n=1;nnext; *e=cd->data; cd->prior->next=cd->next; cd->next->prior=cd->prior; free(cd); } void removebottom(struct