Commit 6b226c2e by Michael Schmid

small changes before adapting for EDF

parent 9ea90201
package mvd.jester; package mvd.jester;
import java.io.PrintWriter;
import mvd.jester.model.SystemSetup; import mvd.jester.model.SystemSetup;
import mvd.jester.simulator.EventPrinter;
import mvd.jester.simulator.MaiaBertogna;
import mvd.jester.simulator.SchmidMottok;
/** /**
* Hello world! * Hello world!
......
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());
}
}
package mvd.jester.priority; package mvd.jester.priority;
import java.util.Comparator;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.simulator.internals.TaskContextInterface;
/** /**
* PriorityManager * PriorityManager
*/ */
public interface PriorityManager extends Comparator<Task> { public interface PriorityManager {
} public int compare(Task t1, Task t2);
public int compare(TaskContextInterface t1, TaskContextInterface t2);
}
package mvd.jester.priority; package mvd.jester.priority;
import mvd.jester.model.Task; import mvd.jester.model.Task;
import mvd.jester.simulator.internals.TaskContextInterface;
public class RateMonotonic implements PriorityManager { public class RateMonotonic implements PriorityManager {
...@@ -16,4 +17,9 @@ public class RateMonotonic implements PriorityManager { ...@@ -16,4 +17,9 @@ public class RateMonotonic implements PriorityManager {
public int compare(Task t1, Task t2) { public int compare(Task t1, Task t2) {
return Long.compare(t1.getPeriod(), t2.getPeriod()); return Long.compare(t1.getPeriod(), t2.getPeriod());
} }
@Override
public int compare(TaskContextInterface t1, TaskContextInterface t2) {
return Long.compare(t1.getTask().getPeriod(), t2.getTask().getPeriod());
}
} }
...@@ -18,7 +18,6 @@ public class JobContext implements JobContextInterface { ...@@ -18,7 +18,6 @@ public class JobContext implements JobContextInterface {
private final long wcet; private final long wcet;
private Optional<ProcessorContext> currentProcessor; private Optional<ProcessorContext> currentProcessor;
private Optional<TaskletContext> currentTasklet; private Optional<TaskletContext> currentTasklet;
private long executionTime;
public JobContext(TaskContext taskContext, SegmentContext segmentContext) { public JobContext(TaskContext taskContext, SegmentContext segmentContext) {
...@@ -27,7 +26,6 @@ public class JobContext implements JobContextInterface { ...@@ -27,7 +26,6 @@ public class JobContext implements JobContextInterface {
this.taskContext = taskContext; this.taskContext = taskContext;
this.segmentContext = segmentContext; this.segmentContext = segmentContext;
this.wcet = segmentContext.getSegment().getJobWcet(); this.wcet = segmentContext.getSegment().getJobWcet();
this.executionTime = wcet;
} }
public Optional<TaskContextInterface> updateExecution(long time) { public Optional<TaskContextInterface> updateExecution(long time) {
......
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