Commit cfdd3254 by Michael Schmid

Changes names

parent 9809bc74
......@@ -7,7 +7,7 @@ import mvd.jester.utils.DagUtils;
public class DagTask implements Task {
private DirectedAcyclicGraph<Job, DefaultEdge> jobDag;
private DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag;
private final Set<Segment> workloadDistribution;
private final long workload;
private final long criticalPath;
......@@ -15,7 +15,7 @@ public class DagTask implements Task {
private final long deadline;
private final long numberOfThreads;
public DagTask(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag, final long period,
public DagTask(final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag, final long period,
final long numberOfThreads) {
this.jobDag = jobDag;
this.period = period;
......@@ -41,14 +41,14 @@ public class DagTask implements Task {
/**
* @return the jobDag
*/
public DirectedAcyclicGraph<Job, DefaultEdge> getJobDag() {
public DirectedAcyclicGraph<Subtask, DefaultEdge> getJobDag() {
return jobDag;
}
/**
* @param jobDag the jobDag to set
*/
public void setJobDag(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag) {
public void setJobDag(final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag) {
this.jobDag = jobDag;
}
......
package mvd.jester.model;
public class Job {
public class Subtask {
private final long wcet;
private long relativeCompletionTime;
public Job(long wcet) {
public Subtask(long wcet) {
this.wcet = wcet;
this.relativeCompletionTime = wcet;
}
......
package mvd.jester.model;
public class TreeJob {
public class SubtaskContext {
private long wcet;
private final Job job;
private final Subtask job;
public TreeJob(final Job job) {
public SubtaskContext(final Subtask job) {
this.wcet = job.getWcet();
this.job = job;
}
......@@ -12,7 +12,7 @@ public class TreeJob {
/**
* @return the job
*/
public Job getJob() {
public Subtask getJob() {
return job;
}
......
......@@ -222,10 +222,10 @@ public class SystemManager {
}
public DagTask generateTask(double utilization) {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag =
final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag =
new DirectedAcyclicGraph<>(DefaultEdge.class);
final Job j = fork(jobDag, Optional.empty(), this.depth);
final Subtask j = fork(jobDag, Optional.empty(), this.depth);
fork(jobDag, Optional.of(j), this.depth);
randomEdges(jobDag);
......@@ -237,10 +237,10 @@ public class SystemManager {
}
public DagTask generateTask() {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag =
final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag =
new DirectedAcyclicGraph<>(DefaultEdge.class);
final Job j = fork(jobDag, Optional.empty(), this.depth);
final Subtask j = fork(jobDag, Optional.empty(), this.depth);
fork(jobDag, Optional.of(j), this.depth);
randomEdges(jobDag);
......@@ -252,12 +252,12 @@ public class SystemManager {
return new DagTask(jobDag, period, numberOfProcessors);
}
private Job join(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag, final Job current,
final Set<Job> childs) {
private Subtask join(final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag, final Subtask current,
final Set<Subtask> childs) {
if (childs.size() > 0) {
final Job job = new Job(randomWcet());
final Subtask job = new Subtask(randomWcet());
jobDag.addVertex(job);
for (final Job c : childs) {
for (final Subtask c : childs) {
try {
jobDag.addDagEdge(c, job);
} catch (final Exception e) {
......@@ -269,11 +269,11 @@ public class SystemManager {
return current;
}
private Job fork(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag,
final Optional<Job> predecessor, final long depth) {
final Job job = new Job(randomWcet());
private Subtask fork(final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag,
final Optional<Subtask> predecessor, final long depth) {
final Subtask job = new Subtask(randomWcet());
jobDag.addVertex(job);
final Set<Job> childs = new HashSet<>();
final Set<Subtask> childs = new HashSet<>();
if (predecessor.isPresent()) {
try {
jobDag.addDagEdge(predecessor.get(), job);
......@@ -291,17 +291,17 @@ public class SystemManager {
return join(jobDag, job, childs);
}
private void randomEdges(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag) {
final Multimap<Job, Job> edgePairs = ArrayListMultimap.create();
for (final Job j1 : jobDag) {
for (final Job j2 : jobDag) {
private void randomEdges(final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag) {
final Multimap<Subtask, Subtask> edgePairs = ArrayListMultimap.create();
for (final Subtask j1 : jobDag) {
for (final Subtask j2 : jobDag) {
if (randomProbability() < p_add) {
edgePairs.put(j1, j2);
}
}
}
for (final Map.Entry<Job, Job> pairs : edgePairs.entries()) {
for (final Map.Entry<Subtask, Subtask> pairs : edgePairs.entries()) {
try {
jobDag.addDagEdge(pairs.getKey(), pairs.getValue());
} catch (final Exception e) {
......
......@@ -18,12 +18,12 @@ import org.jgrapht.graph.DefaultEdge;
import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo;
import mvd.jester.model.DagTask;
import mvd.jester.model.Job;
import mvd.jester.model.Subtask;
import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemManager;
import mvd.jester.model.Task;
import mvd.jester.model.TreeJob;
import mvd.jester.model.SubtaskContext;
import mvd.jester.utils.DagUtils;
import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic;
......@@ -64,32 +64,32 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
private void createNFJandDecompositionTree(final SortedTaskSet<DagTask> tasks) {
for (final DagTask t : tasks) {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag = t.getJobDag();
final DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag = t.getJobDag();
final DirectedAcyclicGraph<Job, DefaultEdge> nfjJobDag =
final DirectedAcyclicGraph<Subtask, DefaultEdge> nfjJobDag =
DagUtils.createNFJGraph(jobDag);
final BinaryDecompositionTree<Job> tree = DagUtils.createDecompositionTree(nfjJobDag);
final BinaryDecompositionTree<Subtask> tree = DagUtils.createDecompositionTree(nfjJobDag);
carryOutSegments.put(t, constructCarryOutDistribution(nfjJobDag, tree));
}
}
private Set<Segment> constructCarryOutDistribution(
final DirectedAcyclicGraph<Job, DefaultEdge> nfjDag,
final BinaryDecompositionTree<Job> tree) {
final DirectedAcyclicGraph<Subtask, DefaultEdge> nfjDag,
final BinaryDecompositionTree<Subtask> tree) {
// List statt Set
final Set<Segment> carryOutWorkload = new LinkedHashSet<>();
final BinaryDecompositionTree<TreeJob> modifiedTree = transformTree(tree);
final BinaryDecompositionTree<SubtaskContext> modifiedTree = transformTree(tree);
boolean isEmpty = false;
do {
final Set<TreeJob> parallelJobs = getMaximumParallelism(modifiedTree.getRootNode());
final Optional<TreeJob> min =
final Set<SubtaskContext> parallelJobs = getMaximumParallelism(modifiedTree.getRootNode());
final Optional<SubtaskContext> min =
parallelJobs.stream().min((p1, p2) -> Long.compare(p1.getWcet(), p2.getWcet()));
if (min.isPresent()) {
final long width = min.get().getWcet();
carryOutWorkload.add(new Segment(width, parallelJobs.size()));
for (final TreeJob p : parallelJobs) {
for (final SubtaskContext p : parallelJobs) {
p.setWcet(p.getWcet() - width);
}
} else {
......@@ -102,34 +102,34 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
}
private BinaryDecompositionTree<TreeJob> transformTree(
final BinaryDecompositionTree<Job> tree) {
final BinaryDecompositionTree<TreeJob> modifiedTree = new BinaryDecompositionTree<>();
final Node<TreeJob> root = transformNode(null, tree.getRootNode());
private BinaryDecompositionTree<SubtaskContext> transformTree(
final BinaryDecompositionTree<Subtask> tree) {
final BinaryDecompositionTree<SubtaskContext> modifiedTree = new BinaryDecompositionTree<>();
final Node<SubtaskContext> root = transformNode(null, tree.getRootNode());
modifiedTree.setRoot(root);
return modifiedTree;
}
private Node<TreeJob> transformNode(final Node<TreeJob> parent, final Node<Job> node) {
private Node<SubtaskContext> transformNode(final Node<SubtaskContext> parent, final Node<Subtask> node) {
if (node.getNodeType().equals(NodeType.LEAF)) {
return new Node<TreeJob>(parent, new TreeJob(node.getObject()));
return new Node<SubtaskContext>(parent, new SubtaskContext(node.getObject()));
} else {
final Node<TreeJob> modifiedNode = new Node<TreeJob>(parent, node.getNodeType());
final Node<SubtaskContext> modifiedNode = new Node<SubtaskContext>(parent, node.getNodeType());
modifiedNode.setLeftNode(transformNode(modifiedNode, node.getLeftNode()));
modifiedNode.setRightNode(transformNode(modifiedNode, node.getRightNode()));
return modifiedNode;
}
}
private Set<TreeJob> getMaximumParallelism(final Node<TreeJob> node) {
private Set<SubtaskContext> getMaximumParallelism(final Node<SubtaskContext> node) {
final NodeType nodeType = node.getNodeType();
if (nodeType.equals(NodeType.PAR)) {
final Set<TreeJob> left = getMaximumParallelism(node.getLeftNode());
final Set<TreeJob> right = getMaximumParallelism(node.getRightNode());
final Set<SubtaskContext> left = getMaximumParallelism(node.getLeftNode());
final Set<SubtaskContext> right = getMaximumParallelism(node.getRightNode());
return Sets.union(left, right);
} else if (nodeType.equals(NodeType.SEQ)) {
final Set<TreeJob> left = getMaximumParallelism(node.getLeftNode());
final Set<TreeJob> right = getMaximumParallelism(node.getRightNode());
final Set<SubtaskContext> left = getMaximumParallelism(node.getLeftNode());
final Set<SubtaskContext> right = getMaximumParallelism(node.getRightNode());
if (left.size() >= right.size()) {
return left;
} else {
......
......@@ -16,15 +16,15 @@ public class TestDagUtils {
@Test
@DisplayName("Test if dynamic segments are constructed correctly.")
public void checkPathLength() {
DirectedAcyclicGraph<Job, DefaultEdge> jobDag = createJobDag();
DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag = createJobDag();
long criticalPath = DagUtils.calculateCriticalPath(jobDag);
for (Job j : jobDag) {
for (Subtask j : jobDag) {
assertTrue(j.getRelativeCompletionTime() <= criticalPath);
}
for (DefaultEdge e : jobDag.edgeSet()) {
Job source = jobDag.getEdgeSource(e);
Job target = jobDag.getEdgeTarget(e);
Subtask source = jobDag.getEdgeSource(e);
Subtask target = jobDag.getEdgeTarget(e);
assertTrue(source.getRelativeCompletionTime() < target.getRelativeCompletionTime());
}
......@@ -39,7 +39,7 @@ public class TestDagUtils {
DagTaskBuilder b = new DagTaskBuilder();
DagTask t = b.generateTask();
DirectedAcyclicGraph<Job, DefaultEdge> nfjDag = DagUtils.createNFJGraph(t.getJobDag());
DirectedAcyclicGraph<Subtask, DefaultEdge> nfjDag = DagUtils.createNFJGraph(t.getJobDag());
assertTrue(DagUtils.checkNFJProperty(nfjDag));
}
......@@ -53,11 +53,11 @@ public class TestDagUtils {
long numberOfProcessors = ThreadLocalRandom.current().nextLong(4, 16);
DagTaskBuilder b = new DagTaskBuilder().setNumberOfProcessors(numberOfProcessors);
DagTask t = b.generateTask();
DirectedAcyclicGraph<Job, DefaultEdge> jobDag = t.getJobDag();
DirectedAcyclicGraph<Job, DefaultEdge> nfjJobDag = DagUtils.createNFJGraph(jobDag);
DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag = t.getJobDag();
DirectedAcyclicGraph<Subtask, DefaultEdge> nfjJobDag = DagUtils.createNFJGraph(jobDag);
BinaryDecompositionTree<Job> tree = DagUtils.createDecompositionTree(nfjJobDag);
DirectedAcyclicGraph<Job, DefaultEdge> jobDagFromTree =
BinaryDecompositionTree<Subtask> tree = DagUtils.createDecompositionTree(nfjJobDag);
DirectedAcyclicGraph<Subtask, DefaultEdge> jobDagFromTree =
DagUtils.createNFJfromDecompositionTree(tree);
assertTrue(jobDag.vertexSet().size() == nfjJobDag.vertexSet().size());
......@@ -65,14 +65,14 @@ public class TestDagUtils {
assertTrue(jobDagFromTree.edgeSet().size() == nfjJobDag.edgeSet().size());
for (DefaultEdge e : nfjJobDag.edgeSet()) {
Job target = nfjJobDag.getEdgeTarget(e);
Job source = nfjJobDag.getEdgeSource(e);
Subtask target = nfjJobDag.getEdgeTarget(e);
Subtask source = nfjJobDag.getEdgeSource(e);
assertTrue(jobDagFromTree.containsEdge(source, target));
}
for (Job j : nfjJobDag) {
for (Job n : nfjJobDag) {
for (Subtask j : nfjJobDag) {
for (Subtask n : nfjJobDag) {
if (n == j) {
continue;
}
......@@ -83,19 +83,19 @@ public class TestDagUtils {
assertTrue(nfjJobDag.inDegreeOf(j) == jobDagFromTree.inDegreeOf(j));
assertTrue(nfjJobDag.outDegreeOf(j) == jobDagFromTree.outDegreeOf(j));
for (Job p : Graphs.predecessorListOf(nfjJobDag, j)) {
for (Subtask p : Graphs.predecessorListOf(nfjJobDag, j)) {
assertTrue(Graphs.predecessorListOf(jobDagFromTree, j).contains(p));
}
for (Job s : Graphs.successorListOf(nfjJobDag, j)) {
for (Subtask s : Graphs.successorListOf(nfjJobDag, j)) {
assertTrue(Graphs.successorListOf(jobDagFromTree, j).contains(s));
}
for (Job a : nfjJobDag.getAncestors(nfjJobDag, j)) {
for (Subtask a : nfjJobDag.getAncestors(nfjJobDag, j)) {
assertTrue(jobDagFromTree.getAncestors(jobDagFromTree, j).contains(a));
}
for (Job d : nfjJobDag.getDescendants(nfjJobDag, j)) {
for (Subtask d : nfjJobDag.getDescendants(nfjJobDag, j)) {
assertTrue(jobDagFromTree.getDescendants(jobDagFromTree, j).contains(d));
}
}
......@@ -105,35 +105,35 @@ public class TestDagUtils {
}
private DirectedAcyclicGraph<Job, DefaultEdge> createJobDag() {
DirectedAcyclicGraph<Job, DefaultEdge> jobDag =
private DirectedAcyclicGraph<Subtask, DefaultEdge> createJobDag() {
DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag =
new DirectedAcyclicGraph<>(DefaultEdge.class);
Job source = new Job(20);
Job pathA = new Job(10);
Job pathB = new Job(30);
Job pathC = new Job(40);
Subtask source = new Subtask(20);
Subtask pathA = new Subtask(10);
Subtask pathB = new Subtask(30);
Subtask pathC = new Subtask(40);
Job child1OfA = new Job(5);
Job child2OfA = new Job(15);
Job child3OfA = new Job(5);
Subtask child1OfA = new Subtask(5);
Subtask child2OfA = new Subtask(15);
Subtask child3OfA = new Subtask(5);
Job childsOfAJoin = new Job(10);
Subtask childsOfAJoin = new Subtask(10);
Job child1OfC = new Job(5);
Job child2OfC = new Job(10);
Job child3OfC = new Job(15);
Job child4OfC = new Job(20);
Subtask child1OfC = new Subtask(5);
Subtask child2OfC = new Subtask(10);
Subtask child3OfC = new Subtask(15);
Subtask child4OfC = new Subtask(20);
Job firstJoin = new Job(20);
Subtask firstJoin = new Subtask(20);
Job intermediateFork = new Job(10);
Subtask intermediateFork = new Subtask(10);
Job forkChild1 = new Job(5);
Job forkChild2 = new Job(10);
Job forkChild3 = new Job(15);
Subtask forkChild1 = new Subtask(5);
Subtask forkChild2 = new Subtask(10);
Subtask forkChild3 = new Subtask(15);
Job sink = new Job(30);
Subtask sink = new Subtask(30);
try {
jobDag.addVertex(source);
jobDag.addVertex(pathA);
......
......@@ -75,12 +75,12 @@ public class TestSystemSetup {
for (int i = 0; i < 100; ++i) {
DagTaskBuilder builder = new DagTaskBuilder();
DagTask task = builder.generateTask();
DirectedAcyclicGraph<Job, DefaultEdge> jobDag = task.getJobDag();
DirectedAcyclicGraph<Subtask, DefaultEdge> jobDag = task.getJobDag();
assertTrue(task.getCriticalPath() <= task.getPeriod());
assertTrue(task.getPeriod() <= (long) (task.getWorkload() / builder.getBeta()));
for (Job j : jobDag) {
for (Subtask j : jobDag) {
assertTrue(1 <= j.getWcet() && j.getWcet() <= 100);
assertTrue(j.getRelativeCompletionTime() <= task.getCriticalPath());
if (jobDag.outDegreeOf(j) == 0) {
......@@ -88,8 +88,8 @@ public class TestSystemSetup {
}
}
for (DefaultEdge e : jobDag.edgeSet()) {
Job source = jobDag.getEdgeSource(e);
Job target = jobDag.getEdgeTarget(e);
Subtask source = jobDag.getEdgeSource(e);
Subtask target = jobDag.getEdgeTarget(e);
assertTrue(source.getRelativeCompletionTime() < target.getRelativeCompletionTime());
}
}
......
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