Commit 7999313d by Michael Schmid

intermediate commit, SchmidMottok bug still here

parent ef2d8bd0
package mvd.jester; package mvd.jester;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.simulator.MaiaBertogna;
import mvd.jester.simulator.SchmidMottok;
/** /**
* Hello world! * Hello world!
...@@ -8,17 +10,43 @@ import mvd.jester.model.SystemSetup; ...@@ -8,17 +10,43 @@ import mvd.jester.model.SystemSetup;
*/ */
public class App { public class App {
public static void main(String[] args) { public static void main(String[] args) {
// SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment(builder, 400);
// 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.runTests();
boolean mbWorked = false;
boolean smWorked = false;
SystemSetup thisOne = null;
do {
SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8); 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();
TestEnvironment te = new TestEnvironment(builder, 40000); thisOne = systemSetup;
} while (smWorked == mbWorked);
te.registerTestPair(mvd.jester.tests.MaiaBertogna.class,
mvd.jester.simulator.MaiaBertogna.class);
te.registerTestPair(mvd.jester.tests.SchmidMottok.class, SchmidMottok sm = new SchmidMottok(thisOne);
mvd.jester.simulator.SchmidMottok.class); MaiaBertogna mb = new MaiaBertogna(thisOne);
te.runTests(); mb.runSimulation();
sm.runSimulation();
} }
} }
...@@ -28,7 +28,7 @@ public abstract class AbstractSimulator implements SimulatorInterface { ...@@ -28,7 +28,7 @@ public abstract class AbstractSimulator implements SimulatorInterface {
for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) { for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) {
processors.add(new ProcessorContext(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 { ...@@ -76,7 +76,7 @@ public abstract class AbstractSimulator implements SimulatorInterface {
for (ProcessorContext p : processors) { for (ProcessorContext p : processors) {
p.setJob(null); p.setJob(null);
} }
this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 10; this.hyperPeriod = systemSetup.getTasks().last().getPeriod() * 2;
} }
......
...@@ -46,8 +46,8 @@ public class ProcessorContext { ...@@ -46,8 +46,8 @@ public class ProcessorContext {
} }
currentJob = optionalJob; currentJob = optionalJob;
currentJob.get().setCurrentProcessor(this); currentJob.get().setCurrentProcessor(this);
// System.out.println("Time " + t + ": " + this + " started job " + currentJob.get() System.out.println(
// + " of task" + taskContext + "!"); "Time " + t + ": " + this + " started job " + currentJob.get() + "!");
return true; return true;
} else { } else {
return false; return false;
......
...@@ -10,7 +10,7 @@ public interface TaskContextInterface { ...@@ -10,7 +10,7 @@ public interface TaskContextInterface {
public Task getTask(); public Task getTask();
public Optional<TaskContextInterface> acceptNotification(); public Optional<TaskContextInterface> acceptNotification(long time);
public Optional<JobContextInterface> getNextJob(); public Optional<JobContextInterface> getNextJob();
......
...@@ -31,11 +31,11 @@ public class JobContext implements JobContextInterface { ...@@ -31,11 +31,11 @@ public class JobContext implements JobContextInterface {
executionTime--; executionTime--;
if (executionTime == 0) { if (executionTime == 0) {
// System.out.println("Time " + time + ": " + currentProcessor.get() System.out.println("Time " + time + ": " + currentProcessor.get()
// + " finished execution of job " + this + "!"); + " finished execution of job " + this + "!");
currentProcessor.get().setJob(null); currentProcessor.get().setJob(null);
currentProcessor = Optional.empty(); currentProcessor = Optional.empty();
return taskContext.acceptNotification(); return taskContext.acceptNotification(time);
} }
return Optional.empty(); return Optional.empty();
...@@ -83,7 +83,7 @@ public class JobContext implements JobContextInterface { ...@@ -83,7 +83,7 @@ public class JobContext implements JobContextInterface {
@Override @Override
public String toString() { public String toString() {
return "(jobWcet=" + wcet + ")"; return "(jobWcet=" + wcet + ", of task=" + taskContext + ")";
} }
} }
...@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface { ...@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface {
return deadline; return deadline;
} }
public Optional<TaskContextInterface> acceptNotification() { public Optional<TaskContextInterface> acceptNotification(long time) {
segmentCounter++; segmentCounter++;
if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfJobs()) { if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfJobs()) {
currentSegment++; currentSegment++;
segmentCounter = 0; segmentCounter = 0;
if (currentSegment >= segments.size()) { if (currentSegment >= segments.size()) {
// System.out.println("Time " + time + ": Task " + this + "finished!"); System.out.println("Time " + time + ": Task " + this + "finished!");
return Optional.of(this); return Optional.of(this);
} }
} }
......
...@@ -32,20 +32,23 @@ public class JobContext implements JobContextInterface { ...@@ -32,20 +32,23 @@ public class JobContext implements JobContextInterface {
public Optional<TaskContextInterface> updateExecution(long time) { public Optional<TaskContextInterface> updateExecution(long time) {
if (!currentTasklet.isPresent()) { if (!currentTasklet.isPresent()) {
currentTasklet = segmentContext.getNextTasklet(); currentTasklet = segmentContext.getNextTasklet();
// if (currentTasklet.isPresent()) { if (currentTasklet.isPresent()) {
// System.out.println("Time " + time + ": Job " + this + " started executing tasklet " System.out.println("Time " + time + ": Job " + this + " started executing tasklet "
// + currentTasklet.get() + " on Processor " + currentProcessor.get()); + currentTasklet.get() + " on Processor " + currentProcessor.get());
// } }
} }
if (currentTasklet.isPresent()) { if (currentTasklet.isPresent()) {
currentTasklet.get().setCurrentJob(this); currentTasklet.get().setCurrentJob(this);
return currentTasklet.get().updateExecution(); // Hier update execution time, dann checken if 0, und wenn 0 gleich nächste Tasklet
} else { // auswählen.
return currentTasklet.get().updateExecution(time);
} else if (currentProcessor.isPresent()) {
currentProcessor.get().setJob(null); currentProcessor.get().setJob(null);
currentProcessor = Optional.empty(); currentProcessor = Optional.empty();
return Optional.empty();
} }
return Optional.empty();
} }
public boolean checkExecutionTime() { public boolean checkExecutionTime() {
......
...@@ -37,9 +37,16 @@ public class SegmentContext { ...@@ -37,9 +37,16 @@ public class SegmentContext {
} }
Optional<JobContextInterface> getNextJob() { Optional<JobContextInterface> getNextJob() {
boolean taskletAvailable = tasklets.stream()
.anyMatch(t -> !t.getCurrentJob().isPresent() && t.checkExecutionTime());
if (taskletAvailable) {
return jobs.stream() return jobs.stream()
.filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()) .filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime())
.findFirst(); .findFirst();
} else {
return Optional.empty();
}
} }
Optional<TaskletContext> getNextTasklet() { Optional<TaskletContext> getNextTasklet() {
......
...@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface { ...@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface {
return deadline; return deadline;
} }
public Optional<TaskContextInterface> acceptNotification() { public Optional<TaskContextInterface> acceptNotification(long time) {
segmentCounter++; segmentCounter++;
if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfTasklets()) { if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfTasklets()) {
currentSegment++; currentSegment++;
segmentCounter = 0; segmentCounter = 0;
if (currentSegment >= segments.size()) { if (currentSegment >= segments.size()) {
// System.out.println("Time " + time + ": Task " + this + "finished!"); System.out.println("Time " + time + ": Task " + this + "finished!");
return Optional.of(this); return Optional.of(this);
} }
} }
......
...@@ -33,13 +33,13 @@ public class TaskletContext { ...@@ -33,13 +33,13 @@ public class TaskletContext {
currentJob = Optional.ofNullable(jobContext); currentJob = Optional.ofNullable(jobContext);
} }
public Optional<TaskContextInterface> updateExecution() { public Optional<TaskContextInterface> updateExecution(long time) {
executionTime--; executionTime--;
if (executionTime == 0) { if (executionTime == 0) {
currentJob.get().setCurrentTasklet(null); currentJob.get().setCurrentTasklet(null);
currentJob = Optional.empty(); currentJob = Optional.empty();
return taskContext.acceptNotification(); return taskContext.acceptNotification(time);
} }
return Optional.empty(); return Optional.empty();
} }
......
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