2012-11-10 10:44:10 -05:00
|
|
|
import java.lang.reflect.*;
|
|
|
|
|
2012-11-06 20:12:32 -05:00
|
|
|
public class dummyAlgorithm implements baseAlgorithm{
|
2012-11-05 17:59:08 -05:00
|
|
|
|
|
|
|
int[] memoryBlock;
|
|
|
|
|
2012-11-06 19:53:11 -05:00
|
|
|
dummyAlgorithm(int memorySize){
|
2012-11-05 17:59:08 -05:00
|
|
|
/* Constructor needed for each algorithm */
|
|
|
|
memoryBlock = new int[memorySize];
|
|
|
|
}
|
|
|
|
|
2012-11-06 20:12:32 -05:00
|
|
|
public void allocate(int jobID, int jobSize, int jobTime){
|
2012-11-05 17:59:08 -05:00
|
|
|
/* This method to be overloaded by each algorithm */
|
2012-11-10 10:44:10 -05:00
|
|
|
|
|
|
|
//Generic code to get this classes deallocate() method
|
|
|
|
Method deallocateMethod;
|
|
|
|
try {
|
|
|
|
deallocateMethod = this.getClass().getMethod("deallocate", new Class[]{int.class, int.class});
|
|
|
|
Job newJob = new Job(jobTime, jobID, jobSize, 999, deallocateMethod, this);
|
|
|
|
newJob.start();
|
|
|
|
System.out.println("Allocating job " + jobID + " with size: " + jobSize + " for: " + jobTime + " milliseconds.");
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2012-11-05 17:59:08 -05:00
|
|
|
}
|
2012-11-10 10:44:10 -05:00
|
|
|
|
2012-11-06 20:12:32 -05:00
|
|
|
public void deallocate(int jobSize, int beginningLocation){
|
2012-11-10 10:44:10 -05:00
|
|
|
System.err.println("Removing job with size: " + jobSize + " beginning at: " + beginningLocation);
|
2012-11-05 17:59:08 -05:00
|
|
|
}
|
|
|
|
}
|