From ad6f7a5916450ca25084092ce416263fd8ff2fb7 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Mon, 29 Jun 2020 15:49:02 +0200 Subject: [PATCH] SchmidMottok accepts interface --- src/main/java/mvd/jester/App.java | 33 +++++++++++++++++++-------------- src/main/java/mvd/jester/tests/SchmidMottok.java | 62 ++++++++++++++++++++++++++++++++------------------------------ src/main/java/mvd/jester/tests/TypeFunction.java | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 44 deletions(-) create mode 100644 src/main/java/mvd/jester/tests/TypeFunction.java diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 9142a2b..cb7d80b 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -9,6 +9,8 @@ import mvd.jester.tests.AbstractTest; import mvd.jester.tests.FonsecaNelis; import mvd.jester.tests.MelaniButtazzo; import mvd.jester.tests.SchmidMottok; +import mvd.jester.tests.TypeFunction.KownStructure; +import mvd.jester.tests.TypeFunction.UnkownStructure; /** @@ -23,7 +25,8 @@ public class App { // TestEnvironment te = new TestEnvironment(); // List> tests = - // te.registerTests(Arrays.asList(new SchmidMottok(manager), + // te.registerTests(Arrays.asList(new SchmidMottok(new UnkownStructure(), manager), + // new SchmidMottok(new KownStructure(), manager), // new MelaniButtazzo(manager), new FonsecaNelis(manager))); // te.varyUtilization(builder, tests, 8, 500); @@ -34,11 +37,24 @@ public class App { // TestEnvironment te = new TestEnvironment(); // List> tests = - // te.registerTests(Arrays.asList(new SchmidMottok(manager), + // te.registerTests(Arrays.asList(new SchmidMottok(new UnkownStructure(), manager), + // new SchmidMottok(new KownStructure(), manager), // new MelaniButtazzo(manager), new FonsecaNelis(manager))); // te.varyNumberOfProcessors(builder, tests, manager, 500); // } + { + SystemManager manager = new SystemManager(8); + DagTaskBuilder builder = new DagTaskBuilder(); + TestEnvironment te = new TestEnvironment(); + + List> tests = + te.registerTests(Arrays.asList(new SchmidMottok(new UnkownStructure(), manager), + new SchmidMottok(new KownStructure(), manager), + new MelaniButtazzo(manager), new FonsecaNelis(manager))); + + te.varyNumberOfTasks(builder, tests, 8, 500); + } // { // SystemManager manager = new SystemManager(8); // DagTaskBuilder builder = new DagTaskBuilder(); @@ -48,18 +64,7 @@ public class App { // te.registerTests(Arrays.asList(new SchmidMottok(manager), // new MelaniButtazzo(manager), new FonsecaNelis(manager))); - // te.varyNumberOfTasks(builder, tests, 8, 500); + // te.measureExecutionTimes(builder, tests, manager, 500); // } - { - SystemManager manager = new SystemManager(8); - DagTaskBuilder builder = new DagTaskBuilder(); - TestEnvironment te = new TestEnvironment(); - - List> tests = - te.registerTests(Arrays.asList(new SchmidMottok(manager), - new MelaniButtazzo(manager), new FonsecaNelis(manager))); - - te.measureExecutionTimes(builder, tests, manager, 500); - } } } diff --git a/src/main/java/mvd/jester/tests/SchmidMottok.java b/src/main/java/mvd/jester/tests/SchmidMottok.java index 3d29ac3..98f7368 100644 --- a/src/main/java/mvd/jester/tests/SchmidMottok.java +++ b/src/main/java/mvd/jester/tests/SchmidMottok.java @@ -22,11 +22,13 @@ public class SchmidMottok extends AbstractTest { private final Map responseTimes; private final PriorityManager priorityManager; + private final TypeFunction structure; - public SchmidMottok(final SystemManager manager) { + public SchmidMottok(TypeFunction structure, final SystemManager manager) { super(manager); this.responseTimes = new HashMap<>(); this.priorityManager = new RateMonotonic(); + this.structure = structure; } @Override @@ -47,7 +49,7 @@ public class SchmidMottok extends AbstractTest { @Override public String getName() { - return "SchmidMottok"; + return "SchmidMottok"+ "_" + structure.getType(); } private long calculateResponseTime(final Set tasks, final DagTask task) { @@ -63,7 +65,7 @@ public class SchmidMottok extends AbstractTest { if (t.getPeriod() < task.getPeriod()) { final long numberOfThreads = t.getNumberOfThreads(); for (int p = 0; p < numberOfThreads; ++p) { - taskInterference += Math.min(getTaskInterference(t, responseTime, p + 1), + taskInterference += Math.min(structure.getTaskInterference(t, responseTimes, responseTime, p + 1), responseTime - minimumWcet + 1); } } @@ -93,32 +95,32 @@ public class SchmidMottok extends AbstractTest { } - private double getTaskInterference(final DagTask task, final long interval, - final long parallelism) { - if (responseTimes.containsKey(task)) { - final long responseTime = responseTimes.get(task).getResponseTime(); - final long minWcet = task.getCriticalPath(); - final long period = task.getPeriod(); - final long amountOfJobs = - (LongMath.divide(interval + responseTime - minWcet, period, RoundingMode.FLOOR) - + 1); - - double workload = 0; - - for (final Segment s : task.getWorkloadDistribution()) { - final long numberOfThreads = - s.getNumberOfJobs() > 1 ? task.getNumberOfThreads() : 1; - if (numberOfThreads >= parallelism) { - workload += s.getNumberOfJobs() * s.getJobWcet() / numberOfThreads; - } - } - - final double interference = amountOfJobs * workload; - - return interference; - } else { - throw new RuntimeException("Task was not found in task set!"); - } - } + // private double getTaskInterference(final DagTask task, final long interval, + // final long parallelism) { + // if (responseTimes.containsKey(task)) { + // final long responseTime = responseTimes.get(task).getResponseTime(); + // final long minWcet = task.getCriticalPath(); + // final long period = task.getPeriod(); + // final long amountOfJobs = + // (LongMath.divide(interval + responseTime - minWcet, period, RoundingMode.FLOOR) + // + 1); + + // double workload = 0; + + // for (final Segment s : task.getWorkloadDistribution()) { + // final long numberOfThreads = + // s.getNumberOfJobs() > 1 ? task.getNumberOfThreads() : 1; + // if (numberOfThreads >= parallelism) { + // workload += (double)(s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads; + // } + // } + + // final double interference = amountOfJobs * workload; + + // return interference; + // } else { + // throw new RuntimeException("Task was not found in task set!"); + // } + // } } diff --git a/src/main/java/mvd/jester/tests/TypeFunction.java b/src/main/java/mvd/jester/tests/TypeFunction.java new file mode 100644 index 0000000..5b4f142 --- /dev/null +++ b/src/main/java/mvd/jester/tests/TypeFunction.java @@ -0,0 +1,98 @@ +package mvd.jester.tests; + +import java.math.RoundingMode; +import java.util.Map; +import com.google.common.math.LongMath; +import mvd.jester.info.TerminationInfo; +import mvd.jester.model.DagTask; +import mvd.jester.model.Segment; +import mvd.jester.model.Task; + +public interface TypeFunction { + + public double getTaskInterference(final DagTask task, + final Map responseTimes, + final long interval, + final long parallelism); + + public String getType(); + + public class UnkownStructure implements TypeFunction { + + @Override + public double getTaskInterference(final DagTask task, + final Map responseTimes, + final long interval, + final long parallelism) { + if (responseTimes.containsKey(task)) { + final long responseTime = responseTimes.get(task).getResponseTime(); + final long minWcet = task.getCriticalPath(); + final long period = task.getPeriod(); + final long amountOfJobs = + (LongMath.divide(interval + responseTime - minWcet, period, RoundingMode.FLOOR) + + 1); + + double workload = 0; + + for (final Segment s : task.getWorkloadDistribution()) { + final long numberOfThreads = + task.getNumberOfThreads(); + if (numberOfThreads >= parallelism) { + workload += (double)(s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads; + } + } + + final double interference = amountOfJobs * workload; + + return interference; + } else { + throw new RuntimeException("Task was not found in task set!"); + } + } + + @Override + public String getType() { + return "SU"; + } + } + + public class KownStructure implements TypeFunction { + + @Override + public double getTaskInterference(final DagTask task, + final Map responseTimes, + final long interval, + final long parallelism) { + if (responseTimes.containsKey(task)) { + final long responseTime = responseTimes.get(task).getResponseTime(); + final long minWcet = task.getCriticalPath(); + final long period = task.getPeriod(); + final long amountOfJobs = + (LongMath.divide(interval + responseTime - minWcet, period, RoundingMode.FLOOR) + + 1); + + double workload = 0; + + for (final Segment s : task.getWorkloadDistribution()) { + final long numberOfThreads = + s.getNumberOfJobs() > 1 ? task.getNumberOfThreads() : 1; + if (numberOfThreads >= parallelism) { + workload += (double)(s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads; + } + } + + final double interference = amountOfJobs * workload; + + return interference; + } else { + throw new RuntimeException("Task was not found in task set!"); + } + } + + @Override + public String getType() { + return "SK"; + } + } + +} \ No newline at end of file -- libgit2 0.26.0