Java模拟操作系统实现存储管理Word版_第1页
Java模拟操作系统实现存储管理Word版_第2页
Java模拟操作系统实现存储管理Word版_第3页
Java模拟操作系统实现存储管理Word版_第4页
Java模拟操作系统实现存储管理Word版_第5页
已阅读5页,还剩11页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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()+

5、", getpageinaddress()=" + this.getpageinaddress()+ ", getclass()=" + this.getclass() + ", hashcode()="+ this.hashcode() + ", tostring()=" + super.tostring() + ""package xiao.zhang.bean;import java.util.linkedlist;public class executefifo 传播优秀word版文档

6、,希望对您有帮助,可双击去除!/* * 指令队列 */public linkedlist<instruction> is;/* * 页面存储 */public linkedlist<page> pages;/* * 是否还有存储页架 */private final int isuseablepageframe;public static int point = 0;/* * 默认设置页架为4个 */public executefifo() this.isuseablepageframe = 4;传播优秀word版文档 ,希望对您有帮助,可双击去除!public exec

7、utefifo(int isuseablepageframe) is = new linkedlist<instruction>();pages = new linkedlist<page>();this.isuseablepageframe = isuseablepageframe;public executefifo(linkedlist<instruction> is, linkedlist<page> pages,int isuseablepageframe) this.is = is;this.pages = pages;this.is

8、useablepageframe = isuseablepageframe;/* * 一次性调度完成,装载所有的可用的页 */public void initalexecute() for (int i = 0; i < isuseablepageframe; i+) /* * 从指令队列出一条指令 */传播优秀word版文档 ,希望对您有帮助,可双击去除!instruction ins = is.poll();/* * 访问指定页号的主存 */page p = pages.get(i);p.setpageid(ins.getpageid();p.setinmen(true);p.set

9、modifyflag(ismodify(ins.getop();printininformation(ins);/* * 执行指令 */public void executeinstruction() /* * 先判断执行的页是否住存 指令序列中将其删除 */while (!is.isempty() instruction ins = is.poll();if (isexistmemeroy(ins) 传播优秀word版文档 ,希望对您有帮助,可双击去除!system.out.println("页号为:t" + ins.getpageid() + "t存在&quo

10、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 % isuseablepageframe);p.setpageframeid(outp.getpagefr

11、ameid();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(i).getpageid() = ins.getpageid

12、()&& 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" + "物理

13、地址:"+ (1024 * ins.getpageid() + ins.getpageinaddress() + "");/* * 打印调出信息 * * param p */public void printoutinformation(page p) if (p.ismodifyflag() system.out.println("页号:" + p.getpageid() + "toutt" + "页架号:"+ p.getpageframeid() + "t修改t" + "

14、写回磁盘:"+ p.getlocationindisk() + ""); else system.out.println("页号:" + p.getpageid() + "toutt" + "页架号:"+ p.getpageframeid() + "t未修改t" + "不用写回磁盘");传播优秀word版文档 ,希望对您有帮助,可双击去除!/* * 判断指令是否修改主存内容 * * param op * return */public boolean ismodif

15、y(string op) if (op.equals("r") | op.equals("w") return true;return false;/* * return the isuseablepageframe */public int getisuseablepageframe() return isuseablepageframe;传播优秀word版文档 ,希望对您有帮助,可双击去除!/* * return the is */public linkedlist<instruction> getis() return this.is;

16、/* * return the pages */public linkedlist<page> getpages() return this.pages;/* * param is * the is to set */public void setis(linkedlist<instruction> is) this.is = is;传播优秀word版文档 ,希望对您有帮助,可双击去除!/* * param pages * the pages to set */public void setpages(linkedlist<page> pages) this

17、.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 instruction("-&

18、quot;, 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 = new instruc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论