RoundRobin.zip

  • PUDN用户
    了解作者
  • Java
    开发工具
  • 29KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2016-08-09 22:56
    上传日期
CPU Scheduling Round Robin
RoundRobin.zip
  • RoundRobin
  • src
  • Processes
  • processes.csv
    110B
  • generateProcessesCSV.py
    1.7KB
  • animeFrame.java
    4.7KB
  • RR4.java
    2.9KB
  • inputFrame.java
    5.1KB
  • Scheduler.java
    2.2KB
  • statsFrame.java
    3.8KB
  • GUI.java
    962B
  • Packet.java
    887B
  • ReadCSV.java
    1.2KB
  • AlgAnime.java
    4KB
  • processes1.csv
    80B
  • process.java
    2.3KB
  • RRinfo.java
    1.2KB
  • bin
  • inputFrame.class
    4.1KB
  • animeFrame.class
    3.3KB
  • GUI.class
    470B
  • Packet.class
    847B
  • Scheduler.class
    1.3KB
  • processes.csv
    110B
  • RR4.class
    2.5KB
  • AlgAnime.class
    3.3KB
  • process.class
    2KB
  • statsFrame.class
    3.2KB
  • ReadCSV.class
    2KB
  • java.policy.applet
    141B
  • RRinfo.class
    733B
  • .settings
  • org.eclipse.jdt.core.prefs
    598B
  • .project
    386B
  • .classpath
    301B
内容介绍
/***************************************************************** Input Frame PURPOSE: This is the input view that prompts user for input in order to run simulation. This view is meant for the instructor, author. *****************************************************************/ import java.awt.*; import java.util.Observable; @SuppressWarnings("serial") public class inputFrame extends Frame { TextArea proc,arriv,serv; Panel knobs; Choice alg; CheckboxGroup functions; Checkbox[] fun; Packet info; GUI vigil; String PrevBut; /*-------------------------------------------------------- Constructor PURPOSE: To generate the input view frame, and to ask animation view to be ready PARAMETERS: references the animation view --------------------------------------------------------*/ @SuppressWarnings("deprecation") public inputFrame(AlgAnime parent) { super("Input View"); vigil = new GUI(); vigil.addObserver((java.util.Observer)parent); ReadCSV processesFile=new ReadCSV(); processesFile.run(); String sampleP = ""; String sampleA = ""; String sampleS = ""; for(int i=1; i<processesFile.pNames.size(); i++){ sampleP+=processesFile.pNames.get(i)+"\n"; sampleA+=processesFile.pArriveTime.get(i)+"\n"; sampleS+=processesFile.pBurstTime.get(i)+"\n"; } proc = new TextArea(30,10); proc.setEditable(true); proc.appendText(sampleP); arriv = new TextArea(30,5); arriv.setEditable(true); arriv.appendText(sampleA); serv = new TextArea(30,5); serv.setEditable(true); serv.appendText(sampleS); alg = new Choice(); alg.addItem("RR3"); functions = new CheckboxGroup(); fun = new Checkbox[5]; fun[0] = new Checkbox("clear",functions,false); fun[1] = new Checkbox("run",functions,false); fun[2] = new Checkbox("pause",functions,false); fun[3] = new Checkbox("resume",functions,false); fun[4] = new Checkbox("quit",functions,false); PrevBut = ""; // init knobs = new Panel(); knobs.setLayout(new FlowLayout(FlowLayout.CENTER)); knobs.add(alg); knobs.add(fun[0]); knobs.add(fun[1]); knobs.add(fun[2]); knobs.add(fun[3]); knobs.add(fun[4]); Panel labels = new Panel(); labels.setLayout(new BorderLayout()); labels.add("West", new Label("Arrival time:")); labels.add("Center", new Label("Process name:")); labels.add("East", new Label("Service time:")); this.setLayout(new BorderLayout()); this.add("North",labels); this.add("West", arriv); this.add("Center",proc); this.add("East",serv); this.add("South", knobs); } // set display /*-------------------------------------------------------- Handle Event PURPOSE: To handle all events by dialog box --------------------------------------------------------*/ @SuppressWarnings("deprecation") public boolean handleEvent (Event evtObj) { if (evtObj.id == Event.WINDOW_DESTROY) { this.dispose(); return true; } // destroy button else if (evtObj.id==Event.ACTION_EVENT) if (evtObj.target==fun[0]) { proc.setText(""); arriv.setText(""); serv.setText(""); fun[1].enable(); String cmd = functions.getCurrent().getLabel(); vigil.input(cmd); return true; } // handle clear button else if (evtObj.target==fun[1]) { fun[1].disable(); info = new Packet(proc.getText(), arriv.getText(), serv.getText(), alg.getSelectedItem()); vigil.input(info); proc.setEditable(false); arriv.setEditable(false); serv.setEditable(false); return true; } // handle run button else if (evtObj.target==fun[2] || evtObj.target==fun[3]) { String cmd = functions.getCurrent().getLabel(); if (PrevBut.equals(cmd)) return false; else { PrevBut = cmd; // stagger for next event vigil.input(cmd); return true; } // balance pause to resume request } // handle pause/resume buttons else if (evtObj.target==fun[4]) { vigil.input("quit"); return true; } // handle quit option return false; } // handle event /*-------------------------------------------------------- Reset input GUI PURPOSE: To enable more input --------------------------------------------------------*/ @SuppressWarnings("deprecation") public void resetGUI() { proc.setEditable(true); serv.setEditable(true); arriv.setEditable(true); fun[1].enable(); } // allow user input } // input Frame
评论
    相关推荐