From 6b226c2e0b4761e71e5d98e4bd7dcb894acd62c5 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Thu, 5 Sep 2019 14:08:19 +0200 Subject: [PATCH] small changes before adapting for EDF --- src/main/java/mvd/jester/App.java | 5 +---- src/main/java/mvd/jester/priority/EarliestDeadineFirst.java | 29 +++++++++++++++++++++++++++++ src/main/java/mvd/jester/priority/PriorityManager.java | 9 ++++++--- src/main/java/mvd/jester/priority/RateMonotonic.java | 6 ++++++ src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java | 2 -- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 48fc1d6..d70be57 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -1,10 +1,7 @@ package mvd.jester; -import java.io.PrintWriter; import mvd.jester.model.SystemSetup; -import mvd.jester.simulator.EventPrinter; -import mvd.jester.simulator.MaiaBertogna; -import mvd.jester.simulator.SchmidMottok; + /** * Hello world! diff --git a/src/main/java/mvd/jester/priority/EarliestDeadineFirst.java b/src/main/java/mvd/jester/priority/EarliestDeadineFirst.java index e69de29..4d4ea23 100644 --- a/src/main/java/mvd/jester/priority/EarliestDeadineFirst.java +++ b/src/main/java/mvd/jester/priority/EarliestDeadineFirst.java @@ -0,0 +1,29 @@ +package mvd.jester.priority; + +import mvd.jester.model.Task; +import mvd.jester.simulator.internals.TaskContextInterface; + +/** + * EarliestDeadineFirst + */ +public class EarliestDeadineFirst implements PriorityManager { + + /** + * Compare the priority of two tasks according to the Rate Monotonic policy + * + * @param t1 The first task + * @param t2 The second task + * @return 0 if both tasks have the same priority, positive number if the first task has a + * higher priority, negative number if the second task has a higher priority + */ + @Override + public int compare(Task t1, Task t2) { + throw new RuntimeException( + "Earliest Deadline First does not have Priority Manager for tasks"); + } + + @Override + public int compare(TaskContextInterface t1, TaskContextInterface t2) { + return (int) (t1.getDeadline() - t2.getDeadline()); + } +} diff --git a/src/main/java/mvd/jester/priority/PriorityManager.java b/src/main/java/mvd/jester/priority/PriorityManager.java index 273b0ac..f87036d 100644 --- a/src/main/java/mvd/jester/priority/PriorityManager.java +++ b/src/main/java/mvd/jester/priority/PriorityManager.java @@ -1,12 +1,15 @@ package mvd.jester.priority; -import java.util.Comparator; import mvd.jester.model.Task; +import mvd.jester.simulator.internals.TaskContextInterface; /** * PriorityManager */ -public interface PriorityManager extends Comparator { +public interface PriorityManager { -} + public int compare(Task t1, Task t2); + + public int compare(TaskContextInterface t1, TaskContextInterface t2); +} diff --git a/src/main/java/mvd/jester/priority/RateMonotonic.java b/src/main/java/mvd/jester/priority/RateMonotonic.java index d650e1b..7b23fc1 100644 --- a/src/main/java/mvd/jester/priority/RateMonotonic.java +++ b/src/main/java/mvd/jester/priority/RateMonotonic.java @@ -1,6 +1,7 @@ package mvd.jester.priority; import mvd.jester.model.Task; +import mvd.jester.simulator.internals.TaskContextInterface; public class RateMonotonic implements PriorityManager { @@ -16,4 +17,9 @@ public class RateMonotonic implements PriorityManager { public int compare(Task t1, Task t2) { return Long.compare(t1.getPeriod(), t2.getPeriod()); } + + @Override + public int compare(TaskContextInterface t1, TaskContextInterface t2) { + return Long.compare(t1.getTask().getPeriod(), t2.getTask().getPeriod()); + } } diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java b/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java index 410917a..4a71c5e 100644 --- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java +++ b/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java @@ -18,7 +18,6 @@ public class JobContext implements JobContextInterface { private final long wcet; private Optional currentProcessor; private Optional currentTasklet; - private long executionTime; public JobContext(TaskContext taskContext, SegmentContext segmentContext) { @@ -27,7 +26,6 @@ public class JobContext implements JobContextInterface { this.taskContext = taskContext; this.segmentContext = segmentContext; this.wcet = segmentContext.getSegment().getJobWcet(); - this.executionTime = wcet; } public Optional updateExecution(long time) { -- libgit2 0.26.0