内存管理FIFO算法(实验7) 您所在的位置:网站首页 页缓冲队列长度影响页面置换速度 内存管理FIFO算法(实验7)

内存管理FIFO算法(实验7)

2024-07-12 08:07| 来源: 网络整理| 查看: 265

编程实验任务 编写一个程序,用rand()生成一个随机的页访问序列,该序列长度为320;采用FIFO的页面置换策略,计算当页数为32,帧数为4~32时的页面访问命中率。(命中率=1-页面失效次数/页面访问序列长度。)

注:在计算过程中,需要构造一个页面数组,一个页面访问序列,一个空闲帧队列,一个被占用帧队列。

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102#include #include #include #include struct pl_type {     int pn,pfn; }; struct pfc_struct {     int pn,pfn;     struct pfc_struct * next; }; int s[320];                 struct pl_type pl[32];  struct pfc_struct pfc[32];  struct pfc_struct * freepf_head,* busypf_head,* busypf_tail; void initial(int pf); void fifo(int pf); int main() {     int i,total_pf;     srand(getpid());                for(i=0;inext=NULL;             freepf_head->pn=s[i];             pl[s[i]].pfn=freepf_head->pfn;             if(busypf_tail==NULL)                 busypf_head=busypf_tail=freepf_head;             else             {                 busypf_tail->next=freepf_head;                 busypf_tail=freepf_head;                 busypf_tail->next=NULL;             }             freepf_head=p;         }     }     printf("%d frames %f\n",pf,1-(float)diseffect/320); }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有