操作系统实验(金虎)实验二页面置换源代码.doc

操作系统实验(金虎)实验二页面置换源代码.doc

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
操作系统实验(金虎)实验二页面置换源代码

操作系统实验(金虎)实验二页面置换源代码 #includestdio.h #includemalloc.h #includeiostream.h #define L 10 typedef struct FixedList { int Pagenomber;//页号=(逻辑地址/块长) int PBnumber;//物理块号,根据找到位示图的空白而定 bool flag; int OuterAddress[L];//物理地址=块号*块长+余数 FixedList *next; FixedList *linkTo; }FixedList; typedef struct Static { int Pagenomber;//页号 Static *next; }Static; int AddressPhoto[8][8]={1,1,1,1,0,1,1,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,1,0, 1,1,0,1,0,1,1,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,1,0};//位示图 int IsMemoryFull(Static*queue,int memory) { Static*q=queue; int i=0; while(q-next){i=i+1;q=q-next;} if(i==memory)return 1; if(imemory)return 0; } void PreDeal(FixedList *head,int pageLength) { head-next=NULL; FixedList *tmp=head; for(int i=0;ipageLength;i++) { FixedList *p=(FixedList*)malloc(sizeof(FixedList)); p-next=NULL; p-Pagenomber=i; p-flag=0; for(int j=0;jL;j++) { p-OuterAddress[j]=-1; } tmp-next=p; tmp=tmp-next; } } /* 页 块 状态 物理地址 0 0 -1,-1,-1,-1 1 0 -1 2 0 -1 3 0 -1 4 0 5 0 M9 */ void Push(FixedList *h,Static *queue) { Static *q=(Static *)malloc(sizeof(Static)); q-Pagenomber=h-Pagenomber; q-next=NULL; Static *n=queue; while(n-next){n=n-next;} n-next=q; } void FIFO(FixedList *head,FixedList *h,Static *queue) { FixedList *tok=head-next; Static *q=queue-next; while(tok-Pagenomber!=q-Pagenomber){tok=tok-next;} //weishitu //q-Pagenomber=tok-Pagenomber; h-PBnumber=tok-PBnumber; h-flag=1; // h-OuterAddress=h-PBnumber*; tok-flag=0; for(int i=0;iL;i++){tok-OuterAddress[i]=-1;} queue-next=q-next;//free(q) Static *n=(Static *)malloc(sizeof(Static)); n-Pagenomber=h-Pagenomber; n-next=NULL; Static *m=queue; while(m-next){m=m-next;} m-next=n; //h- } void Init(FixedList *head,int blocklength,Static *queue,int k,int pageLength,int memory) { int logicAddress,Page,remain; cout输入逻辑地址:endl; cinlogicAddress; Page=logicAddress/blocklength;//页号=(逻辑地址/块长),根据页号找到对应的块

文档评论(0)

sy78219 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档