Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
jester
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a9eacf10
authored
Mar 23, 2020
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed namespace and added a few tests
parent
4391562c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
564 additions
and
122 deletions
+564
-122
pom.xml
+17
-0
src/main/java/mvd/jester/App.java
+10
-22
src/main/java/mvd/jester/ResultCollector.java
+2
-2
src/main/java/mvd/jester/ResultLogger.java
+0
-0
src/main/java/mvd/jester/info/SchedulingInfo.java
+9
-3
src/main/java/mvd/jester/info/TerminationInfo.java
+28
-0
src/main/java/mvd/jester/model/SystemSetup.java
+2
-2
src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
+3
-3
src/main/java/mvd/jester/priority/RateMonotonic.java
+4
-4
src/main/java/mvd/jester/simulator/AbstractSimulator.java
+8
-9
src/main/java/mvd/jester/simulator/DynamicForkJoin.java
+3
-3
src/main/java/mvd/jester/simulator/ParallelSynchronous.java
+3
-3
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
+1
-1
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
+1
-2
src/main/java/mvd/jester/tests/AbstractTest.java
+0
-3
src/main/java/mvd/jester/tests/ChwaLee.java
+7
-4
src/main/java/mvd/jester/tests/MaiaBertogna.java
+7
-4
src/main/java/mvd/jester/tests/SchmidMottok.java
+7
-4
src/main/java/mvd/jester/utils/Logger.java
+2
-2
src/test/java/mvd/jester/TestResultCollector.java
+62
-0
src/test/java/mvd/jester/info/TestSchedulingInfo.java
+79
-0
src/test/java/mvd/jester/info/TestTerminationInfo.java
+40
-0
src/test/java/mvd/jester/model/TestSystemSetup.java
+53
-5
src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
+44
-6
src/test/java/mvd/jester/priority/TestRateMonotonic.java
+42
-5
src/test/java/mvd/jester/simulator/TestProcessorContext.java
+2
-2
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
+5
-5
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
+5
-5
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
+2
-2
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
+5
-5
src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
+4
-4
src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
+3
-3
src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
+2
-2
src/test/java/mvd/jester/tests/TestMaiaBertogna.java
+40
-2
src/test/java/mvd/jester/tests/TestSchmidMottok.java
+57
-0
No files found.
pom.xml
View file @
a9eacf10
...
...
@@ -15,6 +15,12 @@
</properties>
<dependencies>
<dependency>
<groupId>
net.sourceforge.cobertura
</groupId>
<artifactId>
cobertura
</artifactId>
<version>
2.1.1
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-math3
</artifactId>
...
...
@@ -56,6 +62,17 @@
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
cobertura-maven-plugin
</artifactId>
<version>
2.7
</version>
</plugin>
</plugins>
</reporting>
<build>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
...
...
src/main/java/mvd/jester/App.java
View file @
a9eacf10
...
...
@@ -11,30 +11,18 @@ import mvd.jester.priority.RateMonotonic;
*/
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
SystemSetup
.
Builder
builder
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
8
);
TestEnvironment
te
=
new
TestEnvironment
(
builder
,
40000
);
for
(
int
p
=
4
;
p
<=
16
;
p
*=
2
)
{
SystemSetup
.
Builder
builder
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
p
);
TestEnvironment
te
=
new
TestEnvironment
(
builder
,
40000
);
te
.
registerSchedulingAlgorithm
(
new
RateMonotonic
());
te
.
registerSchedulingAlgorithm
(
new
EarliestDeadlineFirst
());
te
.
registerSchedulingAlgorithm
(
new
RateMonotonic
());
te
.
registerSchedulingAlgorithm
(
new
EarliestDeadlineFirst
());
te
.
registerTest
(
mvd
.
jester
.
tests
.
SchmidMottok
.
class
);
te
.
registerTest
(
mvd
.
jester
.
tests
.
MaiaBertogna
.
class
);
te
.
registerTest
(
mvd
.
jester
.
tests
.
ChwaLee
.
class
);
te
.
registerTest
(
mvd
.
jester
.
tests
.
SchmidMottok
.
class
);
te
.
registerTest
(
mvd
.
jester
.
tests
.
MaiaBertogna
.
class
);
te
.
registerTest
(
mvd
.
jester
.
tests
.
ChwaLee
.
class
);
te
.
registerSimulator
(
mvd
.
jester
.
simulator
.
MaiaBertogna
.
class
);
te
.
registerSimulator
(
mvd
.
jester
.
simulator
.
SchmidMottok
.
class
);
te
.
runExperiments
();
// SystemSetup setup = SystemSetup.readFromFile(
// "/home/mike/Promotion/projects/eclipse/jester/results/test_this.txt", 16);
// SchmidMottok sm = new SchmidMottok(setup);
// MaiaBertogna mb = new MaiaBertogna(setup);
// RateMonotonic rm = new RateMonotonic();
// sm.runSchedulabilityCheck(rm);
// mb.runSchedulabilityCheck(rm);
te
.
runExperiments
();
}
}
}
src/main/java/mvd/jester/ResultCollector.java
View file @
a9eacf10
...
...
@@ -39,8 +39,8 @@ public class ResultCollector<T extends TypeInterface>
}
public
void
addResult
(
SchedulingInfo
schedulingInfo
)
{
this
.
schedulingInfos
.
add
(
schedulingInfo
);
public
boolean
addResult
(
SchedulingInfo
schedulingInfo
)
{
return
this
.
schedulingInfos
.
add
(
schedulingInfo
);
}
public
Set
<
SchedulingInfo
>
getResults
()
{
...
...
src/main/java/mvd/jester/ResultLogger.java
View file @
a9eacf10
This diff is collapsed.
Click to expand it.
src/main/java/mvd/jester/info/SchedulingInfo.java
View file @
a9eacf10
...
...
@@ -3,9 +3,10 @@ package mvd.jester.info;
import
java.util.HashSet
;
import
java.util.Optional
;
import
java.util.Set
;
import
mvd.jester.info.TerminationInfo.Level
;
/**
*
DeadlineMiss
Info
*
Scheduling
Info
*/
public
class
SchedulingInfo
{
...
...
@@ -44,13 +45,18 @@ public class SchedulingInfo {
terminationInfos
.
stream
().
filter
(
t
->
t
.
getLateness
()
>
0
).
findFirst
();
}
public
boolean
checkLevelFail
(
Level
level
)
{
return
terminationInfos
.
stream
()
.
anyMatch
(
t
->
t
.
getLateness
()
>
0
&&
t
.
getTaskLevel
()
==
level
);
}
public
boolean
checkTasksetFeasible
()
{
// return terminationInfos.isEmpty();
return
!
terminationInfos
.
stream
().
anyMatch
(
t
->
t
.
getLateness
()
>
0
);
}
public
void
addTerminationInfo
(
TerminationInfo
terminationInfo
)
{
terminationInfos
.
add
(
terminationInfo
);
public
boolean
addTerminationInfo
(
TerminationInfo
terminationInfo
)
{
return
terminationInfos
.
add
(
terminationInfo
);
}
/**
...
...
src/main/java/mvd/jester/info/TerminationInfo.java
View file @
a9eacf10
...
...
@@ -9,14 +9,31 @@ public class TerminationInfo {
private
final
long
deadline
;
private
final
long
responseTime
;
private
final
long
lateness
;
private
final
Level
taskLevel
;
public
TerminationInfo
(
long
releaseTime
,
long
deadline
,
long
responseTime
)
{
this
.
releaseTime
=
releaseTime
;
this
.
deadline
=
deadline
;
this
.
responseTime
=
responseTime
;
this
.
lateness
=
responseTime
-
deadline
;
this
.
taskLevel
=
Level
.
LOW
;
}
public
TerminationInfo
(
long
releaseTime
,
long
deadline
,
long
responseTime
,
Level
taskLevel
)
{
this
.
releaseTime
=
releaseTime
;
this
.
deadline
=
deadline
;
this
.
responseTime
=
responseTime
;
this
.
lateness
=
responseTime
-
deadline
;
this
.
taskLevel
=
taskLevel
;
}
public
TerminationInfo
(
long
deadline
,
long
responseTime
,
Level
taskLevel
)
{
this
.
releaseTime
=
0
;
this
.
deadline
=
deadline
;
this
.
responseTime
=
responseTime
;
this
.
lateness
=
responseTime
-
deadline
;
this
.
taskLevel
=
taskLevel
;
}
/**
* @return the deadline
...
...
@@ -45,4 +62,15 @@ public class TerminationInfo {
public
long
getResponseTime
()
{
return
responseTime
;
}
/**
* @return the taskLevel
*/
public
Level
getTaskLevel
()
{
return
taskLevel
;
}
public
enum
Level
{
HIGH
,
LOW
}
}
src/main/java/mvd/jester/model/SystemSetup.java
View file @
a9eacf10
...
...
@@ -180,8 +180,8 @@ public class SystemSetup {
systemSetup
.
tasks
=
generateTaskSet
();
}
public
void
addTask
(
SystemSetup
systemSetup
)
{
systemSetup
.
tasks
.
add
(
generateTask
());
public
boolean
addTask
(
SystemSetup
systemSetup
)
{
return
systemSetup
.
tasks
.
add
(
generateTask
());
}
public
Builder
setNumberOfProcessors
(
long
numberOfProcessors
)
{
...
...
src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
View file @
a9eacf10
...
...
@@ -5,8 +5,8 @@ import java.util.HashSet;
import
java.util.Set
;
import
mvd.jester.model.Task
;
import
mvd.jester.simulator.AbstractSimulator
;
import
mvd.jester.simulator.
MaiaBertogna
;
import
mvd.jester.simulator.
SchmidMottok
;
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
;
...
...
@@ -19,7 +19,7 @@ public class EarliestDeadlineFirst implements PriorityManager {
final
static
Set
<
Class
<?
extends
AbstractTest
>>
abstractTests
=
new
HashSet
<>(
Arrays
.
asList
(
ChwaLee
.
class
));
final
static
Set
<
Class
<?
extends
AbstractSimulator
>>
abstractSimulators
=
new
HashSet
<>(
Arrays
.
asList
(
MaiaBertogna
.
class
,
SchmidMottok
.
class
));
new
HashSet
<>(
Arrays
.
asList
(
ParallelSynchronous
.
class
,
DynamicForkJoin
.
class
));
/**
* Compare the priority of two tasks according to the Rate Monotonic policy
...
...
src/main/java/mvd/jester/priority/RateMonotonic.java
View file @
a9eacf10
...
...
@@ -13,16 +13,16 @@ public class RateMonotonic implements PriorityManager {
final
static
Set
<
Class
<?
extends
AbstractTest
>>
abstractTests
=
new
HashSet
<>(
Arrays
.
asList
(
mvd
.
jester
.
tests
.
MaiaBertogna
.
class
,
mvd
.
jester
.
tests
.
SchmidMottok
.
class
));
final
static
Set
<
Class
<?
extends
AbstractSimulator
>>
abstractSimulators
=
new
HashSet
<>(
Arrays
.
asList
(
mvd
.
jester
.
simulator
.
MaiaBertogna
.
class
,
mvd
.
jester
.
simulator
.
SchmidMottok
.
class
));
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
*
* @param t1 The first task
* @param t2 The second task
* @return 0 if both tasks have the same priority,
posi
tive number if the first task has a
* higher priority,
nega
tive number if the second task has a higher priority
* @return 0 if both tasks have the same priority,
nega
tive number if the first task has a
* higher priority,
posi
tive number if the second task has a higher priority
*/
@Override
public
int
compare
(
Task
t1
,
Task
t2
)
{
...
...
src/main/java/mvd/jester/simulator/AbstractSimulator.java
View file @
a9eacf10
...
...
@@ -25,7 +25,6 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
protected
final
SystemSetup
systemSetup
;
protected
final
Set
<
ProcessorContext
>
processors
;
protected
TreeMultiset
<
TaskContextInterface
>
readyTasks
;
protected
long
hyperPeriod
;
AbstractSimulator
(
SystemSetup
systemSetup
)
{
this
.
systemSetup
=
systemSetup
;
...
...
@@ -34,8 +33,6 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
for
(
int
i
=
0
;
i
<
systemSetup
.
getNumberOfProcessors
();
++
i
)
{
processors
.
add
(
new
ProcessorContext
(
i
));
}
this
.
hyperPeriod
=
getHyperPeriod
();
}
...
...
@@ -45,7 +42,7 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
public
SchedulingInfo
runSimulation
(
PriorityManager
priorityManager
)
{
SchedulingInfo
schedulingInfo
=
new
SchedulingInfo
(
systemSetup
.
getParallelTaskRatio
(),
systemSetup
.
getUtilization
());
init
(
priorityManager
);
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!"
);
...
...
@@ -66,10 +63,12 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
Optional
<
TaskContextInterface
>
optionalTc
=
p
.
updateExecution
(
t
);
if
(
optionalTc
.
isPresent
())
{
TaskContextInterface
tc
=
optionalTc
.
get
();
TerminationInfo
terminationInfo
=
new
TerminationInfo
(
tc
.
getReleaseTime
(),
tc
.
getDeadline
(),
t
);
schedulingInfo
.
addTerminationInfo
(
terminationInfo
);
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
;
...
...
@@ -83,12 +82,12 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
return
schedulingInfo
;
}
private
void
init
(
PriorityManager
priorityManager
)
{
private
long
init
(
PriorityManager
priorityManager
)
{
this
.
readyTasks
=
TreeMultiset
.
create
((
t1
,
t2
)
->
priorityManager
.
compare
(
t1
,
t2
));
for
(
ProcessorContext
p
:
processors
)
{
p
.
setJob
(
null
);
}
this
.
hyperPeriod
=
getHyperPeriod
();
return
getHyperPeriod
();
}
private
Set
<
ProcessorContext
>
sortProcessors
(
Set
<
ProcessorContext
>
processors
)
{
...
...
src/main/java/mvd/jester/simulator/
SchmidMottok
.java
→
src/main/java/mvd/jester/simulator/
DynamicForkJoin
.java
View file @
a9eacf10
...
...
@@ -3,14 +3,14 @@ package mvd.jester.simulator;
import
mvd.jester.model.SystemSetup
;
import
mvd.jester.model.Task
;
import
mvd.jester.simulator.internals.
schmidmottok
.TaskContext
;
import
mvd.jester.simulator.internals.
dynamicforkjoin
.TaskContext
;
/**
* SchmidMottok
*/
public
class
SchmidMottok
extends
AbstractSimulator
{
public
class
DynamicForkJoin
extends
AbstractSimulator
{
public
SchmidMottok
(
SystemSetup
systemSetup
)
{
public
DynamicForkJoin
(
SystemSetup
systemSetup
)
{
super
(
systemSetup
);
}
...
...
src/main/java/mvd/jester/simulator/
MaiaBertogna
.java
→
src/main/java/mvd/jester/simulator/
ParallelSynchronous
.java
View file @
a9eacf10
...
...
@@ -2,14 +2,14 @@ package mvd.jester.simulator;
import
mvd.jester.model.SystemSetup
;
import
mvd.jester.model.Task
;
import
mvd.jester.simulator.internals.
maiabertogna
.TaskContext
;
import
mvd.jester.simulator.internals.
parallelsynchronous
.TaskContext
;
/**
* MaiaBertogna
*/
public
class
MaiaBertogna
extends
AbstractSimulator
{
public
class
ParallelSynchronous
extends
AbstractSimulator
{
public
MaiaBertogna
(
SystemSetup
systemSetup
)
{
public
ParallelSynchronous
(
SystemSetup
systemSetup
)
{
super
(
systemSetup
);
}
...
...
src/main/java/mvd/jester/simulator/internals/
schmidmottok
/JobContext.java
→
src/main/java/mvd/jester/simulator/internals/
dynamicforkjoin
/JobContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
package
mvd
.
jester
.
simulator
.
internals
.
dynamicforkjoin
;
import
java.util.Optional
;
import
mvd.jester.simulator.EventPrinter
;
...
...
src/main/java/mvd/jester/simulator/internals/
schmidmottok
/SegmentContext.java
→
src/main/java/mvd/jester/simulator/internals/
dynamicforkjoin
/SegmentContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
package
mvd
.
jester
.
simulator
.
internals
.
dynamicforkjoin
;
import
java.util.HashSet
;
import
java.util.Optional
;
...
...
src/main/java/mvd/jester/simulator/internals/
schmidmottok
/TaskContext.java
→
src/main/java/mvd/jester/simulator/internals/
dynamicforkjoin
/TaskContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
package
mvd
.
jester
.
simulator
.
internals
.
dynamicforkjoin
;
import
java.util.ArrayList
;
import
java.util.Optional
;
...
...
src/main/java/mvd/jester/simulator/internals/
schmidmottok
/TaskletContext.java
→
src/main/java/mvd/jester/simulator/internals/
dynamicforkjoin
/TaskletContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
package
mvd
.
jester
.
simulator
.
internals
.
dynamicforkjoin
;
import
java.util.Optional
;
...
...
src/main/java/mvd/jester/simulator/internals/
maiabertogna
/JobContext.java
→
src/main/java/mvd/jester/simulator/internals/
parallelsynchronous
/JobContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
maiabertogna
;
package
mvd
.
jester
.
simulator
.
internals
.
parallelsynchronous
;
import
java.util.Optional
;
import
mvd.jester.simulator.EventPrinter
;
...
...
src/main/java/mvd/jester/simulator/internals/
maiabertogna
/SegmentContext.java
→
src/main/java/mvd/jester/simulator/internals/
parallelsynchronous
/SegmentContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
maiabertogna
;
package
mvd
.
jester
.
simulator
.
internals
.
parallelsynchronous
;
import
java.util.HashSet
;
import
java.util.Optional
;
...
...
src/main/java/mvd/jester/simulator/internals/
maiabertogna
/TaskContext.java
→
src/main/java/mvd/jester/simulator/internals/
parallelsynchronous
/TaskContext.java
View file @
a9eacf10
package
mvd
.
jester
.
simulator
.
internals
.
maiabertogna
;
package
mvd
.
jester
.
simulator
.
internals
.
parallelsynchronous
;
import
java.util.ArrayList
;
import
java.util.Optional
;
...
...
@@ -20,7 +20,6 @@ public class TaskContext implements TaskContextInterface {
private
int
currentSegment
;
private
int
segmentCounter
;
public
TaskContext
(
Task
task
,
long
releaseTime
)
{
this
.
task
=
task
;
this
.
segments
=
new
ArrayList
<>();
...
...
src/main/java/mvd/jester/tests/AbstractTest.java
View file @
a9eacf10
...
...
@@ -2,7 +2,6 @@ package mvd.jester.tests;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
mvd.jester.TypeInterface
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.model.SystemSetup
;
...
...
@@ -15,12 +14,10 @@ public abstract class AbstractTest implements TestInterface, TypeInterface {
protected
final
Map
<
Task
,
TerminationInfo
>
responseTimes
;
protected
final
SystemSetup
systemSetup
;
protected
Set
<
Task
>
tasks
;
public
AbstractTest
(
SystemSetup
systemSetup
)
{
this
.
systemSetup
=
systemSetup
;
this
.
responseTimes
=
new
HashMap
<>();
this
.
tasks
=
systemSetup
.
getTasks
();
}
}
src/main/java/mvd/jester/tests/ChwaLee.java
View file @
a9eacf10
...
...
@@ -5,9 +5,11 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
com.google.common.math.LongMath
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.info.TerminationInfo.Level
;
import
mvd.jester.model.Segment
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SystemSetup
;
...
...
@@ -25,19 +27,20 @@ public class ChwaLee extends AbstractTest {
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
PriorityManager
priorityManager
)
{
tasks
=
new
SortedTaskSet
(
priorityManager
);
SortedTaskSet
tasks
=
new
SortedTaskSet
(
priorityManager
);
tasks
.
addAll
(
systemSetup
.
getTasks
());
responseTimes
.
clear
();
for
(
Task
t
:
tasks
)
{
long
responseTime
=
calculateResponseTime
(
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
0
,
t
.
getDeadline
(),
responseTime
));
Level
taskLevel
=
tasks
.
headSet
(
t
).
size
()
<=
tasks
.
size
()
/
2
?
Level
.
HIGH
:
Level
.
LOW
;
long
responseTime
=
calculateResponseTime
(
tasks
,
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
t
.
getDeadline
(),
responseTime
,
taskLevel
));
}
return
new
SchedulingInfo
(
new
HashSet
<>(
responseTimes
.
values
()),
systemSetup
.
getParallelTaskRatio
(),
systemSetup
.
getUtilization
());
}
private
long
calculateResponseTime
(
Task
task
)
{
private
long
calculateResponseTime
(
Set
<
Task
>
tasks
,
Task
task
)
{
long
minimumWcet
=
getMinimumWcet
(
task
);
long
deadline
=
task
.
getDeadline
();
long
numberOfProcessors
=
systemSetup
.
getNumberOfProcessors
();
...
...
src/main/java/mvd/jester/tests/MaiaBertogna.java
View file @
a9eacf10
...
...
@@ -2,9 +2,11 @@ package mvd.jester.tests;
import
java.math.RoundingMode
;
import
java.util.HashSet
;
import
java.util.Set
;
import
com.google.common.math.LongMath
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.info.TerminationInfo.Level
;
import
mvd.jester.model.Segment
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.Task
;
...
...
@@ -22,12 +24,13 @@ public class MaiaBertogna extends AbstractTest {
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
PriorityManager
priorityManager
)
{
tasks
=
new
SortedTaskSet
(
priorityManager
);
SortedTaskSet
tasks
=
new
SortedTaskSet
(
priorityManager
);
tasks
.
addAll
(
systemSetup
.
getTasks
());
responseTimes
.
clear
();
for
(
Task
t
:
tasks
)
{
long
responseTime
=
calculateResponseTime
(
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
0
,
t
.
getDeadline
(),
responseTime
));
Level
taskLevel
=
tasks
.
headSet
(
t
).
size
()
<=
tasks
.
size
()
/
2
?
Level
.
HIGH
:
Level
.
LOW
;
long
responseTime
=
calculateResponseTime
(
tasks
,
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
t
.
getDeadline
(),
responseTime
,
taskLevel
));
}
return
new
SchedulingInfo
(
new
HashSet
<>(
responseTimes
.
values
()),
...
...
@@ -39,7 +42,7 @@ public class MaiaBertogna extends AbstractTest {
return
"MaiaBertogna"
;
}
private
long
calculateResponseTime
(
Task
task
)
{
private
long
calculateResponseTime
(
Set
<
Task
>
tasks
,
Task
task
)
{
long
minimumWcet
=
getMinimumWcet
(
task
);
long
responseTime
=
minimumWcet
;
long
previousResponseTime
=
0
;
...
...
src/main/java/mvd/jester/tests/SchmidMottok.java
View file @
a9eacf10
...
...
@@ -2,9 +2,11 @@ package mvd.jester.tests;
import
java.math.RoundingMode
;
import
java.util.HashSet
;
import
java.util.Set
;
import
com.google.common.math.LongMath
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.info.TerminationInfo.Level
;
import
mvd.jester.model.Segment
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.Task
;
...
...
@@ -22,12 +24,13 @@ public class SchmidMottok extends AbstractTest {
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
PriorityManager
priorityManager
)
{
tasks
=
new
SortedTaskSet
(
priorityManager
);
SortedTaskSet
tasks
=
new
SortedTaskSet
(
priorityManager
);
tasks
.
addAll
(
systemSetup
.
getTasks
());
responseTimes
.
clear
();
for
(
Task
t
:
tasks
)
{
long
responseTime
=
calculateResponseTime
(
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
0
,
t
.
getDeadline
(),
responseTime
));
Level
taskLevel
=
tasks
.
headSet
(
t
).
size
()
<=
tasks
.
size
()
/
2
?
Level
.
HIGH
:
Level
.
LOW
;
long
responseTime
=
calculateResponseTime
(
tasks
,
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
t
.
getDeadline
(),
responseTime
,
taskLevel
));
}
return
new
SchedulingInfo
(
new
HashSet
<>(
responseTimes
.
values
()),
...
...
@@ -39,7 +42,7 @@ public class SchmidMottok extends AbstractTest {
return
"SchmidMottok"
;
}
private
long
calculateResponseTime
(
Task
task
)
{
private
long
calculateResponseTime
(
Set
<
Task
>
tasks
,
Task
task
)
{
long
minimumWcet
=
getMinimumWcet
(
task
);
long
responseTime
=
minimumWcet
;
long
previousResponseTime
=
0
;
...
...
src/main/java/mvd/jester/utils/Logger.java
View file @
a9eacf10
...
...
@@ -31,10 +31,10 @@ public class Logger {
public
void
finalize
()
{
try
{
if
(
printWriter
!=
null
)
{
printWriter
.
close
();
// Will close bw and fw too
printWriter
.
close
();
}
if
(
bufferedWriter
!=
null
)
{
bufferedWriter
.
close
();
// Will close fw too
bufferedWriter
.
close
();
}
if
(
fileWriter
!=
null
)
{
fileWriter
.
close
();
...
...
src/test/java/mvd/jester/TestResultCollector.java
0 → 100644
View file @
a9eacf10
package
mvd
.
jester
;
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.HashSet
;
import
java.util.Set
;
import
java.util.concurrent.ThreadLocalRandom
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.priority.PriorityManager
;
/**
* TestResultCollector
*/
public
class
TestResultCollector
{
@Test
@DisplayName
(
"Test if getters and setters work correctly."
)
void
testGettersAndSetters
()
{
final
PriorityManager
pm
=
mock
(
PriorityManager
.
class
);
final
String
pmName
=
"PriorityManagerName"
;
when
(
pm
.
getName
()).
thenReturn
(
pmName
);
final
TypeInterface
ti
=
mock
(
TypeInterface
.
class
);
final
String
tiName
=
"TypeInterfaceName"
;
when
(
ti
.
getName
()).
thenReturn
(
tiName
);
final
ResultCollector
<
TypeInterface
>
rc1
=
new
ResultCollector
<>(
pm
,
ti
);
final
ResultCollector
<
TypeInterface
>
rc2
=
new
ResultCollector
<>(
pm
,
ti
);
assertTrue
(
rc1
.
getPriorityManager
()
==
pm
);
assertTrue
(
rc1
.
getAbstractValue
()
==
ti
);
assertTrue
(
rc1
.
getName
().
equals
(
tiName
+
"_"
+
pmName
));
assertTrue
(
rc1
.
compareTo
(
rc2
)
==
0
);
}
@Test
@DisplayName
(
"Check if adding SchedulingInfos works correctly."
)
void
testSchedulingInfos
()
{
final
TypeInterface
ti
=
mock
(
TypeInterface
.
class
);
final
PriorityManager
pm
=
mock
(
PriorityManager
.
class
);
final
ResultCollector
<
TypeInterface
>
rc
=
new
ResultCollector
<>(
pm
,
ti
);
final
Set
<
SchedulingInfo
>
schedulingInfos
=
new
HashSet
<>();
long
numberOfSchedulingInfos
=
ThreadLocalRandom
.
current
().
nextLong
(
5
,
10
);
for
(
int
i
=
0
;
i
<
numberOfSchedulingInfos
;
++
i
)
{
SchedulingInfo
si
=
mock
(
SchedulingInfo
.
class
);
schedulingInfos
.
add
(
si
);
assertTrue
(
rc
.
addResult
(
si
));
assertFalse
(
rc
.
addResult
(
si
));
}
assertTrue
(
rc
.
getResults
().
size
()
==
numberOfSchedulingInfos
);
assertTrue
(
rc
.
getResults
().
equals
(
schedulingInfos
));
assertTrue
(
rc
.
addResult
(
null
));
}
}
src/test/java/mvd/jester/info/TestSchedulingInfo.java
0 → 100644
View file @
a9eacf10
package
mvd
.
jester
.
info
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.concurrent.ThreadLocalRandom
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
mvd.jester.info.TerminationInfo.Level
;
/**
* TestTerminationInfo
*/
public
class
TestSchedulingInfo
{
@Test
@DisplayName
(
"Check if SchedulingInfos parameters are calculated correctly."
)
public
void
testSchedulingInfo
()
{
for
(
int
run
=
0
;
run
<
1000
;
++
run
)
{
Set
<
TerminationInfo
>
terminationInfos
=
new
HashSet
<>();
int
numberOfTerminationInfos
=
ThreadLocalRandom
.
current
().
nextInt
(
5
,
10
);
boolean
feasibile
=
true
;
boolean
levelFailed
=
false
;
for
(
int
i
=
0
;
i
<
numberOfTerminationInfos
;
++
i
)
{
long
deadline
=
ThreadLocalRandom
.
current
().
nextLong
(
50
,
100
);
long
responseTime
=
ThreadLocalRandom
.
current
().
nextLong
(
50
,
100
);
Level
taskLevel
=
ThreadLocalRandom
.
current
().
nextLong
(
0
,
100
)
<
50
?
Level
.
LOW
:
Level
.
HIGH
;
terminationInfos
.
add
(
new
TerminationInfo
(
deadline
,
responseTime
,
taskLevel
));
if
(
deadline
<
responseTime
)
{
feasibile
=
false
;
if
(
taskLevel
==
Level
.
HIGH
)
{
levelFailed
=
true
;
}
}
}
SchedulingInfo
schedulingInfo
=
new
SchedulingInfo
(
terminationInfos
,
2
,
numberOfTerminationInfos
);
assertTrue
(
schedulingInfo
.
checkLevelFail
(
Level
.
HIGH
)
==
levelFailed
);
assertTrue
(
schedulingInfo
.
checkTasksetFeasible
()
==
feasibile
);
}
}
@Test
@DisplayName
(
"Check Getters and Setters."
)
public
void
testGettersAndSetters
()
{
double
taskRatio
=
0.23
;
double
utilization
=
0.49
;
SchedulingInfo
si
=
new
SchedulingInfo
(
taskRatio
,
utilization
);
Set
<
TerminationInfo
>
terminationInfos
=
new
HashSet
<>();
long
numberOfTerminationInfos
=
ThreadLocalRandom
.
current
().
nextLong
(
5
,
10
);
for
(
int
i
=
0
;
i
<
numberOfTerminationInfos
;
++
i
)
{
TerminationInfo
ti
=
mock
(
TerminationInfo
.
class
);
terminationInfos
.
add
(
ti
);
assertTrue
(
si
.
addTerminationInfo
(
ti
));
assertFalse
(
si
.
addTerminationInfo
(
ti
));
}
assertTrue
(
si
.
getParallelTaskRatio
()
==
taskRatio
);
assertTrue
(
si
.
getUtilization
()
==
utilization
);
assertTrue
(
si
.
getTerminationInfos
().
size
()
==
numberOfTerminationInfos
);
assertTrue
(
si
.
getTerminationInfos
().
equals
(
terminationInfos
));
assertTrue
(
si
.
addTerminationInfo
(
null
));
assertFalse
(
si
.
getFailedTerminationInfo
().
isPresent
());
TerminationInfo
ti
=
mock
(
TerminationInfo
.
class
);
si
.
setFailedTerminationInfo
(
ti
);
assertTrue
(
si
.
getFailedTerminationInfo
().
isPresent
());
assertTrue
(
si
.
getFailedTerminationInfo
().
get
().
equals
(
ti
));
}
}
src/test/java/mvd/jester/info/TestTerminationInfo.java
0 → 100644
View file @
a9eacf10
package
mvd
.
jester
.
info
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
mvd.jester.info.TerminationInfo.Level
;
/**
* TestTerminationInfo
*/
public
class
TestTerminationInfo
{
@Test
@DisplayName
(
"Check Getters and Setters"
)
public
void
testGettersAndSetters
()
{
long
releaseTime
=
20
;
long
deadline
=
40
;
long
responseTime
=
30
;
Level
taskLevel
=
Level
.
LOW
;
TerminationInfo
ti
=
new
TerminationInfo
(
releaseTime
,
deadline
,
responseTime
);
TerminationInfo
til
=
new
TerminationInfo
(
deadline
,
responseTime
,
taskLevel
);
TerminationInfo
tirl
=
new
TerminationInfo
(
releaseTime
,
deadline
,
responseTime
,
taskLevel
);
assertTrue
(
ti
.
getDeadline
()
==
deadline
);
assertTrue
(
til
.
getDeadline
()
==
deadline
);
assertTrue
(
tirl
.
getDeadline
()
==
deadline
);
assertTrue
(
ti
.
getResponseTime
()
==
responseTime
);
assertTrue
(
til
.
getResponseTime
()
==
responseTime
);
assertTrue
(
tirl
.
getResponseTime
()
==
responseTime
);
assertTrue
(
ti
.
getReleaseTime
()
==
releaseTime
);
assertTrue
(
tirl
.
getReleaseTime
()
==
releaseTime
);
assertTrue
(
til
.
getTaskLevel
()
==
taskLevel
);
assertTrue
(
tirl
.
getTaskLevel
()
==
taskLevel
);
assertTrue
(
ti
.
getLateness
()
==
responseTime
-
deadline
);
assertTrue
(
til
.
getLateness
()
==
responseTime
-
deadline
);
assertTrue
(
tirl
.
getLateness
()
==
responseTime
-
deadline
);
}
}
src/test/java/mvd/jester/model/TestSystemSetup.java
View file @
a9eacf10
package
mvd
.
jester
.
model
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
java.io.IOException
;
import
java.util.Set
;
import
java.util.concurrent.ThreadLocalRandom
;