欢迎来到天天文库
浏览记录
ID:47430439
大小:300.85 KB
页数:16页
时间:2020-01-11
《Java模拟操作系统实现存储管理》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、存储器管理1.实验内容:模拟请求页式存储管理中硬件的地址转换和缺页中断,并用先进先出调度算法(FIFO)处理缺页中断;2.要求:①指令序列的设定可以执行拟定,格式如表3;②在完成了FIFO换页策略后,可以选做LRU的换页策略,并进行比较;③作业允许的页架数m在不同情况下的缺页中断率;④程序运行时显示地址转变和页面调入调出过程。3.实验控制流图:4.数据结构核心代码:packagexiao.zhang.bean;publicclassInstruction{/***指令操作符号*/privateString
2、op;/***页号*/privateintpageId;/***页内地址*/privateintpageInAddress;publicInstruction(){}publicInstruction(Stringop,intpageId,intpageInAddress){this.op=op;this.pageId=pageId;this.pageInAddress=pageInAddress;}publicStringgetOp(){returnop;}publicvoidsetOp(Stringo
3、p){this.op=op;}publicintgetPageId(){returnpageId;}publicvoidsetPageId(intpageId){this.pageId=pageId;}publicintgetPageInAddress(){returnpageInAddress;}publicvoidsetPageInAddress(intpageInAddress){this.pageInAddress=pageInAddress;}/**(non-Javadoc)**@seejava
4、.lang.Object#toString()*/@OverridepublicStringtoString(){return"Instruction[op="+this.op+",pageId="+this.pageId+",pageInAddress="+this.pageInAddress+",getOp()="+this.getOp()+",getPageId()="+this.getPageId()+",getPageInAddress()="+this.getPageInAddress()+"
5、,getClass()="+this.getClass()+",hashCode()="+this.hashCode()+",toString()="+super.toString()+"]";}}packagexiao.zhang.bean;importjava.util.LinkedList;publicclassExecuteFiFo{/***指令队列*/publicLinkedListis;/***页面存储*/publicLinkedListpages;/**
6、*是否还有存储页架*/privatefinalintisUseablePageFrame;publicstaticintpoint=0;/***默认设置页架为4个*/publicExecuteFiFo(){this.isUseablePageFrame=4;}publicExecuteFiFo(intisUseablePageFrame){is=newLinkedList();pages=newLinkedList();this.isUseablePageFrame=
7、isUseablePageFrame;}publicExecuteFiFo(LinkedListis,LinkedListpages,intisUseablePageFrame){this.is=is;this.pages=pages;this.isUseablePageFrame=isUseablePageFrame;}/***一次性调度完成,装载所有的可用的页*/publicvoidinitalExecute(){for(inti=0;i8、eFrame;i++){/***从指令队列出一条指令*/Instructionins=is.poll();/***访问指定页号的主存*/Pagep=pages.get(i);p.setPageId(ins.getPageId());p.setInMen(true);p.setModifyFlag(isModify(ins.getOp()));printINInformation(ins);}}/***执行指令*/publicv
8、eFrame;i++){/***从指令队列出一条指令*/Instructionins=is.poll();/***访问指定页号的主存*/Pagep=pages.get(i);p.setPageId(ins.getPageId());p.setInMen(true);p.setModifyFlag(isModify(ins.getOp()));printINInformation(ins);}}/***执行指令*/publicv
此文档下载收益归作者所有