Commit 7999313d by Michael Schmid

intermediate commit, SchmidMottok bug still here

parent ef2d8bd0
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();
}
}
......@@ -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;
}
......
......@@ -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;
......
......@@ -10,7 +10,7 @@ public interface TaskContextInterface {
public Task getTask();
public Optional<TaskContextInterface> acceptNotification();
public Optional<TaskContextInterface> acceptNotification(long time);
public Optional<JobContextInterface> getNextJob();
......
......@@ -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 + ")";
}
}
......@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface {
return deadline;
}
public Optional<TaskContextInterface> acceptNotification() {
public Optional<TaskContextInterface> 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);
}
}
......
......@@ -32,20 +32,23 @@ public class JobContext implements JobContextInterface {
public Optional<TaskContextInterface> 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() {
......
......@@ -37,9 +37,16 @@ public class SegmentContext {
}
Optional<JobContextInterface> 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<TaskletContext> getNextTasklet() {
......
......@@ -45,14 +45,14 @@ public class TaskContext implements TaskContextInterface {
return deadline;
}
public Optional<TaskContextInterface> acceptNotification() {
public Optional<TaskContextInterface> 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);
}
}
......
......@@ -33,13 +33,13 @@ public class TaskletContext {
currentJob = Optional.ofNullable(jobContext);
}
public Optional<TaskContextInterface> updateExecution() {
public Optional<TaskContextInterface> updateExecution(long time) {
executionTime--;
if (executionTime == 0) {
currentJob.get().setCurrentTasklet(null);
currentJob = Optional.empty();
return taskContext.acceptNotification();
return taskContext.acceptNotification(time);
}
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