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
9ea90201
authored
Sep 04, 2019
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model seems to finally work, need to verify
parent
7999313d
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
192 additions
and
57 deletions
+192
-57
src/main/java/mvd/jester/App.java
+36
-23
src/main/java/mvd/jester/model/Segment.java
+7
-2
src/main/java/mvd/jester/priority/EarliestDeadineFirst.java
+0
-0
src/main/java/mvd/jester/simulator/AbstractSimulator.java
+31
-4
src/main/java/mvd/jester/simulator/EventPrinter.java
+28
-0
src/main/java/mvd/jester/simulator/MaiaBertogna.java
+5
-1
src/main/java/mvd/jester/simulator/SchmidMottok.java
+4
-2
src/main/java/mvd/jester/simulator/internals/JobContextInterface.java
+2
-0
src/main/java/mvd/jester/simulator/internals/ProcessorContext.java
+6
-3
src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java
+7
-1
src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java
+2
-1
src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java
+35
-10
src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java
+17
-3
src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java
+4
-3
src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java
+8
-4
No files found.
src/main/java/mvd/jester/App.java
View file @
9ea90201
package
mvd
.
jester
;
import
java.io.PrintWriter
;
import
mvd.jester.model.SystemSetup
;
import
mvd.jester.simulator.EventPrinter
;
import
mvd.jester.simulator.MaiaBertogna
;
import
mvd.jester.simulator.SchmidMottok
;
...
...
@@ -10,43 +12,54 @@ import mvd.jester.simulator.SchmidMottok;
*/
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
//
SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment(builder, 4
00);
SystemSetup
.
Builder
builder
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
8
);
TestEnvironment
te
=
new
TestEnvironment
(
builder
,
400
00
);
//
te.registerTestPair(mvd.jester.tests.MaiaBertogna.class,
//
mvd.jester.simulator.MaiaBertogna.class);
te
.
registerTestPair
(
mvd
.
jester
.
tests
.
MaiaBertogna
.
class
,
mvd
.
jester
.
simulator
.
MaiaBertogna
.
class
);
//
te.registerTestPair(mvd.jester.tests.SchmidMottok.class,
//
mvd.jester.simulator.SchmidMottok.class);
te
.
registerTestPair
(
mvd
.
jester
.
tests
.
SchmidMottok
.
class
,
mvd
.
jester
.
simulator
.
SchmidMottok
.
class
);
//
te.runTests();
te
.
runTests
();
boolean
mbWorked
=
false
;
boolean
smWorked
=
false
;
//
boolean mbWorked = false;
//
boolean smWorked = false;
SystemSetup
thisOne
=
null
;
// SystemSetup thisOne = null;
// EventPrinter.enablePrinter();
do
{
SystemSetup
.
Builder
builder
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
8
);
SystemSetup
systemSetup
=
builder
.
build
();
// do {
// SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
// SystemSetup systemSetup = builder.build();
// SchmidMottok sm = new SchmidMottok(systemSetup);
// MaiaBertogna mb = new MaiaBertogna(systemSetup);
SchmidMottok
sm
=
new
SchmidMottok
(
systemSetup
);
MaiaBertogna
mb
=
new
MaiaBertogna
(
systemSetup
);
// smWorked = sm.runSimulation();
// mbWorked = mb.runSimulation();
smWorked
=
sm
.
runSimulation
();
mbWorked
=
mb
.
runSimulation
();
// thisOne = systemSetup;
// } while (smWorked == mbWorked);
thisOne
=
systemSetup
;
}
while
(
smWorked
==
mbWorked
);
// try (PrintWriter out = new PrintWriter("./results/manCheck.txt")) {
// out.println(thisOne);
// } catch (Exception e) {
// System.out.println("Ähm something went horribly wrong!");
// }
// SchmidMottok sm = new SchmidMottok(thisOne);
// MaiaBertogna mb = new MaiaBertogna(thisOne);
SchmidMottok
sm
=
new
SchmidMottok
(
thisOne
);
MaiaBertogna
mb
=
new
MaiaBertogna
(
thisOne
);
// mb.runSimulation(
);
// sm.runSimulation(
);
mb
.
runSimulation
();
sm
.
runSimulation
();
// SystemSetup systemSetup = SystemSetup.fromFile("results/manCheck.txt");
// EventPrinter.enablePrinter();
// SchmidMottok sm = new SchmidMottok(systemSetup);
// sm.runSimulation();
}
}
src/main/java/mvd/jester/model/Segment.java
View file @
9ea90201
package
mvd
.
jester
.
model
;
import
com.google.common.math.LongMath
;
// import com.google.common.math.LongMath;
public
class
Segment
{
...
...
@@ -15,14 +17,17 @@ public class Segment {
if
(
numberOfJobs
==
1
)
{
this
.
taskletWcet
=
this
.
jobWcet
;
this
.
numberOfTasklets
=
this
.
numberOfJobs
;
}
else
if
(
this
.
numberOfJobs
>
this
.
jobWcet
)
{
this
.
taskletWcet
=
LongMath
.
gcd
(
jobWcet
,
numberOfJobs
);
this
.
numberOfTasklets
=
this
.
jobWcet
*
this
.
numberOfJobs
/
this
.
taskletWcet
;
}
else
{
// this.taskletWcet = LongMath.gcd(jobWcet, numberOfJobs);
// this.numberOfTasklets = this.jobWcet * this.numberOfJobs / this.taskletWcet;
this
.
taskletWcet
=
numberOfJobs
;
this
.
numberOfTasklets
=
jobWcet
;
}
}
/**
* @return the numberOfJobs
*/
...
...
src/main/java/mvd/jester/priority/EarliestDeadineFirst.java
0 → 100644
View file @
9ea90201
src/main/java/mvd/jester/simulator/AbstractSimulator.java
View file @
9ea90201
package
mvd
.
jester
.
simulator
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.Optional
;
import
java.util.Set
;
...
...
@@ -42,11 +43,8 @@ public abstract class AbstractSimulator implements SimulatorInterface {
return
false
;
}
Set
<
ProcessorContext
>
sortedProcessors
=
new
TreeSet
<>((
p1
,
p2
)
->
(
int
)
(!
p1
.
getJob
().
isPresent
()
?
-
1
:
!
p2
.
getJob
().
isPresent
()
?
1
:
-
1
));
Set
<
ProcessorContext
>
sortedProcessors
=
sortProcessors
(
processors
);
processors
.
forEach
(
p
->
sortedProcessors
.
add
(
p
));
for
(
ProcessorContext
p
:
sortedProcessors
)
{
for
(
TaskContextInterface
tc
:
readyTasks
)
{
if
(
p
.
acceptTask
(
tc
,
t
))
{
...
...
@@ -61,6 +59,7 @@ public abstract class AbstractSimulator implements SimulatorInterface {
if
(
optionalTc
.
isPresent
())
{
TaskContextInterface
tc
=
optionalTc
.
get
();
if
(
t
>=
tc
.
getDeadline
())
{
EventPrinter
.
print
(
"Time "
+
t
+
": Task "
+
tc
+
" failed its deadline!"
);
return
false
;
}
readyTasks
.
remove
(
optionalTc
.
get
());
...
...
@@ -79,6 +78,34 @@ public abstract class AbstractSimulator implements SimulatorInterface {
this
.
hyperPeriod
=
systemSetup
.
getTasks
().
last
().
getPeriod
()
*
2
;
}
private
Set
<
ProcessorContext
>
sortProcessors
(
Set
<
ProcessorContext
>
processors
)
{
Set
<
ProcessorContext
>
sortedProcessors
=
new
TreeSet
<>(
new
ProcessorComparator
());
processors
.
forEach
(
p
->
sortedProcessors
.
add
(
p
));
return
sortedProcessors
;
}
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/EventPrinter.java
0 → 100644
View file @
9ea90201
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/MaiaBertogna.java
View file @
9ea90201
...
...
@@ -17,9 +17,13 @@ public class MaiaBertogna extends AbstractSimulator {
protected
boolean
releaseTasks
(
long
timeStep
)
{
for
(
Task
t
:
systemSetup
.
getTasks
())
{
if
(
timeStep
%
t
.
getPeriod
()
==
0
)
{
if
(!
readyTasks
.
add
(
new
TaskContext
(
t
,
timeStep
)))
{
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
;
...
...
src/main/java/mvd/jester/simulator/SchmidMottok.java
View file @
9ea90201
...
...
@@ -19,11 +19,13 @@ public class SchmidMottok extends AbstractSimulator {
protected
boolean
releaseTasks
(
long
timeStep
)
{
for
(
Task
t
:
systemSetup
.
getTasks
())
{
if
(
timeStep
%
t
.
getPeriod
()
==
0
)
{
TaskContext
tc
=
new
TaskContext
(
t
,
timeStep
);
TaskContext
tc
=
new
TaskContext
(
t
,
systemSetup
.
getNumberOfProcessors
(),
timeStep
);
if
(!
readyTasks
.
add
(
tc
))
{
EventPrinter
.
print
(
"Time "
+
timeStep
+
": Task "
+
tc
+
" could not be released!"
);
return
false
;
}
// System.out.println("Time " + timeStep + ": " + "Task " + tc + "activat
ed!");
EventPrinter
.
print
(
"Time "
+
timeStep
+
": Task "
+
tc
+
" releas
ed!"
);
}
}
return
true
;
...
...
src/main/java/mvd/jester/simulator/internals/JobContextInterface.java
View file @
9ea90201
...
...
@@ -16,4 +16,6 @@ public interface JobContextInterface {
public
Optional
<
ProcessorContext
>
getCurrentProcessor
();
public
TaskContextInterface
getTaskContext
();
public
boolean
prepareJob
(
long
time
);
}
src/main/java/mvd/jester/simulator/internals/ProcessorContext.java
View file @
9ea90201
package
mvd
.
jester
.
simulator
.
internals
;
import
java.util.Optional
;
import
mvd.jester.simulator.EventPrinter
;
/**
* Processor
...
...
@@ -41,17 +42,19 @@ public class ProcessorContext {
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
);
System
.
out
.
println
(
EventPrinter
.
print
(
"Time "
+
t
+
": "
+
this
+
" started job "
+
currentJob
.
get
()
+
"!"
);
return
true
;
}
else
{
return
false
;
}
}
return
false
;
...
...
src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java
View file @
9ea90201
package
mvd
.
jester
.
simulator
.
internals
.
maiabertogna
;
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
;
...
...
@@ -31,7 +32,7 @@ public class JobContext implements JobContextInterface {
executionTime
--;
if
(
executionTime
==
0
)
{
System
.
out
.
println
(
"Time "
+
time
+
": "
+
currentProcessor
.
get
()
EventPrinter
.
print
(
"Time "
+
time
+
": "
+
currentProcessor
.
get
()
+
" finished execution of job "
+
this
+
"!"
);
currentProcessor
.
get
().
setJob
(
null
);
currentProcessor
=
Optional
.
empty
();
...
...
@@ -86,4 +87,9 @@ public class JobContext implements JobContextInterface {
return
"(jobWcet="
+
wcet
+
", of task="
+
taskContext
+
")"
;
}
@Override
public
boolean
prepareJob
(
long
time
)
{
return
true
;
}
}
src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java
View file @
9ea90201
...
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.Optional
;
import
mvd.jester.model.Segment
;
import
mvd.jester.model.Task
;
import
mvd.jester.simulator.EventPrinter
;
import
mvd.jester.simulator.internals.JobContextInterface
;
import
mvd.jester.simulator.internals.TaskContextInterface
;
...
...
@@ -52,7 +53,7 @@ public class TaskContext implements TaskContextInterface {
currentSegment
++;
segmentCounter
=
0
;
if
(
currentSegment
>=
segments
.
size
())
{
System
.
out
.
println
(
"Time "
+
time
+
": Task "
+
this
+
"finished!"
);
EventPrinter
.
print
(
"Time "
+
time
+
": Task "
+
this
+
"finished!"
);
return
Optional
.
of
(
this
);
}
}
...
...
src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java
View file @
9ea90201
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
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
;
...
...
@@ -30,29 +31,36 @@ public class JobContext implements JobContextInterface {
}
public
Optional
<
TaskContextInterface
>
updateExecution
(
long
time
)
{
if
(!
currentTasklet
.
isPresent
())
{
currentTasklet
=
segmentContext
.
getNextTasklet
();
boolean
jobIsIdle
=
true
;
if
(
currentTasklet
.
isPresent
())
{
System
.
out
.
println
(
"Time "
+
time
+
": Job "
+
this
+
" started executing tasklet "
+
currentTasklet
.
get
()
+
" on Processor "
+
currentProcessor
.
get
());
}
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
);
// Hier update execution time, dann checken if 0, und wenn 0 gleich nächste Tasklet
// auswählen.
return
currentTasklet
.
get
().
updateExecution
(
time
);
}
else
if
(
currentProcessor
.
isPresent
())
{
}
else
{
if
(
currentProcessor
.
isPresent
())
{
currentProcessor
.
get
().
setJob
(
null
);
}
currentProcessor
=
Optional
.
empty
();
return
tc
;
}
}
return
Optional
.
empty
();
}
public
boolean
checkExecutionTime
()
{
return
executionTime
>
0
;
if
(
currentTasklet
.
isPresent
())
{
return
currentTasklet
.
get
().
checkExecutionTime
();
}
return
false
;
}
/**
...
...
@@ -103,4 +111,21 @@ public class JobContext implements JobContextInterface {
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/schmidmottok/SegmentContext.java
View file @
9ea90201
...
...
@@ -14,12 +14,15 @@ public class SegmentContext {
private
final
Set
<
JobContextInterface
>
jobs
;
private
final
Set
<
TaskletContext
>
tasklets
;
public
SegmentContext
(
TaskContext
taskContext
,
Segment
segment
)
{
public
SegmentContext
(
TaskContext
taskContext
,
Segment
segment
,
long
numberOfProcessors
)
{
this
.
segment
=
segment
;
jobs
=
new
HashSet
<>();
tasklets
=
new
HashSet
<>();
for
(
int
j
=
0
;
j
<
segment
.
getNumberOfJobs
();
++
j
)
{
long
numberOfJobs
=
segment
.
getNumberOfJobs
()
>
numberOfProcessors
?
numberOfProcessors
:
segment
.
getNumberOfJobs
();
for
(
int
j
=
0
;
j
<
numberOfJobs
;
++
j
)
{
jobs
.
add
(
new
JobContext
(
taskContext
,
this
));
}
...
...
@@ -36,14 +39,25 @@ public class SegmentContext {
return
segment
;
}
public
long
getNumberOfJobs
()
{
return
jobs
.
size
();
}
Optional
<
JobContextInterface
>
getNextJob
()
{
boolean
taskletAvailable
=
tasklets
.
stream
()
.
anyMatch
(
t
->
!
t
.
getCurrentJob
().
isPresent
()
&&
t
.
checkExecutionTime
());
if
(
taskletAvailable
)
{
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
();
}
...
...
src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java
View file @
9ea90201
...
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.Optional
;
import
mvd.jester.model.Segment
;
import
mvd.jester.model.Task
;
import
mvd.jester.simulator.EventPrinter
;
import
mvd.jester.simulator.internals.JobContextInterface
;
import
mvd.jester.simulator.internals.TaskContextInterface
;
...
...
@@ -19,7 +20,7 @@ public class TaskContext implements TaskContextInterface {
private
int
segmentCounter
;
public
TaskContext
(
Task
task
,
long
timeStep
)
{
public
TaskContext
(
Task
task
,
long
numberOfProcessors
,
long
timeStep
)
{
this
.
task
=
task
;
this
.
segments
=
new
ArrayList
<>();
this
.
currentSegment
=
0
;
...
...
@@ -27,7 +28,7 @@ public class TaskContext implements TaskContextInterface {
this
.
deadline
=
timeStep
+
task
.
getDeadline
();
for
(
Segment
s
:
task
.
getSegments
())
{
segments
.
add
(
new
SegmentContext
(
this
,
s
));
segments
.
add
(
new
SegmentContext
(
this
,
s
,
numberOfProcessors
));
}
}
...
...
@@ -52,7 +53,7 @@ public class TaskContext implements TaskContextInterface {
currentSegment
++;
segmentCounter
=
0
;
if
(
currentSegment
>=
segments
.
size
())
{
System
.
out
.
println
(
"Time "
+
time
+
": Task "
+
this
+
"finished!"
);
EventPrinter
.
print
(
"Time "
+
time
+
": Task "
+
this
+
"finished!"
);
return
Optional
.
of
(
this
);
}
}
...
...
src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java
View file @
9ea90201
package
mvd
.
jester
.
simulator
.
internals
.
schmidmottok
;
import
java.util.Optional
;
import
mvd.jester.simulator.internals.TaskContextInterface
;
/**
* Tasklet
...
...
@@ -33,15 +32,20 @@ public class TaskletContext {
currentJob
=
Optional
.
ofNullable
(
jobContext
);
}
public
Optional
<
TaskContextInterface
>
updateExecution
(
long
time
)
{
/**
* @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
t
askContext
.
acceptNotification
(
time
)
;
return
t
rue
;
}
return
Optional
.
empty
()
;
return
false
;
}
public
boolean
checkExecutionTime
()
{
...
...
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