Java模拟操作系统实现存储管理Word版.doc

上传人:rrsccc 文档编号:9420884 上传时间:2021-02-25 格式:DOC 页数:16 大小:325KB
返回 下载 相关 举报
Java模拟操作系统实现存储管理Word版.doc_第1页
第1页 / 共16页
Java模拟操作系统实现存储管理Word版.doc_第2页
第2页 / 共16页
Java模拟操作系统实现存储管理Word版.doc_第3页
第3页 / 共16页
Java模拟操作系统实现存储管理Word版.doc_第4页
第4页 / 共16页
Java模拟操作系统实现存储管理Word版.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《Java模拟操作系统实现存储管理Word版.doc》由会员分享,可在线阅读,更多相关《Java模拟操作系统实现存储管理Word版.doc(16页珍藏版)》请在三一文库上搜索。

1、传播优秀Word版文档 ,希望对您有帮助,可双击去除!存储器管理1实验内容:模拟请求页式存储管理中硬件的地址转换和缺页中断,并用先进先出调度算法(FIFO)处理缺页中断;2要求: 指令序列的设定可以执行拟定,格式如表3; 在完成了FIFO换页策略后,可以选做LRU的换页策略,并进行比较; 作业允许的页架数m在不同情况下的缺页中断率; 程序运行时显示地址转变和页面调入调出过程。3.实验控制流图:4数据结构核心代码:传播优秀Word版文档 ,希望对您有帮助,可双击去除!package xiao.zhang.bean;public class Instruction /* * 指令操作符号 */pr

2、ivate String op;/* * 页号 */private int pageId;/* * 页内地址 */private int pageInAddress;public Instruction() public Instruction(String op, int pageId, int pageInAddress) this.op = op;传播优秀Word版文档 ,希望对您有帮助,可双击去除!this.pageId = pageId;this.pageInAddress = pageInAddress;public String getOp() return op;public

3、void setOp(String op) this.op = op;public int getPageId() return pageId;public void setPageId(int pageId) this.pageId = pageId;public int getPageInAddress() return pageInAddress;public void setPageInAddress(int pageInAddress) this.pageInAddress = pageInAddress;传播优秀Word版文档 ,希望对您有帮助,可双击去除!/* * (non-Ja

4、vadoc) * * see java.lang.Object#toString() */Overridepublic String toString() return Instruction op= + this.op + , pageId= + this.pageId+ , pageInAddress= + this.pageInAddress + , getOp()=+ this.getOp() + , getPageId()= + this.getPageId()+ , getPageInAddress()= + this.getPageInAddress()+ , getClass(

5、)= + this.getClass() + , hashCode()=+ this.hashCode() + , toString()= + super.toString() + ;package xiao.zhang.bean;import java.util.LinkedList;public class ExecuteFiFo 传播优秀Word版文档 ,希望对您有帮助,可双击去除!/* * 指令队列 */public LinkedList is;/* * 页面存储 */public LinkedList pages;/* * 是否还有存储页架 */private final int i

6、sUseablePageFrame;public static int point = 0;/* * 默认设置页架为4个 */public ExecuteFiFo() this.isUseablePageFrame = 4;传播优秀Word版文档 ,希望对您有帮助,可双击去除!public ExecuteFiFo(int isUseablePageFrame) is = new LinkedList();pages = new LinkedList();this.isUseablePageFrame = isUseablePageFrame;public ExecuteFiFo(LinkedL

7、ist is, LinkedList pages,int isUseablePageFrame) this.is = is;this.pages = pages;this.isUseablePageFrame = isUseablePageFrame;/* * 一次性调度完成,装载所有的可用的页 */public void initalExecute() for (int i = 0; i isUseablePageFrame; i+) /* * 从指令队列出一条指令 */传播优秀Word版文档 ,希望对您有帮助,可双击去除!Instruction ins = is.poll();/* * 访

8、问指定页号的主存 */Page p = pages.get(i);p.setPageId(ins.getPageId();p.setInMen(true);p.setModifyFlag(isModify(ins.getOp();printINInformation(ins);/* * 执行指令 */public void executeInstruction() /* * 先判断执行的页是否住存 指令序列中将其删除 */while (!is.isEmpty() Instruction ins = is.poll();if (isExistMemeroy(ins) 传播优秀Word版文档 ,希

9、望对您有帮助,可双击去除!System.out.println(页号为:t + ins.getPageId() + t存在);Page p = pages.get(ins.getPageId();printOUTInformation(p);printINInformation(ins); else System.out.println(页号为:t + ins.getPageId() + t不存在);Page p = pages.get(ins.getPageId();p.setInMen(true);Page outP = pages.get(point % isUseablePageFra

10、me);p.setPageFrameId(outP.getPageFrameId();p.setModifyFlag(isModify(ins.getOp();printOUTInformation(outP);printINInformation(ins);point+;/* * 判断指定序列是否住存传播优秀Word版文档 ,希望对您有帮助,可双击去除! * * return */public boolean isExistMemeroy(Instruction ins) for (int i = 0; i this.pages.size(); i+) if (this.pages.get(

11、i).getPageId() = ins.getPageId()& this.pages.get(i).isInMen() return true;return false;/* * 打印装载信息 * * param ins */public void printINInformation(Instruction ins) System.out.println(页号: + ins.getPageId() + tINt + 执行:传播优秀Word版文档 ,希望对您有帮助,可双击去除!+ ins.getOp() + 操作t + 物理地址:+ (1024 * ins.getPageId() + in

12、s.getPageInAddress() + );/* * 打印调出信息 * * param p */public void printOUTInformation(Page p) if (p.isModifyFlag() System.out.println(页号: + p.getPageId() + tOUTt + 页架号:+ p.getPageFrameId() + t修改t + 写回磁盘:+ p.getLocationInDisk() + ); else System.out.println(页号: + p.getPageId() + tOUTt + 页架号:+ p.getPageFr

13、ameId() + t未修改t + 不用写回磁盘);传播优秀Word版文档 ,希望对您有帮助,可双击去除!/* * 判断指令是否修改主存内容 * * param op * return */public boolean isModify(String op) if (op.equals(R) | op.equals(W) return true;return false;/* * return the isUseablePageFrame */public int getIsUseablePageFrame() return isUseablePageFrame;传播优秀Word版文档 ,希望

14、对您有帮助,可双击去除!/* * return the is */public LinkedList getIs() return this.is;/* * return the pages */public LinkedList getPages() return this.pages;/* * param is * the is to set */public void setIs(LinkedList is) this.is = is;传播优秀Word版文档 ,希望对您有帮助,可双击去除!/* * param pages * the pages to set */public void

15、setPages(LinkedList pages) this.pages = pages;package xiao.zhang;import xiao.zhang.bean.ExecuteFiFo;import xiao.zhang.bean.Instruction;import xiao.zhang.bean.Page;public class MainExecute public static void main(String args) Instruction i = new Instruction12;i0 = new Instruction(+, 0, 70);i1 = new I

16、nstruction(-, 1, 50);传播优秀Word版文档 ,希望对您有帮助,可双击去除!i2 = new Instruction(*, 2, 15);i3 = new Instruction(R, 3, 21);i4 = new Instruction(W, 0, 56);i5 = new Instruction(-, 6, 40);i6 = new Instruction(RM, 4, 53);i7 = new Instruction(+, 5, 23);i8 = new Instruction(W, 1, 37);i9 = new Instruction(R, 2, 78);i10

17、 = new Instruction(+, 4, 1);i11 = new Instruction(W, 6, 84);Page p = new Page7;p0 = new Page(0, true, 5, false, 11);p1 = new Page(2, true, 8, false, 12);p2 = new Page(3, true, 9, false, 13);p3 = new Page(4, true, 1, false, 21);p4 = new Page(5, false, 0, false, 22);p5 = new Page(6, false, 0, false, 23);p6 = new Page(7, false, 0, false, 121);ExecuteFiFo xf = new ExecuteFiFo(4);for (int j = 0; j p.length; j+) 传播优秀Word版文档 ,希望对您有帮助,可双击去除!xf.getPages().add(pj);for (int j = 0; j i.length; j+) xf.getIs().add(ij);xf.initalExecute();xf.executeInstruction();传播优秀Word版文档 ,希望对您有帮助,可双击去除!6.程序运行结构截图:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1