diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index d88d5cc..2aea9e8 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -6,6 +6,8 @@ import mvd.jester.model.DagTask; import mvd.jester.model.SystemSetup; import mvd.jester.tests.AbstractTest; import mvd.jester.tests.FonsecaNelis; +import mvd.jester.tests.MelaniButtazzo; +import mvd.jester.tests.SchmidMottok; /** @@ -19,12 +21,10 @@ public class App { new SystemSetup.DagTaskBuilder().setNumberOfProcessors(p); TestEnvironment te = new TestEnvironment(); - List> tests = - te.registerTests(Arrays.asList(/* - * new SchmidMottok(p), new MelaniButtazzo(p) , - */ new FonsecaNelis(p))); + List> tests = te.registerTests(Arrays.asList(new SchmidMottok(p), + /* new MelaniButtazzo(p), */ new FonsecaNelis(p))); - te.runExperiments(builder, tests, p, 100); + te.runExperiments(builder, tests, p, 100); // TODO: Change back to 500 } } } diff --git a/src/main/java/mvd/jester/TestEnvironment.java b/src/main/java/mvd/jester/TestEnvironment.java index e4a5c09..92ad2a1 100644 --- a/src/main/java/mvd/jester/TestEnvironment.java +++ b/src/main/java/mvd/jester/TestEnvironment.java @@ -91,7 +91,7 @@ public class TestEnvironment { abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0)); for (double util = 1; util <= numberOfProcessors; util += 0.25) { resultMap.replaceAll((k, v) -> (long) 0); - nextTry: for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { + for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { final Set taskSet = builder.generateTaskSet(util); System.out.print(Math.round((double) checkedTasksets / numberOfTaskSets * 100) @@ -102,14 +102,8 @@ public class TestEnvironment { final SortedTaskSet sortedTaskSet = new SortedTaskSet<>(priorityManager); sortedTaskSet.addAll(taskSet); - final SchedulingInfo schedulingInfo; - try { - schedulingInfo = testInstance.runSchedulabilityCheck(sortedTaskSet); - } catch (Exception e) { - i--; - continue nextTry; - // TODO: remove this exception - } + final SchedulingInfo schedulingInfo = + testInstance.runSchedulabilityCheck(sortedTaskSet); if (schedulingInfo.getFeasibility() == Feasiblity.SUCCEEDED) { resultMap.computeIfPresent(testInstance, (k, v) -> v + 1); diff --git a/src/main/java/mvd/jester/model/SystemSetup.java b/src/main/java/mvd/jester/model/SystemSetup.java index a2ada5b..03d732f 100644 --- a/src/main/java/mvd/jester/model/SystemSetup.java +++ b/src/main/java/mvd/jester/model/SystemSetup.java @@ -209,7 +209,7 @@ public class SystemSetup { private long maxNumberOfBranches = 5; private long depth = 2; private long p_par = 80; - private long p_add = 20; + private long p_add = 5; // TODO: Change back to 20 public DagTaskBuilder() { } diff --git a/src/main/java/mvd/jester/tests/FonsecaNelis.java b/src/main/java/mvd/jester/tests/FonsecaNelis.java index 6074a0b..333fd43 100644 --- a/src/main/java/mvd/jester/tests/FonsecaNelis.java +++ b/src/main/java/mvd/jester/tests/FonsecaNelis.java @@ -13,7 +13,6 @@ import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.math.LongMath; -import org.jgrapht.Graphs; import org.jgrapht.experimental.dag.DirectedAcyclicGraph; import org.jgrapht.graph.DefaultEdge; import mvd.jester.info.SchedulingInfo; @@ -35,13 +34,13 @@ public class FonsecaNelis extends AbstractTest { private final Map responseTimes; private final PriorityManager priorityManager; - private final Map> sortedSegments; + private final Map> carryOutSegments; public FonsecaNelis(final long numberOfProcessors) { super(numberOfProcessors); this.responseTimes = new HashMap<>(); this.priorityManager = new RateMonotonic(); - this.sortedSegments = new HashMap<>(); + this.carryOutSegments = new HashMap<>(); } @Override @@ -51,7 +50,7 @@ public class FonsecaNelis extends AbstractTest { @Override public SchedulingInfo runSchedulabilityCheck(final SortedTaskSet tasks) { - sortedSegments.clear(); + carryOutSegments.clear(); responseTimes.clear(); createNFJandDecompositionTree(tasks); for (final DagTask t : tasks) { @@ -69,78 +68,9 @@ public class FonsecaNelis extends AbstractTest { final DirectedAcyclicGraph nfjJobDag = DagUtils.createNFJGraph(jobDag); final BinaryDecompositionTree tree = DagUtils.createDecompositionTree(nfjJobDag); - // TODO: remove this - if (!DagUtils.checkNFJProperty(nfjJobDag) || !checkTree(nfjJobDag, tree)) { - throw new RuntimeException("Nicht NFJ in Test!"); - } - - sortedSegments.put(t, constructCarryOutDistribution(nfjJobDag, tree)); - } - } - - // TODO: Remove this function - private boolean checkTree(DirectedAcyclicGraph nfjJobDag, - BinaryDecompositionTree tree) { - DirectedAcyclicGraph jobDagFromTree = - DagUtils.createNFJfromDecompositionTree(tree); - - if (nfjJobDag.vertexSet().size() != jobDagFromTree.vertexSet().size()) { - return false; - } - if (jobDagFromTree.edgeSet().size() != nfjJobDag.edgeSet().size()) { - return false; - } - - - for (DefaultEdge e : nfjJobDag.edgeSet()) { - Job target = nfjJobDag.getEdgeTarget(e); - Job source = nfjJobDag.getEdgeSource(e); - - if (!jobDagFromTree.containsEdge(source, target)) { - return false; - } - } - - for (Job j : nfjJobDag) { - for (Job n : nfjJobDag) { - if (n == j) { - continue; - } - if (nfjJobDag.containsEdge(n, j) && !jobDagFromTree.containsEdge(n, j)) { - return false; - } - } - if (nfjJobDag.inDegreeOf(j) != jobDagFromTree.inDegreeOf(j)) - return false; - if (nfjJobDag.outDegreeOf(j) != jobDagFromTree.outDegreeOf(j)) - return false; - - for (Job p : Graphs.predecessorListOf(nfjJobDag, j)) { - if (!Graphs.predecessorListOf(jobDagFromTree, j).contains(p)) { - return false; - } - } - - for (Job s : Graphs.successorListOf(nfjJobDag, j)) { - if (!Graphs.successorListOf(jobDagFromTree, j).contains(s)) { - return false; - } - } - for (Job a : nfjJobDag.getAncestors(nfjJobDag, j)) { - if (!jobDagFromTree.getAncestors(jobDagFromTree, j).contains(a)) { - return false; - } - } - - for (Job d : nfjJobDag.getDescendants(nfjJobDag, j)) { - if (!jobDagFromTree.getDescendants(jobDagFromTree, j).contains(d)) { - return false; - } - } + carryOutSegments.put(t, constructCarryOutDistribution(nfjJobDag, tree)); } - - return true; } private Set constructCarryOutDistribution( @@ -182,7 +112,7 @@ public class FonsecaNelis extends AbstractTest { if (node.getNodeType().equals(NodeType.LEAF)) { return new Node(parent, new TreeJob(node.getObject())); } else { - final Node modifiedNode = new Node(null, node.getNodeType()); + final Node modifiedNode = new Node(parent, node.getNodeType()); modifiedNode.setLeftNode(transformNode(modifiedNode, node.getLeftNode())); modifiedNode.setRightNode(transformNode(modifiedNode, node.getRightNode())); return modifiedNode; @@ -233,10 +163,6 @@ public class FonsecaNelis extends AbstractTest { final long totalInterference = (long) Math.floor(taskInterference + selfInterference); responseTime = criticalPath + totalInterference; - // TODO: remove check of deadline if bug is found - if (responseTime > task.getDeadline()) { - return responseTime; - } } while (responseTime != previousResponseTime); return responseTime; @@ -245,9 +171,9 @@ public class FonsecaNelis extends AbstractTest { private double getTaskInterference(final DagTask task, final long interval) { final long period = task.getPeriod(); final long criticalPath = task.getCriticalPath(); - final long numberOfIntervals = + final long numberOfPeriods = LongMath.divide(interval - criticalPath, period, RoundingMode.FLOOR); - final long carryInAndOutInterval = interval - Math.max(0, numberOfIntervals) * period; + final long carryInAndOutInterval = interval - Math.max(0, numberOfPeriods) * period; final long numberOfBodyJobs = LongMath.divide(interval - carryInAndOutInterval, period, RoundingMode.FLOOR); @@ -255,7 +181,7 @@ public class FonsecaNelis extends AbstractTest { final long carryInAndOutWorkload = getCarryInAndOutWorkload(task, - task.getWorkloadDistribution(), sortedSegments.get(task), carryInAndOutInterval); + task.getWorkloadDistribution(), carryOutSegments.get(task), carryInAndOutInterval); return carryInAndOutWorkload + bodyWorkload; } @@ -299,8 +225,8 @@ public class FonsecaNelis extends AbstractTest { private long getCarryOutWorkload(final DagTask task, final Set carryOutDistribution, final long carryOutPeriod) { long workload = 0; - final long period = task.getPeriod(); - final long responseTime = responseTimes.get(task).getResponseTime(); + final long taskWorkload = task.getWorkload(); + final long criticalPath = task.getCriticalPath(); final List distributionList = Lists.newArrayList(carryOutDistribution); for (int i = 0; i < distributionList.size(); ++i) { @@ -314,10 +240,12 @@ public class FonsecaNelis extends AbstractTest { workload += Math.max(Math.min(width, s.getJobWcet()), 0) * s.getNumberOfJobs(); } - final long improvedWorkload = - Math.max(carryOutPeriod - (period - responseTime), 0) * numberOfProcessors; + final long improvedWorkloadFromTask = + taskWorkload - Math.max(0, criticalPath - carryOutPeriod); + final long improvedWorkloadFromProcessors = carryOutPeriod * numberOfProcessors; - return Math.min(improvedWorkload, workload); + return Math.min(Math.min(improvedWorkloadFromTask, improvedWorkloadFromProcessors), + workload); } private long getCarryInWorkload(final DagTask task, final Set carryInDistribution,