From db00ddd11a714eddfa08c61266614f1d19d070a4 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Tue, 23 Feb 2021 14:59:25 +0100 Subject: [PATCH] removed simulator --- src/main/java/mvd/jester/App.java | 3 --- src/main/java/mvd/jester/priority/DeadlineMonotonic.java | 20 -------------------- src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java | 21 --------------------- src/main/java/mvd/jester/priority/PriorityManager.java | 8 -------- src/main/java/mvd/jester/priority/RateMonotonic.java | 20 -------------------- src/main/java/mvd/jester/simulator/AbstractSimulator.java | 129 --------------------------------------------------------------------------------------------------------------------------------- src/main/java/mvd/jester/simulator/DynamicForkJoin.java | 37 ------------------------------------- src/main/java/mvd/jester/simulator/EventPrinter.java | 28 ---------------------------- src/main/java/mvd/jester/simulator/ParallelSynchronous.java | 36 ------------------------------------ src/main/java/mvd/jester/simulator/SimulatorInterface.java | 15 --------------- src/main/java/mvd/jester/simulator/internals/JobContextInterface.java | 21 --------------------- src/main/java/mvd/jester/simulator/internals/ProcessorContext.java | 68 -------------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java | 17 ----------------- src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java | 20 -------------------- src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java | 129 --------------------------------------------------------------------------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java | 79 ------------------------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java | 87 --------------------------------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java | 62 -------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java | 97 ------------------------------------------------------------------------------------------------- src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java | 43 ------------------------------------------- src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java | 86 -------------------------------------------------------------------------------------- src/main/java/mvd/jester/tests/MelaniButtazzo.java | 1 - src/main/java/mvd/jester/tests/Tester.java | 9 --------- src/main/java/mvd/jester/tests/UeterAgrawal.java | 2 +- src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java | 15 --------------- src/test/java/mvd/jester/priority/TestRateMonotonic.java | 15 --------------- src/test/java/mvd/jester/simulator/TestProcessorContext.java | 107 ----------------------------------------------------------------------------------------------------------- src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java | 98 -------------------------------------------------------------------------------------------------- src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java | 101 ----------------------------------------------------------------------------------------------------- src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java | 95 ----------------------------------------------------------------------------------------------- src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java | 52 ---------------------------------------------------- src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java | 61 ------------------------------------------------------------- src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java | 57 --------------------------------------------------------- src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java | 96 ------------------------------------------------------------------------------------------------ 34 files changed, 1 insertion(+), 1734 deletions(-) delete mode 100644 src/main/java/mvd/jester/simulator/AbstractSimulator.java delete mode 100644 src/main/java/mvd/jester/simulator/DynamicForkJoin.java delete mode 100644 src/main/java/mvd/jester/simulator/EventPrinter.java delete mode 100644 src/main/java/mvd/jester/simulator/ParallelSynchronous.java delete mode 100644 src/main/java/mvd/jester/simulator/SimulatorInterface.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/JobContextInterface.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/ProcessorContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java delete mode 100644 src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java delete mode 100644 src/test/java/mvd/jester/simulator/TestProcessorContext.java delete mode 100644 src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java delete mode 100644 src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java delete mode 100644 src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java delete mode 100644 src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java delete mode 100644 src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java delete mode 100644 src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java delete mode 100644 src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 7edac86..0f1c448 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -6,11 +6,8 @@ import mvd.jester.model.DagTask; import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager.DagTaskBuilder; import mvd.jester.tests.AbstractTest; -import mvd.jester.tests.DongLiu; -import mvd.jester.tests.FonsecaNelis; import mvd.jester.tests.JiangYi; import mvd.jester.tests.SchmidMottok; -import mvd.jester.tests.Tester; import mvd.jester.tests.UeterAgrawal; import mvd.jester.tests.TypeFunction.UnknownStructure; diff --git a/src/main/java/mvd/jester/priority/DeadlineMonotonic.java b/src/main/java/mvd/jester/priority/DeadlineMonotonic.java index b081525..6c96604 100644 --- a/src/main/java/mvd/jester/priority/DeadlineMonotonic.java +++ b/src/main/java/mvd/jester/priority/DeadlineMonotonic.java @@ -4,8 +4,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import mvd.jester.model.Task; -import mvd.jester.simulator.AbstractSimulator; -import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.tests.AbstractTest; public class DeadlineMonotonic implements PriorityManager { @@ -13,9 +11,6 @@ public class DeadlineMonotonic implements PriorityManager { final static Set>> abstractTests = new HashSet<>(Arrays.asList(mvd.jester.tests.MaiaBertogna.class, mvd.jester.tests.SchmidMottok.class)); - final static Set> abstractSimulators = - new HashSet<>(Arrays.asList(mvd.jester.simulator.ParallelSynchronous.class, - mvd.jester.simulator.DynamicForkJoin.class)); /** * Compare the priority of two tasks according to the Rate Monotonic policy @@ -31,11 +26,6 @@ public class DeadlineMonotonic implements PriorityManager { } @Override - public int compare(TaskContextInterface t1, TaskContextInterface t2) { - return Long.compare(t1.getTask().getDeadline(), t2.getTask().getDeadline()); - } - - @Override public boolean hasTest(AbstractTest abstractTest) { return abstractTests.contains(abstractTest.getClass()); } @@ -46,16 +36,6 @@ public class DeadlineMonotonic implements PriorityManager { } @Override - public boolean hasSimulator(AbstractSimulator abstractSimulator) { - return abstractSimulators.contains(abstractSimulator.getClass()); - } - - @Override - public boolean hasSimulator(Class abstractSimulatorClass) { - return abstractSimulators.contains(abstractSimulatorClass); - } - - @Override public String getName() { return "DM"; } diff --git a/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java b/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java index c642ad2..d48bedb 100644 --- a/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java +++ b/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java @@ -4,10 +4,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import mvd.jester.model.Task; -import mvd.jester.simulator.AbstractSimulator; -import mvd.jester.simulator.ParallelSynchronous; -import mvd.jester.simulator.DynamicForkJoin; -import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.tests.AbstractTest; import mvd.jester.tests.ChwaLee; @@ -18,8 +14,6 @@ public class EarliestDeadlineFirst implements PriorityManager { final static Set>> abstractTests = new HashSet<>(Arrays.asList(ChwaLee.class)); - final static Set> abstractSimulators = - new HashSet<>(Arrays.asList(ParallelSynchronous.class, DynamicForkJoin.class)); /** * Compare the priority of two tasks according to the Rate Monotonic policy @@ -35,11 +29,6 @@ public class EarliestDeadlineFirst implements PriorityManager { } @Override - public int compare(TaskContextInterface t1, TaskContextInterface t2) { - return (int) (t1.getDeadline() - t2.getDeadline()); - } - - @Override public boolean hasTest(AbstractTest abstractTest) { return abstractTests.contains(abstractTest.getClass()); } @@ -50,16 +39,6 @@ public class EarliestDeadlineFirst implements PriorityManager { } @Override - public boolean hasSimulator(AbstractSimulator abstractSimulator) { - return abstractSimulators.contains(abstractSimulator.getClass()); - } - - @Override - public boolean hasSimulator(Class abstractSimulatorClass) { - return abstractSimulators.contains(abstractSimulatorClass); - } - - @Override public String getName() { return "EDF"; } diff --git a/src/main/java/mvd/jester/priority/PriorityManager.java b/src/main/java/mvd/jester/priority/PriorityManager.java index c6daf0c..7c53078 100644 --- a/src/main/java/mvd/jester/priority/PriorityManager.java +++ b/src/main/java/mvd/jester/priority/PriorityManager.java @@ -1,8 +1,6 @@ package mvd.jester.priority; import mvd.jester.model.Task; -import mvd.jester.simulator.AbstractSimulator; -import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.tests.AbstractTest; /** @@ -12,16 +10,10 @@ public interface PriorityManager { public int compare(Task t1, Task t2); - public int compare(TaskContextInterface t1, TaskContextInterface t2); - public boolean hasTest(AbstractTest abstractTest); public boolean hasTest(Class> abstractTestClass); - public boolean hasSimulator(AbstractSimulator abstractTest); - - public boolean hasSimulator(Class abstractTestClass); - public String getName(); } diff --git a/src/main/java/mvd/jester/priority/RateMonotonic.java b/src/main/java/mvd/jester/priority/RateMonotonic.java index 1818bb3..39d30da 100644 --- a/src/main/java/mvd/jester/priority/RateMonotonic.java +++ b/src/main/java/mvd/jester/priority/RateMonotonic.java @@ -4,8 +4,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import mvd.jester.model.Task; -import mvd.jester.simulator.AbstractSimulator; -import mvd.jester.simulator.internals.TaskContextInterface; import mvd.jester.tests.AbstractTest; public class RateMonotonic implements PriorityManager { @@ -13,9 +11,6 @@ public class RateMonotonic implements PriorityManager { final static Set>> abstractTests = new HashSet<>(Arrays.asList(mvd.jester.tests.MaiaBertogna.class, mvd.jester.tests.SchmidMottok.class)); - final static Set> abstractSimulators = - new HashSet<>(Arrays.asList(mvd.jester.simulator.ParallelSynchronous.class, - mvd.jester.simulator.DynamicForkJoin.class)); /** * Compare the priority of two tasks according to the Rate Monotonic policy @@ -31,11 +26,6 @@ public class RateMonotonic implements PriorityManager { } @Override - public int compare(TaskContextInterface t1, TaskContextInterface t2) { - return Long.compare(t1.getTask().getPeriod(), t2.getTask().getPeriod()); - } - - @Override public boolean hasTest(AbstractTest abstractTest) { return abstractTests.contains(abstractTest.getClass()); } @@ -46,16 +36,6 @@ public class RateMonotonic implements PriorityManager { } @Override - public boolean hasSimulator(AbstractSimulator abstractSimulator) { - return abstractSimulators.contains(abstractSimulator.getClass()); - } - - @Override - public boolean hasSimulator(Class abstractSimulatorClass) { - return abstractSimulators.contains(abstractSimulatorClass); - } - - @Override public String getName() { return "RM"; } diff --git a/src/main/java/mvd/jester/simulator/AbstractSimulator.java b/src/main/java/mvd/jester/simulator/AbstractSimulator.java deleted file mode 100644 index 54152df..0000000 --- a/src/main/java/mvd/jester/simulator/AbstractSimulator.java +++ /dev/null @@ -1,129 +0,0 @@ -package mvd.jester.simulator; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; -import java.util.TreeSet; -import com.google.common.collect.TreeMultiset; -import mvd.jester.model.SystemManager; -import mvd.jester.priority.PriorityManager; -import mvd.jester.priority.RateMonotonic; -import mvd.jester.TypeInterface; -import mvd.jester.info.SchedulingInfo; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.TaskContextInterface; - - -/** - * AbstractSimulator - */ -public abstract class AbstractSimulator implements SimulatorInterface, TypeInterface { - - protected final SystemManager systemSetup; - protected final Set processors; - protected TreeMultiset readyTasks; - - AbstractSimulator(SystemManager systemSetup) { - this.systemSetup = systemSetup; - this.readyTasks = TreeMultiset.create((t1, t2) -> new RateMonotonic().compare(t1, t2)); - processors = new HashSet<>(); - for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) { - processors.add(new ProcessorContext(i)); - } - } - - - protected abstract boolean releaseTasks(long timeStep); - - @Override - public SchedulingInfo runSimulation(PriorityManager priorityManager) { - // SchedulingInfo schedulingInfo = new SchedulingInfo(systemSetup.getParallelTaskRatio(), - // systemSetup.getUtilization()); - // long hyperPeriod = init(priorityManager); - // for (int t = 0; t < hyperPeriod; ++t) { - // if (!releaseTasks(t)) { - // throw new RuntimeException("Could not release a task. This should not happen!"); - // } - - // Set sortedProcessors = sortProcessors(processors); - - // for (ProcessorContext p : sortedProcessors) { - // for (TaskContextInterface tc : readyTasks) { - // if (p.acceptTask(tc, t)) { - // break; - // } - // } - - // } - - // for (ProcessorContext p : processors) { - // Optional optionalTc = p.updateExecution(t); - // if (optionalTc.isPresent()) { - // TaskContextInterface tc = optionalTc.get(); - // if (t >= tc.getDeadline()) { - // TerminationInfo terminationInfo = - // new TerminationInfo(tc.getReleaseTime(), tc.getDeadline(), t); - // schedulingInfo.addTerminationInfo(terminationInfo); - - - // EventPrinter.print("Time " + t + ": Task " + tc + " failed its deadline!"); - // schedulingInfo.setFailedTerminationInfo(terminationInfo); - // return schedulingInfo; - // } - - // readyTasks.remove(optionalTc.get()); - // } - // } - // } - - // return schedulingInfo; - return null; - } - - private long init(PriorityManager priorityManager) { - this.readyTasks = TreeMultiset.create((t1, t2) -> priorityManager.compare(t1, t2)); - for (ProcessorContext p : processors) { - p.setJob(null); - } - return getHyperPeriod(); - } - - private Set sortProcessors(Set processors) { - Set sortedProcessors = new TreeSet<>(new ProcessorComparator()); - - processors.forEach(p -> sortedProcessors.add(p)); - - return sortedProcessors; - } - - private long getHyperPeriod() { - // return - // systemSetup.getTasks().stream().max(Comparator.comparing(SynchronousTask::getPeriod)) - // .get().getPeriod() * 10; - return 10; - } - - - - private class ProcessorComparator implements Comparator { - - @Override - public int compare(ProcessorContext p1, ProcessorContext p2) { - if (!p1.getJob().isPresent()) { - return -1; - } else if (!p2.getJob().isPresent()) { - return 1; - } else { - long p1Period = p1.getJob().get().getTaskContext().getTask().getPeriod(); - long p2Period = p2.getJob().get().getTaskContext().getTask().getPeriod(); - if (p1Period == p2Period) { - return 1; - } else { - return (int) (p2.getJob().get().getTaskContext().getTask().getPeriod() - - p1.getJob().get().getTaskContext().getTask().getPeriod()); - } - } - } - - } -} diff --git a/src/main/java/mvd/jester/simulator/DynamicForkJoin.java b/src/main/java/mvd/jester/simulator/DynamicForkJoin.java deleted file mode 100644 index a0d6a1b..0000000 --- a/src/main/java/mvd/jester/simulator/DynamicForkJoin.java +++ /dev/null @@ -1,37 +0,0 @@ -package mvd.jester.simulator; - - -import mvd.jester.model.SystemManager; - -/** - * SchmidMottok - */ -public class DynamicForkJoin extends AbstractSimulator { - - public DynamicForkJoin(SystemManager systemSetup) { - super(systemSetup); - } - - - @Override - protected boolean releaseTasks(long timeStep) { - // // for (SynchronousTask t : systemSetup.getTasks()) { - // if (timeStep % t.getPeriod() == 0) { - // TaskContext tc = new TaskContext(t, systemSetup.getNumberOfProcessors(), timeStep); - // if (!readyTasks.add(tc)) { - // EventPrinter - // .print("Time " + timeStep + ": Task " + tc + " could not be released!"); - // return false; - // } - // EventPrinter.print("Time " + timeStep + ": Task " + tc + " released!"); - // } - // } - return true; - } - - - @Override - public String getName() { - return "SchmidMottok"; - } -} diff --git a/src/main/java/mvd/jester/simulator/EventPrinter.java b/src/main/java/mvd/jester/simulator/EventPrinter.java deleted file mode 100644 index e4ac56d..0000000 --- a/src/main/java/mvd/jester/simulator/EventPrinter.java +++ /dev/null @@ -1,28 +0,0 @@ -package mvd.jester.simulator; - -/** - * EventPrinter - */ -public class EventPrinter { - - private static boolean printerEnabled; - - private EventPrinter() { - printerEnabled = false; - } - - public static void enablePrinter() { - printerEnabled = true; - } - - public static void disablePrinter() { - printerEnabled = false; - } - - public static void print(String text) { - if (printerEnabled) { - System.out.println(text); - } - } - -} diff --git a/src/main/java/mvd/jester/simulator/ParallelSynchronous.java b/src/main/java/mvd/jester/simulator/ParallelSynchronous.java deleted file mode 100644 index 99f2346..0000000 --- a/src/main/java/mvd/jester/simulator/ParallelSynchronous.java +++ /dev/null @@ -1,36 +0,0 @@ -package mvd.jester.simulator; - -import mvd.jester.model.SystemManager; - -/** - * MaiaBertogna - */ -public class ParallelSynchronous extends AbstractSimulator { - - public ParallelSynchronous(SystemManager systemSetup) { - super(systemSetup); - } - - @Override - protected boolean releaseTasks(long timeStep) { - // for (SynchronousTask t : systemSetup.getTasks()) { - // if (timeStep % t.getPeriod() == 0) { - // TaskContext tc = new TaskContext(t, timeStep); - // if (!readyTasks.add(tc)) { - // EventPrinter - // .print("Time " + timeStep + ": Task " + tc + " could not be released!"); - // return false; - // } - // EventPrinter.print("Time " + timeStep + ": Task " + tc + " released!"); - // } - // } - return true; - } - - @Override - public String getName() { - return "MaiaBertogna"; - } - - -} diff --git a/src/main/java/mvd/jester/simulator/SimulatorInterface.java b/src/main/java/mvd/jester/simulator/SimulatorInterface.java deleted file mode 100644 index f95461a..0000000 --- a/src/main/java/mvd/jester/simulator/SimulatorInterface.java +++ /dev/null @@ -1,15 +0,0 @@ -package mvd.jester.simulator; - -import mvd.jester.info.SchedulingInfo; -import mvd.jester.priority.PriorityManager; - -/** - * SimulatorInterface - */ -public interface SimulatorInterface { - - public SchedulingInfo runSimulation(PriorityManager priorityManager); - - public String getName(); - -} diff --git a/src/main/java/mvd/jester/simulator/internals/JobContextInterface.java b/src/main/java/mvd/jester/simulator/internals/JobContextInterface.java deleted file mode 100644 index 7a9c7a5..0000000 --- a/src/main/java/mvd/jester/simulator/internals/JobContextInterface.java +++ /dev/null @@ -1,21 +0,0 @@ -package mvd.jester.simulator.internals; - -import java.util.Optional; - -/** - * JobContextInterface - */ -public interface JobContextInterface { - - public Optional updateExecution(long time); - - public boolean checkExecutionTime(); - - public void setCurrentProcessor(ProcessorContext processor); - - public Optional getCurrentProcessor(); - - public TaskContextInterface getTaskContext(); - - public boolean prepareJob(long time); -} diff --git a/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java b/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java deleted file mode 100644 index 733c512..0000000 --- a/src/main/java/mvd/jester/simulator/internals/ProcessorContext.java +++ /dev/null @@ -1,68 +0,0 @@ -package mvd.jester.simulator.internals; - -import java.util.Optional; -import mvd.jester.simulator.EventPrinter; - -/** - * Processor - */ -public class ProcessorContext { - - private Optional currentJob; - private final long processorId; - - public ProcessorContext(long processorId) { - currentJob = Optional.empty(); - this.processorId = processorId; - } - - public void setJob(JobContextInterface job) { - this.currentJob = Optional.ofNullable(job); - } - - /** - * @return the currentJob - */ - public Optional getJob() { - return currentJob; - } - - public Optional updateExecution(long time) { - if (currentJob.isPresent()) { - return currentJob.get().updateExecution(time); - } - - return Optional.empty(); - } - - - public boolean acceptTask(TaskContextInterface taskContext, int t) { - if (!currentJob.isPresent() || currentJob.get().getTaskContext().getTask() - .getPeriod() > taskContext.getTask().getPeriod()) { - Optional optionalJob = taskContext.getNextJob(); - - if (optionalJob.isPresent()) { - if (!optionalJob.get().prepareJob(t)) { - return false; - } - if (currentJob.isPresent()) { - currentJob.get().setCurrentProcessor(null); - } - currentJob = optionalJob; - currentJob.get().setCurrentProcessor(this); - EventPrinter.print( - "Time " + t + ": " + this + " started job " + currentJob.get() + "!"); - return true; - } - - } - - return false; - } - - @Override - public String toString() { - return "Processor " + processorId; - } - -} diff --git a/src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java b/src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java deleted file mode 100644 index a16cb02..0000000 --- a/src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java +++ /dev/null @@ -1,17 +0,0 @@ -package mvd.jester.simulator.internals; - -import java.util.TreeSet; -import mvd.jester.priority.PriorityManager; - -/** - * SortedTaskContextSet - */ -public class SortedTaskContextSet extends TreeSet { - - private static final long serialVersionUID = 4808544133562675597L; - - public SortedTaskContextSet(PriorityManager priorityMananger) { - super((t1, t2) -> priorityMananger.compare(t1, t2)); - } -} - diff --git a/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java b/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java deleted file mode 100644 index c109b34..0000000 --- a/src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java +++ /dev/null @@ -1,20 +0,0 @@ -package mvd.jester.simulator.internals; - -import java.util.Optional; -import mvd.jester.model.SynchronousTask; - -/** - * TaskContextInterface - */ -public interface TaskContextInterface { - - public SynchronousTask getTask(); - - public Optional acceptNotification(long time); - - public Optional getNextJob(); - - public long getDeadline(); - - public long getReleaseTime(); -} diff --git a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java deleted file mode 100644 index ef92607..0000000 --- a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java +++ /dev/null @@ -1,129 +0,0 @@ -package mvd.jester.simulator.internals.dynamicforkjoin; - -import java.util.Optional; -import mvd.jester.simulator.EventPrinter; -import mvd.jester.simulator.internals.JobContextInterface; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.TaskContextInterface; - -/** - * Job - * - * @param - */ -public class JobContext implements JobContextInterface { - - private final TaskContext taskContext; - private final SegmentContext segmentContext; - private final long wcet; - private Optional currentProcessor; - private Optional currentTasklet; - - - public JobContext(TaskContext taskContext, SegmentContext segmentContext) { - this.currentProcessor = Optional.empty(); - this.currentTasklet = Optional.empty(); - this.taskContext = taskContext; - this.segmentContext = segmentContext; - this.wcet = segmentContext.getSegment().getWidth(); - } - - public Optional updateExecution(long time) { - boolean jobIsIdle = true; - if (currentTasklet.isPresent()) { - jobIsIdle = currentTasklet.get().updateExecution(time); - } - - if (jobIsIdle) { - currentTasklet = segmentContext.getNextTasklet(); - Optional tc = taskContext.acceptNotification(time); - - if (currentTasklet.isPresent()) { - EventPrinter.print("Time " + time + ": Job " + this + " started executing tasklet " - + currentTasklet.get() + " on Processor " + currentProcessor.get()); - currentTasklet.get().setCurrentJob(this); - } else { - if (currentProcessor.isPresent()) { - currentProcessor.get().setJob(null); - } - currentProcessor = Optional.empty(); - return tc; - } - } - - return Optional.empty(); - } - - public boolean checkExecutionTime() { - if (currentTasklet.isPresent()) { - return currentTasklet.get().checkExecutionTime(); - } - return false; - } - - /** - * @return the wcet - */ - public long getWcet() { - return wcet; - } - - /** - * @param processor the currentProcessor to set - */ - public void setCurrentProcessor(ProcessorContext processor) { - this.currentProcessor = Optional.ofNullable(processor); - } - - /** - * @return the currentProcessor - */ - public Optional getCurrentProcessor() { - return currentProcessor; - } - - /** - * @param currentTasklet the currentTasklet to set - */ - public void setCurrentTasklet(TaskletContext currentTasklet) { - this.currentTasklet = Optional.ofNullable(currentTasklet); - } - - /** - * @return the segmentContext - */ - public SegmentContext getSegmentContext() { - return segmentContext; - } - - - /** - * @return the taskContext - */ - public TaskContext getTaskContext() { - return taskContext; - } - - @Override - public String toString() { - return "(of task=" + taskContext + ")"; - } - - @Override - public boolean prepareJob(long time) { - if (!currentTasklet.isPresent()) { - currentTasklet = segmentContext.getNextTasklet(); - if (currentTasklet.isPresent()) { - currentTasklet.get().setCurrentJob(this); - // EventPrinter.print("Time " + time + ": Job " + this + " started executing - // tasklet" - // + currentTasklet.get()); - return true; - } else { - return false; - } - } - return true; - } - -} diff --git a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java deleted file mode 100644 index 2fb24f9..0000000 --- a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java +++ /dev/null @@ -1,79 +0,0 @@ -package mvd.jester.simulator.internals.dynamicforkjoin; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import mvd.jester.model.Segment; -import mvd.jester.simulator.internals.JobContextInterface; - -/** - * Segment - */ -public class SegmentContext { - private final Segment segment; - private final Set jobs; - private final Set tasklets; - - public SegmentContext(TaskContext taskContext, Segment segment, long numberOfProcessors) { - this.segment = segment; - jobs = new HashSet<>(); - tasklets = new HashSet<>(); - - long numberOfJobs = - segment.getHeight() > numberOfProcessors ? numberOfProcessors : segment.getHeight(); - - for (int j = 0; j < numberOfJobs; ++j) { - jobs.add(new JobContext(taskContext, this)); - } - - // for (int j = 0; j < segment.getNumberOfTasklets(); ++j) { - // tasklets.add(new TaskletContext(taskContext, this)); - // } - } - - - /** - * @return the segment - */ - public Segment getSegment() { - return segment; - } - - public long getNumberOfJobs() { - return jobs.size(); - } - - public Optional getNextJob() { - boolean taskletAvailable = tasklets.stream() - .anyMatch(t -> !t.getCurrentJob().isPresent() && t.checkExecutionTime()); - - boolean jobNotFinished = jobs.stream() - .anyMatch(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()); - - if (jobNotFinished) { - return jobs.stream() - .filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()) - .findFirst(); - } else if (taskletAvailable) { - return jobs.stream() - .filter(j -> !j.getCurrentProcessor().isPresent() && !j.checkExecutionTime()) - .findFirst(); - } else { - return Optional.empty(); - } - } - - public Optional getNextTasklet() { - return tasklets.stream() - .filter(t -> !t.getCurrentJob().isPresent() && t.checkExecutionTime()).findFirst(); - } - - - - @Override - public String toString() { - return "something"; - // return "(nJobs=" + segment.getNumberOfJobs() + ", nTasklets=" - // + segment.getNumberOfTasklets() + ", taskletWcet=" + segment.getTaskletWcet() + ")"; - } -} diff --git a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java deleted file mode 100644 index de9c586..0000000 --- a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java +++ /dev/null @@ -1,87 +0,0 @@ -package mvd.jester.simulator.internals.dynamicforkjoin; - -import java.util.ArrayList; -import java.util.Optional; -import mvd.jester.model.Segment; -import mvd.jester.model.SynchronousTask; -import mvd.jester.simulator.internals.JobContextInterface; -import mvd.jester.simulator.internals.TaskContextInterface; - -/** - * TaskContext - */ -public class TaskContext implements TaskContextInterface { - - private final SynchronousTask task; - private final ArrayList segments; - private final long releaseTime; - private final long deadline; - private int currentSegment; - private int segmentCounter; - - - public TaskContext(SynchronousTask task, long numberOfProcessors, long releaseTime) { - this.task = task; - this.segments = new ArrayList<>(); - this.currentSegment = 0; - this.segmentCounter = 0; - this.deadline = releaseTime + task.getDeadline(); - this.releaseTime = releaseTime; - - for (Segment s : task.getWorkloadDistribution()) { - segments.add(new SegmentContext(this, s, numberOfProcessors)); - } - } - - /** - * @return the task - */ - public SynchronousTask getTask() { - return task; - } - - /** - * @return the deadline - */ - @Override - public long getDeadline() { - return deadline; - } - - @Override - public long getReleaseTime() { - return releaseTime; - } - - public Optional acceptNotification(long time) { - segmentCounter++; - - // if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfTasklets()) { - // currentSegment++; - // segmentCounter = 0; - // if (currentSegment >= segments.size()) { - // EventPrinter.print("Time " + time + ": Task " + this + "finished!"); - // return Optional.of(this); - // } - // } - - - return Optional.empty(); - } - - public Optional getNextJob() { - if (currentSegment < segments.size()) { - return segments.get(currentSegment).getNextJob(); - } - - return Optional.empty(); - } - - - @Override - public String toString() { - return "(period=" + task.getPeriod() + ", deadline=" + deadline + ", segments=" - + segments.size() + ")"; - } - -} diff --git a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java deleted file mode 100644 index 4989ba8..0000000 --- a/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java +++ /dev/null @@ -1,62 +0,0 @@ -package mvd.jester.simulator.internals.dynamicforkjoin; - -import java.util.Optional; - -/** - * Tasklet - */ -public class TaskletContext { - - private final TaskContext taskContext; - private Optional currentJob; - private final long wcet; - private long executionTime; - - - public TaskletContext(TaskContext taskContext, SegmentContext segment) { - this.taskContext = taskContext; - this.wcet = 88; - // segment.getSegment().getTaskletWcet(); - this.executionTime = wcet; - currentJob = Optional.empty(); - } - - - /** - * @return the currentJob - */ - public Optional getCurrentJob() { - return currentJob; - } - - public void setCurrentJob(JobContext jobContext) { - currentJob = Optional.ofNullable(jobContext); - } - - /** - * @return true if tasklet finished, false otherwise - */ - public boolean updateExecution(long time) { - executionTime--; - - if (executionTime == 0) { - if (currentJob.isPresent()) { - currentJob.get().setCurrentTasklet(null); - } - currentJob = Optional.empty(); - return true; - } else if (executionTime < 0) { - throw new RuntimeException("Tasklet was executed for longer than its WCET!"); - } - return false; - } - - public boolean checkExecutionTime() { - return executionTime > 0; - } - - @Override - public String toString() { - return "(wcet=" + wcet + ", task=" + taskContext + ")"; - } -} diff --git a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java deleted file mode 100644 index 99389aa..0000000 --- a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java +++ /dev/null @@ -1,97 +0,0 @@ -package mvd.jester.simulator.internals.parallelsynchronous; - -import java.util.Optional; -import mvd.jester.simulator.EventPrinter; -import mvd.jester.simulator.internals.JobContextInterface; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.TaskContextInterface; - -/** - * Job - * - * @param - */ -public class JobContext implements JobContextInterface { - - private final TaskContext taskContext; - private final SegmentContext segmentContext; - private final long wcet; - private Optional currentProcessor; - private long executionTime; - - - public JobContext(TaskContext taskContext, SegmentContext segmentContext) { - this.currentProcessor = Optional.empty(); - this.taskContext = taskContext; - this.segmentContext = segmentContext; - this.wcet = segmentContext.getSegment().getWidth(); - this.executionTime = wcet; - } - - public Optional updateExecution(long time) { - executionTime--; - - if (executionTime == 0) { - EventPrinter.print("Time " + time + ": " + currentProcessor.get() - + " finished execution of job " + this + "!"); - currentProcessor.get().setJob(null); - currentProcessor = Optional.empty(); - return taskContext.acceptNotification(time); - } else if (executionTime < 0) { - throw new RuntimeException("Job was executed for longer than its WCET!"); - } - - return Optional.empty(); - } - - public boolean checkExecutionTime() { - return executionTime > 0; - } - - /** - * @return the wcet - */ - public long getWcet() { - return wcet; - } - - /** - * @param processor the currentProcessor to set - */ - public void setCurrentProcessor(ProcessorContext processor) { - this.currentProcessor = Optional.ofNullable(processor); - } - - /** - * @return the currentProcessor - */ - public Optional getCurrentProcessor() { - return currentProcessor; - } - - /** - * @return the segmentContext - */ - public SegmentContext getSegmentContext() { - return segmentContext; - } - - - /** - * @return the taskContext - */ - public TaskContext getTaskContext() { - return taskContext; - } - - @Override - public String toString() { - return "(jobWcet=" + wcet + ", of task=" + taskContext + ")"; - } - - @Override - public boolean prepareJob(long time) { - return true; - } - -} diff --git a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java deleted file mode 100644 index ff4abd9..0000000 --- a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java +++ /dev/null @@ -1,43 +0,0 @@ -package mvd.jester.simulator.internals.parallelsynchronous; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import mvd.jester.model.Segment; -import mvd.jester.simulator.internals.JobContextInterface; - -/** - * Segment - */ -public class SegmentContext { - private final Segment segment; - private final Set jobs; - - public SegmentContext(TaskContext taskContext, Segment segment) { - this.segment = segment; - jobs = new HashSet<>(); - - for (int j = 0; j < segment.getHeight(); ++j) { - jobs.add(new JobContext(taskContext, this)); - } - } - - - /** - * @return the segment - */ - public Segment getSegment() { - return segment; - } - - public Optional getNextJob() { - return jobs.stream() - .filter(j -> !j.getCurrentProcessor().isPresent() && j.checkExecutionTime()) - .findFirst(); - } - - @Override - public String toString() { - return "(nJobs=" + segment.getHeight() + ", jobWcet=" + segment.getWidth() + ")"; - } -} diff --git a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java deleted file mode 100644 index 8aaaff5..0000000 --- a/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java +++ /dev/null @@ -1,86 +0,0 @@ -package mvd.jester.simulator.internals.parallelsynchronous; - -import java.util.ArrayList; -import java.util.Optional; -import mvd.jester.model.Segment; -import mvd.jester.model.SynchronousTask; -import mvd.jester.simulator.EventPrinter; -import mvd.jester.simulator.internals.JobContextInterface; -import mvd.jester.simulator.internals.TaskContextInterface; - -/** - * TaskContext - */ -public class TaskContext implements TaskContextInterface { - - private final SynchronousTask task; - private final ArrayList segments; - private final long deadline; - private final long releaseTime; - private int currentSegment; - private int segmentCounter; - - public TaskContext(SynchronousTask task, long releaseTime) { - this.task = task; - this.segments = new ArrayList<>(); - this.currentSegment = 0; - this.segmentCounter = 0; - this.releaseTime = releaseTime; - this.deadline = releaseTime + task.getDeadline(); - - for (Segment s : task.getWorkloadDistribution()) { - segments.add(new SegmentContext(this, s)); - } - } - - /** - * @return the task - */ - public SynchronousTask getTask() { - return task; - } - - /** - * @return the deadline - */ - @Override - public long getDeadline() { - return deadline; - } - - @Override - public long getReleaseTime() { - return releaseTime; - } - - public Optional acceptNotification(long time) { - segmentCounter++; - - if (segmentCounter >= segments.get(currentSegment).getSegment().getHeight()) { - currentSegment++; - segmentCounter = 0; - if (currentSegment >= segments.size()) { - EventPrinter.print("Time " + time + ": Task " + this + "finished!"); - return Optional.of(this); - } - } - - - return Optional.empty(); - } - - public Optional getNextJob() { - if (currentSegment < segments.size()) { - return segments.get(currentSegment).getNextJob(); - } - - return Optional.empty(); - } - - - @Override - public String toString() { - return "(period=" + task.getPeriod() + ", deadline=" + deadline + ", segments=" - + segments.size() + ")"; - } -} diff --git a/src/main/java/mvd/jester/tests/MelaniButtazzo.java b/src/main/java/mvd/jester/tests/MelaniButtazzo.java index 3d8cb10..bc367f3 100644 --- a/src/main/java/mvd/jester/tests/MelaniButtazzo.java +++ b/src/main/java/mvd/jester/tests/MelaniButtazzo.java @@ -63,7 +63,6 @@ public class MelaniButtazzo extends AbstractTest { taskInterference /= manager.getNumberOfProcessors(); final double selfInterference = getSelfInterference(task); - // TODO: Einzeln abrunden oder self interference als long abrunden final long totalInterference = (long) Math.floor(taskInterference + selfInterference); responseTime = criticalPath + totalInterference; diff --git a/src/main/java/mvd/jester/tests/Tester.java b/src/main/java/mvd/jester/tests/Tester.java index 763e9b0..261a5a2 100644 --- a/src/main/java/mvd/jester/tests/Tester.java +++ b/src/main/java/mvd/jester/tests/Tester.java @@ -3,25 +3,16 @@ package mvd.jester.tests; import java.math.RoundingMode; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.Set; import com.google.common.math.LongMath; import mvd.jester.info.SchedulingInfo; -import mvd.jester.info.TerminationInfo; import mvd.jester.info.SchedulingInfo.Feasiblity; import mvd.jester.model.DagTask; -import mvd.jester.model.LightTask; import mvd.jester.model.SortedTaskSet; import mvd.jester.model.SystemManagerInterface; -import mvd.jester.model.Task; import mvd.jester.priority.DeadlineMonotonic; import mvd.jester.priority.PriorityManager; -import mvd.jester.priority.RateMonotonic; public class Tester extends AbstractTest { diff --git a/src/main/java/mvd/jester/tests/UeterAgrawal.java b/src/main/java/mvd/jester/tests/UeterAgrawal.java index 8712000..131c63b 100644 --- a/src/main/java/mvd/jester/tests/UeterAgrawal.java +++ b/src/main/java/mvd/jester/tests/UeterAgrawal.java @@ -101,7 +101,7 @@ public class UeterAgrawal extends AbstractTest { final long second = (long) Math .ceil(((double) workload - criticalPath) / (criticalPath * (strechRatio - 1))); - // TODO: include fucking boundaries + // TODO: what are those boundaries? final long max = Math.max(first, second); return max; diff --git a/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java b/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java index bbd40a6..92cb62d 100644 --- a/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java +++ b/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java @@ -9,9 +9,6 @@ import org.junit.jupiter.api.Test; import mvd.jester.model.SynchronousTask; import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager.SynchronousTaskBuilder; -import mvd.jester.simulator.DynamicForkJoin; -import mvd.jester.simulator.ParallelSynchronous; -import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; import mvd.jester.tests.ChwaLee; import mvd.jester.tests.MaiaBertogna; import mvd.jester.tests.SchmidMottok; @@ -32,17 +29,9 @@ public class TestEarliestDeadlineFirst { when(t1.getDeadline()).thenReturn((long) 100); when(t2.getDeadline()).thenReturn((long) 200); - TaskContext tc1 = mock(TaskContext.class); - TaskContext tc2 = mock(TaskContext.class); - when(tc1.getDeadline()).thenReturn((long) 100); - when(tc2.getDeadline()).thenReturn((long) 200); - assertTrue(edf.compare(t1, t2) < 0); - assertTrue(edf.compare(tc1, tc2) < 0); assertTrue(edf.compare(t1, t1) == 0); - assertTrue(edf.compare(tc1, tc1) == 0); assertTrue(edf.compare(t2, t1) > 0); - assertTrue(edf.compare(tc2, tc1) > 0); } @@ -55,14 +44,10 @@ public class TestEarliestDeadlineFirst { assertTrue(edf.hasTest(ChwaLee.class)); assertFalse(edf.hasTest(MaiaBertogna.class)); assertFalse(edf.hasTest(SchmidMottok.class)); - assertTrue(edf.hasSimulator(ParallelSynchronous.class)); - assertTrue(edf.hasSimulator(DynamicForkJoin.class)); assertTrue(edf.hasTest(new ChwaLee(manager))); assertFalse(edf.hasTest(new SchmidMottok(new TypeFunction.KnownStructure(), manager))); assertFalse(edf.hasTest(new MaiaBertogna(manager))); - // assertTrue(edf.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class)))); - // assertTrue(edf.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class)))); assertTrue(edf.getName().equals("EDF")); } diff --git a/src/test/java/mvd/jester/priority/TestRateMonotonic.java b/src/test/java/mvd/jester/priority/TestRateMonotonic.java index 4fd940c..a7ab79e 100644 --- a/src/test/java/mvd/jester/priority/TestRateMonotonic.java +++ b/src/test/java/mvd/jester/priority/TestRateMonotonic.java @@ -9,9 +9,6 @@ import org.junit.jupiter.api.Test; import mvd.jester.model.SynchronousTask; import mvd.jester.model.SystemManager; import mvd.jester.model.SystemManager.SynchronousTaskBuilder; -import mvd.jester.simulator.DynamicForkJoin; -import mvd.jester.simulator.ParallelSynchronous; -import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; import mvd.jester.tests.ChwaLee; import mvd.jester.tests.MaiaBertogna; import mvd.jester.tests.SchmidMottok; @@ -31,17 +28,9 @@ public class TestRateMonotonic { when(t1.getPeriod()).thenReturn((long) 100); when(t2.getPeriod()).thenReturn((long) 200); - TaskContext tc1 = mock(TaskContext.class); - TaskContext tc2 = mock(TaskContext.class); - when(tc1.getTask()).thenReturn(t1); - when(tc2.getTask()).thenReturn(t2); - assertTrue(rm.compare(t1, t2) < 0); - assertTrue(rm.compare(tc1, tc2) < 0); assertTrue(rm.compare(t1, t1) == 0); - assertTrue(rm.compare(tc1, tc1) == 0); assertTrue(rm.compare(t2, t1) > 0); - assertTrue(rm.compare(tc2, tc1) > 0); } @@ -54,14 +43,10 @@ public class TestRateMonotonic { assertFalse(rm.hasTest(ChwaLee.class)); assertTrue(rm.hasTest(MaiaBertogna.class)); assertTrue(rm.hasTest(SchmidMottok.class)); - assertTrue(rm.hasSimulator(ParallelSynchronous.class)); - assertTrue(rm.hasSimulator(DynamicForkJoin.class)); assertFalse(rm.hasTest(new ChwaLee(manager))); assertTrue(rm.hasTest(new SchmidMottok(new TypeFunction.UnknownStructure(), manager))); assertTrue(rm.hasTest(new MaiaBertogna(manager))); - // assertTrue(rm.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class)))); - // assertTrue(rm.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class)))); assertTrue(rm.getName().equals("RM")); } diff --git a/src/test/java/mvd/jester/simulator/TestProcessorContext.java b/src/test/java/mvd/jester/simulator/TestProcessorContext.java deleted file mode 100644 index 0ed0dfc..0000000 --- a/src/test/java/mvd/jester/simulator/TestProcessorContext.java +++ /dev/null @@ -1,107 +0,0 @@ -package mvd.jester.simulator; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.AdditionalMatchers.gt; -import static org.mockito.AdditionalMatchers.lt; -import java.util.Optional; -import java.util.concurrent.ThreadLocalRandom; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import mvd.jester.model.SynchronousTask; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.TaskContextInterface; -import mvd.jester.simulator.internals.parallelsynchronous.JobContext; -import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; - -/** - * TestProcessorContext - */ -public class TestProcessorContext { - - @Test - @DisplayName("Check if the job execution is updated correctly.") - void testUpdateExecution() { - for (int run = 0; run < 100; ++run) { - long jobWcet = ThreadLocalRandom.current().nextLong(1, 10); - - TaskContext task = mock(TaskContext.class); - JobContext job = mock(JobContext.class); - when(job.updateExecution(lt(jobWcet))).thenReturn(Optional.empty()); - when(job.updateExecution(jobWcet)).thenReturn(Optional.of(task)); - when(job.updateExecution(gt(jobWcet))).thenThrow(RuntimeException.class); - - ProcessorContext processor = new ProcessorContext(1); - assertFalse(processor.updateExecution(0).isPresent()); - processor.setJob(job); - - for (int i = 0; i < jobWcet; ++i) { - assertFalse(processor.updateExecution(i).isPresent()); - } - Optional tci = processor.updateExecution(jobWcet); - assertTrue(tci.isPresent()); - assertTrue(tci.get().equals(task)); - - assertThrows(RuntimeException.class, () -> processor.updateExecution(jobWcet + 1)); - - verify(job, times((int) jobWcet + 2)).updateExecution(anyLong()); - } - } - - - @Test - @DisplayName("Check if the processor correctly accepts jobs") - void testAcceptTask() { - for (int run = 0; run < 100; ++run) { - long firstPeriod = ThreadLocalRandom.current().nextLong(100, 1000); - long secondPeriod = ThreadLocalRandom.current().nextLong(100, 1000); - - JobContext firstJob = mock(JobContext.class); - TaskContext firstTaskContext = mock(TaskContext.class); - SynchronousTask firstTask = mock(SynchronousTask.class); - - when(firstJob.getTaskContext()).thenReturn(firstTaskContext); - when(firstJob.prepareJob(anyLong())).thenReturn(true); - when(firstTaskContext.getTask()).thenReturn(firstTask); - when(firstTaskContext.getNextJob()).thenReturn(Optional.of(firstJob)); - when(firstTask.getPeriod()).thenReturn((long) firstPeriod); - - - JobContext secondJob = mock(JobContext.class); - TaskContext secondTaskContext = mock(TaskContext.class); - SynchronousTask secondTask = mock(SynchronousTask.class); - - when(secondJob.getTaskContext()).thenReturn(secondTaskContext); - when(secondJob.prepareJob(anyLong())).thenReturn(true); - when(secondTaskContext.getTask()).thenReturn(secondTask); - when(secondTaskContext.getNextJob()).thenReturn(Optional.of(secondJob)); - when(secondTask.getPeriod()).thenReturn((long) secondPeriod); - - ProcessorContext processor = new ProcessorContext(1); - - assertTrue(processor.acceptTask(secondTaskContext, run)); - if (firstPeriod < secondPeriod) { - assertTrue(processor.acceptTask(firstTaskContext, run)); - } else { - assertFalse(processor.acceptTask(firstTaskContext, run)); - } - assertFalse(processor.acceptTask(secondTaskContext, run)); - - int time = firstPeriod < secondPeriod ? 1 : 0; - verify(firstJob, times(time)).prepareJob(anyLong()); - verify(firstJob, times(time)).setCurrentProcessor(processor); - verify(firstTaskContext, times(time)).getNextJob(); - verify(secondJob, times(1)).prepareJob(anyLong()); - verify(secondJob, times(1)).setCurrentProcessor(processor); - verify(secondJob, times(time)).setCurrentProcessor(null); - verify(secondTaskContext, times(1)).getNextJob(); - } - } - -} diff --git a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java deleted file mode 100644 index 74cbc19..0000000 --- a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java +++ /dev/null @@ -1,98 +0,0 @@ -package mvd.jester.simulator.dynamicforkjoin; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.AdditionalMatchers.not; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.Optional; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import mvd.jester.model.Segment; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.dynamicforkjoin.JobContext; -import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext; -import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext; -import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext;; - -/** - * TestJobContext - */ -public class TestJobContext { - - @Test - @DisplayName("Check if the job is prepared correctly.") - public void testPrepareJob() { - TaskContext tc = mock(TaskContext.class); - TaskletContext tlc = mock(TaskletContext.class); - SegmentContext sc = mock(SegmentContext.class); - Segment s = mock(Segment.class); - when(sc.getSegment()).thenReturn(s); - when(s.getWidth()).thenReturn((long) 20); - when(sc.getNextTasklet()).thenReturn(Optional.of(tlc)) - .thenReturn(Optional.ofNullable(null)); - - - JobContext jc = new JobContext(tc, sc); - - assertTrue(jc.prepareJob(0)); - assertTrue(jc.prepareJob(1)); - jc.setCurrentTasklet(null); - assertFalse(jc.prepareJob(2)); - } - - @Test - @DisplayName("Check if the execution time is checked correctly.") - void testCheckExecutionTime() { - TaskContext tc = mock(TaskContext.class); - TaskletContext tlc = mock(TaskletContext.class); - SegmentContext sc = mock(SegmentContext.class); - Segment s = mock(Segment.class); - when(sc.getSegment()).thenReturn(s); - when(s.getWidth()).thenReturn((long) 20); - when(tlc.checkExecutionTime()).thenReturn(true, false); - - JobContext jc = new JobContext(tc, sc); - - assertFalse(jc.checkExecutionTime()); - jc.setCurrentTasklet(tlc); - assertTrue(jc.checkExecutionTime()); - assertFalse(jc.checkExecutionTime()); - } - - @Test - @DisplayName("Check if the execution is updated correctly.") - void checkUpdateExecution() { - TaskContext tc = mock(TaskContext.class); - TaskletContext tlc = mock(TaskletContext.class); - SegmentContext sc = mock(SegmentContext.class); - Segment s = mock(Segment.class); - ProcessorContext pc = mock(ProcessorContext.class); - when(sc.getSegment()).thenReturn(s); - when(sc.getNextTasklet()).thenReturn(Optional.ofNullable(tlc)) - .thenReturn(Optional.ofNullable(null)); - when(s.getWidth()).thenReturn((long) 20); - when(tlc.checkExecutionTime()).thenReturn(true, false); - when(tlc.updateExecution(not(eq(0)))).thenReturn(true); - when(tlc.updateExecution(0)).thenReturn(false); - when(tc.acceptNotification(not(eq(1)))).thenReturn(Optional.ofNullable(null)); - when(tc.acceptNotification(1)).thenReturn(Optional.ofNullable(tc)); - - JobContext jc = new JobContext(tc, sc); - jc.setCurrentProcessor(pc); - - assertFalse(jc.updateExecution(0).isPresent()); - assertFalse(jc.updateExecution(0).isPresent()); - - jc.setCurrentTasklet(tlc); - assertTrue(jc.updateExecution(1).isPresent()); - - verify(tlc, times(2)).updateExecution(anyLong()); - verify(tc, times(2)).acceptNotification(anyLong()); - verify(sc, times(2)).getNextTasklet(); - } -} diff --git a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java deleted file mode 100644 index a726ce9..0000000 --- a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java +++ /dev/null @@ -1,101 +0,0 @@ -// package mvd.jester.simulator.dynamicforkjoin; - -// import static org.junit.jupiter.api.Assertions.assertFalse; -// import static org.junit.jupiter.api.Assertions.assertTrue; -// import static org.mockito.Mockito.mock; -// import static org.mockito.Mockito.when; -// import java.util.Optional; -// import java.util.concurrent.ThreadLocalRandom; -// import org.junit.jupiter.api.DisplayName; -// import org.junit.jupiter.api.Test; -// import mvd.jester.model.Segment; -// import mvd.jester.simulator.internals.JobContextInterface; -// import mvd.jester.simulator.internals.ProcessorContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.JobContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext; - -// /** -// * TestSegmentContext -// */ -// public class TestSegmentContext { - -// @Test -// @DisplayName("Check if segment returns the jobs correctly.") -// void testGetNextJob() { -// for (int run = 0; run < 100; ++run) { -// long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// long jobWcet = ThreadLocalRandom.current().nextLong(20, 50); - -// Segment s = mock(Segment.class); -// when(s.getNumberOfJobs()).thenReturn(numberOfJobs); -// when(s.getJobWcet()).thenReturn(jobWcet); -// TaskContext tc = mock(TaskContext.class); - -// SegmentContext sc = new SegmentContext(tc, s, 4); -// Optional job = Optional.empty(); - -// when(tc.acceptNotification(jobWcet - 1)).thenReturn(Optional.empty()); - -// long numJobs = numberOfJobs > 4 ? 4 : numberOfJobs; -// for (int i = 0; i < numJobs; ++i) { -// job = sc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(i)); -// } - -// assertFalse(sc.getNextJob().isPresent()); - -// sc = new SegmentContext(tc, s, 4); - -// job = sc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(0)); -// for (int i = 0; i < jobWcet * numberOfJobs; ++i) { -// job.get().updateExecution(i); -// } - -// assertFalse(sc.getNextJob().isPresent()); -// } -// } - -// @Test -// @DisplayName("Check if SegmentContext returns the correct amount of tasklets.") -// void testGetNextTasklet() { -// for (int run = 0; run < 100; ++run) { -// long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// long jobWcet = ThreadLocalRandom.current().nextLong(20, 50); - -// Segment s = mock(Segment.class); -// when(s.getNumberOfJobs()).thenReturn(numberOfJobs); -// when(s.getJobWcet()).thenReturn(jobWcet); -// TaskContext tc = mock(TaskContext.class); -// when(tc.acceptNotification(jobWcet - 1)).thenReturn(Optional.empty()); - -// SegmentContext sc = new SegmentContext(tc, s, 4); - -// for (int i = 0; i < jobWcet; ++i) { -// Optional tci = sc.getNextTasklet(); -// assertTrue(tci.isPresent()); -// tci.get().setCurrentJob(mock(JobContext.class)); -// } - -// assertFalse(sc.getNextTasklet().isPresent()); - -// sc = new SegmentContext(tc, s, 4); - -// for (int i = 0; i < jobWcet; ++i) { -// Optional tasklet = sc.getNextTasklet(); -// assertTrue(tasklet.isPresent()); -// tasklet.get().setCurrentJob(mock(JobContext.class)); -// for (int j = 0; j < numberOfJobs; ++j) { -// tasklet.get().updateExecution(j); -// } -// } - -// assertFalse(sc.getNextTasklet().isPresent()); -// } -// } - -// } diff --git a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java deleted file mode 100644 index eb2fb52..0000000 --- a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java +++ /dev/null @@ -1,95 +0,0 @@ -// package mvd.jester.simulator.dynamicforkjoin; - -// import static org.junit.jupiter.api.Assertions.assertFalse; -// import static org.junit.jupiter.api.Assertions.assertTrue; -// import java.util.ArrayList; -// import java.util.LinkedHashSet; -// import java.util.Optional; -// import java.util.Set; -// import java.util.concurrent.ThreadLocalRandom; -// import org.junit.jupiter.api.DisplayName; -// import org.junit.jupiter.api.Test; -// import mvd.jester.model.Segment; -// import mvd.jester.model.SynchronousTask; -// import mvd.jester.simulator.internals.JobContextInterface; -// import mvd.jester.simulator.internals.ProcessorContext; -// import mvd.jester.simulator.internals.TaskContextInterface; -// import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext; - -// /** -// * TestTaskContext -// */ -// public class TestTaskContext { -// @Test -// @DisplayName("Check if TaskContext accepts its notification correctly.") -// public void testAcceptNotification() { -// for (int run = 0; run < 100; ++run) { -// long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// long numberOfSegments = ThreadLocalRandom.current().nextLong(3, 10); -// ArrayList segments = new ArrayList<>(); - -// for (int i = 0; i < numberOfSegments; ++i) { -// long numJobs = i % 2 == 0 ? 1 : numberOfJobs; -// segments.add(new Segment(10, numJobs)); -// } - -// SynchronousTask t = new SynchronousTask(new LinkedHashSet<>(segments), 100, 8); -// TaskContext tc = new TaskContext(t, 1, 0); - -// for (int i = 0; i < segments.size() - 1; ++i) { -// Segment s = segments.get(i); -// } - - -// Optional tci = tc.acceptNotification(0); - -// assertTrue(tci.isPresent()); -// assertTrue(tci.get().equals(tc)); -// } -// } - -// @Test -// @DisplayName("Check if the next job is returned correctly.") -// public void testGetNextJob() { -// for (int run = 0; run < 100; ++run) { -// long numberOfProcessors = ThreadLocalRandom.current().nextLong(2, 10); - -// Set segments = new LinkedHashSet<>(); -// segments.add(new Segment(5, 1)); -// segments.add(new Segment(10, 10)); -// segments.add(new Segment(15, 1)); -// SynchronousTask t = new SynchronousTask(segments, 100, 8); - -// TaskContext tc = new TaskContext(t, numberOfProcessors, 0); - -// Optional job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(0)); -// assertFalse(tc.getNextJob().isPresent()); - -// tc.acceptNotification(0); - -// for (int i = 0; i < numberOfProcessors - 1; ++i) { -// job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(i)); -// } - -// job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(10)); - -// assertFalse(tc.getNextJob().isPresent()); -// job.get().setCurrentProcessor(null); -// assertTrue(tc.getNextJob().isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(10)); -// assertFalse(tc.getNextJob().isPresent()); - -// for (int i = 0; i < 10; ++i) { -// tc.acceptNotification(0); -// } -// assertTrue(tc.getNextJob().isPresent()); -// } -// } - -// } diff --git a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java deleted file mode 100644 index f157fd7..0000000 --- a/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java +++ /dev/null @@ -1,52 +0,0 @@ -// package mvd.jester.simulator.dynamicforkjoin; - -// import static org.junit.jupiter.api.Assertions.assertFalse; -// import static org.junit.jupiter.api.Assertions.assertThrows; -// import static org.junit.jupiter.api.Assertions.assertTrue; -// import static org.mockito.Mockito.mock; -// import static org.mockito.Mockito.times; -// import static org.mockito.Mockito.verify; -// import static org.mockito.Mockito.when; -// import java.util.concurrent.ThreadLocalRandom; -// import org.junit.jupiter.api.DisplayName; -// import org.junit.jupiter.api.Test; -// import mvd.jester.model.Segment; -// import mvd.jester.simulator.internals.dynamicforkjoin.JobContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext; -// import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext; - -// /** -// * TestTaskletContext -// */ -// public class TestTaskletContext { - -// @Test -// @DisplayName("Check if the execution of the tasklet is updated correctly.") -// void testUpdateExecution() { -// for (int run = 0; run < 100; ++run) { -// long taskletWcet = ThreadLocalRandom.current().nextLong(20, 50); - -// Segment s = mock(Segment.class); -// SegmentContext sc = mock(SegmentContext.class); -// when(sc.getSegment()).thenReturn(s); -// TaskContext tc = mock(TaskContext.class); -// JobContext jc = mock(JobContext.class); - -// TaskletContext tasklet = new TaskletContext(tc, sc); -// tasklet.setCurrentJob(jc); - -// assertTrue(tasklet.checkExecutionTime()); - -// for (int i = 0; i < taskletWcet - 1; ++i) { -// assertFalse(tasklet.updateExecution(i)); -// } -// assertTrue(tasklet.updateExecution(taskletWcet)); -// assertFalse(tasklet.getCurrentJob().isPresent()); -// assertFalse(tasklet.checkExecutionTime()); - -// verify(jc, times(1)).setCurrentTasklet(null); -// assertThrows(RuntimeException.class, () -> tasklet.updateExecution(1)); -// } -// } -// } diff --git a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java deleted file mode 100644 index 1ff7618..0000000 --- a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java +++ /dev/null @@ -1,61 +0,0 @@ -package mvd.jester.simulator.parallelsynchronous; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.Optional; -import java.util.concurrent.ThreadLocalRandom; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import mvd.jester.model.Segment; -import mvd.jester.simulator.internals.ProcessorContext; -import mvd.jester.simulator.internals.TaskContextInterface; -import mvd.jester.simulator.internals.parallelsynchronous.JobContext; -import mvd.jester.simulator.internals.parallelsynchronous.SegmentContext; -import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; - -/** - * TestJobContext - */ -public class TestJobContext { - - @Test - @DisplayName("Check if execution of Job is updated correctly.") - public void testUpdateExecution() { - for (int run = 0; run < 100; ++run) { - long jobWcet = ThreadLocalRandom.current().nextLong(20, 50); - - Segment s = mock(Segment.class); - when(s.getWidth()).thenReturn(jobWcet); - SegmentContext sc = mock(SegmentContext.class); - when(sc.getSegment()).thenReturn(s); - TaskContext tc = mock(TaskContext.class); - when(tc.acceptNotification(anyLong())).thenReturn(Optional.of(tc)); - - JobContext job = new JobContext(tc, sc); - ProcessorContext p = mock(ProcessorContext.class); - job.setCurrentProcessor(p); - - assertTrue(job.checkExecutionTime()); - - for (int i = 0; i < jobWcet - 1; ++i) { - assertFalse(job.updateExecution(i).isPresent()); - } - - Optional otc = job.updateExecution(0); - assertTrue(otc.isPresent()); - assertTrue(tc.equals(otc.get())); - assertFalse(p.getJob().isPresent()); - assertFalse(job.getCurrentProcessor().isPresent()); - assertFalse(job.checkExecutionTime()); - - verify(p, times(1)).setJob(null); - assertThrows(RuntimeException.class, () -> job.updateExecution(1)); - } - } -} diff --git a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java deleted file mode 100644 index e1cc17a..0000000 --- a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java +++ /dev/null @@ -1,57 +0,0 @@ -// package mvd.jester.simulator.parallelsynchronous; - -// import static org.junit.jupiter.api.Assertions.assertFalse; -// import static org.junit.jupiter.api.Assertions.assertTrue; -// import static org.mockito.Mockito.mock; -// import static org.mockito.Mockito.when; -// import java.util.Optional; -// import java.util.concurrent.ThreadLocalRandom; -// import org.junit.jupiter.api.DisplayName; -// import org.junit.jupiter.api.Test; -// import mvd.jester.model.Segment; -// import mvd.jester.simulator.internals.JobContextInterface; -// import mvd.jester.simulator.internals.parallelsynchronous.SegmentContext; -// import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; -// import mvd.jester.simulator.internals.ProcessorContext; - -// /** -// * TestSegmentContext -// */ -// public class TestSegmentContext { - -// @Test -// @DisplayName("Check if segment returns the jobs correctly.") -// void testGetNextJob() { -// for (int run = 0; run < 100; ++run) { -// long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// long jobWcet = ThreadLocalRandom.current().nextLong(20, 50); -// Segment s = new Segment(jobWcet, numberOfJobs); -// TaskContext tc = mock(TaskContext.class); -// when(tc.acceptNotification(jobWcet - 1)).thenReturn(Optional.empty()); - -// SegmentContext sc = new SegmentContext(tc, s); - -// Optional job = Optional.empty(); -// for (int i = 0; i < numberOfJobs; ++i) { -// job = sc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(i)); -// } - -// assertFalse(sc.getNextJob().isPresent()); - -// sc = new SegmentContext(tc, s); - -// for (int i = 0; i < numberOfJobs; ++i) { -// job = sc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(i)); -// for (int j = 0; j < jobWcet; ++j) { -// job.get().updateExecution(i); -// } -// } - -// assertFalse(sc.getNextJob().isPresent()); -// } -// } -// } diff --git a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java deleted file mode 100644 index d6fc8ce..0000000 --- a/src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java +++ /dev/null @@ -1,96 +0,0 @@ -// package mvd.jester.simulator.parallelsynchronous; - -// import static org.junit.jupiter.api.Assertions.assertFalse; -// import static org.junit.jupiter.api.Assertions.assertTrue; -// import java.util.ArrayList; -// import java.util.LinkedHashSet; -// import java.util.Optional; -// import java.util.Set; -// import java.util.concurrent.ThreadLocalRandom; -// import org.junit.jupiter.api.DisplayName; -// import org.junit.jupiter.api.Test; -// import mvd.jester.model.Segment; -// import mvd.jester.model.SynchronousTask; -// import mvd.jester.simulator.internals.JobContextInterface; -// import mvd.jester.simulator.internals.ProcessorContext; -// import mvd.jester.simulator.internals.TaskContextInterface; -// import mvd.jester.simulator.internals.parallelsynchronous.TaskContext; - -// /** -// * TestTaskContext -// */ -// public class TestTaskContext { - -// @Test -// @DisplayName("Check if TaskContext accepts its notification correctly.") -// public void testAcceptNotification() { -// for (int run = 0; run < 100; ++run) { -// long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// long numberOfSegments = ThreadLocalRandom.current().nextLong(3, 10); -// ArrayList segments = new ArrayList<>(); - -// for (int i = 0; i < numberOfSegments; ++i) { -// long numJobs = i % 2 == 0 ? 1 : numberOfJobs; -// segments.add(new Segment(10, numJobs)); -// } - -// SynchronousTask t = new SynchronousTask(new LinkedHashSet<>(segments), 100, 8); -// TaskContext tc = new TaskContext(t, 0); - -// for (int i = 0; i < segments.size() - 1; ++i) { -// Segment s = segments.get(i); -// for (int j = 0; j < s.getNumberOfJobs(); ++j) { -// assertFalse(tc.acceptNotification(0).isPresent()); -// } -// } - -// for (int i = 0; i < segments.get(segments.size() - 1).getNumberOfJobs() - 1; ++i) { -// assertFalse(tc.acceptNotification(0).isPresent()); -// } - -// Optional tci = tc.acceptNotification(0); - -// assertTrue(tci.isPresent()); -// assertTrue(tci.get().equals(tc)); -// } -// } - -// @Test -// @DisplayName("Check if the next job is returned correctly.") -// public void testGetNextJob() { -// for (int run = 0; run < 100; ++run) { -// // long numberOfJobs = ThreadLocalRandom.current().nextLong(1, 10); -// // long numberOfSegments = ThreadLocalRandom.current().nextLong(3, 10); - -// Set segments = new LinkedHashSet<>(); -// segments.add(new Segment(5, 1)); -// segments.add(new Segment(10, 10)); -// segments.add(new Segment(15, 1)); -// SynchronousTask t = new SynchronousTask(segments, 100, 8); - -// TaskContext tc = new TaskContext(t, 0); - -// Optional job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(0)); -// assertFalse(tc.getNextJob().isPresent()); - -// tc.acceptNotification(0); - -// for (int i = 0; i < 9; ++i) { -// job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(i)); -// tc.acceptNotification(0); -// } -// job = tc.getNextJob(); -// assertTrue(job.isPresent()); -// job.get().setCurrentProcessor(new ProcessorContext(20)); -// assertFalse(tc.getNextJob().isPresent()); - -// tc.acceptNotification(0); - -// assertTrue(tc.getNextJob().isPresent()); -// } -// } -// } -- libgit2 0.26.0