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
b00f2d0e
authored
Aug 12, 2020
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simulator now works
parent
36080fd3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
83 additions
and
26 deletions
+83
-26
src/main/java/mvd/jester/App.java
+4
-1
src/main/java/mvd/jester/model/DagTask.java
+5
-0
src/main/java/mvd/jester/model/Subtask.java
+6
-0
src/main/java/mvd/jester/model/SystemManager.java
+5
-5
src/main/java/mvd/jester/simulator/GlobalScheduler.java
+0
-0
src/main/java/mvd/jester/simulator/events/AbstractContextEvent.java
+2
-2
src/main/java/mvd/jester/simulator/events/AbstractSubtaskEvent.java
+1
-1
src/main/java/mvd/jester/simulator/events/ISubtaskEvent.java
+1
-1
src/main/java/mvd/jester/simulator/events/SubtaskActivatedEvent.java
+3
-13
src/main/java/mvd/jester/simulator/events/SubtaskCompletedEvent.java
+2
-1
src/main/java/mvd/jester/simulator/events/TaskReleasedEvent.java
+1
-1
src/main/java/mvd/jester/simulator/model/ExtendedSubtaskContext.java
+5
-0
src/main/java/mvd/jester/simulator/model/JobContext.java
+23
-1
src/main/java/mvd/jester/simulator/model/ProcessorContext.java
+25
-0
No files found.
src/main/java/mvd/jester/App.java
View file @
b00f2d0e
...
...
@@ -7,6 +7,8 @@ import mvd.jester.model.SystemManager;
import
mvd.jester.model.SystemManager.DagTaskBuilder
;
import
mvd.jester.priority.RateMonotonic
;
import
mvd.jester.simulator.GlobalScheduler
;
import
mvd.jester.simulator.model.ExtendedSubtaskContext
;
import
mvd.jester.simulator.model.JobContext
;
import
mvd.jester.tests.AbstractTest
;
import
mvd.jester.tests.FonsecaNelis
;
import
mvd.jester.tests.MelaniButtazzo
;
...
...
@@ -25,7 +27,8 @@ public class App {
GlobalScheduler
scheduler
=
new
GlobalScheduler
(
new
RateMonotonic
(),
4
);
DagTaskBuilder
builder
=
new
DagTaskBuilder
().
setNumberOfProcessors
(
4
);
scheduler
.
schedule
(
builder
.
generateTaskSet
(
3
),
10000
);
scheduler
.
schedule
(
builder
.
generateTaskSet
(
1.0
),
10000
);
// {
// SystemManager manager = new SystemManager(8);
// DagTaskBuilder builder = new DagTaskBuilder();
...
...
src/main/java/mvd/jester/model/DagTask.java
View file @
b00f2d0e
...
...
@@ -98,4 +98,9 @@ public class DagTask implements Task {
return
numberOfThreads
;
}
@Override
public
String
toString
()
{
return
"(P="
+
period
+
", D="
+
deadline
+
")"
;
}
}
src/main/java/mvd/jester/model/Subtask.java
View file @
b00f2d0e
...
...
@@ -27,4 +27,10 @@ public class Subtask {
public
void
setRelativeCompletionTime
(
long
relativeCompletionTime
)
{
this
.
relativeCompletionTime
=
relativeCompletionTime
;
}
@Override
public
String
toString
()
{
return
"(C="
+
wcet
+
")"
;
}
}
src/main/java/mvd/jester/model/SystemManager.java
View file @
b00f2d0e
...
...
@@ -160,10 +160,10 @@ public class SystemManager {
private
long
numberOfProcessors
=
8
;
private
long
minimumWcet
=
1
;
private
long
maximumWcet
=
100
;
private
long
maxNumberOfBranches
=
5
;
private
long
depth
=
2
;
private
long
maxNumberOfBranches
=
3
;
// TODO: Change back to 5
private
long
depth
=
1
;
// TODO: Change back to 2
private
long
p_par
=
80
;
private
long
p_add
=
20
;
private
long
p_add
=
10
;
// TODO: Change back to 20
public
DagTaskBuilder
()
{
}
...
...
@@ -252,8 +252,8 @@ public class SystemManager {
return
new
DagTask
(
jobDag
,
period
,
numberOfProcessors
);
}
private
Subtask
join
(
final
DirectedAcyclicGraph
<
Subtask
,
DefaultEdge
>
jobDag
,
final
Subtask
current
,
final
Set
<
Subtask
>
childs
)
{
private
Subtask
join
(
final
DirectedAcyclicGraph
<
Subtask
,
DefaultEdge
>
jobDag
,
final
S
ubtask
current
,
final
S
et
<
Subtask
>
childs
)
{
if
(
childs
.
size
()
>
0
)
{
final
Subtask
job
=
new
Subtask
(
randomWcet
());
jobDag
.
addVertex
(
job
);
...
...
src/main/java/mvd/jester/simulator/GlobalScheduler.java
View file @
b00f2d0e
This diff is collapsed.
Click to expand it.
src/main/java/mvd/jester/simulator/events/AbstractContextEvent.java
View file @
b00f2d0e
...
...
@@ -3,7 +3,7 @@ package mvd.jester.simulator.events;
import
mvd.jester.simulator.model.ExtendedSubtaskContext
;
import
mvd.jester.simulator.model.JobContext
;
public
abstract
class
AbstractContextEvent
extends
AbstractSubtaskEvent
implements
ISubtaskEvent
{
public
abstract
class
AbstractContextEvent
extends
AbstractSubtaskEvent
{
private
final
ExtendedSubtaskContext
subtask
;
...
...
@@ -13,7 +13,7 @@ public abstract class AbstractContextEvent extends AbstractSubtaskEvent implemen
this
.
subtask
=
subtask
;
}
@Override
//
@Override
public
ExtendedSubtaskContext
getSubtaskContext
()
{
return
subtask
;
}
...
...
src/main/java/mvd/jester/simulator/events/AbstractSubtaskEvent.java
View file @
b00f2d0e
...
...
@@ -2,7 +2,7 @@ package mvd.jester.simulator.events;
import
mvd.jester.simulator.model.JobContext
;
public
abstract
class
AbstractSubtaskEvent
extends
AbstractEvent
{
public
abstract
class
AbstractSubtaskEvent
extends
AbstractEvent
implements
ISubtaskEvent
{
private
final
JobContext
jobContext
;
...
...
src/main/java/mvd/jester/simulator/events/ISubtaskEvent.java
View file @
b00f2d0e
...
...
@@ -5,7 +5,7 @@ import mvd.jester.simulator.model.JobContext;
public
interface
ISubtaskEvent
extends
IEvent
{
public
ExtendedSubtaskContext
getSubtaskContext
();
//
public ExtendedSubtaskContext getSubtaskContext();
public
JobContext
getJobContext
();
...
...
src/main/java/mvd/jester/simulator/events/SubtaskActivatedEvent.java
View file @
b00f2d0e
...
...
@@ -3,25 +3,15 @@ package mvd.jester.simulator.events;
import
mvd.jester.model.Subtask
;
import
mvd.jester.simulator.model.JobContext
;
public
class
SubtaskActivatedEvent
extends
AbstractEvent
{
public
class
SubtaskActivatedEvent
extends
Abstract
Subtask
Event
{
private
final
JobContext
job
;
private
final
Subtask
subtask
;
public
SubtaskActivatedEvent
(
final
long
time
,
final
JobContext
job
,
final
Subtask
subtask
)
{
super
(
EventType
.
SUBTASK_ACTIVATED
,
time
);
this
.
job
=
job
;
super
(
EventType
.
SUBTASK_ACTIVATED
,
time
,
job
);
this
.
subtask
=
subtask
;
}
/**
* @return the job
*/
public
JobContext
getJobContext
()
{
return
job
;
}
/**
* @return the subtask
*/
...
...
@@ -31,7 +21,7 @@ public class SubtaskActivatedEvent extends AbstractEvent {
@Override
protected
String
getLoggingMessage
()
{
return
"Subtask "
+
getSubtask
()
+
" released"
;
return
"Subtask "
+
getSubtask
()
+
"
of task "
+
getJobContext
().
getTask
()
+
"
released"
;
}
}
src/main/java/mvd/jester/simulator/events/SubtaskCompletedEvent.java
View file @
b00f2d0e
...
...
@@ -10,7 +10,8 @@ public class SubtaskCompletedEvent extends AbstractContextEvent {
@Override
protected
String
getLoggingMessage
()
{
return
"Subtask "
+
getSubtaskContext
()
+
" completed"
;
return
"Subtask "
+
getSubtaskContext
()
+
" of task "
+
getJobContext
().
getTask
()
+
" completed"
;
}
}
src/main/java/mvd/jester/simulator/events/TaskReleasedEvent.java
View file @
b00f2d0e
...
...
@@ -16,6 +16,6 @@ public class TaskReleasedEvent extends AbstractEvent {
@Override
public
String
getLoggingMessage
()
{
return
"
t
ask "
+
getTask
()
+
" started"
;
return
"
T
ask "
+
getTask
()
+
" started"
;
}
}
src/main/java/mvd/jester/simulator/model/ExtendedSubtaskContext.java
View file @
b00f2d0e
...
...
@@ -15,4 +15,9 @@ public class ExtendedSubtaskContext extends SubtaskContext {
public
JobContext
getJobContext
()
{
return
jobContext
;
}
@Override
public
String
toString
()
{
return
getSubtask
()
+
" of task "
+
getJobContext
().
getTask
();
}
}
src/main/java/mvd/jester/simulator/model/JobContext.java
View file @
b00f2d0e
package
mvd
.
jester
.
simulator
.
model
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.jgrapht.experimental.dag.DirectedAcyclicGraph
;
import
org.jgrapht.graph.DefaultEdge
;
import
mvd.jester.model.DagTask
;
...
...
@@ -11,6 +13,7 @@ public class JobContext {
private
final
long
releaseTime
;
private
final
long
deadline
;
private
final
Subtask
source
;
private
final
Set
<
ExtendedSubtaskContext
>
finishedSubtasks
;
// private long activeThreads; // TODO: Use threads
public
JobContext
(
DagTask
task
,
long
releaseTime
)
{
...
...
@@ -18,6 +21,7 @@ public class JobContext {
this
.
releaseTime
=
releaseTime
;
this
.
deadline
=
releaseTime
+
task
.
getDeadline
();
this
.
source
=
findSource
(
task
);
this
.
finishedSubtasks
=
new
HashSet
<>();
// this.activeThreads = task.getNumberOfThreads();
}
...
...
@@ -59,8 +63,26 @@ public class JobContext {
return
releaseTime
;
}
/**
* @return the finishedSubtasks
*/
public
Set
<
ExtendedSubtaskContext
>
getFinishedSubtasks
()
{
return
finishedSubtasks
;
}
public
void
registerFinishedSubtask
(
ExtendedSubtaskContext
subtaskContext
)
{
if
(!
finishedSubtasks
.
add
(
subtaskContext
))
{
throw
new
RuntimeException
(
"Subtask could not be added to finished subtask which means it was executed twice!"
);
}
}
public
boolean
checkRemainingThreads
()
{
return
false
;
return
true
;
// TODO: implement check in future
}
public
String
toString
()
{
return
"of task "
+
getTask
();
}
}
src/main/java/mvd/jester/simulator/model/ProcessorContext.java
View file @
b00f2d0e
package
mvd
.
jester
.
simulator
.
model
;
import
java.util.Comparator
;
import
java.util.Optional
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.simulator.exceptions.DeadlineMissedException
;
...
...
@@ -96,4 +97,28 @@ public class ProcessorContext {
return
"Processor "
+
processorId
;
}
public
static
class
ProcessorComparator
implements
Comparator
<
ProcessorContext
>
{
private
final
PriorityManager
priorityManager
;
public
ProcessorComparator
(
PriorityManager
priorityManager
)
{
this
.
priorityManager
=
priorityManager
;
}
@Override
public
int
compare
(
ProcessorContext
p1
,
ProcessorContext
p2
)
{
if
(!
p1
.
getSubtask
().
isPresent
())
{
return
-
1
;
}
else
if
(!
p2
.
getSubtask
().
isPresent
())
{
return
1
;
}
else
{
// Sort in reverse
return
priorityManager
.
compare
(
p2
.
currentSubtask
.
get
().
getJobContext
(),
p1
.
currentSubtask
.
get
().
getJobContext
());
}
}
}
}
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