Commit 0c8665f9 by Tobias Langer

Adjusted for smaller hyperperiods.

parent 14aaeabd
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
""" """
Generates real time tasksets according to the method described in 'A Comparison Generates real time tasksets according to the method described in 'A Comparison
of Global and Partitioned EDF Schedulability Tests for Multiprocessors'. of Global and Partitioned EDF Schedulability Tests for Multiprocessors'.
Therefore tasks with random periods within the range 1 to 1000 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 Depending on the mode, the utilization of these tasks is either determined by
* uniform distribution between 1/period and 1 * uniform distribution between 1/period and 1
* bimodal distribution heavy tasks with uniform distribution between 0.5 / 1 and * bimodal distribution heavy tasks with uniform distribution between 0.5 / 1 and
...@@ -14,13 +14,47 @@ is 1/3 ...@@ -14,13 +14,47 @@ is 1/3
""" """
import datetime import datetime
import shutil
import sys import sys
import os import os
import random import random
import argparse import argparse
import json import json
import math
from enum import Enum 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): class Timebase(Enum):
seconds = 1 seconds = 1
milliseconds = 2 milliseconds = 2
...@@ -59,7 +93,7 @@ def get_timebase_string(base): ...@@ -59,7 +93,7 @@ def get_timebase_string(base):
return 'std::chrono::nanoseconds', 'embb::base::DurationNanoseconds' return 'std::chrono::nanoseconds', 'embb::base::DurationNanoseconds'
def create_task(distribution): def create_task(distribution):
period = random.uniform(1, 1000) period = random.uniform(1, 30)
if distribution is Distribution.uniform: if distribution is Distribution.uniform:
util = random.uniform(1.0 / period, 1.0) util = random.uniform(1.0 / period, 1.0)
elif distribution is Distribution.bimodal: elif distribution is Distribution.bimodal:
...@@ -140,7 +174,8 @@ def main(): ...@@ -140,7 +174,8 @@ def main():
while len(tasksets) < args.tasksetcount: while len(tasksets) < args.tasksetcount:
taskset = [] taskset = []
while len(taskset) < args.cores + 1 or \ 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)) taskset.append(create_task(distribution))
if len(taskset) >= args.cores + 1: if len(taskset) >= args.cores + 1:
tasksets.append(taskset) tasksets.append(taskset)
...@@ -149,6 +184,14 @@ def main(): ...@@ -149,6 +184,14 @@ def main():
cpp_base, embb_base = get_timebase_string(timebase) 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) print('Writing tasks…', file=sys.stderr)
for taskset in tasksets: for taskset in tasksets:
task_out = [] task_out = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment