您的当前位置:首页正文

JAVA分页式存储管理算法

2023-10-13 来源:易榕旅网
闽江学院 软件学院 2014 周艺伟 某年某月某作业 package cn.edu.mju.zyw;

public class Block { private int id;

private boolean state; private int wy;

public int size = 2048; int jid; int pageid;

public int getJid() { return jid; }

public void setJid(int jid) { this.jid = jid; }

public int getPageid() { return pageid; }

public void setPageid(int pageid) { this.pageid = pageid; }

public int getId() { return id; }

public void setId(int id) { this.id = id; }

public boolean isState() { return state; }

public void setState(boolean state) { this.state = state; }

public int getWy() { return wy; }

public void setWy(int wy) { this.wy = wy; } }

package cn.edu.mju.zyw;

public class Init { int assigned=0; String Jname;

Block block[] = new Block[33]; int bnum = block.length; int notAssign;

public Init(){ for(int i= 0;ipublic int getAssigned() { return assigned; }

public void setAssigned(int assigned){ this.assigned = assigned; }

public int getBnum() { return bnum; }

public void setBnum(int bnum) { this.bnum = bnum; } }

package cn.edu.mju.zyw;

public class Show { //Init a = new Init(); //Block b = new Block();

public Show(Job j){ System.out.println(\"总块号:\"+j.s.block.length+\已分配:\"+j.s.notAssign+\每块大小:\"+j.b.size); for(int i = 0;i\"+j.s.assigned+\剩余: } else if(j.s.block[i].getWy()>0) System.out.println(\"作业:\"+j.s.block[i].getJid()+\",\"+j.s.block[i].getPageid()+\块号:\"+i+\页内位移:\"+j.s.block[i].getWy()); else System.out.println(\"作业:\"+j.s.block[i].getJid()+\",页号:

页号:

\"+j.s.block[i].getPageid()+\块号:\"+i); } } }

package cn.edu.mju.zyw;

import java.util.Scanner;

public class Fenye { public static void main(String[] args) { Job j = new Job(); Scanner input = new Scanner(System.in); new Show(j); while(true){ System.out.println(\"x退出 1申请内存 String ac=input.next(); if(\"1\".equals(ac)){ System.out.println(\"输入作业号\"); int jId=input.nextInt(); System.out.println(\"输入作业大小\"); int jSize=input.nextInt(); j.app(jId, jSize); } if(\"2\".equals(ac)){ System.out.println(\"输入作业号\"); int jId=input.nextInt(); j.release(jId); } if(\"x\".equals(ac)){ break; } new Show(j); } //j.app(1, 2500);

2释放内存\"); }

}

//j.app(2, 5250); //j.app(3, 5000);

//System.out.println(\"释放前\"+j.s.block[1].isState()); //new Show(j); //j.release(1); //j.release(2); //j.app(3, 5000);

//System.out.println(\"释放后\"+j.s.block[1].isState());

因篇幅问题不能全部显示,请点此查看更多更全内容