Commit 39635336 by Michael Schmid

Integrated builder into manager

parent eb53dcfb
...@@ -23,34 +23,33 @@ import mvd.jester.tests.TypeFunction.UnkownStructure; ...@@ -23,34 +23,33 @@ import mvd.jester.tests.TypeFunction.UnkownStructure;
*/ */
public class App { public class App {
public static void main(String[] args) { public static void main(String[] args) {
// { {
// SystemManager manager = new SystemManager(8); SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// DagTaskBuilder builder = new DagTaskBuilder(); TestEnvironment te = new TestEnvironment();
// TestEnvironment te = new TestEnvironment();
// // SchmidMottok sm = new SchmidMottok(new KnownStructure(), manager); // SchmidMottok sm = new SchmidMottok(new KnownStructure(), manager);
// // JiangYi jy = new JiangYi(manager); // JiangYi jy = new JiangYi(manager);
// // Set<DagTask> set = builder.generateRenyiTaskSet(7.0); // Set<DagTask> set = builder.generateRenyiTaskSet(7.0);
// // final SortedTaskSet<DagTask> rmTasks = new SortedTaskSet<>(sm.getPriorityManager()); // final SortedTaskSet<DagTask> rmTasks = new SortedTaskSet<>(sm.getPriorityManager());
// // rmTasks.addAll(set); // rmTasks.addAll(set);
// // final SortedTaskSet<DagTask> edfTasks = new SortedTaskSet<>(jy.getPriorityManager()); // final SortedTaskSet<DagTask> edfTasks = new SortedTaskSet<>(jy.getPriorityManager());
// // edfTasks.addAll(set); // edfTasks.addAll(set);
// // jy.runSchedulabilityCheck(edfTasks); // jy.runSchedulabilityCheck(edfTasks);
// // sm.runSchedulabilityCheck(rmTasks); // sm.runSchedulabilityCheck(rmTasks);
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(
// new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager),
// new SchmidMottok(new KnownStructure(), manager), new SchmidMottok(new KnownStructure(), manager),
// // new MelaniButtazzo(manager), // new MelaniButtazzo(manager),
// // new FonsecaNelis(manager), // new FonsecaNelis(manager),
// new JiangYi(manager))); new JiangYi(manager)));
// te.varyRenyiUtilization(builder, tests, 8, 500); te.varyRenyiUtilization(manager, tests, 500);
// } }
// { // {
// SystemManager manager = new SystemManager(8); // SystemManager manager = new SystemManager(8);
// DagTaskBuilder builder = new DagTaskBuilder(); // DagTaskBuilder builder = new DagTaskBuilder();
......
...@@ -78,15 +78,15 @@ public class TestEnvironment { ...@@ -78,15 +78,15 @@ public class TestEnvironment {
// resultLogger.logTests(abstractTestInstances); // resultLogger.logTests(abstractTestInstances);
} }
public void measureExecutionTimes(final DagTaskBuilder builder, public void measureExecutionTimes(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances, SystemManager manager, final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfMeasurements) { final long numberOfMeasurements) {
Map<AbstractTest<DagTask>, List<Long>> results = new LinkedHashMap<>(); Map<AbstractTest<DagTask>, List<Long>> results = new LinkedHashMap<>();
abstractTestInstances.forEach(t -> results.put(t, new ArrayList<>())); abstractTestInstances.forEach(t -> results.put(t, new ArrayList<>()));
for (int i = 0; i < numberOfMeasurements; ++i) { for (int i = 0; i < numberOfMeasurements; ++i) {
double utilization = double utilization =
ThreadLocalRandom.current().nextDouble(1, manager.getNumberOfProcessors()); ThreadLocalRandom.current().nextDouble(1, manager.getNumberOfProcessors());
Set<DagTask> taskSet = builder.generateTaskSet(utilization); Set<DagTask> taskSet = manager.getBuilder().generateTaskSet(utilization);
for (AbstractTest<DagTask> testInstance : abstractTestInstances) { for (AbstractTest<DagTask> testInstance : abstractTestInstances) {
final PriorityManager priorityManager = testInstance.getPriorityManager(); final PriorityManager priorityManager = testInstance.getPriorityManager();
...@@ -108,8 +108,8 @@ public class TestEnvironment { ...@@ -108,8 +108,8 @@ public class TestEnvironment {
} }
public void varyNumberOfProcessors(final DagTaskBuilder builder, public void varyNumberOfProcessors(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances, SystemManager manager, final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfTaskSetsPerStep) { final long numberOfTaskSetsPerStep) {
long checkedTasksets = 0; long checkedTasksets = 0;
final long numberOfTaskSets = 8 * numberOfTaskSetsPerStep; final long numberOfTaskSets = 8 * numberOfTaskSetsPerStep;
...@@ -123,7 +123,7 @@ public class TestEnvironment { ...@@ -123,7 +123,7 @@ public class TestEnvironment {
manager.setNumberOfProcessors(numberOfProcessors); manager.setNumberOfProcessors(numberOfProcessors);
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerStep; ++i) { for (int i = 0; i < numberOfTaskSetsPerStep; ++i) {
final Set<DagTask> taskSet = builder.generateUUnifastTaskSet( final Set<DagTask> taskSet = manager.getBuilder().generateUUnifastTaskSet(
(long) (1.5 * numberOfProcessors), (double) numberOfProcessors * 0.5); (long) (1.5 * numberOfProcessors), (double) numberOfProcessors * 0.5);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
...@@ -150,10 +150,11 @@ public class TestEnvironment { ...@@ -150,10 +150,11 @@ public class TestEnvironment {
} }
public void varyNumberOfTasks(final DagTaskBuilder builder, public void varyNumberOfTasks(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances, final long numberOfProcessors, final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfTaskSetsPerStep) { final long numberOfTaskSetsPerStep) {
long checkedTasksets = 0; long checkedTasksets = 0;
final long numberOfProcessors = manager.getNumberOfProcessors();
final long numberOfTaskSets = 9 * numberOfTaskSetsPerStep; final long numberOfTaskSets = 9 * numberOfTaskSetsPerStep;
final ResultLogger resultLogger = new ResultLogger("numberOfTasks_" + numberOfProcessors); final ResultLogger resultLogger = new ResultLogger("numberOfTasks_" + numberOfProcessors);
...@@ -164,8 +165,8 @@ public class TestEnvironment { ...@@ -164,8 +165,8 @@ public class TestEnvironment {
for (long numberOfTasks = 4; numberOfTasks <= 20; numberOfTasks += 2) { for (long numberOfTasks = 4; numberOfTasks <= 20; numberOfTasks += 2) {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerStep; ++i) { for (int i = 0; i < numberOfTaskSetsPerStep; ++i) {
final Set<DagTask> taskSet = builder.generateUUnifastTaskSet(numberOfTasks, final Set<DagTask> taskSet = manager.getBuilder()
(double) numberOfProcessors * 0.5); .generateUUnifastTaskSet(numberOfTasks, (double) numberOfProcessors * 0.5);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) { for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
...@@ -190,10 +191,10 @@ public class TestEnvironment { ...@@ -190,10 +191,10 @@ public class TestEnvironment {
resultLogger.finalize(); resultLogger.finalize();
} }
public void varyUtilization(final DagTaskBuilder builder, public void varyUtilization(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances, final long numberOfProcessors, final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfTaskSetsPerUtil) { final long numberOfTaskSetsPerUtil) {
final long numberOfProcessors = manager.getNumberOfProcessors();
long checkedTasksets = 0; long checkedTasksets = 0;
final long numberOfTaskSets = ((numberOfProcessors * 4) - 3) * numberOfTaskSetsPerUtil; final long numberOfTaskSets = ((numberOfProcessors * 4) - 3) * numberOfTaskSetsPerUtil;
...@@ -205,7 +206,7 @@ public class TestEnvironment { ...@@ -205,7 +206,7 @@ public class TestEnvironment {
for (double util = 1; util <= numberOfProcessors; util += 0.25) { for (double util = 1; util <= numberOfProcessors; util += 0.25) {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) {
final Set<DagTask> taskSet = builder.generateTaskSet(util); final Set<DagTask> taskSet = manager.getBuilder().generateTaskSet(util);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) { for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
...@@ -230,10 +231,10 @@ public class TestEnvironment { ...@@ -230,10 +231,10 @@ public class TestEnvironment {
resultLogger.finalize(); resultLogger.finalize();
} }
public void varyRenyiUtilization(final DagTaskBuilder builder, public void varyRenyiUtilization(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances, final long numberOfProcessors, final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfTaskSetsPerUtil) { final long numberOfTaskSetsPerUtil) {
final long numberOfProcessors = manager.getNumberOfProcessors();
long checkedTasksets = 0; long checkedTasksets = 0;
final long numberOfTaskSets = ((numberOfProcessors * 4) - 3) * numberOfTaskSetsPerUtil; final long numberOfTaskSets = ((numberOfProcessors * 4) - 3) * numberOfTaskSetsPerUtil;
...@@ -242,10 +243,10 @@ public class TestEnvironment { ...@@ -242,10 +243,10 @@ public class TestEnvironment {
abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0)); abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0));
resultLogger.logHeader(resultMap, "Utilization"); resultLogger.logHeader(resultMap, "Utilization");
for (double util = 5; util <= numberOfProcessors; util += 0.25) { for (double util = 1; util <= numberOfProcessors; util += 0.25) {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) {
final Set<DagTask> taskSet = builder.generateRenyiTaskSet(util); final Set<DagTask> taskSet = manager.getBuilder().generateRenyiTaskSet(util);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) { for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
......
...@@ -14,32 +14,50 @@ import org.apache.commons.math3.distribution.GammaDistribution; ...@@ -14,32 +14,50 @@ import org.apache.commons.math3.distribution.GammaDistribution;
import org.jgrapht.experimental.dag.DirectedAcyclicGraph; import org.jgrapht.experimental.dag.DirectedAcyclicGraph;
import org.jgrapht.graph.DefaultEdge; import org.jgrapht.graph.DefaultEdge;
import mvd.jester.utils.DagUtils; import mvd.jester.utils.DagUtils;
import mvd.jester.model.SystemManager.Builder;
/** /**
* TaskSet * TaskSet
*/ */
public class SystemManager { public class SystemManager<T extends Builder> implements SystemManagerInterface {
private long numberOfProcessors;
public SystemManager(final long numberOfProcessors) { private final T builder;
this.numberOfProcessors = numberOfProcessors;
public SystemManager(Class<T> builder) {
try {
this.builder = builder.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException("Builder could not be instantiated!");
}
} }
/** /**
* @return the numberOfProcessors * @return the numberOfProcessors
*/ */
public long getNumberOfProcessors() { public long getNumberOfProcessors() {
return numberOfProcessors; return builder.getNumberOfProcessors();
} }
/** /**
* @param numberOfProcessors the numberOfProcessors to set * @param numberOfProcessors the numberOfProcessors to set
*/ */
public void setNumberOfProcessors(long numberOfProcessors) { public void setNumberOfProcessors(long numberOfProcessors) {
this.numberOfProcessors = numberOfProcessors; builder.setNumberOfProcessors(numberOfProcessors);
} }
public static class SynchronousTaskBuilder { public T getBuilder() {
return builder;
}
public static interface Builder {
public long getNumberOfProcessors();
public Builder setNumberOfProcessors(long numberOfProcessors);
}
public static class SynchronousTaskBuilder implements Builder {
private long numberOfProcessors = 4; private long numberOfProcessors = 4;
private long minPeriod = 100; private long minPeriod = 100;
private long maxSequentialPeriod = 1000; private long maxSequentialPeriod = 1000;
...@@ -53,7 +71,6 @@ public class SystemManager { ...@@ -53,7 +71,6 @@ public class SystemManager {
private final long parallelTaskRatio = 0; private final long parallelTaskRatio = 0;
public SynchronousTaskBuilder() { public SynchronousTaskBuilder() {
} }
private long randomSequentialTaskPeriod() { private long randomSequentialTaskPeriod() {
...@@ -110,21 +127,11 @@ public class SystemManager { ...@@ -110,21 +127,11 @@ public class SystemManager {
return taskSet; return taskSet;
} }
// public SystemSetup<SynchronousTask> build() {
// this.ratio = randomTaskRatio(this.parallelTaskRatio);
// final Set<SynchronousTask> taskSet = generateTaskSet();
// return new SystemSetup<>(taskSet, numberOfProcessors);
// }
// public Set<SynchronousTask> rebuild(final SystemSetup<SynchronousTask> systemSetup) {
// this.ratio = randomTaskRatio(this.parallelTaskRatio);
// return generateTaskSet();
// }
public boolean addTask(final Set<SynchronousTask> taskSet) { public boolean addTask(final Set<SynchronousTask> taskSet) {
return taskSet.add(generateTask()); return taskSet.add(generateTask());
} }
@Override
public SynchronousTaskBuilder setNumberOfProcessors(final long numberOfProcessors) { public SynchronousTaskBuilder setNumberOfProcessors(final long numberOfProcessors) {
this.numberOfProcessors = numberOfProcessors; this.numberOfProcessors = numberOfProcessors;
...@@ -157,9 +164,14 @@ public class SystemManager { ...@@ -157,9 +164,14 @@ public class SystemManager {
this.maxNumberOfJobs = maxNumberOfJobs; this.maxNumberOfJobs = maxNumberOfJobs;
return this; return this;
} }
@Override
public long getNumberOfProcessors() {
return numberOfProcessors;
}
} }
public static class DagTaskBuilder { public static class DagTaskBuilder implements Builder {
private long numberOfProcessors = 8; private long numberOfProcessors = 8;
private long minimumWcet = 1; private long minimumWcet = 1;
private long maximumWcet = 100; private long maximumWcet = 100;
...@@ -167,7 +179,7 @@ public class SystemManager { ...@@ -167,7 +179,7 @@ public class SystemManager {
private long maxNumberOfThreads = numberOfProcessors; private long maxNumberOfThreads = numberOfProcessors;
private long depth = 2; private long depth = 2;
private long p_par = 80; private long p_par = 80;
private long p_add = 10; // TODO: Change back to 0.2 private long p_add = 20; // TODO: Change back to 0.2
public DagTaskBuilder() { public DagTaskBuilder() {
} }
...@@ -268,12 +280,13 @@ public class SystemManager { ...@@ -268,12 +280,13 @@ public class SystemManager {
final long criticalPath = DagUtils.calculateCriticalPath(jobDag); final long criticalPath = DagUtils.calculateCriticalPath(jobDag);
final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization); final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization);
// final long numberOfThreads = LongMath.divide(workload - criticalPath, final long minNumberOfThreads = LongMath.divide(workload - criticalPath,
// period - criticalPath, RoundingMode.CEILING) + 1; period - criticalPath, RoundingMode.FLOOR);
final long numberOfThreads = randomNumberOfThreads(numberOfProcessors / 2); // TODO: change back to following:
// final long numberOfThreads = randomNumberOfThreads(minNumberOfThreads);
return new DagTask(jobDag, period, numberOfThreads); return new DagTask(jobDag, period, minNumberOfThreads);
} }
private long randomRenyiPeriod(final long workload, final long criticalPath, private long randomRenyiPeriod(final long workload, final long criticalPath,
...@@ -448,6 +461,7 @@ public class SystemManager { ...@@ -448,6 +461,7 @@ public class SystemManager {
/** /**
* @param numberOfProcessors the numberOfProcessors to set * @param numberOfProcessors the numberOfProcessors to set
*/ */
@Override
public DagTaskBuilder setNumberOfProcessors(final long numberOfProcessors) { public DagTaskBuilder setNumberOfProcessors(final long numberOfProcessors) {
this.numberOfProcessors = numberOfProcessors; this.numberOfProcessors = numberOfProcessors;
return this; return this;
...@@ -456,6 +470,7 @@ public class SystemManager { ...@@ -456,6 +470,7 @@ public class SystemManager {
/** /**
* @return the numberOfProcessors * @return the numberOfProcessors
*/ */
@Override
public long getNumberOfProcessors() { public long getNumberOfProcessors() {
return numberOfProcessors; return numberOfProcessors;
} }
......
package mvd.jester.model;
public interface SystemManagerInterface {
public long getNumberOfProcessors();
}
package mvd.jester.tests; package mvd.jester.tests;
import mvd.jester.TypeInterface; import mvd.jester.TypeInterface;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
/** /**
...@@ -9,9 +9,9 @@ import mvd.jester.model.Task; ...@@ -9,9 +9,9 @@ import mvd.jester.model.Task;
*/ */
public abstract class AbstractTest<T extends Task> implements TestInterface<T>, TypeInterface { public abstract class AbstractTest<T extends Task> implements TestInterface<T>, TypeInterface {
protected final SystemManager manager; protected final SystemManagerInterface manager;
public AbstractTest(final SystemManager manager) { public AbstractTest(final SystemManagerInterface manager) {
this.manager = manager; this.manager = manager;
} }
......
...@@ -13,7 +13,7 @@ import mvd.jester.info.TerminationInfo; ...@@ -13,7 +13,7 @@ import mvd.jester.info.TerminationInfo;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SynchronousTask; import mvd.jester.model.SynchronousTask;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.priority.EarliestDeadlineFirst; import mvd.jester.priority.EarliestDeadlineFirst;
import mvd.jester.priority.PriorityManager; import mvd.jester.priority.PriorityManager;
...@@ -25,7 +25,7 @@ public class ChwaLee extends AbstractTest<SynchronousTask> { ...@@ -25,7 +25,7 @@ public class ChwaLee extends AbstractTest<SynchronousTask> {
private final Map<SynchronousTask, TerminationInfo> responseTimes; private final Map<SynchronousTask, TerminationInfo> responseTimes;
private final PriorityManager priorityManager; private final PriorityManager priorityManager;
public ChwaLee(final SystemManager manager) { public ChwaLee(final SystemManagerInterface manager) {
super(manager); super(manager);
this.responseTimes = new HashMap<>(); this.responseTimes = new HashMap<>();
this.priorityManager = new EarliestDeadlineFirst(); this.priorityManager = new EarliestDeadlineFirst();
......
...@@ -21,7 +21,7 @@ import mvd.jester.model.DagTask; ...@@ -21,7 +21,7 @@ import mvd.jester.model.DagTask;
import mvd.jester.model.Job; import mvd.jester.model.Job;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.model.TreeJob; import mvd.jester.model.TreeJob;
import mvd.jester.utils.DagUtils; import mvd.jester.utils.DagUtils;
...@@ -37,7 +37,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> { ...@@ -37,7 +37,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
private final PriorityManager priorityManager; private final PriorityManager priorityManager;
private final Map<Task, Set<Segment>> carryOutSegments; private final Map<Task, Set<Segment>> carryOutSegments;
public FonsecaNelis(final SystemManager manager) { public FonsecaNelis(final SystemManagerInterface manager) {
super(manager); super(manager);
this.responseTimes = new HashMap<>(); this.responseTimes = new HashMap<>();
this.priorityManager = new RateMonotonic(); this.priorityManager = new RateMonotonic();
......
...@@ -12,7 +12,7 @@ import mvd.jester.info.SchedulingInfo.Feasiblity; ...@@ -12,7 +12,7 @@ import mvd.jester.info.SchedulingInfo.Feasiblity;
import mvd.jester.model.ContainerTask; import mvd.jester.model.ContainerTask;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.priority.EarliestDeadlineFirst; import mvd.jester.priority.EarliestDeadlineFirst;
import mvd.jester.priority.PriorityManager; import mvd.jester.priority.PriorityManager;
...@@ -21,7 +21,7 @@ public class JiangYi extends AbstractTest<DagTask> { ...@@ -21,7 +21,7 @@ public class JiangYi extends AbstractTest<DagTask> {
private final EarliestDeadlineFirst priorityManager; private final EarliestDeadlineFirst priorityManager;
public JiangYi(SystemManager manager) { public JiangYi(SystemManagerInterface manager) {
super(manager); super(manager);
this.priorityManager = new EarliestDeadlineFirst(); this.priorityManager = new EarliestDeadlineFirst();
} }
......
...@@ -10,7 +10,7 @@ import mvd.jester.info.TerminationInfo; ...@@ -10,7 +10,7 @@ import mvd.jester.info.TerminationInfo;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SynchronousTask; import mvd.jester.model.SynchronousTask;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.priority.PriorityManager; import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic; import mvd.jester.priority.RateMonotonic;
...@@ -22,7 +22,7 @@ public class MaiaBertogna extends AbstractTest<SynchronousTask> { ...@@ -22,7 +22,7 @@ public class MaiaBertogna extends AbstractTest<SynchronousTask> {
private final Map<SynchronousTask, TerminationInfo> responseTimes; private final Map<SynchronousTask, TerminationInfo> responseTimes;
private final PriorityManager priorityManager; private final PriorityManager priorityManager;
public MaiaBertogna(final SystemManager manager) { public MaiaBertogna(final SystemManagerInterface manager) {
super(manager); super(manager);
this.responseTimes = new HashMap<>(); this.responseTimes = new HashMap<>();
this.priorityManager = new RateMonotonic(); this.priorityManager = new RateMonotonic();
......
...@@ -9,7 +9,7 @@ import mvd.jester.info.SchedulingInfo; ...@@ -9,7 +9,7 @@ import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager; import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic; import mvd.jester.priority.RateMonotonic;
...@@ -19,7 +19,7 @@ public class MelaniButtazzo extends AbstractTest<DagTask> { ...@@ -19,7 +19,7 @@ public class MelaniButtazzo extends AbstractTest<DagTask> {
private final Map<Task, TerminationInfo> responseTimes; private final Map<Task, TerminationInfo> responseTimes;
private final PriorityManager priorityManager; private final PriorityManager priorityManager;
public MelaniButtazzo(final SystemManager manager) { public MelaniButtazzo(final SystemManagerInterface manager) {
super(manager); super(manager);
this.responseTimes = new HashMap<>(); this.responseTimes = new HashMap<>();
this.priorityManager = new RateMonotonic(); this.priorityManager = new RateMonotonic();
......
...@@ -7,7 +7,7 @@ import mvd.jester.info.SchedulingInfo; ...@@ -7,7 +7,7 @@ import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager; import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic; import mvd.jester.priority.RateMonotonic;
...@@ -21,7 +21,7 @@ public class SchmidMottok extends AbstractTest<DagTask> { ...@@ -21,7 +21,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
private final PriorityManager priorityManager; private final PriorityManager priorityManager;
private final TypeFunction structure; private final TypeFunction structure;
public SchmidMottok(TypeFunction structure, final SystemManager manager) { public SchmidMottok(TypeFunction structure, final SystemManagerInterface manager) {
super(manager); super(manager);
this.responseTimes = new HashMap<>(); this.responseTimes = new HashMap<>();
this.priorityManager = new RateMonotonic(); this.priorityManager = new RateMonotonic();
...@@ -54,22 +54,21 @@ public class SchmidMottok extends AbstractTest<DagTask> { ...@@ -54,22 +54,21 @@ public class SchmidMottok extends AbstractTest<DagTask> {
long responseTime = minimumWcet; long responseTime = minimumWcet;
long previousResponseTime = 0; long previousResponseTime = 0;
long occupiedProcessors = 0; // manager.getNumberOfProcessors() + 1;
for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) {
final long numberOfProcessors = structure.getNumberOfThreads(t);
occupiedProcessors += numberOfProcessors;
}
}
do { do {
previousResponseTime = responseTime; previousResponseTime = responseTime;
double taskInterference = 0; double taskInterference = 0;
long occupiedProcessors = manager.getNumberOfProcessors() + 1;
// for (final DagTask t : tasks) {
// if (t.getPeriod() < task.getPeriod()) {
// final long numberOfProcessors = structure.getNumerOfThreads(t);
// occupiedProcessors += numberOfProcessors;
// }
// }
for (final DagTask t : tasks) { for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) { if (t.getPeriod() < task.getPeriod()) {
final long numberOfProcessors = structure.getNumerOfThreads(t); final long numberOfThreads = structure.getNumberOfThreads(t);
for (int p = 0; p < numberOfProcessors; ++p) { for (int p = 0; p < numberOfThreads; ++p) {
if (occupiedProcessors > manager.getNumberOfProcessors()) { if (occupiedProcessors > manager.getNumberOfProcessors()) {
taskInterference += taskInterference +=
Math.min( Math.min(
......
...@@ -6,7 +6,7 @@ import com.google.common.math.LongMath; ...@@ -6,7 +6,7 @@ import com.google.common.math.LongMath;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
import mvd.jester.model.Segment; import mvd.jester.model.Segment;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task; import mvd.jester.model.Task;
public interface TypeFunction { public interface TypeFunction {
...@@ -17,15 +17,15 @@ public interface TypeFunction { ...@@ -17,15 +17,15 @@ public interface TypeFunction {
public double getSelfInterference(final DagTask task); public double getSelfInterference(final DagTask task);
public long getNumerOfThreads(final DagTask task); public long getNumberOfThreads(final DagTask task);
public String getType(); public String getType();
public class KnownStructureWithMaxThreads implements TypeFunction { public class KnownStructureWithMaxThreads implements TypeFunction {
private final SystemManager manager; private final SystemManagerInterface manager;
public KnownStructureWithMaxThreads(final SystemManager manager) { public KnownStructureWithMaxThreads(final SystemManagerInterface manager) {
this.manager = manager; this.manager = manager;
} }
...@@ -75,7 +75,7 @@ public interface TypeFunction { ...@@ -75,7 +75,7 @@ public interface TypeFunction {
} }
@Override @Override
public long getNumerOfThreads(final DagTask task) { public long getNumberOfThreads(final DagTask task) {
return manager.getNumberOfProcessors(); return manager.getNumberOfProcessors();
} }
} }
...@@ -127,7 +127,7 @@ public interface TypeFunction { ...@@ -127,7 +127,7 @@ public interface TypeFunction {
} }
@Override @Override
public long getNumerOfThreads(final DagTask task) { public long getNumberOfThreads(final DagTask task) {
return task.getNumberOfThreads(); return task.getNumberOfThreads();
} }
} }
...@@ -180,7 +180,7 @@ public interface TypeFunction { ...@@ -180,7 +180,7 @@ public interface TypeFunction {
} }
@Override @Override
public long getNumerOfThreads(final DagTask task) { public long getNumberOfThreads(final DagTask task) {
return task.getNumberOfThreads(); return task.getNumberOfThreads();
} }
} }
......
...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayName; ...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import mvd.jester.model.SynchronousTask; import mvd.jester.model.SynchronousTask;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager;
import mvd.jester.model.SystemManager.SynchronousTaskBuilder;
import mvd.jester.simulator.DynamicForkJoin; import mvd.jester.simulator.DynamicForkJoin;
import mvd.jester.simulator.ParallelSynchronous; import mvd.jester.simulator.ParallelSynchronous;
import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
...@@ -49,7 +50,8 @@ public class TestEarliestDeadlineFirst { ...@@ -49,7 +50,8 @@ public class TestEarliestDeadlineFirst {
@DisplayName("Check Getters, Tests and Simulators.") @DisplayName("Check Getters, Tests and Simulators.")
void testGettersTestsAndSimulators() { void testGettersTestsAndSimulators() {
EarliestDeadlineFirst edf = new EarliestDeadlineFirst(); EarliestDeadlineFirst edf = new EarliestDeadlineFirst();
SystemManager manager = new SystemManager(4); SystemManager<SynchronousTaskBuilder> manager =
new SystemManager<>(SynchronousTaskBuilder.class);
assertTrue(edf.hasTest(ChwaLee.class)); assertTrue(edf.hasTest(ChwaLee.class));
assertFalse(edf.hasTest(MaiaBertogna.class)); assertFalse(edf.hasTest(MaiaBertogna.class));
assertFalse(edf.hasTest(SchmidMottok.class)); assertFalse(edf.hasTest(SchmidMottok.class));
......
...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayName; ...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import mvd.jester.model.SynchronousTask; import mvd.jester.model.SynchronousTask;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager;
import mvd.jester.model.SystemManager.SynchronousTaskBuilder;
import mvd.jester.simulator.DynamicForkJoin; import mvd.jester.simulator.DynamicForkJoin;
import mvd.jester.simulator.ParallelSynchronous; import mvd.jester.simulator.ParallelSynchronous;
import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
...@@ -48,7 +49,8 @@ public class TestRateMonotonic { ...@@ -48,7 +49,8 @@ public class TestRateMonotonic {
@DisplayName("Check Tests and Simulators.") @DisplayName("Check Tests and Simulators.")
void testTestsAndSimulators() { void testTestsAndSimulators() {
RateMonotonic rm = new RateMonotonic(); RateMonotonic rm = new RateMonotonic();
SystemManager manager = new SystemManager(8); SystemManager<SynchronousTaskBuilder> manager =
new SystemManager<>(SynchronousTaskBuilder.class);
assertFalse(rm.hasTest(ChwaLee.class)); assertFalse(rm.hasTest(ChwaLee.class));
assertTrue(rm.hasTest(MaiaBertogna.class)); assertTrue(rm.hasTest(MaiaBertogna.class));
assertTrue(rm.hasTest(SchmidMottok.class)); assertTrue(rm.hasTest(SchmidMottok.class));
......
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