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
8768d1a4
authored
Jul 15, 2019
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor changes, TestEnvironment modified for logging
parent
0232b488
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
21 deletions
+107
-21
src/main/java/mvd/jester/App.java
+2
-2
src/main/java/mvd/jester/model/SystemSetup.java
+6
-2
src/main/java/mvd/jester/tests/AbstractTest.java
+1
-1
src/main/java/mvd/jester/tests/MaiaBertogna.java
+8
-4
src/main/java/mvd/jester/tests/SchmidMottok.java
+5
-4
src/main/java/mvd/jester/tests/TestEnvironment.java
+39
-8
src/main/java/mvd/jester/utils/Logger.java
+46
-0
No files found.
src/main/java/mvd/jester/App.java
View file @
8768d1a4
...
...
@@ -11,9 +11,9 @@ import mvd.jester.tests.TestEnvironment;
*/
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
SystemSetup
.
Builder
generator
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
4
);
SystemSetup
.
Builder
builder
=
new
SystemSetup
.
Builder
().
setNumberOfProcessors
(
8
);
TestEnvironment
te
=
new
TestEnvironment
(
generator
,
1
0000
);
TestEnvironment
te
=
new
TestEnvironment
(
builder
,
4
0000
);
te
.
registerTestInterface
(
SchmidMottok
.
class
);
te
.
registerTestInterface
(
MaiaBertogna
.
class
);
...
...
src/main/java/mvd/jester/model/SystemSetup.java
View file @
8768d1a4
...
...
@@ -74,6 +74,7 @@ public class SystemSetup {
}
private
long
randomNumberOfJobs
()
{
this
.
maxNumberOfJobs
=
3
*
this
.
numberOfProcessors
/
2
;
return
ThreadLocalRandom
.
current
().
nextLong
(
minNumberOfJobs
,
maxNumberOfJobs
);
}
...
...
@@ -93,10 +94,13 @@ public class SystemSetup {
}
else
{
numberOfSegments
=
1
;
}
long
parallelNumberOfJobs
=
serial
?
1
:
randomNumberOfJobs
();
for
(
int
i
=
0
;
i
<
numberOfSegments
;
++
i
)
{
serial
=
i
%
2
==
0
;
long
numberOfJobs
=
1
;
if
(
i
%
2
==
1
)
{
numberOfJobs
=
parallelNumberOfJobs
;
}
long
wcet
=
randomWcet
(
period
,
numberOfSegments
);
long
numberOfJobs
=
serial
?
1
:
randomNumberOfJobs
();
segments
.
add
(
new
Segment
(
wcet
,
numberOfJobs
));
}
return
new
Task
(
period
,
segments
);
...
...
src/main/java/mvd/jester/tests/AbstractTest.java
View file @
8768d1a4
...
...
@@ -9,7 +9,7 @@ import mvd.jester.model.Task;
*/
public
abstract
class
AbstractTest
implements
TestInterface
{
protected
Map
<
Task
,
Long
>
responseTimes
;
protected
final
Map
<
Task
,
Long
>
responseTimes
;
public
AbstractTest
()
{
this
.
responseTimes
=
new
HashMap
<
Task
,
Long
>();
...
...
src/main/java/mvd/jester/tests/MaiaBertogna.java
View file @
8768d1a4
...
...
@@ -46,19 +46,18 @@ public class MaiaBertogna extends AbstractTest {
do
{
previousResponseTime
=
responseTime
;
long
i
nterference
=
0
;
long
taskI
nterference
=
0
;
for
(
Task
t
:
systemSetup
.
getTasks
())
{
if
(
t
.
getPeriod
()
<
task
.
getPeriod
())
{
long
maxNumberOfJobsOfT
=
t
.
getMaximumParallelism
();
for
(
int
p
=
0
;
p
<
maxNumberOfJobsOfT
;
++
p
)
{
i
nterference
+=
Math
.
min
(
getTaskInterference
(
t
,
responseTime
,
p
+
1
),
taskI
nterference
+=
Math
.
min
(
getTaskInterference
(
t
,
responseTime
,
p
+
1
),
responseTime
-
minimumWcet
+
1
);
}
}
}
double
taskInterference
=
(
double
)
interference
/
systemSetup
.
getNumberOfProcessors
();
long
selfInterference
=
0
;
long
maxNumberOfJobs
=
task
.
getMaximumParallelism
();
...
...
@@ -67,7 +66,8 @@ public class MaiaBertogna extends AbstractTest {
Math
.
min
(
getSelfInterference
(
task
,
p
+
1
),
responseTime
-
minimumWcet
+
1
);
}
long
totalInterference
=
(
long
)
Math
.
floor
(
taskInterference
+
selfInterference
);
long
totalInterference
=
LongMath
.
divide
(
taskInterference
+
selfInterference
,
systemSetup
.
getNumberOfProcessors
(),
RoundingMode
.
FLOOR
);
responseTime
=
minimumWcet
+
totalInterference
;
}
while
(
previousResponseTime
!=
responseTime
);
...
...
@@ -89,6 +89,7 @@ public class MaiaBertogna extends AbstractTest {
}
private
long
getTaskInterference
(
Task
task
,
long
interval
,
long
parallelism
)
{
if
(
responseTimes
.
containsKey
(
task
))
{
long
responseTime
=
responseTimes
.
get
(
task
);
long
minWcet
=
getMinimumWcet
(
task
);
long
period
=
task
.
getPeriod
();
...
...
@@ -107,6 +108,9 @@ public class MaiaBertogna extends AbstractTest {
long
interference
=
numberOfJobs
*
workload
;
return
interference
;
}
else
{
throw
new
RuntimeException
(
"Task was not found in task set!"
);
}
}
private
long
getMinimumWcet
(
Task
task
)
{
...
...
src/main/java/mvd/jester/tests/SchmidMottok.java
View file @
8768d1a4
...
...
@@ -72,14 +72,15 @@ public class SchmidMottok extends AbstractTest {
private
double
getSelfInterference
(
Task
task
)
{
double
interference
=
0
;
long
numberOfProcessors
=
systemSetup
.
getNumberOfProcessors
();
long
numberOfJobs
=
task
.
getMaximumParallelism
()
>
numberOfProcessors
?
numberOfProcessors
:
task
.
getMaximumParallelism
();
for
(
Segment
s
:
task
.
getSegments
())
{
long
numberOfJobs
=
s
.
getNumberOfJobs
()
>
numberOfProcessors
?
numberOfProcessors
:
s
.
getNumberOfJobs
();
interference
+=
(
double
)
(
s
.
getNumberOfTasklets
()
-
1
)
*
s
.
getTaskletWcet
()
/
numberOfJobs
;
interference
+=
(
double
)
(
s
.
getNumberOfTasklets
()
-
1
)
*
s
.
getTaskletWcet
();
}
interference
/=
numberOfJobs
;
return
interference
;
}
...
...
src/main/java/mvd/jester/tests/TestEnvironment.java
View file @
8768d1a4
package
mvd
.
jester
.
tests
;
import
java.lang.reflect.Constructor
;
import
java.time.LocalTime
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
mvd.jester.model.SystemSetup
;
import
mvd.jester.utils.Logger
;
/**
* TestEnvironment
...
...
@@ -36,17 +38,18 @@ public class TestEnvironment {
}
public
void
runTests
()
{
Map
<
AbstractTest
,
Long
>
testCases
=
new
HashMap
<>();
Set
<
AbstractTest
>
testCases
=
new
HashSet
<>();
Map
<
Long
,
Map
<
AbstractTest
,
Long
>>
results
=
new
HashMap
<>();
for
(
Constructor
<?
extends
AbstractTest
>
t
:
abstractTests
)
{
try
{
testCases
.
put
(
t
.
newInstance
(
this
.
systemSetup
),
(
long
)
0
);
testCases
.
add
(
t
.
newInstance
(
this
.
systemSetup
)
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Ahhh SHIT!"
);
}
}
long
checkedTasksets
=
0
;
while
(
checkedTasksets
<
numberOfTaskSets
)
{
...
...
@@ -58,9 +61,13 @@ public class TestEnvironment {
&&
checkedTasksets
<
numberOfTaskSets
)
{
checkedTasksets
++;
for
(
AbstractTest
t
:
testCases
.
keySet
())
{
long
roundedUtilization
=
(
long
)
(
utilization
*
10
);
for
(
AbstractTest
t
:
testCases
)
{
if
(
t
.
runSchedulabilityCheck
())
{
testCases
.
computeIfPresent
(
t
,
(
k
,
v
)
->
v
+
1
);
results
.
computeIfAbsent
(
roundedUtilization
,
k
->
new
HashMap
<
AbstractTest
,
Long
>())
.
compute
(
t
,
(
k
,
v
)
->
(
v
==
null
)
?
1
:
v
+
1
);
}
}
builder
.
addTask
(
systemSetup
);
...
...
@@ -69,12 +76,36 @@ public class TestEnvironment {
}
}
logResults
(
testCases
,
results
);
}
private
void
logResults
(
Set
<
AbstractTest
>
testCases
,
Map
<
Long
,
Map
<
AbstractTest
,
Long
>>
results
)
{
LocalTime
date
=
LocalTime
.
now
();
Logger
log
=
new
Logger
(
"results_"
+
systemSetup
.
getNumberOfProcessors
()
+
"_"
+
date
.
getHour
()
+
":"
+
date
.
getMinute
()
+
".txt"
);
String
firstLine
=
new
String
(
"Utilization"
);
for
(
AbstractTest
t
:
testCases
.
keySet
())
{
System
.
out
.
println
(
"Testcase "
+
t
.
getName
()
+
" scheduled "
+
testCases
.
get
(
t
)
+
" of "
+
numberOfTaskSets
+
" tasks!"
);
for
(
AbstractTest
t
:
testCases
)
{
firstLine
=
firstLine
+
"\t"
+
t
.
getName
();
}
log
.
log
(
firstLine
);
for
(
Long
util
:
results
.
keySet
())
{
String
line
=
String
.
valueOf
((
double
)
util
/
10
);
Map
<
AbstractTest
,
Long
>
tests
=
results
.
get
(
util
);
for
(
AbstractTest
t
:
testCases
)
{
if
(
tests
.
containsKey
(
t
))
{
line
+=
"\t"
+
tests
.
get
(
t
);
}
else
{
line
+=
"\t"
+
"0"
;
}
}
log
.
log
(
line
);
}
log
.
finalize
();
}
}
src/main/java/mvd/jester/utils/Logger.java
0 → 100644
View file @
8768d1a4
package
mvd
.
jester
.
utils
;
import
java.io.BufferedWriter
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
/**
* Logger
*/
public
class
Logger
{
private
FileWriter
fileWriter
;
private
BufferedWriter
bufferedWriter
;
private
PrintWriter
printWriter
;
public
Logger
(
String
pathToFile
)
{
try
{
fileWriter
=
new
FileWriter
(
pathToFile
,
true
);
bufferedWriter
=
new
BufferedWriter
(
fileWriter
);
printWriter
=
new
PrintWriter
(
bufferedWriter
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Could not create file!"
);
}
}
public
void
log
(
String
line
)
{
printWriter
.
println
(
line
);
}
public
void
finalize
()
{
try
{
if
(
printWriter
!=
null
)
{
printWriter
.
close
();
// Will close bw and fw too
}
if
(
bufferedWriter
!=
null
)
{
bufferedWriter
.
close
();
// Will close fw too
}
if
(
fileWriter
!=
null
)
{
fileWriter
.
close
();
}
}
catch
(
Exception
e
)
{
}
}
}
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