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
db00ddd1
authored
Feb 23, 2021
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed simulator
parent
da04ff1c
Show whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
1 additions
and
1734 deletions
+1
-1734
src/main/java/mvd/jester/App.java
+0
-3
src/main/java/mvd/jester/priority/DeadlineMonotonic.java
+0
-20
src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
+0
-21
src/main/java/mvd/jester/priority/PriorityManager.java
+0
-8
src/main/java/mvd/jester/priority/RateMonotonic.java
+0
-20
src/main/java/mvd/jester/simulator/AbstractSimulator.java
+0
-129
src/main/java/mvd/jester/simulator/DynamicForkJoin.java
+0
-37
src/main/java/mvd/jester/simulator/EventPrinter.java
+0
-28
src/main/java/mvd/jester/simulator/ParallelSynchronous.java
+0
-36
src/main/java/mvd/jester/simulator/SimulatorInterface.java
+0
-15
src/main/java/mvd/jester/simulator/internals/JobContextInterface.java
+0
-21
src/main/java/mvd/jester/simulator/internals/ProcessorContext.java
+0
-68
src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java
+0
-17
src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java
+0
-20
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
+0
-129
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
+0
-79
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
+0
-87
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
+0
-62
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
+0
-97
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
+0
-43
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
+0
-86
src/main/java/mvd/jester/tests/MelaniButtazzo.java
+0
-1
src/main/java/mvd/jester/tests/Tester.java
+0
-9
src/main/java/mvd/jester/tests/UeterAgrawal.java
+1
-1
src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
+0
-15
src/test/java/mvd/jester/priority/TestRateMonotonic.java
+0
-15
src/test/java/mvd/jester/simulator/TestProcessorContext.java
+0
-107
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
+0
-98
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
+0
-101
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
+0
-95
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
+0
-52
src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
+0
-61
src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
+0
-57
src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
+0
-96
No files found.
src/main/java/mvd/jester/App.java
View file @
db00ddd1
...
...
@@ -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
;
...
...
src/main/java/mvd/jester/priority/DeadlineMonotonic.java
View file @
db00ddd1
...
...
@@ -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
<
Class
<?
extends
AbstractTest
<?
extends
Task
>>>
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
.
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
<?
extends
Task
>
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
<?
extends
AbstractSimulator
>
abstractSimulatorClass
)
{
return
abstractSimulators
.
contains
(
abstractSimulatorClass
);
}
@Override
public
String
getName
()
{
return
"DM"
;
}
...
...
src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
View file @
db00ddd1
...
...
@@ -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
<
Class
<?
extends
AbstractTest
<?
extends
Task
>>>
abstractTests
=
new
HashSet
<>(
Arrays
.
asList
(
ChwaLee
.
class
));
final
static
Set
<
Class
<?
extends
AbstractSimulator
>>
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
<?
extends
Task
>
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
<?
extends
AbstractSimulator
>
abstractSimulatorClass
)
{
return
abstractSimulators
.
contains
(
abstractSimulatorClass
);
}
@Override
public
String
getName
()
{
return
"EDF"
;
}
...
...
src/main/java/mvd/jester/priority/PriorityManager.java
View file @
db00ddd1
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
<?
extends
Task
>
abstractTest
);
public
boolean
hasTest
(
Class
<?
extends
AbstractTest
<?
extends
Task
>>
abstractTestClass
);
public
boolean
hasSimulator
(
AbstractSimulator
abstractTest
);
public
boolean
hasSimulator
(
Class
<?
extends
AbstractSimulator
>
abstractTestClass
);
public
String
getName
();
}
src/main/java/mvd/jester/priority/RateMonotonic.java
View file @
db00ddd1
...
...
@@ -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
<
Class
<?
extends
AbstractTest
<?
extends
Task
>>>
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
.
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
<?
extends
Task
>
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
<?
extends
AbstractSimulator
>
abstractSimulatorClass
)
{
return
abstractSimulators
.
contains
(
abstractSimulatorClass
);
}
@Override
public
String
getName
()
{
return
"RM"
;
}
...
...
src/main/java/mvd/jester/simulator/AbstractSimulator.java
deleted
100644 → 0
View file @
da04ff1c
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
<
ProcessorContext
>
processors
;
protected
TreeMultiset
<
TaskContextInterface
>
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<ProcessorContext> sortedProcessors = sortProcessors(processors);
// for (ProcessorContext p : sortedProcessors) {
// for (TaskContextInterface tc : readyTasks) {
// if (p.acceptTask(tc, t)) {
// break;
// }
// }
// }
// for (ProcessorContext p : processors) {
// Optional<TaskContextInterface> 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
<
ProcessorContext
>
sortProcessors
(
Set
<
ProcessorContext
>
processors
)
{
Set
<
ProcessorContext
>
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
<
ProcessorContext
>
{
@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
());
}
}
}
}
}
src/main/java/mvd/jester/simulator/DynamicForkJoin.java
deleted
100644 → 0
View file @
da04ff1c
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"
;
}
}
src/main/java/mvd/jester/simulator/EventPrinter.java
deleted
100644 → 0
View file @
da04ff1c
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
);
}
}
}
src/main/java/mvd/jester/simulator/ParallelSynchronous.java
deleted
100644 → 0
View file @
da04ff1c
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"
;
}
}
src/main/java/mvd/jester/simulator/SimulatorInterface.java
deleted
100644 → 0
View file @
da04ff1c
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
();
}
src/main/java/mvd/jester/simulator/internals/JobContextInterface.java
deleted
100644 → 0
View file @
da04ff1c
package
mvd
.
jester
.
simulator
.
internals
;
import
java.util.Optional
;
/**
* JobContextInterface
*/
public
interface
JobContextInterface
{
public
Optional
<
TaskContextInterface
>
updateExecution
(
long
time
);
public
boolean
checkExecutionTime
();
public
void
setCurrentProcessor
(
ProcessorContext
processor
);
public
Optional
<
ProcessorContext
>
getCurrentProcessor
();
public
TaskContextInterface
getTaskContext
();
public
boolean
prepareJob
(
long
time
);
}
src/main/java/mvd/jester/simulator/internals/ProcessorContext.java
deleted
100644 → 0
View file @
da04ff1c
package
mvd
.
jester
.
simulator
.
internals
;
import
java.util.Optional
;
import
mvd.jester.simulator.EventPrinter
;
/**
* Processor
*/
public
class
ProcessorContext
{
private
Optional
<
JobContextInterface
>
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
<
JobContextInterface
>
getJob
()
{
return
currentJob
;
}
public
Optional
<
TaskContextInterface
>
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
<
JobContextInterface
>
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
;
}
}
src/main/java/mvd/jester/simulator/internals/SortedTaskContextSet.java
deleted
100644 → 0
View file @
da04ff1c
package
mvd
.
jester
.
simulator
.
internals
;
import
java.util.TreeSet
;
import
mvd.jester.priority.PriorityManager
;
/**
* SortedTaskContextSet
*/
public
class
SortedTaskContextSet
extends
TreeSet
<
TaskContextInterface
>
{
private
static
final
long
serialVersionUID
=
4808544133562675597L
;
public
SortedTaskContextSet
(
PriorityManager
priorityMananger
)
{
super
((
t1
,
t2
)
->
priorityMananger
.
compare
(
t1
,
t2
));
}
}
src/main/java/mvd/jester/simulator/internals/TaskContextInterface.java
deleted
100644 → 0
View file @
da04ff1c
package
mvd
.
jester
.
simulator
.
internals
;
import
java.util.Optional
;
import
mvd.jester.model.SynchronousTask
;
/**
* TaskContextInterface
*/
public
interface
TaskContextInterface
{
public
SynchronousTask
getTask
();
public
Optional
<
TaskContextInterface
>
acceptNotification
(
long
time
);
public
Optional
<
JobContextInterface
>
getNextJob
();
public
long
getDeadline
();
public
long
getReleaseTime
();
}
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
deleted
100644 → 0
View file @
da04ff1c
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 <Job>
*/
public
class
JobContext
implements
JobContextInterface
{
private
final
TaskContext
taskContext
;
private
final
SegmentContext
segmentContext
;
private
final
long
wcet
;
private
Optional
<
ProcessorContext
>
currentProcessor
;
private
Optional
<
TaskletContext
>
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
<
TaskContextInterface
>
updateExecution
(
long
time
)
{
boolean
jobIsIdle
=
true
;
if
(
currentTasklet
.
isPresent
())
{
jobIsIdle
=
currentTasklet
.
get
().
updateExecution
(
time
);
}
if
(
jobIsIdle
)
{
currentTasklet
=
segmentContext
.
getNextTasklet
();
Optional
<
TaskContextInterface
>
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
<
ProcessorContext
>
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
;
}
}
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
JobContextInterface
>
jobs
;
private
final
Set
<
TaskletContext
>
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
<
JobContextInterface
>
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
<
TaskletContext
>
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() + ")";
}
}
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
SegmentContext
>
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
<
TaskContextInterface
>
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
<
JobContextInterface
>
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
()
+
")"
;
}
}
src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
deleted
100644 → 0
View file @
da04ff1c
package
mvd
.
jester
.
simulator
.
internals
.
dynamicforkjoin
;
import
java.util.Optional
;
/**
* Tasklet
*/
public
class
TaskletContext
{
private
final
TaskContext
taskContext
;
private
Optional
<
JobContext
>
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
<
JobContext
>
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
+
")"
;
}
}
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
deleted
100644 → 0
View file @
da04ff1c
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 <Job>
*/
public
class
JobContext
implements
JobContextInterface
{
private
final
TaskContext
taskContext
;
private
final
SegmentContext
segmentContext
;
private
final
long
wcet
;
private
Optional
<
ProcessorContext
>
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
<
TaskContextInterface
>
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
<
ProcessorContext
>
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
;
}
}
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
JobContextInterface
>
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
<
JobContextInterface
>
getNextJob
()
{
return
jobs
.
stream
()
.
filter
(
j
->
!
j
.
getCurrentProcessor
().
isPresent
()
&&
j
.
checkExecutionTime
())
.
findFirst
();
}
@Override
public
String
toString
()
{
return
"(nJobs="
+
segment
.
getHeight
()
+
", jobWcet="
+
segment
.
getWidth
()
+
")"
;
}
}
src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
SegmentContext
>
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
<
TaskContextInterface
>
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
<
JobContextInterface
>
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
()
+
")"
;
}
}
src/main/java/mvd/jester/tests/MelaniButtazzo.java
View file @
db00ddd1
...
...
@@ -63,7 +63,6 @@ public class MelaniButtazzo extends AbstractTest<DagTask> {
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
;
...
...
src/main/java/mvd/jester/tests/Tester.java
View file @
db00ddd1
...
...
@@ -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
<
DagTask
>
{
...
...
src/main/java/mvd/jester/tests/UeterAgrawal.java
View file @
db00ddd1
...
...
@@ -101,7 +101,7 @@ public class UeterAgrawal extends AbstractTest<DagTask> {
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
;
...
...
src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
View file @
db00ddd1
...
...
@@ -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"
));
}
...
...
src/test/java/mvd/jester/priority/TestRateMonotonic.java
View file @
db00ddd1
...
...
@@ -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"
));
}
...
...
src/test/java/mvd/jester/simulator/TestProcessorContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
TaskContextInterface
>
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
();
}
}
}
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
deleted
100644 → 0
View file @
da04ff1c
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
();
}
}
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
deleted
100644 → 0
View file @
da04ff1c
// 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<JobContextInterface> 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<TaskletContext> 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<TaskletContext> 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());
// }
// }
// }
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
deleted
100644 → 0
View file @
da04ff1c
// 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<Segment> 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<TaskContextInterface> 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<Segment> 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<JobContextInterface> 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());
// }
// }
// }
src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
deleted
100644 → 0
View file @
da04ff1c
// 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));
// }
// }
// }
src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
deleted
100644 → 0
View file @
da04ff1c
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
<
TaskContextInterface
>
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
));
}
}
}
src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
deleted
100644 → 0
View file @
da04ff1c
// 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<JobContextInterface> 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());
// }
// }
// }
src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
deleted
100644 → 0
View file @
da04ff1c
// 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<Segment> 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<TaskContextInterface> 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<Segment> 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<JobContextInterface> 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());
// }
// }
// }
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment