/** Main program for Programming assignment 3. ** Simulate cpu scheduling. ** This version does RR and calls skeletons for the other schedulers. **/ public class Proj3 { final static String usage = "usage: java Proj3 [-v...] [-t] [-cTYPE] data-file quantum\n" + " ctype is cRR, cX1, or cX2\n"; public static void main(String argv[]) throws Exception { int arg, pos, cpuSched = Sim.CPU_RR; for (arg = 0; arg < argv.length; arg++) { if (argv[arg].charAt(0) != '-') break; for (pos = 1; pos < argv[arg].length(); pos++) { switch (argv[arg].charAt(pos)) { case 'v': for (int po = 1; po < argv[arg].length(); po++) { if (argv[arg].charAt(po) != 'v') throw new RuntimeException(usage); Sim.moreVerbose(); } break; case 't': Sim.traceFlag = true; // <-- break; case 'c': if (argv[arg].substring(2).toUpperCase().equals("RR")) cpuSched = Sim.CPU_RR; else if (argv[arg].substring(2).toUpperCase().equals("X1")) cpuSched = Sim.CPU_XQ1; else if (argv[arg].substring(2).toUpperCase().equals("X2")) cpuSched = Sim.CPU_XQ2; else throw new RuntimeException( "Unknown cpu scheduler type: '" + argv[arg].substring(2) + "'\n" + usage); pos += 2; break; default: throw new Exception(usage); } } } if (argv.length - arg != 2) throw new Exception(usage); //System.out.println("==========> arg["+(arg+1)+"]="+argv[arg+1]); Sim.QUANTUM = Integer.parseInt(argv[arg+1]); // <-- //System.out.println("==========> arg["+(arg)+"]="+argv[arg]); Sim.mainLoop(argv[arg] , cpuSched); // <-- } static private void pl(String msg) { System.out.println( msg ); } } // Proj3