aboutsummaryrefslogtreecommitdiffstats
path: root/gen/edf_generators.py
diff options
context:
space:
mode:
Diffstat (limited to 'gen/edf_generators.py')
-rw-r--r--gen/edf_generators.py33
1 files changed, 32 insertions, 1 deletions
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
6#end for""" 6#end for"""
7TP_GLOB_TASK = TP_TBASE.format("") 7TP_GLOB_TASK = TP_TBASE.format("")
8TP_PART_TASK = TP_TBASE.format("-p $t.cpu") 8TP_PART_TASK = TP_TBASE.format("-p $t.cpu")
9TP_MC_TASK = TP_TBASE.format("-p $t.cpu -m $t.crit -i $t.id")
9 10
10class EdfGenerator(gen.Generator): 11class EdfGenerator(gen.Generator):
11 '''Creates sporadic task sets with the most common Litmus options.''' 12 '''Creates sporadic task sets with the most common Litmus options.'''
@@ -16,7 +17,7 @@ class EdfGenerator(gen.Generator):
16 17
17 def __make_options(self): 18 def __make_options(self):
18 '''Return generic EDF options.''' 19 '''Return generic EDF options.'''
19 return [gen.Generator._dist_option('utils', 'uni-medium', 20 return [gen.Generator._dist_option('utils', 'uni-very-light',
20 gen.NAMED_UTILIZATIONS, 21 gen.NAMED_UTILIZATIONS,
21 'Task utilization distributions.'), 22 'Task utilization distributions.'),
22 gen.Generator._dist_option('periods', 'harmonic', 23 gen.Generator._dist_option('periods', 'harmonic',
@@ -87,3 +88,33 @@ class GedfGenerator(EdfGenerator):
87 def __init__(self, params={}): 88 def __init__(self, params={}):
88 super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK], 89 super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK],
89 [], params) 90 [], params)
91
92class Mc2Generator(EdfGenerator):
93 def __init__(self, params={}):
94 super(Mc2Generator, self).__init__("MC2", [TP_MC_TASK],
95 [], params)
96
97 def _customize(self, taskset, exp_params):
98 cpus = exp_params['cpus']
99 start = 0
100
101 # Partition using worst-fit for most even distribution
102 utils = [0]*cpus
103 tasks = [0]*cpus
104 index = [1]*cpus
105 taskset = sorted(taskset, key=lambda task: task.period)
106 for t in taskset:
107 t.cpu = utils.index(min(utils))
108 t.id = index[t.cpu]
109 if utils[t.cpu] < 0.05:
110 t.crit = 0
111 elif utils[t.cpu] < 0.10:
112 t.crit = 1
113 else:
114 t.crit = 2
115 utils[t.cpu] += t.utilization()
116 tasks[t.cpu] += 1
117 index[t.cpu] += 1
118
119 # Increment by one so release master has no tasks
120 t.cpu += start