Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Tobias Langer
/
experiment
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
0c8665f9
authored
8 years ago
by
Tobias Langer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted for smaller hyperperiods.
parent
14aaeabd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
3 deletions
+46
-3
tasksetgen.py
+46
-3
No files found.
tasksetgen.py
View file @
0c8665f9
...
...
@@ -3,7 +3,7 @@
"""
Generates real time tasksets according to the method described in 'A Comparison
of Global and Partitioned EDF Schedulability Tests for Multiprocessors'.
Therefore tasks with random periods within the range 1 to 100
0
are generated.
Therefore tasks with random periods within the range 1 to 100 are generated.
Depending on the mode, the utilization of these tasks is either determined by
* uniform distribution between 1/period and 1
* bimodal distribution heavy tasks with uniform distribution between 0.5 / 1 and
...
...
@@ -14,13 +14,47 @@ is 1/3
"""
import
datetime
import
shutil
import
sys
import
os
import
random
import
argparse
import
json
import
math
from
enum
import
Enum
def
query_yes_no
(
question
,
default
=
None
):
"""
Queries the user for a decision.
"""
if
default
is
None
:
prompt
=
' [y/n]'
elif
default
.
lower
()
==
'yes'
:
prompt
=
' [Y/n]'
elif
default
.
lower
()
==
'no'
:
prompt
=
' [y/N]'
else
:
raise
ValueError
(
'Invalid default answer {}'
.
format
(
default
))
while
True
:
print
(
question
,
prompt
,
end
=
''
)
choice
=
input
()
.
lower
()
if
'yes'
.
find
(
choice
)
==
0
:
return
True
elif
'no'
.
find
(
choice
)
==
0
:
return
False
def
lcm
(
a
,
b
):
return
(
a
*
b
)
/
math
.
gcd
(
a
,
b
)
def
hyperperiod
(
tasks
):
periods
=
[
x
.
period
for
task
in
tasks
]
hyperperiod
=
periods
[
0
]
for
period
in
periods
[
1
:]:
hyperperiod
=
lcm
(
hyperperiod
,
period
)
return
hyperperiod
class
Timebase
(
Enum
):
seconds
=
1
milliseconds
=
2
...
...
@@ -59,7 +93,7 @@ def get_timebase_string(base):
return
'std::chrono::nanoseconds'
,
'embb::base::DurationNanoseconds'
def
create_task
(
distribution
):
period
=
random
.
uniform
(
1
,
100
0
)
period
=
random
.
uniform
(
1
,
3
0
)
if
distribution
is
Distribution
.
uniform
:
util
=
random
.
uniform
(
1.0
/
period
,
1.0
)
elif
distribution
is
Distribution
.
bimodal
:
...
...
@@ -140,7 +174,8 @@ def main():
while
len
(
tasksets
)
<
args
.
tasksetcount
:
taskset
=
[]
while
len
(
taskset
)
<
args
.
cores
+
1
or
\
check_taskset
(
args
.
cores
,
taskset
)
<=
1
:
check_taskset
(
args
.
cores
,
taskset
)
<=
1
and
\
hyperperiod
(
taskset
)
<
300000
:
# Limit hyperperiod to 5 minutes
taskset
.
append
(
create_task
(
distribution
))
if
len
(
taskset
)
>=
args
.
cores
+
1
:
tasksets
.
append
(
taskset
)
...
...
@@ -149,6 +184,14 @@ def main():
cpp_base
,
embb_base
=
get_timebase_string
(
timebase
)
try
:
os
.
makedirs
(
args
.
target
)
except
FileExistsError
:
if
not
query_yes_no
(
'Folder exists, remove?'
,
default
=
'yes'
):
sys
.
exit
(
1
)
shutil
.
rmtree
(
args
.
target
)
os
.
makedirs
(
args
.
target
)
print
(
'Writing tasks…'
,
file
=
sys
.
stderr
)
for
taskset
in
tasksets
:
task_out
=
[]
...
...
This diff is collapsed.
Click to expand it.
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