Commit 6bc244f2 by Michael Schmid

Different algorithms work now, log doesn't work

parent 6b226c2e
/.vscode /.vscode
/.settings /.settings
/results
/target /target
\ No newline at end of file
package mvd.jester; package mvd.jester;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.priority.EarliestDeadlineFirst;
import mvd.jester.priority.RateMonotonic;
/** /**
...@@ -10,7 +12,10 @@ import mvd.jester.model.SystemSetup; ...@@ -10,7 +12,10 @@ import mvd.jester.model.SystemSetup;
public class App { public class App {
public static void main(String[] args) { public static void main(String[] args) {
SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8); SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
TestEnvironment te = new TestEnvironment(builder, 40000); TestEnvironment te = new TestEnvironment(builder, 4000);
te.registerSchedulingAlgorithm(new RateMonotonic());
te.registerSchedulingAlgorithm(new EarliestDeadlineFirst());
te.registerTestPair(mvd.jester.tests.MaiaBertogna.class, te.registerTestPair(mvd.jester.tests.MaiaBertogna.class,
mvd.jester.simulator.MaiaBertogna.class); mvd.jester.simulator.MaiaBertogna.class);
......
package mvd.jester; package mvd.jester;
import java.io.PrintWriter;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.google.common.collect.Table;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.priority.PriorityManager;
import mvd.jester.simulator.AbstractSimulator; import mvd.jester.simulator.AbstractSimulator;
import mvd.jester.tests.AbstractTest; import mvd.jester.tests.AbstractTest;
import mvd.jester.utils.Logger; import mvd.jester.utils.Logger;
...@@ -20,44 +21,88 @@ public class TestEnvironment { ...@@ -20,44 +21,88 @@ public class TestEnvironment {
private final long numberOfTaskSets; private final long numberOfTaskSets;
private final SystemSetup systemSetup; private final SystemSetup systemSetup;
private final SystemSetup.Builder builder; private final SystemSetup.Builder builder;
private final Map<Constructor<? extends AbstractTest>, Constructor<? extends AbstractSimulator>> abstractTestPairs; private final Set<Constructor<? extends AbstractTest>> abstractTests;
private final Set<Constructor<? extends AbstractSimulator>> abstractSimulators;
private final Set<PriorityManager> schedulingAlgorithms;
public TestEnvironment(SystemSetup.Builder builder, long numberOfTaskSets) { public TestEnvironment(SystemSetup.Builder builder, long numberOfTaskSets) {
this.numberOfTaskSets = numberOfTaskSets; this.numberOfTaskSets = numberOfTaskSets;
abstractTestPairs = new HashMap<>(); this.abstractTests = new HashSet<>();
this.abstractSimulators = new HashSet<>();
this.schedulingAlgorithms = new HashSet<>();
this.builder = builder; this.builder = builder;
this.systemSetup = builder.build(); this.systemSetup = builder.build();
} }
public TestEnvironment registerSchedulingAlgorithm(PriorityManager priorityManager) {
schedulingAlgorithms.add(priorityManager);
return this;
}
public TestEnvironment registerTest(Class<? extends AbstractTest> abstractTest) {
try {
abstractTests.add(abstractTest.getConstructor(SystemSetup.class));
} catch (Exception e) {
System.out.println("Missing constructor for abstract test!");
}
return this;
}
public TestEnvironment registerSimulator(Class<? extends AbstractSimulator> abstractSimulator) {
try {
abstractSimulators.add(abstractSimulator.getConstructor(SystemSetup.class));
} catch (Exception e) {
System.out.println("Missing constructor for abstract simulator!");
}
return this;
}
public TestEnvironment registerTestPair(Class<? extends AbstractTest> abstractTest, public TestEnvironment registerTestPair(Class<? extends AbstractTest> abstractTest,
Class<? extends AbstractSimulator> abstractSimulator) { Class<? extends AbstractSimulator> abstractSimulator) {
try { try {
abstractTestPairs.put(abstractTest.getConstructor(SystemSetup.class), abstractTests.add(abstractTest.getConstructor(SystemSetup.class));
abstractSimulator.getConstructor(SystemSetup.class)); } catch (Exception e) {
System.out.println("Missing constructor for abstract test!");
}
try {
abstractSimulators.add(abstractSimulator.getConstructor(SystemSetup.class));
} catch (Exception e) { } catch (Exception e) {
System.out.println("Missing constructor!"); System.out.println("Missing constructor for abstract simulator!");
} }
return this; return this;
} }
public void runTests() { public void runTests() {
Map<AbstractTest, AbstractSimulator> testPairs = new HashMap<>(); Set<AbstractTest> abstractTestInstances = new HashSet<>();
Set<AbstractSimulator> abstractSimulatorInstances = new HashSet<>();
Map<Long, Map<AbstractTest, Long>> testResults = new HashMap<>(); Map<Long, Map<AbstractTest, Long>> testResults = new HashMap<>();
Map<Long, Map<AbstractSimulator, Long>> simulatorResults = new HashMap<>(); Map<Long, Map<AbstractSimulator, Long>> simulatorResults = new HashMap<>();
// Map<Long, Table<PriorityManager, AbstractTest, Long>> testResults = new HashMap<>();
// Map<Long, Table<PriorityManager, AbstractSimulator, Long>> simulatorResults =
// new HashMap<>();
for (Map.Entry<Constructor<? extends AbstractTest>, Constructor<? extends AbstractSimulator>> kv : abstractTestPairs for (Constructor<? extends AbstractTest> c : abstractTests) {
.entrySet()) {
try { try {
testPairs.put(kv.getKey().newInstance(this.systemSetup), abstractTestInstances.add(c.newInstance(this.systemSetup));
kv.getValue().newInstance(this.systemSetup));
} catch (Exception e) { } catch (Exception e) {
System.out.println("Could not instantiate object of AbstractTest!"); System.out.println("Could not instantiate object of AbstractTest!");
} }
} }
for (Constructor<? extends AbstractSimulator> c : abstractSimulators) {
try {
abstractSimulatorInstances.add(c.newInstance(this.systemSetup));
} catch (Exception e) {
System.out.println("Could not instantiate object of AbstractSimulator!");
}
}
long checkedTasksets = 0; long checkedTasksets = 0;
while (checkedTasksets < numberOfTaskSets) { while (checkedTasksets < numberOfTaskSets) {
...@@ -74,29 +119,28 @@ public class TestEnvironment { ...@@ -74,29 +119,28 @@ public class TestEnvironment {
} }
long roundedUtilization = (long) (utilization * 10); long roundedUtilization = (long) (utilization * 10);
for (Map.Entry<AbstractTest, AbstractSimulator> kv : testPairs.entrySet()) {
boolean schedCheck = kv.getKey().runSchedulabilityCheck(); for (PriorityManager priorityManager : schedulingAlgorithms) {
boolean simCheck = kv.getValue().runSimulation(); for (AbstractTest test : abstractTestInstances) {
if (schedCheck) { if (priorityManager.hasTest(test)
testResults && test.runSchedulabilityCheck(priorityManager)) {
.computeIfAbsent(roundedUtilization, testResults
k -> new HashMap<AbstractTest, Long>()) .computeIfAbsent(roundedUtilization,
.compute(kv.getKey(), (k, v) -> (v == null) ? 1 : v + 1); k -> new HashMap<AbstractTest, Long>())
} .compute(test, (k, v) -> (v == null) ? 1 : v + 1);
if (simCheck) { }
simulatorResults
.computeIfAbsent(roundedUtilization,
k -> new HashMap<AbstractSimulator, Long>())
.compute(kv.getValue(), (k, v) -> (v == null) ? 1 : v + 1);
} }
if (schedCheck == true && simCheck == false) {
try (PrintWriter out = for (AbstractSimulator simulator : abstractSimulatorInstances) {
new PrintWriter("results/manualCheck" + checkedTasksets + ".txt")) { if (priorityManager.hasSimulator(simulator)
out.println(systemSetup); && simulator.runSimulation(priorityManager)) {
} catch (Exception e) { simulatorResults
System.out.println("Ähm something went horribly wrong!"); .computeIfAbsent(roundedUtilization,
k -> new HashMap<AbstractSimulator, Long>())
.compute(simulator, (k, v) -> (v == null) ? 1 : v + 1);
} }
} }
} }
builder.addTask(systemSetup); builder.addTask(systemSetup);
...@@ -104,11 +148,11 @@ public class TestEnvironment { ...@@ -104,11 +148,11 @@ public class TestEnvironment {
} }
} }
logResults(testPairs.keySet(), testResults); logTestResults(abstractTestInstances, testResults);
logSimulations(new HashSet<AbstractSimulator>(testPairs.values()), simulatorResults); logSimulationResults(abstractSimulatorInstances, simulatorResults);
} }
private void logResults(Set<AbstractTest> testCases, private void logTestResults(Set<AbstractTest> testCases,
Map<Long, Map<AbstractTest, Long>> results) { Map<Long, Map<AbstractTest, Long>> results) {
LocalTime date = LocalTime.now(); LocalTime date = LocalTime.now();
Logger log = new Logger("./results/results_" + systemSetup.getNumberOfProcessors() + "_" Logger log = new Logger("./results/results_" + systemSetup.getNumberOfProcessors() + "_"
...@@ -138,7 +182,7 @@ public class TestEnvironment { ...@@ -138,7 +182,7 @@ public class TestEnvironment {
log.finalize(); log.finalize();
} }
private void logSimulations(Set<AbstractSimulator> testCases, private void logSimulationResults(Set<AbstractSimulator> testCases,
Map<Long, Map<AbstractSimulator, Long>> results) { Map<Long, Map<AbstractSimulator, Long>> results) {
LocalTime date = LocalTime.now(); LocalTime date = LocalTime.now();
Logger log = new Logger("./results/results_sim_" + systemSetup.getNumberOfProcessors() + "_" Logger log = new Logger("./results/results_sim_" + systemSetup.getNumberOfProcessors() + "_"
......
...@@ -4,22 +4,21 @@ import java.io.IOException; ...@@ -4,22 +4,21 @@ import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic;
/** /**
* TaskSet * TaskSet
*/ */
public class SystemSetup { public class SystemSetup {
private SortedTaskSet tasks; private Set<Task> tasks;
private final long numberOfProcessors; private final long numberOfProcessors;
public SystemSetup(SortedTaskSet tasks, long numberOfProcessors) { public SystemSetup(Set<Task> tasks, long numberOfProcessors) {
this.tasks = tasks; this.tasks = tasks;
this.numberOfProcessors = numberOfProcessors; this.numberOfProcessors = numberOfProcessors;
} }
...@@ -27,11 +26,11 @@ public class SystemSetup { ...@@ -27,11 +26,11 @@ public class SystemSetup {
/** /**
* @return the tasks * @return the tasks
*/ */
public SortedTaskSet getTasks() { public Set<Task> getTasks() {
return tasks; return tasks;
} }
public void setTasks(SortedTaskSet tasks) { public void setTasks(Set<Task> tasks) {
this.tasks = tasks; this.tasks = tasks;
} }
...@@ -88,7 +87,6 @@ public class SystemSetup { ...@@ -88,7 +87,6 @@ public class SystemSetup {
private long maxNumberOfJobs = 3 * numberOfProcessors / 2; private long maxNumberOfJobs = 3 * numberOfProcessors / 2;
private long minWcet = 1; private long minWcet = 1;
private long ratio = randomTaskRatio(); private long ratio = randomTaskRatio();
private PriorityManager priorityManager = new RateMonotonic();
public Builder() { public Builder() {
...@@ -139,8 +137,9 @@ public class SystemSetup { ...@@ -139,8 +137,9 @@ public class SystemSetup {
return new Task(period, segments); return new Task(period, segments);
} }
private SortedTaskSet generateTaskSet() { private Set<Task> generateTaskSet() {
SortedTaskSet taskSet = new SortedTaskSet(priorityManager); // SortedTaskSet taskSet = new SortedTaskSet(priorityManager);
Set<Task> taskSet = new HashSet<>();
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
Task task = generateTask(); Task task = generateTask();
...@@ -152,7 +151,7 @@ public class SystemSetup { ...@@ -152,7 +151,7 @@ public class SystemSetup {
public SystemSetup build() { public SystemSetup build() {
this.ratio = randomTaskRatio(); this.ratio = randomTaskRatio();
SortedTaskSet taskSet = generateTaskSet(); Set<Task> taskSet = generateTaskSet();
return new SystemSetup(taskSet, numberOfProcessors); return new SystemSetup(taskSet, numberOfProcessors);
} }
...@@ -185,11 +184,6 @@ public class SystemSetup { ...@@ -185,11 +184,6 @@ public class SystemSetup {
return this; return this;
} }
public Builder setPriorityManager(PriorityManager priorityManager) {
this.priorityManager = priorityManager;
return this;
}
/** /**
* @param maxNumberOfJobs the maxNumberOfJobs to set * @param maxNumberOfJobs the maxNumberOfJobs to set
*/ */
...@@ -200,5 +194,4 @@ public class SystemSetup { ...@@ -200,5 +194,4 @@ public class SystemSetup {
} }
} }
} }
package mvd.jester.priority; package mvd.jester.priority;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.simulator.AbstractSimulator;
import mvd.jester.simulator.MaiaBertogna;
import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.simulator.internals.TaskContextInterface;
import mvd.jester.tests.AbstractTest;
/** /**
* EarliestDeadineFirst * EarliestDeadineFirst
*/ */
public class EarliestDeadineFirst implements PriorityManager { public class EarliestDeadlineFirst implements PriorityManager {
final static Set<Class<? extends AbstractTest>> abstractTests = new HashSet<>();
final static Set<Class<? extends AbstractSimulator>> abstractSimulators =
new HashSet<>(Arrays.asList(MaiaBertogna.class));
/** /**
* Compare the priority of two tasks according to the Rate Monotonic policy * Compare the priority of two tasks according to the Rate Monotonic policy
...@@ -26,4 +36,19 @@ public class EarliestDeadineFirst implements PriorityManager { ...@@ -26,4 +36,19 @@ public class EarliestDeadineFirst implements PriorityManager {
public int compare(TaskContextInterface t1, TaskContextInterface t2) { public int compare(TaskContextInterface t1, TaskContextInterface t2) {
return (int) (t1.getDeadline() - t2.getDeadline()); return (int) (t1.getDeadline() - t2.getDeadline());
} }
@Override
public boolean hasTest(AbstractTest abstractTest) {
return abstractTests.contains(abstractTest.getClass());
}
@Override
public boolean hasSimulator(AbstractSimulator abstractSimulator) {
return abstractSimulators.contains(abstractSimulator.getClass());
}
@Override
public String getName() {
return "EDF";
}
} }
package mvd.jester.priority; package mvd.jester.priority;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.simulator.AbstractSimulator;
import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.simulator.internals.TaskContextInterface;
import mvd.jester.tests.AbstractTest;
/** /**
* PriorityManager * PriorityManager
...@@ -12,4 +14,10 @@ public interface PriorityManager { ...@@ -12,4 +14,10 @@ public interface PriorityManager {
public int compare(TaskContextInterface t1, TaskContextInterface t2); public int compare(TaskContextInterface t1, TaskContextInterface t2);
public boolean hasTest(AbstractTest abstractTest);
public boolean hasSimulator(AbstractSimulator abstractTest);
public String getName();
} }
package mvd.jester.priority; package mvd.jester.priority;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.simulator.AbstractSimulator;
import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.simulator.internals.TaskContextInterface;
import mvd.jester.tests.AbstractTest;
public class RateMonotonic implements PriorityManager { public class RateMonotonic implements PriorityManager {
final static Set<Class<? extends AbstractTest>> abstractTests = new HashSet<>(Arrays
.asList(mvd.jester.tests.MaiaBertogna.class, mvd.jester.tests.SchmidMottok.class));
final static Set<Class<? extends AbstractSimulator>> abstractSimulators =
new HashSet<>(Arrays.asList(mvd.jester.simulator.MaiaBertogna.class,
mvd.jester.simulator.SchmidMottok.class));
/** /**
* Compare the priority of two tasks according to the Rate Monotonic policy * Compare the priority of two tasks according to the Rate Monotonic policy
* *
...@@ -22,4 +33,20 @@ public class RateMonotonic implements PriorityManager { ...@@ -22,4 +33,20 @@ public class RateMonotonic implements PriorityManager {
public int compare(TaskContextInterface t1, TaskContextInterface t2) { public int compare(TaskContextInterface t1, TaskContextInterface t2) {
return Long.compare(t1.getTask().getPeriod(), t2.getTask().getPeriod()); return Long.compare(t1.getTask().getPeriod(), t2.getTask().getPeriod());
} }
@Override
public boolean hasTest(AbstractTest abstractTest) {
return abstractTests.contains(abstractTest.getClass());
}
@Override
public boolean hasSimulator(AbstractSimulator abstractSimulator) {
return abstractSimulators.contains(abstractSimulator.getClass());
}
@Override
public String getName() {
return "RM";
}
} }
...@@ -6,6 +6,8 @@ import java.util.Optional; ...@@ -6,6 +6,8 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic; import mvd.jester.priority.RateMonotonic;
import mvd.jester.simulator.internals.ProcessorContext; import mvd.jester.simulator.internals.ProcessorContext;
import mvd.jester.simulator.internals.SortedTaskContextSet; import mvd.jester.simulator.internals.SortedTaskContextSet;
...@@ -19,7 +21,7 @@ public abstract class AbstractSimulator implements SimulatorInterface { ...@@ -19,7 +21,7 @@ public abstract class AbstractSimulator implements SimulatorInterface {
protected final SystemSetup systemSetup; protected final SystemSetup systemSetup;
protected final Set<ProcessorContext> processors; protected final Set<ProcessorContext> processors;
protected final SortedTaskContextSet readyTasks; protected Set<TaskContextInterface> readyTasks;
protected long hyperPeriod; protected long hyperPeriod;
AbstractSimulator(SystemSetup systemSetup) { AbstractSimulator(SystemSetup systemSetup) {
...@@ -29,15 +31,16 @@ public abstract class AbstractSimulator implements SimulatorInterface { ...@@ -29,15 +31,16 @@ public abstract class AbstractSimulator implements SimulatorInterface {
for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) { for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) {
processors.add(new ProcessorContext(i)); processors.add(new ProcessorContext(i));
} }
this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 2 /* * 10 */; this.hyperPeriod = getHyperPeriod();
} }
protected abstract boolean releaseTasks(long timeStep); protected abstract boolean releaseTasks(long timeStep);
@Override @Override
public boolean runSimulation() { public boolean runSimulation(PriorityManager priorityManager) {
init(); init(priorityManager);
for (int t = 0; t < hyperPeriod; ++t) { for (int t = 0; t < hyperPeriod; ++t) {
if (!releaseTasks(t)) { if (!releaseTasks(t)) {
return false; return false;
...@@ -70,12 +73,12 @@ public abstract class AbstractSimulator implements SimulatorInterface { ...@@ -70,12 +73,12 @@ public abstract class AbstractSimulator implements SimulatorInterface {
return true; return true;
} }
private void init() { private void init(PriorityManager priorityManager) {
this.readyTasks.clear(); this.readyTasks = new SortedTaskContextSet(priorityManager);
for (ProcessorContext p : processors) { for (ProcessorContext p : processors) {
p.setJob(null); p.setJob(null);
} }
this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 2; this.hyperPeriod = getHyperPeriod();
} }
private Set<ProcessorContext> sortProcessors(Set<ProcessorContext> processors) { private Set<ProcessorContext> sortProcessors(Set<ProcessorContext> processors) {
...@@ -86,6 +89,11 @@ public abstract class AbstractSimulator implements SimulatorInterface { ...@@ -86,6 +89,11 @@ public abstract class AbstractSimulator implements SimulatorInterface {
return sortedProcessors; return sortedProcessors;
} }
private long getHyperPeriod() {
return systemSetup.getTasks().stream().max(Comparator.comparing(Task::getPeriod)).get()
.getPeriod() * 2; /* * 10 */
}
private class ProcessorComparator implements Comparator<ProcessorContext> { private class ProcessorComparator implements Comparator<ProcessorContext> {
@Override @Override
......
package mvd.jester.simulator; package mvd.jester.simulator;
import mvd.jester.priority.PriorityManager;
/** /**
* SimulatorInterface * SimulatorInterface
*/ */
public interface SimulatorInterface { public interface SimulatorInterface {
public boolean runSimulation(); public boolean runSimulation(PriorityManager priorityManager);
public String getName(); public String getName();
......
...@@ -11,7 +11,7 @@ public class SortedTaskContextSet extends TreeSet<TaskContextInterface> { ...@@ -11,7 +11,7 @@ public class SortedTaskContextSet extends TreeSet<TaskContextInterface> {
private static final long serialVersionUID = 4808544133562675597L; private static final long serialVersionUID = 4808544133562675597L;
public SortedTaskContextSet(PriorityManager priorityMananger) { public SortedTaskContextSet(PriorityManager priorityMananger) {
super((t1, t2) -> priorityMananger.compare(t1.getTask(), t2.getTask())); super((t1, t2) -> priorityMananger.compare(t1, t2));
} }
} }
...@@ -2,6 +2,7 @@ package mvd.jester.tests; ...@@ -2,6 +2,7 @@ package mvd.jester.tests;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task; import mvd.jester.model.Task;
...@@ -12,9 +13,11 @@ public abstract class AbstractTest implements TestInterface { ...@@ -12,9 +13,11 @@ public abstract class AbstractTest implements TestInterface {
protected final Map<Task, Long> responseTimes; protected final Map<Task, Long> responseTimes;
protected final SystemSetup systemSetup; protected final SystemSetup systemSetup;
protected Set<Task> tasks;
public AbstractTest(SystemSetup systemSetup) { public AbstractTest(SystemSetup systemSetup) {
this.systemSetup = systemSetup; this.systemSetup = systemSetup;
this.responseTimes = new HashMap<Task, Long>(); this.responseTimes = new HashMap<Task, Long>();
this.tasks = systemSetup.getTasks();
} }
} }
...@@ -4,7 +4,9 @@ import java.math.RoundingMode; ...@@ -4,7 +4,9 @@ import java.math.RoundingMode;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.google.common.math.LongMath; import com.google.common.math.LongMath;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
/** /**
...@@ -17,9 +19,11 @@ public class MaiaBertogna extends AbstractTest { ...@@ -17,9 +19,11 @@ public class MaiaBertogna extends AbstractTest {
} }
@Override @Override
public boolean runSchedulabilityCheck() { public boolean runSchedulabilityCheck(PriorityManager priorityManager) {
tasks = new SortedTaskSet(priorityManager);
tasks.addAll(systemSetup.getTasks());
responseTimes.clear(); responseTimes.clear();
for (Task t : systemSetup.getTasks()) { for (Task t : tasks) {
responseTimes.put(t, calculateResponseTime(t)); responseTimes.put(t, calculateResponseTime(t));
} }
...@@ -46,7 +50,7 @@ public class MaiaBertogna extends AbstractTest { ...@@ -46,7 +50,7 @@ public class MaiaBertogna extends AbstractTest {
previousResponseTime = responseTime; previousResponseTime = responseTime;
long taskInterference = 0; long taskInterference = 0;
for (Task t : systemSetup.getTasks()) { for (Task t : tasks) {
if (t.getPeriod() < task.getPeriod()) { if (t.getPeriod() < task.getPeriod()) {
long maxNumberOfJobsOfT = t.getMaximumParallelism(); long maxNumberOfJobsOfT = t.getMaximumParallelism();
for (int p = 0; p < maxNumberOfJobsOfT; ++p) { for (int p = 0; p < maxNumberOfJobsOfT; ++p) {
......
...@@ -4,7 +4,9 @@ import java.math.RoundingMode; ...@@ -4,7 +4,9 @@ import java.math.RoundingMode;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.google.common.math.LongMath; import com.google.common.math.LongMath;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
/** /**
...@@ -17,9 +19,11 @@ public class SchmidMottok extends AbstractTest { ...@@ -17,9 +19,11 @@ public class SchmidMottok extends AbstractTest {
} }
@Override @Override
public boolean runSchedulabilityCheck() { public boolean runSchedulabilityCheck(PriorityManager priorityManager) {
tasks = new SortedTaskSet(priorityManager);
tasks.addAll(systemSetup.getTasks());
responseTimes.clear(); responseTimes.clear();
for (Task t : systemSetup.getTasks()) { for (Task t : tasks) {
responseTimes.put(t, calculateResponseTime(t)); responseTimes.put(t, calculateResponseTime(t));
} }
...@@ -47,7 +51,7 @@ public class SchmidMottok extends AbstractTest { ...@@ -47,7 +51,7 @@ public class SchmidMottok extends AbstractTest {
previousResponseTime = responseTime; previousResponseTime = responseTime;
double taskInterference = 0; double taskInterference = 0;
for (Task t : systemSetup.getTasks()) { for (Task t : tasks) {
if (t.getPeriod() < task.getPeriod()) { if (t.getPeriod() < task.getPeriod()) {
long numberOfJobs = long numberOfJobs =
t.getMaximumParallelism() > numberOfProcessors ? numberOfProcessors t.getMaximumParallelism() > numberOfProcessors ? numberOfProcessors
......
package mvd.jester.tests; package mvd.jester.tests;
import mvd.jester.priority.PriorityManager;
/** /**
* TestInterface * TestInterface
*/ */
public interface TestInterface { public interface TestInterface {
public boolean runSchedulabilityCheck(); public boolean runSchedulabilityCheck(PriorityManager priorityManager);
public String getName(); public String getName();
......
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 sign in to comment