The goal of this program is Process Scheduling, change part of the code of from First_In_First_Out to Shortest_Job_First. I am spinning wheels now and I have made changes many times, I still get different exception errors...need help here..
This is the section of the code that I believe is giving me the hang ups..
public PCB popFront()
{
int time[] = new int[4];
int a[] = new int[4];
PCB p = null;
int shorttime = 0, temptime = 0;
if(vReady.size() == 0)
return null;
else
{
PCB pcb = (PCB) vReady.elementAt(0);
//vReady.remove(0);
for (int i=0; i < vReady.size(); ++i){
p = (PCB) vReady.get(i);
time = p.getHistory();
temptime = time;
if ((temptime < shorttime) || (i == 0)) {
shorttime = temptime;
pcb = p;
}
}
//a = pcb.getHistory();
//Arrays.sort(a);
//p("array: " + a[0] +" " + a[1] + " " + a[2] + " " + a[3]);
//p(" popFront " + pcb + " new size " + vReady.size()); vReady.remove(pcb);
return pcb;
}
}
********************************************************
This is the error message...
Exception: java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
at opsys.sched.cpu.STSchedSJF_popFront(STSchedSJF.java:60)
at opsys.sched.Kernel.runKernel(Kernel.java:114)
at opsys.sched.CPU.clockTick(CPU.java:95)
at opsys.sched.Sim.doSim(Sim.java:82)
at opsys.sched.SimTrend.<init>(SimTrend.java:109)
at opsys.sched.SimSet.<init>(SimSet.java:36)
at opsys.sched.cpu.STSchedSJF.main(STSchedSJF.java:84)
Thanks for the help..
This is the section of the code that I believe is giving me the hang ups..
public PCB popFront()
{
int time[] = new int[4];
int a[] = new int[4];
PCB p = null;
int shorttime = 0, temptime = 0;
if(vReady.size() == 0)
return null;
else
{
PCB pcb = (PCB) vReady.elementAt(0);
//vReady.remove(0);
for (int i=0; i < vReady.size(); ++i){
p = (PCB) vReady.get(i);
time = p.getHistory();
temptime = time;
if ((temptime < shorttime) || (i == 0)) {
shorttime = temptime;
pcb = p;
}
}
//a = pcb.getHistory();
//Arrays.sort(a);
//p("array: " + a[0] +" " + a[1] + " " + a[2] + " " + a[3]);
//p(" popFront " + pcb + " new size " + vReady.size()); vReady.remove(pcb);
return pcb;
}
}
********************************************************
This is the error message...
Exception: java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
at opsys.sched.cpu.STSchedSJF_popFront(STSchedSJF.java:60)
at opsys.sched.Kernel.runKernel(Kernel.java:114)
at opsys.sched.CPU.clockTick(CPU.java:95)
at opsys.sched.Sim.doSim(Sim.java:82)
at opsys.sched.SimTrend.<init>(SimTrend.java:109)
at opsys.sched.SimSet.<init>(SimSet.java:36)
at opsys.sched.cpu.STSchedSJF.main(STSchedSJF.java:84)
Thanks for the help..