From ece7d61d9b4b5220357512761fa22639a4134b9b Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Tue, 21 Jan 2020 09:57:47 +0100 Subject: [PATCH] Minor changes --- src/main/java/mvd/jester/model/SystemSetup.java | 22 +++++++++++++--------- src/test/java/mvd/jester/model/TestSystemSetup.java | 2 +- src/test/java/mvd/jester/tests/TestMaiaBertogna.java | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 src/test/java/mvd/jester/tests/TestMaiaBertogna.java diff --git a/src/main/java/mvd/jester/model/SystemSetup.java b/src/main/java/mvd/jester/model/SystemSetup.java index 9d344d6..ea8b6c9 100644 --- a/src/main/java/mvd/jester/model/SystemSetup.java +++ b/src/main/java/mvd/jester/model/SystemSetup.java @@ -102,7 +102,8 @@ public class SystemSetup { public static class Builder { private long numberOfProcessors = 4; private long minPeriod = 100; - private long maxPeriod = 1000; + private long maxSequentialPeriod = 1000; + private long maxParallelPeriod = 10000; private long minNumberOfSegments = 3; private long maxNumberOfSegments = 7; private long minNumberOfJobs = 2; @@ -115,11 +116,12 @@ public class SystemSetup { } - private long randomTaskPeriod(boolean serial) { - if (serial) - return ThreadLocalRandom.current().nextLong(minPeriod, maxPeriod); - else - return ThreadLocalRandom.current().nextLong(minPeriod, maxPeriod /* * 10 */); + private long randomSequentialTaskPeriod() { + return ThreadLocalRandom.current().nextLong(minPeriod, maxSequentialPeriod); + } + + private long randomParallelTaskPeriod() { + return ThreadLocalRandom.current().nextLong(minPeriod, maxParallelPeriod); } private long randomTaskRatio(long min) { @@ -143,7 +145,7 @@ public class SystemSetup { private Task generateTask() { boolean serial = randomTaskRatio(0) > this.ratio; - long period = randomTaskPeriod(serial); + long period = serial ? randomSequentialTaskPeriod() : randomParallelTaskPeriod(); long numberOfSegments = serial ? 1 : randomNumberOfSegments(); long parallelNumberOfJobs = serial ? 1 : randomNumberOfJobs(); Set segments = new LinkedHashSet(); @@ -195,9 +197,11 @@ public class SystemSetup { return this; } - public Builder setPeriods(long minPeriod, long maxPeriod) { + public Builder setPeriods(long minPeriod, long maxSequentialPeriod, + long maxParallelPeriod) { this.minPeriod = minPeriod; - this.maxPeriod = maxPeriod; + this.maxSequentialPeriod = maxSequentialPeriod; + this.maxParallelPeriod = maxParallelPeriod; return this; } diff --git a/src/test/java/mvd/jester/model/TestSystemSetup.java b/src/test/java/mvd/jester/model/TestSystemSetup.java index f525d78..c39c803 100644 --- a/src/test/java/mvd/jester/model/TestSystemSetup.java +++ b/src/test/java/mvd/jester/model/TestSystemSetup.java @@ -15,7 +15,7 @@ public class TestSystemSetup { for (int i = 0; i < NUMBER_OF_SETS; ++i) { SystemSetup taskSet = new SystemSetup.Builder().setNumberOfSegments(1, 7) - .setNumberOfJobs(2, 10).setPeriods(100, 1000).build(); + .setNumberOfJobs(2, 10).setPeriods(100, 1000, 1000).build(); for (Task t : taskSet.getTasks()) { assertTrue(t.getPeriod() >= 100); diff --git a/src/test/java/mvd/jester/tests/TestMaiaBertogna.java b/src/test/java/mvd/jester/tests/TestMaiaBertogna.java new file mode 100644 index 0000000..50bf7b5 --- /dev/null +++ b/src/test/java/mvd/jester/tests/TestMaiaBertogna.java @@ -0,0 +1,18 @@ +package mvd.jester.tests; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import mvd.jester.model.SystemSetup; + +/** + * TestMaiaBertogna + */ +public class TestMaiaBertogna { + + @Test + @DisplayName("Check if the schedulability check returns the correct values.") + public void testRunSchedulabilityCheck() { + SystemSetup systemSetup = SystemSetup.readFromFile("/resources/Taskset1.txt", 0); + MaiaBertogna mb = new MaiaBertogna(systemSetup); + } +} -- libgit2 0.26.0