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
1b8a538a
authored
Jan 12, 2021
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
latest changes, used on paper
parent
8054de06
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
526 additions
and
146 deletions
+526
-146
src/main/java/mvd/jester/App.java
+64
-35
src/main/java/mvd/jester/ResultLogger.java
+2
-2
src/main/java/mvd/jester/TestEnvironment.java
+7
-7
src/main/java/mvd/jester/model/DagTask.java
+9
-0
src/main/java/mvd/jester/model/LightTask.java
+26
-0
src/main/java/mvd/jester/model/SystemManager.java
+21
-8
src/main/java/mvd/jester/priority/DeadlineMonotonic.java
+62
-0
src/main/java/mvd/jester/tests/DongLiu.java
+59
-0
src/main/java/mvd/jester/tests/FonsecaNelis.java
+3
-2
src/main/java/mvd/jester/tests/JiangYi.java
+2
-2
src/main/java/mvd/jester/tests/SchmidMottok.java
+12
-10
src/main/java/mvd/jester/tests/Tester.java
+68
-80
src/main/java/mvd/jester/tests/UeterAgrawal.java
+191
-0
No files found.
src/main/java/mvd/jester/App.java
View file @
1b8a538a
...
@@ -6,9 +6,12 @@ import mvd.jester.model.DagTask;
...
@@ -6,9 +6,12 @@ import mvd.jester.model.DagTask;
import
mvd.jester.model.SystemManager
;
import
mvd.jester.model.SystemManager
;
import
mvd.jester.model.SystemManager.DagTaskBuilder
;
import
mvd.jester.model.SystemManager.DagTaskBuilder
;
import
mvd.jester.tests.AbstractTest
;
import
mvd.jester.tests.AbstractTest
;
import
mvd.jester.tests.DongLiu
;
import
mvd.jester.tests.FonsecaNelis
;
import
mvd.jester.tests.FonsecaNelis
;
import
mvd.jester.tests.JiangYi
;
import
mvd.jester.tests.JiangYi
;
import
mvd.jester.tests.SchmidMottok
;
import
mvd.jester.tests.SchmidMottok
;
import
mvd.jester.tests.Tester
;
import
mvd.jester.tests.UeterAgrawal
;
import
mvd.jester.tests.TypeFunction.UnknownStructure
;
import
mvd.jester.tests.TypeFunction.UnknownStructure
;
...
@@ -19,66 +22,92 @@ import mvd.jester.tests.TypeFunction.UnknownStructure;
...
@@ -19,66 +22,92 @@ import mvd.jester.tests.TypeFunction.UnknownStructure;
public
class
App
{
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
{
{
SystemManager
<
DagTaskBuilder
>
manager
=
new
SystemManager
<>(
DagTaskBuilder
.
class
);
SystemManager
<
DagTaskBuilder
>
manager
=
new
SystemManager
<>(
DagTaskBuilder
.
class
);
manager
.
setNumberOfProcessors
(
8
);
manager
.
setNumberOfProcessors
(
8
);
TestEnvironment
te
=
new
TestEnvironment
();
TestEnvironment
te
=
new
TestEnvironment
();
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
/* new SchmidMottok(new KnownStructure(), manager), */
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
//
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
// new Tester(new UnknownStructure(),manager),
// new Tester(new UnknownStructure(), manager),
// new MelaniButtazzo(manager),,
// new MelaniButtazzo(manager),,
new
FonsecaNelis
(
manager
),
//
// new FonsecaNelis(manager), //
// new DongLiu(manager), //
new
UeterAgrawal
(
manager
),
//
new
JiangYi
(
manager
)
//
new
JiangYi
(
manager
)
//
));
));
te
.
varyRenyiUtilization
(
manager
,
tests
,
5
00
);
te
.
varyRenyiUtilization
(
manager
,
tests
,
2
00
);
}
}
{
{
SystemManager
<
DagTaskBuilder
>
manager
=
new
SystemManager
<>(
DagTaskBuilder
.
class
);
SystemManager
<
DagTaskBuilder
>
manager
=
manager
.
setNumberOfProcessors
(
8
);
new
SystemManager
<>(
DagTaskBuilder
.
class
);
manager
.
setNumberOfProcessors
(
16
);
TestEnvironment
te
=
new
TestEnvironment
();
TestEnvironment
te
=
new
TestEnvironment
();
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
/* new SchmidMottok(new KnownStructure(), manager), */
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
//
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
// new Tester(new UnknownStructure(),manager),
// new Tester(new UnknownStructure(), manager),
// new MelaniButtazzo(manager),,
// new MelaniButtazzo(manager),,
new
FonsecaNelis
(
manager
),
//
// new FonsecaNelis(manager), //
// new DongLiu(manager), //
new
UeterAgrawal
(
manager
),
//
new
JiangYi
(
manager
)
//
new
JiangYi
(
manager
)
//
));
));
te
.
varyPropability
(
manager
,
tests
,
5
00
);
te
.
varyRenyiUtilization
(
manager
,
tests
,
2
00
);
}
}
{
{
SystemManager
<
DagTaskBuilder
>
manager
=
new
SystemManager
<>(
DagTaskBuilder
.
class
);
SystemManager
<
DagTaskBuilder
>
manager
=
manager
.
setNumberOfProcessors
(
8
);
new
SystemManager
<>(
DagTaskBuilder
.
class
);
manager
.
setNumberOfProcessors
(
32
);
TestEnvironment
te
=
new
TestEnvironment
();
TestEnvironment
te
=
new
TestEnvironment
();
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
//
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
// new SchmidMottok(new KnownStructure(), manager), //
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
//
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
//
// new Tester(new UnknownStructure(), manager), //
// new Tester(new UnknownStructure(),manager),
// new MelaniButtazzo(manager), //
// new MelaniButtazzo(manager),,
new
FonsecaNelis
(
manager
),
//
// new FonsecaNelis(manager), //
new
JiangYi
(
manager
)));
// new DongLiu(manager), //
new
UeterAgrawal
(
manager
),
//
new
JiangYi
(
manager
)
//
));
te
.
varyNumberOfProcessors
(
manager
,
tests
,
5
00
);
te
.
varyRenyiUtilization
(
manager
,
tests
,
2
00
);
}
}
{
// {
SystemManager
<
DagTaskBuilder
>
manager
=
new
SystemManager
<>(
DagTaskBuilder
.
class
);
// SystemManager<DagTaskBuilder> manager = new
manager
.
setNumberOfProcessors
(
8
);
// SystemManager<>(DagTaskBuilder.class);
TestEnvironment
te
=
new
TestEnvironment
();
// manager.setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment();
List
<
AbstractTest
<
DagTask
>>
tests
=
te
.
registerTests
(
Arrays
.
asList
(
//
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( //
// new SchmidMottok(new KnownStructure(), manager), //
// // new SchmidMottok(new KnownStructure(), manager), //
new
SchmidMottok
(
new
UnknownStructure
(),
manager
),
//
// new SchmidMottok(new UnknownStructure(), manager), //
// new Tester(new UnknownStructure(), manager), //
// // new Tester(new UnknownStructure(), manager), //
// new MelaniButtazzo(manager), //
// // new MelaniButtazzo(manager), //
new
FonsecaNelis
(
manager
),
//
// new FonsecaNelis(manager), //
new
JiangYi
(
manager
)));
// new UeterAgrawal(manager), //
// new JiangYi(manager)));
te
.
varyNumberOfTasks
(
manager
,
tests
,
500
);
// te.varyNumberOfProcessors(manager, tests, 200);
}
// }
// {
// SystemManager<DagTaskBuilder> manager = new
// SystemManager<>(DagTaskBuilder.class);
// manager.setNumberOfProcessors(8);
// TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList( //
// // new SchmidMottok(new KnownStructure(), manager), //
// new SchmidMottok(new UnknownStructure(), manager), //
// // new Tester(new UnknownStructure(), manager), //
// // new MelaniButtazzo(manager), //
// new FonsecaNelis(manager), //
// new UeterAgrawal(manager), //
// new JiangYi(manager)));
// te.varyNumberOfTasks(manager, tests, 200);
// }
}
}
}
}
src/main/java/mvd/jester/ResultLogger.java
View file @
1b8a538a
...
@@ -35,12 +35,12 @@ public class ResultLogger {
...
@@ -35,12 +35,12 @@ public class ResultLogger {
public
<
T
extends
Task
>
void
logLine
(
final
double
utilization
,
public
<
T
extends
Task
>
void
logLine
(
final
double
utilization
,
final
Map
<
AbstractTest
<
T
>,
Long
>
results
)
{
final
Map
<
AbstractTest
<
T
>,
Long
>
results
,
long
numberOfTestedTasksets
)
{
final
Appendable
out
=
new
StringBuilder
();
final
Appendable
out
=
new
StringBuilder
();
try
{
try
{
out
.
append
(
""
+
utilization
);
out
.
append
(
""
+
utilization
);
for
(
final
Entry
<
AbstractTest
<
T
>,
Long
>
rc
:
results
.
entrySet
())
{
for
(
final
Entry
<
AbstractTest
<
T
>,
Long
>
rc
:
results
.
entrySet
())
{
final
long
numberOfFeasibleTasks
=
rc
.
getValue
();
final
long
numberOfFeasibleTasks
=
rc
.
getValue
()
/
(
numberOfTestedTasksets
/
100
)
;
out
.
append
(
"\t"
+
numberOfFeasibleTasks
);
out
.
append
(
"\t"
+
numberOfFeasibleTasks
);
}
}
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
...
...
src/main/java/mvd/jester/TestEnvironment.java
View file @
1b8a538a
...
@@ -112,14 +112,14 @@ public class TestEnvironment {
...
@@ -112,14 +112,14 @@ public class TestEnvironment {
final
List
<
AbstractTest
<
DagTask
>>
abstractTestInstances
,
final
List
<
AbstractTest
<
DagTask
>>
abstractTestInstances
,
final
long
numberOfTaskSetsPerStep
)
{
final
long
numberOfTaskSetsPerStep
)
{
long
checkedTasksets
=
0
;
long
checkedTasksets
=
0
;
final
long
numberOfTaskSets
=
8
*
numberOfTaskSetsPerStep
;
final
long
numberOfTaskSets
=
5
*
numberOfTaskSetsPerStep
;
final
ResultLogger
resultLogger
=
new
ResultLogger
(
"numberOfProcessors"
);
final
ResultLogger
resultLogger
=
new
ResultLogger
(
"numberOfProcessors"
);
final
Map
<
AbstractTest
<
DagTask
>,
Long
>
resultMap
=
new
LinkedHashMap
<>();
final
Map
<
AbstractTest
<
DagTask
>,
Long
>
resultMap
=
new
LinkedHashMap
<>();
abstractTestInstances
.
forEach
(
t
->
resultMap
.
put
(
t
,
(
long
)
0
));
abstractTestInstances
.
forEach
(
t
->
resultMap
.
put
(
t
,
(
long
)
0
));
resultLogger
.
logHeader
(
resultMap
,
"NoOfProcessors"
);
resultLogger
.
logHeader
(
resultMap
,
"NoOfProcessors"
);
for
(
long
numberOfProcessors
=
2
;
numberOfProcessors
<=
16
;
numberOfProcessors
+
=
2
)
{
for
(
long
numberOfProcessors
=
2
;
numberOfProcessors
<=
32
;
numberOfProcessors
*
=
2
)
{
manager
.
setNumberOfProcessors
(
numberOfProcessors
);
manager
.
setNumberOfProcessors
(
numberOfProcessors
);
resultMap
.
replaceAll
((
k
,
v
)
->
(
long
)
0
);
resultMap
.
replaceAll
((
k
,
v
)
->
(
long
)
0
);
for
(
int
i
=
0
;
i
<
numberOfTaskSetsPerStep
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numberOfTaskSetsPerStep
;
++
i
)
{
...
@@ -142,7 +142,7 @@ public class TestEnvironment {
...
@@ -142,7 +142,7 @@ public class TestEnvironment {
}
}
checkedTasksets
++;
checkedTasksets
++;
}
}
resultLogger
.
logLine
(
numberOfProcessors
,
resultMap
);
resultLogger
.
logLine
(
numberOfProcessors
,
resultMap
,
numberOfTaskSetsPerStep
);
resultLogger
.
newLine
();
resultLogger
.
newLine
();
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
...
@@ -184,7 +184,7 @@ public class TestEnvironment {
...
@@ -184,7 +184,7 @@ public class TestEnvironment {
}
}
checkedTasksets
++;
checkedTasksets
++;
}
}
resultLogger
.
logLine
(
numberOfTasks
,
resultMap
);
resultLogger
.
logLine
(
numberOfTasks
,
resultMap
,
numberOfTaskSetsPerStep
);
resultLogger
.
newLine
();
resultLogger
.
newLine
();
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
...
@@ -224,7 +224,7 @@ public class TestEnvironment {
...
@@ -224,7 +224,7 @@ public class TestEnvironment {
}
}
checkedTasksets
++;
checkedTasksets
++;
}
}
resultLogger
.
logLine
(
util
,
resultMap
);
resultLogger
.
logLine
(
util
,
resultMap
,
numberOfTaskSetsPerUtil
);
resultLogger
.
newLine
();
resultLogger
.
newLine
();
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
...
@@ -266,7 +266,7 @@ public class TestEnvironment {
...
@@ -266,7 +266,7 @@ public class TestEnvironment {
}
}
checkedTasksets
++;
checkedTasksets
++;
}
}
resultLogger
.
logLine
(
util
,
resultMap
);
resultLogger
.
logLine
(
util
/
numberOfProcessors
,
resultMap
,
numberOfTaskSetsPerUtil
);
resultLogger
.
newLine
();
resultLogger
.
newLine
();
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
...
@@ -306,7 +306,7 @@ public class TestEnvironment {
...
@@ -306,7 +306,7 @@ public class TestEnvironment {
}
}
checkedTasksets
++;
checkedTasksets
++;
}
}
resultLogger
.
logLine
(
p_add
,
resultMap
);
resultLogger
.
logLine
(
p_add
,
resultMap
,
numberOfTaskSetsPerStep
);
resultLogger
.
newLine
();
resultLogger
.
newLine
();
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
...
...
src/main/java/mvd/jester/model/DagTask.java
View file @
1b8a538a
...
@@ -20,6 +20,15 @@ public class DagTask extends Task {
...
@@ -20,6 +20,15 @@ public class DagTask extends Task {
}
}
public
DagTask
(
final
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
,
final
long
period
,
public
DagTask
(
final
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
,
final
long
period
,
final
long
deadline
,
final
long
numberOfThreads
)
{
super
(
period
,
deadline
,
DagUtils
.
calculateWorkload
(
jobDag
),
DagUtils
.
calculateCriticalPath
(
jobDag
),
numberOfThreads
);
this
.
jobDag
=
jobDag
;
this
.
workloadDistribution
=
DagUtils
.
calculateWorkloadDistribution
(
this
.
jobDag
,
this
.
criticalPath
);
}
public
DagTask
(
final
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
,
final
long
period
,
final
Set
<
Segment
>
workloadDistribution
,
final
long
numberOfThreads
)
{
final
Set
<
Segment
>
workloadDistribution
,
final
long
numberOfThreads
)
{
super
(
period
,
period
,
DagUtils
.
calculateWorkload
(
jobDag
),
super
(
period
,
period
,
DagUtils
.
calculateWorkload
(
jobDag
),
DagUtils
.
calculateCriticalPath
(
jobDag
),
numberOfThreads
);
DagUtils
.
calculateCriticalPath
(
jobDag
),
numberOfThreads
);
...
...
src/main/java/mvd/jester/model/LightTask.java
0 → 100644
View file @
1b8a538a
package
mvd
.
jester
.
model
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
LightTask
extends
Task
{
private
final
Set
<
Segment
>
segments
;
public
LightTask
(
long
period
,
long
deadline
,
long
workload
)
{
super
(
period
,
deadline
,
workload
,
workload
,
1
);
segments
=
new
HashSet
<>();
segments
.
add
(
new
Segment
(
workload
,
1
));
}
@Override
public
long
getMaximumParallelism
()
{
return
1
;
}
@Override
public
Set
<
Segment
>
getWorkloadDistribution
()
{
return
segments
;
}
}
src/main/java/mvd/jester/model/SystemManager.java
View file @
1b8a538a
...
@@ -216,17 +216,24 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
...
@@ -216,17 +216,24 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
}
else
{
}
else
{
final
double
remainingUtilization
=
totalUtilization
-
currentUtilization
;
final
double
remainingUtilization
=
totalUtilization
-
currentUtilization
;
final
long
period
=
(
long
)
Math
.
ceil
(
task
.
getWorkload
()
/
remainingUtilization
);
final
long
period
=
(
long
)
Math
.
ceil
(
task
.
getWorkload
()
/
remainingUtilization
);
if
(
period
>=
task
.
getCriticalPath
())
{
final
long
criticalPath
=
task
.
getCriticalPath
();
long
numberOfThreads
=
if
(
period
>=
criticalPath
)
{
LongMath
.
divide
(
task
.
getWorkload
()
-
task
.
getCriticalPath
(),
final
long
deadline
=
randomNumberInRange
(
period
-
task
.
getCriticalPath
(),
RoundingMode
.
CEILING
);
criticalPath
+
(
period
-
criticalPath
)
/
4
,
period
);
// TODO:
// deadline =
// period?
// final long deadline = period;
long
numberOfThreads
=
LongMath
.
divide
(
task
.
getWorkload
()
-
criticalPath
,
deadline
-
criticalPath
,
RoundingMode
.
CEILING
);
if
(
numberOfThreads
==
0
)
{
if
(
numberOfThreads
==
0
)
{
numberOfThreads
=
1
;
numberOfThreads
=
1
;
}
}
final
DagTask
modifiedTask
=
final
DagTask
modifiedTask
=
new
DagTask
(
task
.
getJobDag
(),
period
,
numberOfThreads
);
new
DagTask
(
task
.
getJobDag
(),
period
,
deadline
,
numberOfThreads
);
taskSet
.
add
(
modifiedTask
);
taskSet
.
add
(
modifiedTask
);
break
;
break
;
}
}
...
@@ -324,15 +331,21 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
...
@@ -324,15 +331,21 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
final
long
workload
=
DagUtils
.
calculateWorkload
(
jobDag
);
final
long
workload
=
DagUtils
.
calculateWorkload
(
jobDag
);
final
long
criticalPath
=
DagUtils
.
calculateCriticalPath
(
jobDag
);
final
long
criticalPath
=
DagUtils
.
calculateCriticalPath
(
jobDag
);
final
long
period
=
randomRenyiPeriod
(
workload
,
criticalPath
,
totalUtilization
);
final
long
period
=
randomRenyiPeriod
(
workload
,
criticalPath
,
totalUtilization
);
final
long
deadline
=
randomNumberInRange
(
criticalPath
+
(
period
-
criticalPath
)
/
4
,
period
);
// TODO:
// oder
// period?
// final long deadline = period;
final
long
numberOfThreads
=
LongMath
.
divide
(
workload
-
criticalPath
,
final
long
numberOfThreads
=
LongMath
.
divide
(
workload
-
criticalPath
,
period
-
criticalPath
,
RoundingMode
.
CEILING
);
deadline
-
criticalPath
,
RoundingMode
.
CEILING
);
if
(
numberOfThreads
==
0
)
{
if
(
numberOfThreads
==
0
)
{
return
new
DagTask
(
jobDag
,
period
,
1
);
return
new
DagTask
(
jobDag
,
period
,
deadline
,
1
);
}
}
return
new
DagTask
(
jobDag
,
period
,
numberOfThreads
);
return
new
DagTask
(
jobDag
,
period
,
deadline
,
numberOfThreads
);
}
}
private
long
randomRenyiPeriod
(
final
long
workload
,
final
long
criticalPath
,
private
long
randomRenyiPeriod
(
final
long
workload
,
final
long
criticalPath
,
...
...
src/main/java/mvd/jester/priority/DeadlineMonotonic.java
0 → 100644
View file @
1b8a538a
package
mvd
.
jester
.
priority
;
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
{
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
*
* @param t1 The first task
* @param t2 The second task
* @return 0 if both tasks have the same priority, negative number if the first task has a
* higher priority, positive number if the second task has a higher priority
*/
@Override
public
int
compare
(
Task
t1
,
Task
t2
)
{
return
Long
.
compare
(
t1
.
getDeadline
(),
t2
.
getDeadline
());
}
@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
());
}
@Override
public
boolean
hasTest
(
Class
<?
extends
AbstractTest
<?
extends
Task
>>
abstractTestClass
)
{
return
abstractTests
.
contains
(
abstractTestClass
);
}
@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/tests/DongLiu.java
0 → 100644
View file @
1b8a538a
package
mvd
.
jester
.
tests
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.SchedulingInfo.Feasiblity
;
import
mvd.jester.model.DagTask
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SystemManagerInterface
;
import
mvd.jester.priority.EarliestDeadlineFirst
;
import
mvd.jester.priority.PriorityManager
;
public
class
DongLiu
extends
AbstractTest
<
DagTask
>
{
private
final
EarliestDeadlineFirst
priorityManager
;
public
DongLiu
(
SystemManagerInterface
manager
)
{
super
(
manager
);
this
.
priorityManager
=
new
EarliestDeadlineFirst
();
}
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
SortedTaskSet
<
DagTask
>
tasks
)
{
final
long
numberOfProcessors
=
manager
.
getNumberOfProcessors
();
for
(
DagTask
task
:
tasks
)
{
double
sumOfWorkloads
=
0
;
for
(
DagTask
t
:
tasks
)
{
sumOfWorkloads
+=
getAverageWorkload
(
t
,
task
);
}
final
double
cpUtilization
=
(
double
)
task
.
getCriticalPath
()
/
task
.
getPeriod
();
if
(!(
sumOfWorkloads
<=
numberOfProcessors
-
((
numberOfProcessors
-
1
)
*
cpUtilization
)))
{
return
new
SchedulingInfo
(
Feasiblity
.
FAILED
);
}
}
return
new
SchedulingInfo
(
Feasiblity
.
SUCCEEDED
);
}
private
double
getAverageWorkload
(
DagTask
t
,
DagTask
task
)
{
final
double
cpUtilization
=
(
double
)
task
.
getCriticalPath
()
/
task
.
getPeriod
();
final
double
taskUtilization
=
t
.
getUtilization
();
if
(
cpUtilization
>=
taskUtilization
)
{
return
taskUtilization
;
}
else
{
return
taskUtilization
+
((
double
)
t
.
getWorkload
()
-
cpUtilization
*
t
.
getPeriod
())
/
(
task
.
getPeriod
());
}
}
@Override
public
PriorityManager
getPriorityManager
()
{
return
priorityManager
;
}
@Override
public
String
getName
()
{
return
"DongLiu"
;
}
}
src/main/java/mvd/jester/tests/FonsecaNelis.java
View file @
1b8a538a
...
@@ -25,6 +25,7 @@ import mvd.jester.model.SystemManagerInterface;
...
@@ -25,6 +25,7 @@ import mvd.jester.model.SystemManagerInterface;
import
mvd.jester.model.Task
;
import
mvd.jester.model.Task
;
import
mvd.jester.model.TreeJob
;
import
mvd.jester.model.TreeJob
;
import
mvd.jester.utils.DagUtils
;
import
mvd.jester.utils.DagUtils
;
import
mvd.jester.priority.DeadlineMonotonic
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.RateMonotonic
;
import
mvd.jester.priority.RateMonotonic
;
import
mvd.jester.utils.BinaryDecompositionTree
;
import
mvd.jester.utils.BinaryDecompositionTree
;
...
@@ -40,7 +41,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
...
@@ -40,7 +41,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
public
FonsecaNelis
(
final
SystemManagerInterface
manager
)
{
public
FonsecaNelis
(
final
SystemManagerInterface
manager
)
{
super
(
manager
);
super
(
manager
);
this
.
responseTimes
=
new
HashMap
<>();
this
.
responseTimes
=
new
HashMap
<>();
this
.
priorityManager
=
new
Rat
eMonotonic
();
this
.
priorityManager
=
new
Deadlin
eMonotonic
();
this
.
carryOutSegments
=
new
HashMap
<>();
this
.
carryOutSegments
=
new
HashMap
<>();
}
}
...
@@ -153,7 +154,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
...
@@ -153,7 +154,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
previousResponseTime
=
responseTime
;
previousResponseTime
=
responseTime
;
double
taskInterference
=
0
;
double
taskInterference
=
0
;
for
(
final
DagTask
t
:
tasks
)
{
for
(
final
DagTask
t
:
tasks
)
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
()
)
{
if
(
priorityManager
.
compare
(
t
,
task
)
<
0
)
{
taskInterference
+=
getTaskInterference
(
t
,
responseTime
);
taskInterference
+=
getTaskInterference
(
t
,
responseTime
);
}
}
}
}
...
...
src/main/java/mvd/jester/tests/JiangYi.java
View file @
1b8a538a
...
@@ -34,7 +34,7 @@ public class JiangYi extends AbstractTest<DagTask> {
...
@@ -34,7 +34,7 @@ public class JiangYi extends AbstractTest<DagTask> {
Set
<
Task
>
lightTasks
=
new
HashSet
<>();
Set
<
Task
>
lightTasks
=
new
HashSet
<>();
for
(
DagTask
t
:
tasks
)
{
for
(
DagTask
t
:
tasks
)
{
if
(
t
.
get
Utilization
()
<
1
)
{
if
(
t
.
get
Density
()
<
1
)
{
lightTasks
.
add
(
t
);
lightTasks
.
add
(
t
);
}
else
{
}
else
{
heavyTasks
.
add
(
t
);
heavyTasks
.
add
(
t
);
...
@@ -68,10 +68,10 @@ public class JiangYi extends AbstractTest<DagTask> {
...
@@ -68,10 +68,10 @@ public class JiangYi extends AbstractTest<DagTask> {
Collections
.
sort
(
taskList
,
(
a
,
b
)
->
Double
.
compare
(
b
.
getDensity
(),
a
.
getDensity
()));
Collections
.
sort
(
taskList
,
(
a
,
b
)
->
Double
.
compare
(
b
.
getDensity
(),
a
.
getDensity
()));
List
<
Double
>
bins
=
new
ArrayList
<>();
List
<
Double
>
bins
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numberOfprocessors
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numberOfprocessors
;
++
i
)
{
bins
.
add
((
double
)
0
);
bins
.
add
((
double
)
0
);
}
}
Iterator
<
Task
>
taskIterator
=
taskList
.
iterator
();
Iterator
<
Task
>
taskIterator
=
taskList
.
iterator
();
while
(
taskIterator
.
hasNext
())
{
while
(
taskIterator
.
hasNext
())
{
Collections
.
sort
(
bins
);
Collections
.
sort
(
bins
);
...
...
src/main/java/mvd/jester/tests/SchmidMottok.java
View file @
1b8a538a
...
@@ -11,6 +11,7 @@ import mvd.jester.model.DagTask;
...
@@ -11,6 +11,7 @@ import mvd.jester.model.DagTask;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SystemManagerInterface
;
import
mvd.jester.model.SystemManagerInterface
;
import
mvd.jester.model.Task
;
import
mvd.jester.model.Task
;
import
mvd.jester.priority.DeadlineMonotonic
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.RateMonotonic
;
import
mvd.jester.priority.RateMonotonic
;
...
@@ -26,7 +27,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
...
@@ -26,7 +27,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
public
SchmidMottok
(
TypeFunction
structure
,
final
SystemManagerInterface
manager
)
{
public
SchmidMottok
(
TypeFunction
structure
,
final
SystemManagerInterface
manager
)
{
super
(
manager
);
super
(
manager
);
this
.
responseTimes
=
new
HashMap
<>();
this
.
responseTimes
=
new
HashMap
<>();
this
.
priorityManager
=
new
Rat
eMonotonic
();
this
.
priorityManager
=
new
Deadlin
eMonotonic
();
this
.
structure
=
structure
;
this
.
structure
=
structure
;
}
}
...
@@ -56,10 +57,11 @@ public class SchmidMottok extends AbstractTest<DagTask> {
...
@@ -56,10 +57,11 @@ public class SchmidMottok extends AbstractTest<DagTask> {
long
numberOfProcessors
=
manager
.
getNumberOfProcessors
();
long
numberOfProcessors
=
manager
.
getNumberOfProcessors
();
long
occupiedProcessors
=
0
;
long
occupiedProcessors
=
0
;
for
(
DagTask
t
:
tasks
)
{
for
(
DagTask
t
:
tasks
)
{
if
(
occupiedProcessors
>
=
numberOfProcessors
)
{
if
(
occupiedProcessors
+
t
.
getNumberOfThreads
()
<
=
numberOfProcessors
)
{
t
.
setNumberOfThreads
(
numberOfProcessors
);
occupiedProcessors
+=
t
.
getNumberOfThreads
(
);
}
else
{
}
else
{
occupiedProcessors
+=
t
.
getNumberOfThreads
();
occupiedProcessors
+=
t
.
getNumberOfThreads
();
t
.
setNumberOfThreads
(
numberOfProcessors
);
}
}
}
}
}
}
...
@@ -72,7 +74,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
...
@@ -72,7 +74,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
long
occupiedProcessors
=
0
;
long
occupiedProcessors
=
0
;
for
(
final
DagTask
t
:
tasks
)
{
for
(
final
DagTask
t
:
tasks
)
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
()
)
{
if
(
priorityManager
.
compare
(
t
,
task
)
<
0
)
{
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
occupiedProcessors
+=
numberOfThreads
;
occupiedProcessors
+=
numberOfThreads
;
}
}
...
@@ -88,7 +90,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
...
@@ -88,7 +90,7 @@ public class SchmidMottok extends AbstractTest<DagTask> {
double
taskInterference
=
0
;
double
taskInterference
=
0
;
for
(
final
DagTask
t
:
tasks
)
{
for
(
final
DagTask
t
:
tasks
)
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
()
)
{
if
(
priorityManager
.
compare
(
t
,
task
)
<
0
)
{
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
for
(
int
p
=
0
;
p
<
numberOfThreads
;
++
p
)
{
for
(
int
p
=
0
;
p
<
numberOfThreads
;
++
p
)
{
taskInterference
+=
taskInterference
+=
...
@@ -104,17 +106,17 @@ public class SchmidMottok extends AbstractTest<DagTask> {
...
@@ -104,17 +106,17 @@ public class SchmidMottok extends AbstractTest<DagTask> {
long
totalInterference
=
(
long
)
Math
.
floor
(
taskInterference
+
selfInterference
);
long
totalInterference
=
(
long
)
Math
.
floor
(
taskInterference
+
selfInterference
);
responseTime
=
minimumWcet
+
totalInterference
;
}
while
(
previousResponseTime
!=
responseTime
);
if
(
occupiedProcessors
<
numberOfProcessors
)
{
if
(
occupiedProcessors
<
numberOfProcessors
)
{
long
workloadAmongRemainingProcessors
=
long
workloadAmongRemainingProcessors
=
LongMath
.
divide
(
task
.
getWorkload
()
-
task
.
getCriticalPath
(),
LongMath
.
divide
(
task
.
getWorkload
()
-
task
.
getCriticalPath
(),
numberOfProcessors
-
occupiedProcessors
,
RoundingMode
.
FLOOR
);
numberOfProcessors
-
occupiedProcessors
,
RoundingMode
.
FLOOR
);
totalInterferenc
e
=
responseTim
e
=
Math
.
min
(
totalInterference
,
workloadAmongRemainingProcessors
);
Math
.
min
(
responseTime
,
workloadAmongRemainingProcessors
+
minimumWcet
);
}
}
responseTime
=
minimumWcet
+
totalInterference
;
}
while
(
previousResponseTime
!=
responseTime
);
return
responseTime
;
return
responseTime
;
}
}
}
}
...
...
src/main/java/mvd/jester/tests/Tester.java
View file @
1b8a538a
package
mvd
.
jester
.
tests
;
package
mvd
.
jester
.
tests
;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
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.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
com.google.common.math.LongMath
;
import
com.google.common.math.LongMath
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.SchedulingInfo
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.info.TerminationInfo
;
import
mvd.jester.info.SchedulingInfo.Feasiblity
;
import
mvd.jester.model.DagTask
;
import
mvd.jester.model.DagTask
;
import
mvd.jester.model.LightTask
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SortedTaskSet
;
import
mvd.jester.model.SystemManagerInterface
;
import
mvd.jester.model.SystemManagerInterface
;
import
mvd.jester.model.Task
;
import
mvd.jester.model.Task
;
import
mvd.jester.priority.DeadlineMonotonic
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.PriorityManager
;
import
mvd.jester.priority.RateMonotonic
;
import
mvd.jester.priority.RateMonotonic
;
public
class
Tester
extends
AbstractTest
<
DagTask
>
{
public
class
Tester
extends
AbstractTest
<
DagTask
>
{
private
final
Map
<
Task
,
TerminationInfo
>
responseTimes
;
private
final
PriorityManager
priorityManager
;
private
final
PriorityManager
priorityManager
;
private
final
TypeFunction
structure
;
public
Tester
(
TypeFunction
structure
,
final
SystemManagerInterface
manager
)
{
public
Tester
(
TypeFunction
structure
,
final
SystemManagerInterface
manager
)
{
super
(
manager
);
super
(
manager
);
this
.
responseTimes
=
new
HashMap
<>();
this
.
priorityManager
=
new
DeadlineMonotonic
();
this
.
priorityManager
=
new
RateMonotonic
();
this
.
structure
=
structure
;
}
}
@Override
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
SortedTaskSet
<
DagTask
>
tasks
)
{
public
SchedulingInfo
runSchedulabilityCheck
(
final
SortedTaskSet
<
DagTask
>
tasks
)
{
responseTimes
.
clear
();
reassignNumberOfThreads
(
tasks
);
assignNumberOfThreads
(
tasks
);
for
(
final
DagTask
t
:
tasks
)
{
final
long
responseTime
=
calculateResponseTime
(
tasks
,
t
);
responseTimes
.
put
(
t
,
new
TerminationInfo
(
t
.
getDeadline
(),
responseTime
));
}
return
new
SchedulingInfo
(
responseTimes
.
values
());
List
<
Double
>
processorBins
=
new
ArrayList
<>();
}
@Override
for
(
int
i
=
0
;
i
<
manager
.
getNumberOfProcessors
();
++
i
)
{
public
PriorityManager
getPriorityManager
()
{
processorBins
.
add
((
double
)
0
);
return
priorityManager
;
}
}
private
void
assignNumberOfThreads
(
Set
<
DagTask
>
tasks
)
{
nextTask:
for
(
DagTask
t
:
tasks
)
{
long
occupiedProcessors
=
0
;
final
long
minimumNumberOfThreads
=
t
.
getNumberOfThreads
();
long
numberOfProcessors
=
manager
.
getNumberOfProcessors
();
for
(
long
numberOfThreads
=
minimumNumberOfThreads
;
numberOfThreads
<
manager
for
(
DagTask
t
:
tasks
)
{
.
getNumberOfProcessors
();
++
numberOfThreads
)
{
long
workload
=
t
.
getWorkload
();
List
<
Double
>
copiedProcessorBins
=
copyBins
(
processorBins
);
long
criticalPath
=
t
.
getCriticalPath
();
Collections
.
sort
(
copiedProcessorBins
);
long
period
=
t
.
getPeriod
();
if
(
period
==
criticalPath
)
{
final
long
criticalPath
=
t
.
getCriticalPath
();
t
.
setNumberOfThreads
(
1
);
final
long
workload
=
t
.
getWorkload
();
}
else
if
(
occupiedProcessors
>=
numberOfProcessors
)
{
t
.
setNumberOfThreads
(
numberOfProcessors
);
final
long
processorWorkload
=
(
long
)
Math
.
ceil
(
copiedProcessorBins
.
get
(
0
)
*
t
.
getDeadline
());
final
long
workloadPerThread
=
LongMath
.
divide
(
workload
,
numberOfThreads
,
RoundingMode
.
CEILING
);
final
long
threadWorkload
=
Math
.
max
(
workloadPerThread
,
criticalPath
);
if
(
threadWorkload
+
processorWorkload
<=
t
.
getDeadline
())
{
copiedProcessorBins
.
set
(
0
,
copiedProcessorBins
.
get
(
0
)
+
(
double
)
(
threadWorkload
)
/
t
.
getPeriod
());
for
(
int
m
=
0
;
m
<
numberOfThreads
-
1
;
++
m
)
{
Collections
.
sort
(
copiedProcessorBins
);
final
long
nextProcessorWorkload
=
(
long
)
Math
.
ceil
(
copiedProcessorBins
.
get
(
0
)
*
t
.
getDeadline
());
if
(
threadWorkload
+
nextProcessorWorkload
<=
t
.
getDeadline
())
{
copiedProcessorBins
.
set
(
0
,
copiedProcessorBins
.
get
(
0
)
+
(
double
)
threadWorkload
/
t
.
getPeriod
());
}
else
{
}
else
{
final
long
numberOfThreads
=
LongMath
.
divide
(
workload
-
criticalPath
,
return
new
SchedulingInfo
(
Feasiblity
.
FAILED
);
period
-
criticalPath
,
RoundingMode
.
CEILING
);
t
.
setNumberOfThreads
(
numberOfThreads
);
occupiedProcessors
+=
numberOfThreads
;
}
}
}
}
processorBins
=
copiedProcessorBins
;
}
continue
nextTask
;
@Override
public
String
getName
()
{
return
"Tester_"
+
structure
.
getType
();
}
}
private
long
calculateResponseTime
(
final
Set
<
DagTask
>
tasks
,
final
DagTask
task
)
{
final
long
minimumWcet
=
task
.
getCriticalPath
();
long
responseTime
=
minimumWcet
;
long
previousResponseTime
=
0
;
final
long
numberOfProcessors
=
manager
.
getNumberOfProcessors
();
long
occupiedProcessors
=
0
;
for
(
final
DagTask
t
:
tasks
)
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
())
{
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
occupiedProcessors
+=
numberOfThreads
;
}
}
return
new
SchedulingInfo
(
Feasiblity
.
FAILED
);
}
}
final
double
selfInterference
=
structure
.
getSelfInterference
(
task
);
if
(
occupiedProcessors
+
structure
.
getNumberOfThreads
(
task
)
<=
numberOfProcessors
)
{
return
new
SchedulingInfo
(
Feasiblity
.
SUCCEEDED
);
return
minimumWcet
+
(
long
)
Math
.
floor
(
selfInterference
);
}
else
{
do
{
previousResponseTime
=
responseTime
;
double
taskInterference
=
0
;
for
(
final
DagTask
t
:
tasks
)
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
())
{
final
long
numberOfThreads
=
structure
.
getNumberOfThreads
(
t
);
for
(
int
p
=
0
;
p
<
numberOfThreads
;
++
p
)
{
taskInterference
+=
Math
.
min
(
structure
.
getTaskInterference
(
t
,
responseTimes
,
responseTime
,
p
+
1
),
responseTime
-
minimumWcet
+
1
);
}
}
private
void
reassignNumberOfThreads
(
Set
<
DagTask
>
tasks
)
{
for
(
DagTask
t
:
tasks
)
{
final
long
numberOfThreads
=
LongMath
.
divide
(
t
.
getWorkload
()
-
t
.
getCriticalPath
(),
t
.
getDeadline
()
-
t
.
getCriticalPath
(),
RoundingMode
.
CEILING
);
t
.
setNumberOfThreads
(
numberOfThreads
);
}
}
}
}
taskInterference
/=
numberOfProcessors
;
private
List
<
Double
>
copyBins
(
List
<
Double
>
bins
)
{
List
<
Double
>
copiedBins
=
new
ArrayList
<>();
long
totalInterference
=
(
long
)
Math
.
floor
(
taskInterference
+
selfInterference
);
for
(
Double
b
:
bins
)
{
copiedBins
.
add
(
b
.
doubleValue
());
if
(
occupiedProcessors
<
numberOfProcessors
)
{
long
workloadAmongRemainingProcessors
=
LongMath
.
divide
(
task
.
getWorkload
()
-
task
.
getCriticalPath
(),
numberOfProcessors
-
occupiedProcessors
,
RoundingMode
.
FLOOR
);
totalInterference
=
Math
.
min
(
totalInterference
,
workloadAmongRemainingProcessors
);
}
}
responseTime
=
minimumWcet
+
totalInterference
;
return
copiedBins
;
}
while
(
previousResponseTime
!=
responseTime
);
}
return
responseTime
;
@Override
public
PriorityManager
getPriorityManager
()
{
return
priorityManager
;
}
}
@Override
public
String
getName
()
{
return
"Tester"
;
}
}
}
}
src/main/java/mvd/jester/tests/UeterAgrawal.java
0 → 100644
View file @
1b8a538a
package
mvd
.
jester
.
tests
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
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.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.EarliestDeadlineFirst
;
import
mvd.jester.priority.PriorityManager
;
public
class
UeterAgrawal
extends
AbstractTest
<
DagTask
>
{
private
final
EarliestDeadlineFirst
priorityManager
;
private
final
Map
<
DagTask
,
Double
>
stretchRatios
;
public
UeterAgrawal
(
SystemManagerInterface
manager
)
{
super
(
manager
);
this
.
priorityManager
=
new
EarliestDeadlineFirst
();
this
.
stretchRatios
=
new
HashMap
<>();
}
@Override
public
SchedulingInfo
runSchedulabilityCheck
(
SortedTaskSet
<
DagTask
>
tasks
)
{
stretchRatios
.
clear
();
assignThreadsAndStretchRatio
(
tasks
);
List
<
Double
>
bins
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
manager
.
getNumberOfProcessors
();
++
i
)
{
bins
.
add
((
double
)
0
);
}
for
(
DagTask
t
:
tasks
)
{
if
(
t
.
getNumberOfThreads
()
==
1
)
{
// Light task
if
(!
bestFitBinPackingOfTask
(
bins
,
t
))
{
return
new
SchedulingInfo
(
Feasiblity
.
FAILED
);
}
}
else
{
// heavy task
boolean
failure
=
true
;
long
numberOfServers
=
0
;
List
<
Double
>
binsWithTask
=
copyBins
(
bins
);
final
List
<
Task
>
listOfServerTasks
=
new
ArrayList
<>();
listOfServerTasks
.
add
(
t
);
while
(
numberOfServers
<=
checkNumberOfServers
(
t
))
{
if
(!
binPackingOfServers
(
binsWithTask
,
listOfServerTasks
))
{
binsWithTask
=
copyBins
(
bins
);
numberOfServers
+=
1
;
listOfServerTasks
.
clear
();
for
(
int
l
=
0
;
l
<
numberOfServers
;
++
l
)
{
long
reservationBudget
=
(
long
)
Math
.
ceil
((
double
)
t
.
getWorkload
()
/
numberOfServers
+
(
1
-
(
double
)
1
/
numberOfServers
)
*
t
.
getCriticalPath
());
listOfServerTasks
.
add
(
new
LightTask
(
t
.
getPeriod
(),
t
.
getDeadline
(),
reservationBudget
));
}
}
else
{
failure
=
false
;
bins
=
binsWithTask
;
break
;
}
}
if
(
failure
)
{
return
new
SchedulingInfo
(
Feasiblity
.
FAILED
);
}
}
}
return
new
SchedulingInfo
(
Feasiblity
.
SUCCEEDED
);
}
private
List
<
Double
>
copyBins
(
List
<
Double
>
bins
)
{
List
<
Double
>
copiedBins
=
new
ArrayList
<>();
for
(
Double
b
:
bins
)
{
copiedBins
.
add
(
b
.
doubleValue
());
}
return
copiedBins
;
}
private
long
checkNumberOfServers
(
DagTask
task
)
{
final
long
criticalPath
=
task
.
getCriticalPath
();
final
long
workload
=
task
.
getWorkload
();
final
double
strechRatio
=
stretchRatios
.
get
(
task
);
final
long
first
=
LongMath
.
divide
(
workload
,
criticalPath
,
RoundingMode
.
CEILING
);
final
long
second
=
(
long
)
Math
.
ceil
(((
double
)
workload
-
criticalPath
)
/
(
criticalPath
*
(
strechRatio
-
1
)));
// TODO: include fucking boundaries
final
long
max
=
Math
.
max
(
first
,
second
);
return
max
;
}
private
boolean
binPackingOfServers
(
List
<
Double
>
bins
,
List
<
Task
>
tasks
)
{
for
(
Task
t
:
tasks
)
{
if
(!
bestFitBinPackingOfTask
(
bins
,
t
))
{
return
false
;
}
}
return
true
;
}
private
boolean
bestFitBinPackingOfTask
(
List
<
Double
>
bins
,
Task
task
)
{
int
bestFit
=
0
;
// No one at first
for
(
int
b
=
0
;
b
<
bins
.
size
();
++
b
)
{
if
(
bins
.
get
(
b
)
+
task
.
getDensity
()
<=
1
)
{
double
currentBin
=
bins
.
get
(
b
);
double
bestBin
=
bins
.
get
(
bestFit
);
if
(
currentBin
+
task
.
getDensity
()
>
bestBin
+
task
.
getDensity
()
||
bestBin
+
task
.
getDensity
()
>
1
)
{
bestFit
=
b
;
}
}
}
if
(
bins
.
get
(
bestFit
)
+
task
.
getDensity
()
<=
1
)
{
bins
.
set
(
bestFit
,
bins
.
get
(
bestFit
)
+
task
.
getDensity
());
return
true
;
}
return
false
;
}
private
boolean
firstFitBinPackingOfTask
(
List
<
Double
>
bins
,
Task
task
)
{
Collections
.
sort
(
bins
);
Collections
.
reverse
(
bins
);
for
(
int
b
=
0
;
b
<
bins
.
size
();
++
b
)
{
if
(
bins
.
get
(
b
)
+
task
.
getDensity
()
<=
1
)
{
bins
.
set
(
b
,
bins
.
get
(
b
)
+
task
.
getDensity
());
return
true
;
}
}
return
false
;
}
private
boolean
worstFitBinPackingOfTask
(
List
<
Double
>
bins
,
Task
task
)
{
Collections
.
sort
(
bins
);
if
(
bins
.
get
(
0
)
+
task
.
getDensity
()
<=
1
)
{
bins
.
set
(
0
,
bins
.
get
(
0
)
+
task
.
getDensity
());
return
true
;
}
else
{
return
false
;
}
}
private
void
assignThreadsAndStretchRatio
(
Set
<
DagTask
>
tasks
)
{
for
(
DagTask
t
:
tasks
)
{
final
long
criticalPath
=
t
.
getCriticalPath
();
final
long
workload
=
t
.
getWorkload
();
long
numberOfThreads
=
LongMath
.
divide
(
workload
-
criticalPath
,
t
.
getDeadline
()
-
criticalPath
,
RoundingMode
.
CEILING
);
if
(
numberOfThreads
==
0
)
{
numberOfThreads
=
1
;
}
t
.
setNumberOfThreads
(
numberOfThreads
);
final
double
stretchRatio
=
1
+
((
double
)
workload
-
criticalPath
)
/
(
numberOfThreads
*
criticalPath
);
stretchRatios
.
put
(
t
,
stretchRatio
);
}
}
@Override
public
PriorityManager
getPriorityManager
()
{
return
priorityManager
;
}
@Override
public
String
getName
()
{
return
"UeterAgrawal"
;
}
}
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