Created
April 22, 2015 01:59
-
-
Save astro-gokart/4ad600d44192b0e2899a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tatic public void RR(Processor proc) { | |
System.out.printf("%d processes\n",proc.ready_queue.size()); | |
System.out.println("Using Round-Robin"); | |
System.out.printf("Quantum %d",proc.quantum); | |
int rt = 0; | |
Job current; | |
current = proc.ready_queue.peekFirst(); | |
for(int i=0;i<proc.duration;i++) { //timer | |
// check what processes have arrived at time | |
proc.checkArrival(i); | |
//check if processes have finished | |
proc.checkFinishedProcesses(i); | |
//select current process | |
current = proc.selectJobRR(i,rt); | |
//adjust accordingly | |
if(current != null) { | |
if (current.arrived && !current.finished) | |
current.elapsed--; | |
} | |
if(rt == proc.quantum) { | |
rt =0; | |
} | |
rt++; | |
} | |
System.out.printf("Finished at time %d\n", proc.duration); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment