From 1900789053d66f0bd487e1d47e4f311c7dc64ec1 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Wed, 31 Jul 2019 14:48:09 +0200 Subject: [PATCH] found bug, MaiaBertogna Sim works now --- src/main/java/mvd/jester/App.java | 35 ++++++----------------------------- src/main/java/mvd/jester/TestEnvironment.java | 15 +++++---------- src/main/java/mvd/jester/simulator/AbstractSimulator.java | 9 ++++++++- src/main/java/mvd/jester/simulator/MaiaBertogna.java | 2 +- src/main/java/mvd/jester/tests/AbstractTest.java | 5 ++++- src/main/java/mvd/jester/tests/MaiaBertogna.java | 4 +--- src/main/java/mvd/jester/tests/SchmidMottok.java | 4 +--- 7 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 1770f40..1bb4f56 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -9,39 +9,16 @@ import mvd.jester.model.SystemSetup; */ public class App { public static void main(String[] args) { - boolean runTests = false; - if (runTests) { + 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, 40000); + // te.registerTestInterface(SchmidMottok.class); + te.registerTestPair(mvd.jester.tests.MaiaBertogna.class, + mvd.jester.simulator.MaiaBertogna.class); - // te.registerTestInterface(SchmidMottok.class); - te.registerTestPair(mvd.jester.tests.MaiaBertogna.class, - mvd.jester.simulator.MaiaBertogna.class); - - - te.runTests(); - } else { - File folder = new File("results"); - - for (File f : folder.listFiles()) { - SystemSetup systemSetup = SystemSetup.fromFile(f.toPath().toString()); - - mvd.jester.simulator.MaiaBertogna mb_sim = - new mvd.jester.simulator.MaiaBertogna(systemSetup); - mvd.jester.tests.MaiaBertogna mb_test = - new mvd.jester.tests.MaiaBertogna(systemSetup); - - boolean simCheck = mb_sim.runSimulation(); - boolean schedCheck = mb_test.runSchedulabilityCheck(); - - if (simCheck == false && schedCheck == true) { - System.out.println(f.getName()); - } - } - } + te.runTests(); } } diff --git a/src/main/java/mvd/jester/TestEnvironment.java b/src/main/java/mvd/jester/TestEnvironment.java index b2c88d2..a652023 100644 --- a/src/main/java/mvd/jester/TestEnvironment.java +++ b/src/main/java/mvd/jester/TestEnvironment.java @@ -90,16 +90,11 @@ public class TestEnvironment { .compute(kv.getValue(), (k, v) -> (v == null) ? 1 : v + 1); } if (schedCheck == true && simCheck == false) { - boolean sched = kv.getKey().runSchedulabilityCheck(); - boolean sim = kv.getValue().runSimulation(); - - if (sched == true && sim == false) { - try (PrintWriter out = new PrintWriter( - "results/manualCheck" + checkedTasksets + ".txt")) { - out.println(systemSetup); - } catch (Exception e) { - System.out.println("Ähm something went horribly wrong!"); - } + try (PrintWriter out = + new PrintWriter("results/manualCheck" + checkedTasksets + ".txt")) { + out.println(systemSetup); + } catch (Exception e) { + System.out.println("Ähm something went horribly wrong!"); } } } diff --git a/src/main/java/mvd/jester/simulator/AbstractSimulator.java b/src/main/java/mvd/jester/simulator/AbstractSimulator.java index 2c17afc..54aa99e 100644 --- a/src/main/java/mvd/jester/simulator/AbstractSimulator.java +++ b/src/main/java/mvd/jester/simulator/AbstractSimulator.java @@ -19,7 +19,7 @@ public abstract class AbstractSimulator implements SimulatorInterface { protected final SystemSetup systemSetup; protected final Set processors; protected final SortedTaskContextSet readyTasks; - protected final long hyperPeriod; + protected long hyperPeriod; AbstractSimulator(SystemSetup systemSetup) { this.systemSetup = systemSetup; @@ -32,6 +32,13 @@ public abstract class AbstractSimulator implements SimulatorInterface { // LongMath.pow(systemSetup.getTasks().last().getPeriod(), 2); } + protected void init() { + this.readyTasks.clear(); + for (ProcessorContext p : processors) { + p.setJob(null); + } + this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 10; + } protected boolean releaseTasks(long timeStep) { for (Task t : systemSetup.getTasks()) { diff --git a/src/main/java/mvd/jester/simulator/MaiaBertogna.java b/src/main/java/mvd/jester/simulator/MaiaBertogna.java index 193d8bd..a74729c 100644 --- a/src/main/java/mvd/jester/simulator/MaiaBertogna.java +++ b/src/main/java/mvd/jester/simulator/MaiaBertogna.java @@ -18,7 +18,7 @@ public class MaiaBertogna extends AbstractSimulator { @Override public boolean runSimulation() { - readyTasks.clear(); + init(); for (int t = 0; t < hyperPeriod; ++t) { if (!releaseTasks(t)) { return false; diff --git a/src/main/java/mvd/jester/tests/AbstractTest.java b/src/main/java/mvd/jester/tests/AbstractTest.java index c75bf40..5c7d819 100644 --- a/src/main/java/mvd/jester/tests/AbstractTest.java +++ b/src/main/java/mvd/jester/tests/AbstractTest.java @@ -2,6 +2,7 @@ package mvd.jester.tests; import java.util.HashMap; import java.util.Map; +import mvd.jester.model.SystemSetup; import mvd.jester.model.Task; /** @@ -10,8 +11,10 @@ import mvd.jester.model.Task; public abstract class AbstractTest implements TestInterface { protected final Map responseTimes; + protected final SystemSetup systemSetup; - public AbstractTest() { + public AbstractTest(SystemSetup systemSetup) { + this.systemSetup = systemSetup; this.responseTimes = new HashMap(); } } diff --git a/src/main/java/mvd/jester/tests/MaiaBertogna.java b/src/main/java/mvd/jester/tests/MaiaBertogna.java index aefa137..dafc9c5 100644 --- a/src/main/java/mvd/jester/tests/MaiaBertogna.java +++ b/src/main/java/mvd/jester/tests/MaiaBertogna.java @@ -12,10 +12,8 @@ import mvd.jester.model.SystemSetup; */ public class MaiaBertogna extends AbstractTest { - private final SystemSetup systemSetup; - public MaiaBertogna(SystemSetup systemSetup) { - this.systemSetup = systemSetup; + super(systemSetup); } @Override diff --git a/src/main/java/mvd/jester/tests/SchmidMottok.java b/src/main/java/mvd/jester/tests/SchmidMottok.java index e8fc344..3c89928 100644 --- a/src/main/java/mvd/jester/tests/SchmidMottok.java +++ b/src/main/java/mvd/jester/tests/SchmidMottok.java @@ -12,10 +12,8 @@ import mvd.jester.model.SystemSetup; */ public class SchmidMottok extends AbstractTest { - private final SystemSetup systemSetup; - public SchmidMottok(SystemSetup systemSetup) { - this.systemSetup = systemSetup; + super(systemSetup); } @Override -- libgit2 0.26.0