From 7999313dec22d48c1e69a5921050027011b7bce9 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Tue, 27 Aug 2019 14:01:42 +0200 Subject: [PATCH] intermediate commit, SchmidMottok bug still here --- src/main/java/mvd/jester/App.java | 42 +++++++++++++++++++++++++++++++++++------- src/main/java/mvd/jester/simulator/AbstractSimulator.java | 4 ++-- src/main/java/mvd/jester/simulator/internals/ProcessorContext.java | 4 ++-- src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java | 2 +- src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java | 8 ++++---- src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java | 4 ++-- src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java | 17 ++++++++++------- src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java | 13 ++++++++++--- src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java | 4 ++-- src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java | 4 ++-- 10 files changed, 70 insertions(+), 32 deletions(-) diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 2bfd00d..8c73eff 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -1,6 +1,8 @@ package mvd.jester; import mvd.jester.model.SystemSetup; +import mvd.jester.simulator.MaiaBertogna; +import mvd.jester.simulator.SchmidMottok; /** * Hello world! @@ -8,17 +10,43 @@ import mvd.jester.model.SystemSetup; */ public class App { 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, 400); - TestEnvironment te = new TestEnvironment(builder, 40000); + // te.registerTestPair(mvd.jester.tests.MaiaBertogna.class, + // mvd.jester.simulator.MaiaBertogna.class); - te.registerTestPair(mvd.jester.tests.MaiaBertogna.class, - mvd.jester.simulator.MaiaBertogna.class); + // te.registerTestPair(mvd.jester.tests.SchmidMottok.class, + // mvd.jester.simulator.SchmidMottok.class); - te.registerTestPair(mvd.jester.tests.SchmidMottok.class, - mvd.jester.simulator.SchmidMottok.class); + // te.runTests(); - te.runTests(); + boolean mbWorked = false; + boolean smWorked = false; + + SystemSetup thisOne = null; + + do { + SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8); + SystemSetup systemSetup = builder.build(); + + SchmidMottok sm = new SchmidMottok(systemSetup); + MaiaBertogna mb = new MaiaBertogna(systemSetup); + + + smWorked = sm.runSimulation(); + mbWorked = mb.runSimulation(); + + + thisOne = systemSetup; + } while (smWorked == mbWorked); + + + SchmidMottok sm = new SchmidMottok(thisOne); + MaiaBertogna mb = new MaiaBertogna(thisOne); + + mb.runSimulation(); + sm.runSimulation(); } } diff --git a/src/main/java/mvd/jester/simulator/AbstractSimulator.java b/src/main/java/mvd/jester/simulator/AbstractSimulator.java index 90f190f..9e874a2 100644 --- a/src/main/java/mvd/jester/simulator/AbstractSimulator.java +++ b/src/main/java/mvd/jester/simulator/AbstractSimulator.java @@ -28,7 +28,7 @@ public abstract class AbstractSimulator implements SimulatorInterface { for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) { processors.add(new ProcessorContext(i)); } - this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 10; + this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 2 /* * 10 */; } @@ -76,7 +76,7 @@ public abstract class AbstractSimulator implements SimulatorInterface { for (ProcessorContext p : processors) { p.setJob(null); } - this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 10; + this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 2; } diff --git a/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java b/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java index 2778269..2e017c2 100644 --- a/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java +++ b/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java @@ -46,8 +46,8 @@ public class ProcessorContext { } currentJob = optionalJob; currentJob.get().setCurrentProcessor(this); - // System.out.println("Time " + t + ": " + this + " started job " + currentJob.get() - // + " of task" + taskContext + "!"); + System.out.println( + "Time " + t + ": " + this + " started job " + currentJob.get() + "!"); return true; } else { return false; diff --git a/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java b/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java index c08f761..8cb8d78 100644 --- a/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java +++ b/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java @@ -10,7 +10,7 @@ public interface TaskContextInterface { public Task getTask(); - public Optional acceptNotification(); + public Optional acceptNotification(long time); public Optional getNextJob(); diff --git a/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java b/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java index 8c6ff2c..3af705a 100644 --- a/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java +++ b/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java @@ -31,11 +31,11 @@ public class JobContext implements JobContextInterface { executionTime--; if (executionTime == 0) { - // System.out.println("Time " + time + ": " + currentProcessor.get() - // + " finished execution of job " + this + "!"); + System.out.println("Time " + time + ": " + currentProcessor.get() + + " finished execution of job " + this + "!"); currentProcessor.get().setJob(null); currentProcessor = Optional.empty(); - return taskContext.acceptNotification(); + return taskContext.acceptNotification(time); } return Optional.empty(); @@ -83,7 +83,7 @@ public class JobContext implements JobContextInterface { @Override public String toString() { - return "(jobWcet=" + wcet + ")"; + return "(jobWcet=" + wcet + ", of task=" + taskContext + ")"; } } diff --git a/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java index bf09ec9..d1a7ead 100644 --- a/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java +++ b/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java @@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface { return deadline; } - public Optional acceptNotification() { + public Optional acceptNotification(long time) { segmentCounter++; if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfJobs()) { currentSegment++; segmentCounter = 0; if (currentSegment >= segments.size()) { - // System.out.println("Time " + time + ": Task " + this + "finished!"); + System.out.println("Time " + time + ": Task " + this + "finished!"); return Optional.of(this); } } diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java b/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java index 7a4239d..0f85486 100644 --- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java +++ b/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java @@ -32,20 +32,23 @@ public class JobContext implements JobContextInterface { public Optional updateExecution(long time) { if (!currentTasklet.isPresent()) { currentTasklet = segmentContext.getNextTasklet(); - // if (currentTasklet.isPresent()) { - // System.out.println("Time " + time + ": Job " + this + " started executing tasklet " - // + currentTasklet.get() + " on Processor " + currentProcessor.get()); - // } + if (currentTasklet.isPresent()) { + System.out.println("Time " + time + ": Job " + this + " started executing tasklet " + + currentTasklet.get() + " on Processor " + currentProcessor.get()); + } } if (currentTasklet.isPresent()) { currentTasklet.get().setCurrentJob(this); - return currentTasklet.get().updateExecution(); - } else { + // Hier update execution time, dann checken if 0, und wenn 0 gleich nächste Tasklet + // auswählen. + return currentTasklet.get().updateExecution(time); + } else if (currentProcessor.isPresent()) { currentProcessor.get().setJob(null); currentProcessor = Optional.empty(); - return Optional.empty(); } + + return Optional.empty(); } public boolean checkExecutionTime() { diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java b/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java index ea46968..fef06ab 100644 --- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java +++ b/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java @@ -37,9 +37,16 @@ public class SegmentContext { } Optional getNextJob() { - return jobs.stream() - .filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()) - .findFirst(); + boolean taskletAvailable = tasklets.stream() + .anyMatch(t -> !t.getCurrentJob().isPresent() && t.checkExecutionTime()); + + if (taskletAvailable) { + return jobs.stream() + .filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()) + .findFirst(); + } else { + return Optional.empty(); + } } Optional getNextTasklet() { diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java index fe66331..2c2718c 100644 --- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java +++ b/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java @@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface { return deadline; } - public Optional acceptNotification() { + public Optional acceptNotification(long time) { segmentCounter++; if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfTasklets()) { currentSegment++; segmentCounter = 0; if (currentSegment >= segments.size()) { - // System.out.println("Time " + time + ": Task " + this + "finished!"); + System.out.println("Time " + time + ": Task " + this + "finished!"); return Optional.of(this); } } diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java b/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java index 8662571..38f68ba 100644 --- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java +++ b/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java @@ -33,13 +33,13 @@ public class TaskletContext { currentJob = Optional.ofNullable(jobContext); } - public Optional updateExecution() { + public Optional updateExecution(long time) { executionTime--; if (executionTime == 0) { currentJob.get().setCurrentTasklet(null); currentJob = Optional.empty(); - return taskContext.acceptNotification(); + return taskContext.acceptNotification(time); } return Optional.empty(); } -- libgit2 0.26.0