Commit 8054de06 by Michael Schmid

small changes and improved response time

parent 84d3cbf6
...@@ -2,21 +2,14 @@ package mvd.jester; ...@@ -2,21 +2,14 @@ package mvd.jester;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager;
import mvd.jester.model.SystemManager.DagTaskBuilder; import mvd.jester.model.SystemManager.DagTaskBuilder;
import mvd.jester.tests.AbstractTest; import mvd.jester.tests.AbstractTest;
import mvd.jester.tests.FonsecaNelis; import mvd.jester.tests.FonsecaNelis;
import mvd.jester.tests.JiangYi; import mvd.jester.tests.JiangYi;
import mvd.jester.tests.MelaniButtazzo;
import mvd.jester.tests.SchmidMottok; import mvd.jester.tests.SchmidMottok;
import mvd.jester.tests.Tester; import mvd.jester.tests.TypeFunction.UnknownStructure;
import mvd.jester.tests.TypeFunction.KnownStructureWithMaxThreads;
import mvd.jester.tests.TypeFunction.KnownStructure;
import mvd.jester.tests.TypeFunction.UnkownStructure;
import mvd.jester.tests.TypeFunction.TestFunction;
/** /**
...@@ -27,66 +20,65 @@ public class App { ...@@ -27,66 +20,65 @@ public class App {
public static void main(String[] args) { public static void main(String[] args) {
{ {
SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class); SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
manager.setNumberOfProcessors(32); manager.setNumberOfProcessors(8);
TestEnvironment te = new TestEnvironment(); TestEnvironment te = new TestEnvironment();
List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(
new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), /* new SchmidMottok(new KnownStructure(), manager), */
new Tester(new KnownStructure(), manager), new SchmidMottok(new UnknownStructure(), manager),
// new MelaniButtazzo(manager), // new Tester(new UnknownStructure(), manager),
// new FonsecaNelis(manager) // new MelaniButtazzo(manager),,
new JiangYi(manager))); new FonsecaNelis(manager), //
new JiangYi(manager)//
));
te.varyRenyiUtilization(manager, tests, 100); te.varyRenyiUtilization(manager, tests, 500);
} }
// { {
// SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class); SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// TestEnvironment te = new TestEnvironment(); manager.setNumberOfProcessors(8);
TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(
// new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager),
// new SchmidMottok(new KnownStructure(), manager)
// // new MelaniButtazzo(manager)
// , new FonsecaNelis(manager)
// ));
// te.varyUtilization(manager, tests, 500);
// }
// {
// SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(
// new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), /* new SchmidMottok(new KnownStructure(), manager), */
// new SchmidMottok(new KnownStructure(), manager), new SchmidMottok(new UnknownStructure(), manager),
// // new MelaniButtazzo(manager), // new Tester(new UnknownStructure(), manager),
// // new FonsecaNelis(manager), // new MelaniButtazzo(manager),,
// new JiangYi(manager))); new FonsecaNelis(manager), //
new JiangYi(manager)//
));
// te.varyNumberOfProcessors(manager, tests, 500); te.varyPropability(manager, tests, 500);
// } }
// { {
// SystemManager manager = new SystemManager(8); SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// DagTaskBuilder builder = new DagTaskBuilder(); manager.setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment(); TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( //
// te.registerTests(Arrays.asList(new SchmidMottok(new UnkownStructure(), manager), // new SchmidMottok(new KnownStructure(), manager), //
// new SchmidMottok(new KownStructure(), manager), new SchmidMottok(new UnknownStructure(), manager), //
// new MelaniButtazzo(manager), new FonsecaNelis(manager))); // new Tester(new UnknownStructure(), manager), //
// new MelaniButtazzo(manager), //
new FonsecaNelis(manager), //
new JiangYi(manager)));
// te.varyNumberOfTasks(builder, tests, 8, 500); te.varyNumberOfProcessors(manager, tests, 500);
// } }
// { {
// SystemManager manager = new SystemManager(8); SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// DagTaskBuilder builder = new DagTaskBuilder(); manager.setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment(); TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( //
// te.registerTests(Arrays.asList(new SchmidMottok(manager), // new SchmidMottok(new KnownStructure(), manager), //
// new MelaniButtazzo(manager), new FonsecaNelis(manager))); new SchmidMottok(new UnknownStructure(), manager), //
// new Tester(new UnknownStructure(), manager), //
// new MelaniButtazzo(manager), //
new FonsecaNelis(manager), //
new JiangYi(manager)));
// te.measureExecutionTimes(builder, tests, manager, 500); te.varyNumberOfTasks(manager, tests, 500);
// } }
} }
} }
...@@ -124,7 +124,7 @@ public class TestEnvironment { ...@@ -124,7 +124,7 @@ public class TestEnvironment {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerStep; ++i) { for (int i = 0; i < numberOfTaskSetsPerStep; ++i) {
final Set<DagTask> taskSet = manager.getBuilder().generateUUnifastTaskSet( final Set<DagTask> taskSet = manager.getBuilder().generateUUnifastTaskSet(
(long) (1.5 * numberOfProcessors), (double) numberOfProcessors * 0.5); (long) (1.5 * numberOfProcessors), (double) numberOfProcessors * 0.75);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) { for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
...@@ -166,7 +166,7 @@ public class TestEnvironment { ...@@ -166,7 +166,7 @@ public class TestEnvironment {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerStep; ++i) { for (int i = 0; i < numberOfTaskSetsPerStep; ++i) {
final Set<DagTask> taskSet = manager.getBuilder() final Set<DagTask> taskSet = manager.getBuilder()
.generateUUnifastTaskSet(numberOfTasks, (double) numberOfProcessors * 0.5); .generateUUnifastTaskSet(numberOfTasks, (double) numberOfProcessors * 0.75);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r"); System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) { for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
...@@ -244,7 +244,8 @@ public class TestEnvironment { ...@@ -244,7 +244,8 @@ public class TestEnvironment {
abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0)); abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0));
resultLogger.logHeader(resultMap, "Utilization"); resultLogger.logHeader(resultMap, "Utilization");
for (double util = 1; util <= numberOfProcessors; util += (double)numberOfProcessors/32) { for (double util = 1; util <= numberOfProcessors; util +=
(double) numberOfProcessors / 32) {
resultMap.replaceAll((k, v) -> (long) 0); resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) {
final Set<DagTask> taskSet = manager.getBuilder().generateRenyiTaskSet(util); final Set<DagTask> taskSet = manager.getBuilder().generateRenyiTaskSet(util);
...@@ -271,6 +272,46 @@ public class TestEnvironment { ...@@ -271,6 +272,46 @@ public class TestEnvironment {
System.out.println(""); System.out.println("");
resultLogger.finalize(); resultLogger.finalize();
} }
public void varyPropability(final SystemManager<DagTaskBuilder> manager,
final List<AbstractTest<DagTask>> abstractTestInstances,
final long numberOfTaskSetsPerStep) {
long checkedTasksets = 0;
final long numberOfTaskSets = 10 * numberOfTaskSetsPerStep;
final ResultLogger resultLogger = new ResultLogger("valueOfPadd");
final Map<AbstractTest<DagTask>, Long> resultMap = new LinkedHashMap<>();
abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0));
resultLogger.logHeader(resultMap, "p_Add");
for (long p_add = 10; p_add <= 100; p_add += 10) {
manager.setPropability(p_add);
resultMap.replaceAll((k, v) -> (long) 0);
for (int i = 0; i < numberOfTaskSetsPerStep; ++i) {
final Set<DagTask> taskSet = manager.getBuilder().generateRenyiTaskSet(5.5);
System.out.print(checkedTasksets + "/" + numberOfTaskSets + " tasksets tested!\r");
for (final AbstractTest<DagTask> testInstance : abstractTestInstances) {
final PriorityManager priorityManager = testInstance.getPriorityManager();
final SortedTaskSet<DagTask> sortedTaskSet =
new SortedTaskSet<>(priorityManager);
sortedTaskSet.addAll(taskSet);
final SchedulingInfo schedulingInfo =
testInstance.runSchedulabilityCheck(sortedTaskSet);
if (schedulingInfo.getFeasibility() == Feasiblity.SUCCEEDED) {
resultMap.computeIfPresent(testInstance, (k, v) -> v + 1);
}
}
checkedTasksets++;
}
resultLogger.logLine(p_add, resultMap);
resultLogger.newLine();
}
System.out.println("");
resultLogger.finalize();
}
} }
...@@ -45,6 +45,10 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -45,6 +45,10 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
builder.setNumberOfProcessors(numberOfProcessors); builder.setNumberOfProcessors(numberOfProcessors);
} }
public void setPropability(long p_add) {
builder.setPropability(p_add);
}
public T getBuilder() { public T getBuilder() {
return builder; return builder;
} }
...@@ -55,6 +59,7 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -55,6 +59,7 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
public Builder setNumberOfProcessors(long numberOfProcessors); public Builder setNumberOfProcessors(long numberOfProcessors);
public Builder setPropability(long p);
} }
public static class SynchronousTaskBuilder implements Builder { public static class SynchronousTaskBuilder implements Builder {
...@@ -146,6 +151,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -146,6 +151,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
return this; return this;
} }
public SynchronousTaskBuilder setPropability(long p) {
this.ratio = p;
return this;
}
public SynchronousTaskBuilder setPeriods(final long minPeriod, public SynchronousTaskBuilder setPeriods(final long minPeriod,
final long maxSequentialPeriod, final long maxParallelPeriod) { final long maxSequentialPeriod, final long maxParallelPeriod) {
this.minPeriod = minPeriod; this.minPeriod = minPeriod;
...@@ -197,18 +208,25 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -197,18 +208,25 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
double currentUtilization = 0; double currentUtilization = 0;
while (currentUtilization <= totalUtilization) { while (currentUtilization <= totalUtilization) {
final DagTask dagTask = generateRenyiTask(totalUtilization); final DagTask task = generateRenyiTask(totalUtilization);
if (currentUtilization + dagTask.getUtilization() < totalUtilization) { if (currentUtilization + task.getUtilization() < totalUtilization) {
currentUtilization += dagTask.getUtilization(); currentUtilization += task.getUtilization();
taskSet.add(dagTask); taskSet.add(task);
} else { } else {
final double remainingUtilization = totalUtilization - currentUtilization; final double remainingUtilization = totalUtilization - currentUtilization;
final long period = final long period = (long) Math.ceil(task.getWorkload() / remainingUtilization);
(long) Math.ceil(dagTask.getWorkload() / remainingUtilization); if (period >= task.getCriticalPath()) {
if (period >= dagTask.getCriticalPath()) { long numberOfThreads =
final DagTask modifiedTask = new DagTask(dagTask.getJobDag(), period, LongMath.divide(task.getWorkload() - task.getCriticalPath(),
dagTask.getNumberOfThreads()); period - task.getCriticalPath(), RoundingMode.CEILING);
if (numberOfThreads == 0) {
numberOfThreads = 1;
}
final DagTask modifiedTask =
new DagTask(task.getJobDag(), period, numberOfThreads);
taskSet.add(modifiedTask); taskSet.add(modifiedTask);
break; break;
} }
...@@ -227,11 +245,11 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -227,11 +245,11 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
for (int i = 1; i <= numberOfTasks - 1; i++) { for (int i = 1; i <= numberOfTasks - 1; i++) {
Double nextSumU = sumU * Math.pow(ThreadLocalRandom.current().nextDouble(), Double nextSumU = sumU * Math.pow(ThreadLocalRandom.current().nextDouble(),
(1.0 / (double) (numberOfTasks - i))); (1.0 / (double) (numberOfTasks - i)));
DagTask task = generateTask(sumU - nextSumU); DagTask task = generateRenyiTaskForUUniFast(sumU - nextSumU);
taskSet.add(task); taskSet.add(task);
sumU = nextSumU; sumU = nextSumU;
} }
DagTask task = generateTask(sumU); DagTask task = generateRenyiTaskForUUniFast(sumU);
taskSet.add(task); taskSet.add(task);
} }
...@@ -263,6 +281,33 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -263,6 +281,33 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
return taskSet; return taskSet;
} }
public DagTask generateRenyiTaskForUUniFast(final double utilization) {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag =
new DirectedAcyclicGraph<>(DefaultEdge.class);
final long numberOfVertices = randomNumberInRange(50, 250);
for (int i = 0; i < numberOfVertices - 2; ++i) {
final long wcet = randomNumberInRange(50, 100);
Job j = new Job(wcet);
jobDag.addVertex(j);
}
randomEdgesRenyi(jobDag);
addSourceAndSink(jobDag);
final long workload = DagUtils.calculateWorkload(jobDag);
final long criticalPath = DagUtils.calculateCriticalPath(jobDag);
final long period = (long) Math.ceil(workload / utilization);
final long numberOfThreads = LongMath.divide(workload - criticalPath,
period - criticalPath, RoundingMode.CEILING);
if (numberOfThreads == 0) {
return new DagTask(jobDag, period, 1);
}
return new DagTask(jobDag, period, numberOfThreads);
}
public DagTask generateRenyiTask(final double totalUtilization) { public DagTask generateRenyiTask(final double totalUtilization) {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag = final DirectedAcyclicGraph<Job, DefaultEdge> jobDag =
new DirectedAcyclicGraph<>(DefaultEdge.class); new DirectedAcyclicGraph<>(DefaultEdge.class);
...@@ -280,10 +325,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -280,10 +325,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
final long criticalPath = DagUtils.calculateCriticalPath(jobDag); final long criticalPath = DagUtils.calculateCriticalPath(jobDag);
final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization); final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization);
// final long numberOfThreads = randomNumberOfThreads(numberOfProcessors / 2); final long numberOfThreads = LongMath.divide(workload - criticalPath,
// TODO: Change back to above period - criticalPath, RoundingMode.CEILING);
final long numberOfThreads = LongMath.divide(workload -
criticalPath, period - criticalPath, RoundingMode.CEILING); if (numberOfThreads == 0) {
return new DagTask(jobDag, period, 1);
}
return new DagTask(jobDag, period, numberOfThreads); return new DagTask(jobDag, period, numberOfThreads);
} }
...@@ -480,6 +527,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface ...@@ -480,6 +527,12 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
return this; return this;
} }
public DagTaskBuilder setPropability(long p_add) {
this.p_add = p_add;
return this;
}
/** /**
* @param maxNumberOfBranches the maxNumberOfBranches to set * @param maxNumberOfBranches the maxNumberOfBranches to set
*/ */
......
...@@ -7,7 +7,7 @@ public abstract class Task { ...@@ -7,7 +7,7 @@ public abstract class Task {
protected final long deadline; protected final long deadline;
protected final long workload; protected final long workload;
protected final long criticalPath; protected final long criticalPath;
protected final long numberOfThreads; protected long numberOfThreads;
public Task(final long period, final long deadline, final long workload, public Task(final long period, final long deadline, final long workload,
final long criticalPath, final long numberOfThreads) { final long criticalPath, final long numberOfThreads) {
...@@ -47,6 +47,9 @@ public abstract class Task { ...@@ -47,6 +47,9 @@ public abstract class Task {
return numberOfThreads; return numberOfThreads;
} }
public void setNumberOfThreads(long numberOfThreads) {
this.numberOfThreads = numberOfThreads;
}
abstract public long getMaximumParallelism(); abstract public long getMaximumParallelism();
......
package mvd.jester.tests; package mvd.jester.tests;
import java.math.RoundingMode;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.google.common.math.LongMath;
import mvd.jester.info.SchedulingInfo; import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
...@@ -36,6 +38,7 @@ public class SchmidMottok extends AbstractTest<DagTask> { ...@@ -36,6 +38,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
@Override @Override
public SchedulingInfo runSchedulabilityCheck(final SortedTaskSet<DagTask> tasks) { public SchedulingInfo runSchedulabilityCheck(final SortedTaskSet<DagTask> tasks) {
responseTimes.clear(); responseTimes.clear();
reassignNumberOfThreads(tasks);
for (final DagTask t : tasks) { for (final DagTask t : tasks) {
final long responseTime = calculateResponseTime(tasks, t); final long responseTime = calculateResponseTime(tasks, t);
responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime)); responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime));
...@@ -49,33 +52,70 @@ public class SchmidMottok extends AbstractTest<DagTask> { ...@@ -49,33 +52,70 @@ public class SchmidMottok extends AbstractTest<DagTask> {
return "SchmidMottok" + "_" + structure.getType(); return "SchmidMottok" + "_" + structure.getType();
} }
private void reassignNumberOfThreads(Set<DagTask> tasks) {
long numberOfProcessors = manager.getNumberOfProcessors();
long occupiedProcessors = 0;
for (DagTask t : tasks) {
if (occupiedProcessors >= numberOfProcessors) {
t.setNumberOfThreads(numberOfProcessors);
} else {
occupiedProcessors += t.getNumberOfThreads();
}
}
}
private long calculateResponseTime(final Set<DagTask> tasks, final DagTask task) { private long calculateResponseTime(final Set<DagTask> tasks, final DagTask task) {
final long minimumWcet = task.getCriticalPath(); final long minimumWcet = task.getCriticalPath();
long responseTime = minimumWcet; long responseTime = minimumWcet;
long previousResponseTime = 0; long previousResponseTime = 0;
final long numberOfProcessors = manager.getNumberOfProcessors();
long occupiedProcessors = 0;
for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) {
final long numberOfThreads = structure.getNumberOfThreads(t);
occupiedProcessors += numberOfThreads;
}
}
do { final double selfInterference = structure.getSelfInterference(task);
previousResponseTime = responseTime;
double taskInterference = 0; if (occupiedProcessors + structure.getNumberOfThreads(task) <= numberOfProcessors) {
for (final DagTask t : tasks) { return minimumWcet + (long) Math.floor(selfInterference);
if (t.getPeriod() < task.getPeriod()) { } else {
final long numberOfThreads = structure.getNumberOfThreads(t); do {
for (int p = 0; p < numberOfThreads; ++p) { previousResponseTime = responseTime;
taskInterference += Math.min(structure.getTaskInterference(t, responseTimes, double taskInterference = 0;
responseTime, p + 1), responseTime - minimumWcet + 1);
for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) {
final long numberOfThreads = structure.getNumberOfThreads(t);
for (int p = 0; p < numberOfThreads; ++p) {
taskInterference +=
Math.min(
structure.getTaskInterference(t, responseTimes,
responseTime, p + 1),
responseTime - minimumWcet + 1);
}
} }
} }
}
taskInterference /= manager.getNumberOfProcessors(); taskInterference /= numberOfProcessors;
final double selfInterference = structure.getSelfInterference(task);
final long totalInterference = (long) Math.floor(taskInterference + selfInterference); long totalInterference = (long) Math.floor(taskInterference + selfInterference);
responseTime = minimumWcet + totalInterference; if (occupiedProcessors < numberOfProcessors) {
} while (previousResponseTime != responseTime); long workloadAmongRemainingProcessors =
LongMath.divide(task.getWorkload() - task.getCriticalPath(),
numberOfProcessors - occupiedProcessors, RoundingMode.FLOOR);
totalInterference =
Math.min(totalInterference, workloadAmongRemainingProcessors);
}
return responseTime; responseTime = minimumWcet + totalInterference;
} } while (previousResponseTime != responseTime);
return responseTime;
}
}
} }
package mvd.jester.tests; package mvd.jester.tests;
import java.math.RoundingMode;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.google.common.math.LongMath;
import mvd.jester.info.SchedulingInfo; import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask; import mvd.jester.model.DagTask;
...@@ -29,6 +31,7 @@ public class Tester extends AbstractTest<DagTask> { ...@@ -29,6 +31,7 @@ public class Tester extends AbstractTest<DagTask> {
@Override @Override
public SchedulingInfo runSchedulabilityCheck(SortedTaskSet<DagTask> tasks) { public SchedulingInfo runSchedulabilityCheck(SortedTaskSet<DagTask> tasks) {
responseTimes.clear(); responseTimes.clear();
assignNumberOfThreads(tasks);
for (final DagTask t : tasks) { for (final DagTask t : tasks) {
final long responseTime = calculateResponseTime(tasks, t); final long responseTime = calculateResponseTime(tasks, t);
responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime)); responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime));
...@@ -42,6 +45,27 @@ public class Tester extends AbstractTest<DagTask> { ...@@ -42,6 +45,27 @@ public class Tester extends AbstractTest<DagTask> {
return priorityManager; return priorityManager;
} }
private void assignNumberOfThreads(Set<DagTask> tasks) {
long occupiedProcessors = 0;
long numberOfProcessors = manager.getNumberOfProcessors();
for (DagTask t : tasks) {
long workload = t.getWorkload();
long criticalPath = t.getCriticalPath();
long period = t.getPeriod();
if (period == criticalPath) {
t.setNumberOfThreads(1);
} else if (occupiedProcessors >= numberOfProcessors) {
t.setNumberOfThreads(numberOfProcessors);
} else {
final long numberOfThreads = LongMath.divide(workload - criticalPath,
period - criticalPath, RoundingMode.CEILING);
t.setNumberOfThreads(numberOfThreads);
occupiedProcessors += numberOfThreads;
}
}
}
@Override @Override
public String getName() { public String getName() {
return "Tester_" + structure.getType(); return "Tester_" + structure.getType();
...@@ -51,24 +75,28 @@ public class Tester extends AbstractTest<DagTask> { ...@@ -51,24 +75,28 @@ public class Tester extends AbstractTest<DagTask> {
final long minimumWcet = task.getCriticalPath(); final long minimumWcet = task.getCriticalPath();
long responseTime = minimumWcet; long responseTime = minimumWcet;
long previousResponseTime = 0; long previousResponseTime = 0;
final long numberOfProcessors = manager.getNumberOfProcessors();
long currentNumberOfThreads = 0; long occupiedProcessors = 0;
for (final DagTask t : tasks) { for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) { if (t.getPeriod() < task.getPeriod()) {
final long numberOfThreads = structure.getNumberOfThreads(t); final long numberOfThreads = structure.getNumberOfThreads(t);
currentNumberOfThreads += numberOfThreads; occupiedProcessors += numberOfThreads;
} }
} }
do { final double selfInterference = structure.getSelfInterference(task);
previousResponseTime = responseTime;
double taskInterference = 0; if (occupiedProcessors + structure.getNumberOfThreads(task) <= numberOfProcessors) {
if (currentNumberOfThreads + structure.getNumberOfThreads(task) > manager return minimumWcet + (long) Math.floor(selfInterference);
.getNumberOfProcessors()) { } else {
do {
previousResponseTime = responseTime;
double taskInterference = 0;
for (final DagTask t : tasks) { for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) { if (t.getPeriod() < task.getPeriod()) {
final long numberOfThreads = structure.getNumberOfThreads(t); final long numberOfThreads = structure.getNumberOfThreads(t);
for (int p = 0; p < numberOfThreads; ++p) { for (int p = 0; p < numberOfThreads; ++p) {
taskInterference += taskInterference +=
Math.min( Math.min(
...@@ -79,15 +107,22 @@ public class Tester extends AbstractTest<DagTask> { ...@@ -79,15 +107,22 @@ public class Tester extends AbstractTest<DagTask> {
} }
} }
taskInterference /= manager.getNumberOfProcessors(); taskInterference /= numberOfProcessors;
}
final double selfInterference = structure.getSelfInterference(task);
final long totalInterference = (long) Math.floor(taskInterference + selfInterference); long totalInterference = (long) Math.floor(taskInterference + selfInterference);
responseTime = minimumWcet + totalInterference; if (occupiedProcessors < numberOfProcessors) {
} while (previousResponseTime != responseTime); long workloadAmongRemainingProcessors =
LongMath.divide(task.getWorkload() - task.getCriticalPath(),
numberOfProcessors - occupiedProcessors, RoundingMode.FLOOR);
totalInterference =
Math.min(totalInterference, workloadAmongRemainingProcessors);
}
responseTime = minimumWcet + totalInterference;
} while (previousResponseTime != responseTime);
return responseTime; return responseTime;
}
} }
} }
...@@ -79,7 +79,7 @@ public interface TypeFunction { ...@@ -79,7 +79,7 @@ public interface TypeFunction {
} }
} }
public class UnkownStructure implements TypeFunction { public class UnknownStructure implements TypeFunction {
@Override @Override
public double getTaskInterference(final DagTask task, public double getTaskInterference(final DagTask task,
......
...@@ -58,7 +58,7 @@ public class TestRateMonotonic { ...@@ -58,7 +58,7 @@ public class TestRateMonotonic {
assertTrue(rm.hasSimulator(DynamicForkJoin.class)); assertTrue(rm.hasSimulator(DynamicForkJoin.class));
assertFalse(rm.hasTest(new ChwaLee(manager))); assertFalse(rm.hasTest(new ChwaLee(manager)));
assertTrue(rm.hasTest(new SchmidMottok(new TypeFunction.UnkownStructure(), manager))); assertTrue(rm.hasTest(new SchmidMottok(new TypeFunction.UnknownStructure(), manager)));
assertTrue(rm.hasTest(new MaiaBertogna(manager))); assertTrue(rm.hasTest(new MaiaBertogna(manager)));
// assertTrue(rm.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class)))); // assertTrue(rm.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class))));
// assertTrue(rm.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class)))); // assertTrue(rm.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class))));
......
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