Commit 133e4f48 authored by Nils Vreman's avatar Nils Vreman
Browse files

Added fixedpriority strategy to the strategy pool

parent db88da52
all:
javac gui/ScheduLearn.java
java gui.ScheduLearn
find . -name "*.class" -type f -delete
clean:
find . -name "*.class" -type f -delete
package gui.menu;
import model.SchedulingModel;
import strategy.FixedPriority;
public class FPStrategyMenuItem extends StrategyMenuItem {
public FPStrategyMenuItem(SchedulingModel scheduleMdl) {
super(scheduleMdl, new FixedPriority(), "FP");
}
}
......@@ -26,6 +26,7 @@ public class ScheduLearnMenuBar extends JMenuBar {
edit.add(new ClearTasksetMenuItem(taskset));
edit.add(new ClearAllMenuItem(scheduleMdl));
strategy.add(new NoneStrategyMenuItem(scheduleMdl));
strategy.add(new FPStrategyMenuItem(scheduleMdl));
strategy.add(new EDFStrategyMenuItem(scheduleMdl));
strategy.add(new RMSStrategyMenuItem(scheduleMdl));
......
package strategy;
import tasks.Taskset;
import tasks.Task;
import java.util.Comparator;
import java.util.Queue;
import java.util.PriorityQueue;
import java.util.Map;
import java.util.HashMap;
public class FixedPriority extends QueueStrategy {
protected Queue<Integer> updateQueue(Queue<Integer> q, Taskset ts, int time) {
Comparator<Integer> order =
(Integer i1, Integer i2) -> {
return i1 - i2;
};
Queue<Integer> internalQ = new PriorityQueue<>(order);
while (q.size() != 0) internalQ.add(q.poll());
//If we are at a job release, add that much CPU usage to the Q.
for (int taskNbr : ts.getPriorities()) {
Task t = ts.getTask(taskNbr).get(); //I know it exists so I can collect it from the optional directly
if (time % t.period() == 0) {
for (int i = 0; i < t.exectime(); i++) {
internalQ.add(taskNbr);
}
}
}
return internalQ;
}
/*
* Return which Strategy you are using
*/
public String toString() {
return "FP";
}
/*
* Return a Comparator for this scheduling strategy
*/
public Comparator<Task> prioComparator() {
return new FixedPriorityComparator();
}
}
package strategy;
import tasks.Task;
public class FixedPriorityComparator implements PriorityComparator {
/*
* compares two tasks according to scheduling algorithm.
*/
public int compare(Object o1, Object o2) {
return 1;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment