Commit ad6f7a59 by Michael Schmid

SchmidMottok accepts interface

parent 578e6395
......@@ -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<AbstractTest<DagTask>> 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<AbstractTest<DagTask>> 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<AbstractTest<DagTask>> 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<AbstractTest<DagTask>> tests =
te.registerTests(Arrays.asList(new SchmidMottok(manager),
new MelaniButtazzo(manager), new FonsecaNelis(manager)));
te.measureExecutionTimes(builder, tests, manager, 500);
}
}
}
......@@ -22,11 +22,13 @@ public class SchmidMottok extends AbstractTest<DagTask> {
private final Map<Task, TerminationInfo> 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<DagTask> {
@Override
public String getName() {
return "SchmidMottok";
return "SchmidMottok"+ "_" + structure.getType();
}
private long calculateResponseTime(final Set<DagTask> tasks, final DagTask task) {
......@@ -63,7 +65,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
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<DagTask> {
}
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!");
// }
// }
}
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<Task, TerminationInfo> responseTimes,
final long interval,
final long parallelism);
public String getType();
public class UnkownStructure implements TypeFunction {
@Override
public double getTaskInterference(final DagTask task,
final Map<Task, TerminationInfo> 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<Task, TerminationInfo> 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
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