I am working on a quick Shortest Job first algorithm and ran into a problem. I can't figure a way to implement, each way I try I get the wrong next process.

private static int lowTIme(ArrayList<Process> testProcesss,
			int currTime) {
		int i;
		int temp = testProcesss.get(0).getcpuTime();
		for(i = 1; currTime > testProcesss.get(i).getArrivalTime()
					&& temp < testProcesss.get(i).getcpuTime(); i++){
			temp = testProcesss.get(i).getcpuTime();
		return 0;


Process: 1
Arrival Time: 0
CPU Time: 5

Process: 2
Arrival Time: 2
CPU Time: 1

Process: 3
Arrival Time: 3
CPU Time: 8

Process: 4
Arrival Time: 3
CPU Time: 3

Okay first time around it will choose Process 1, the next would be 2, and the 3.

But it will choose process 2, even though it hasn't arrived

Any help?

7 Years
Discussion Span
Last Post by .11

Forget it, I know what wrong, I am giving it the all the process not the one's that are ready that I created....Lawls!

My first implementation will work

topic can be closed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.