From fb72dd09cfc16d0260363d38df1225b6663bc084 Mon Sep 17 00:00:00 2001 From: Namhoon Kim Date: Tue, 4 Apr 2017 03:35:59 +0000 Subject: MC2 support --- gen/edf_generators.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'gen/edf_generators.py') diff --git a/gen/edf_generators.py b/gen/edf_generators.py index 8e4b8df..c769e46 100644 --- a/gen/edf_generators.py +++ b/gen/edf_generators.py @@ -6,6 +6,7 @@ TP_TBASE = """#for $t in $task_set #end for""" TP_GLOB_TASK = TP_TBASE.format("") TP_PART_TASK = TP_TBASE.format("-p $t.cpu") +TP_MC_TASK = TP_TBASE.format("-p $t.cpu -m $t.crit -i $t.id") class EdfGenerator(gen.Generator): '''Creates sporadic task sets with the most common Litmus options.''' @@ -16,7 +17,7 @@ class EdfGenerator(gen.Generator): def __make_options(self): '''Return generic EDF options.''' - return [gen.Generator._dist_option('utils', 'uni-medium', + return [gen.Generator._dist_option('utils', 'uni-very-light', gen.NAMED_UTILIZATIONS, 'Task utilization distributions.'), gen.Generator._dist_option('periods', 'harmonic', @@ -87,3 +88,33 @@ class GedfGenerator(EdfGenerator): def __init__(self, params={}): super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK], [], params) + +class Mc2Generator(EdfGenerator): + def __init__(self, params={}): + super(Mc2Generator, self).__init__("MC2", [TP_MC_TASK], + [], params) + + def _customize(self, taskset, exp_params): + cpus = exp_params['cpus'] + start = 0 + + # Partition using worst-fit for most even distribution + utils = [0]*cpus + tasks = [0]*cpus + index = [1]*cpus + taskset = sorted(taskset, key=lambda task: task.period) + for t in taskset: + t.cpu = utils.index(min(utils)) + t.id = index[t.cpu] + if utils[t.cpu] < 0.05: + t.crit = 0 + elif utils[t.cpu] < 0.10: + t.crit = 1 + else: + t.crit = 2 + utils[t.cpu] += t.utilization() + tasks[t.cpu] += 1 + index[t.cpu] += 1 + + # Increment by one so release master has no tasks + t.cpu += start -- cgit v1.2.2