2022年页面调度算法 .pdf
《2022年页面调度算法 .pdf》由会员分享,可在线阅读,更多相关《2022年页面调度算法 .pdf(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include #include #include #define null 0 #define len sizeof(struct page) struct page int num; int tag; struct page *next; ; struct page *create(int n) int count=1; struct page *p1,*p2,*head; head=p1=p2=(struct page*)malloc(len); p1-tag=-1; p1-num=-1; while(counttag=-1; p1-num=-1; p2-next=p1; 名师资料总结
2、 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 7 页 - - - - - - - - - p2=p1; p2-next=null; return(head); void FIFO(int array,int n) int *p; struct page *cp,*dp,*head,*New; int count=0; head=create(n); p=array; while(*p!=-1) cp=dp=head; for(;cp-num!=*p&cp-next!=null;)
3、cp=cp-next; if(cp-num=*p) printf(!); else count+; cp=head; for(;cp-tag!=-1&cp-next!=null;) cp=cp-next; if(cp-tag=-1) cp-num=*p; cp-tag=0; printf(*); /if else New=(struct page*)malloc(len); New-num=*p; New-tag=0; New-next=null; cp-next=New; head=head-next; printf(%d,dp-num); free(dp); /else /else 名师资
4、料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 7 页 - - - - - - - - - p+; /while printf(n 缺页次数 :%dn,count); void LRU(int array,int n) int count=0,*p=array; struct page *head,*cp,*dp,*rp,*New,*endp; head=create(n); while(*p!=-1) cp=dp=rp=endp=head; for(;endp-next!=n
5、ull;)endp=endp-next; for(;cp-num!=*p&cp-next!=null;) rp=cp; cp=cp-next; /for if(cp-num=*p) printf(!); if(cp-next!=null) if(cp!=head) rp-next=cp-next; else head=head-next; /if endp-next=cp; cp-next=null; /if else count+; cp=rp=head; for(;cp-tag!=-1&cp-next!=null;) cp=cp-next; if(cp-tag=-1) printf(*);
6、 cp-num=*p; cp-tag=0; /if else 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 7 页 - - - - - - - - - New=(struct page*)malloc(len); New-num=*p; New-tag=0; New-next=null; cp-next=New; dp=head; head=head-next; printf(%d,dp-num); free(dp); /else /else p+; /while pr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年页面调度算法 2022 页面 调度 算法
限制150内