diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-03-30 11:28:51 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-02 10:38:21 -0400 |
commit | 4b75d2b98036195b78d339210ab8d7512d9f2164 (patch) | |
tree | f7de0e91372f760ab8972c5e280023d57abb6b91 /gen/edf_generators.py | |
parent | cb0dda981282df08c544e235f0fefb077268272c (diff) |
Added option to ignore environment issues and rewrote part of the generation scripts for easier generator creation.
Diffstat (limited to 'gen/edf_generators.py')
-rw-r--r-- | gen/edf_generators.py | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/gen/edf_generators.py b/gen/edf_generators.py index c7267f7..9bf6b8f 100644 --- a/gen/edf_generators.py +++ b/gen/edf_generators.py | |||
@@ -1,15 +1,20 @@ | |||
1 | import generator as gen | 1 | import generator as gen |
2 | import random | 2 | import random |
3 | import schedcat.generator.tasks as tasks | 3 | |
4 | TP_TBASE = """#for $t in $task_set | ||
5 | {} $t.cost $t.period | ||
6 | #end for""" | ||
7 | TP_GLOB_TASK = TP_TBASE.format("") | ||
8 | TP_PART_TASK = TP_TBASE.format("-p $t.cpu") | ||
4 | 9 | ||
5 | class EdfGenerator(gen.Generator): | 10 | class EdfGenerator(gen.Generator): |
6 | '''Creates sporadic task sets with the most common Litmus options.''' | 11 | '''Creates sporadic task sets with the most common Litmus options.''' |
7 | def __init__(self, name, templates, options, params): | 12 | def __init__(self, name, templates, options, params): |
8 | super(EdfGenerator, self).__init__(name, templates, | 13 | super(EdfGenerator, self).__init__(name, templates, |
9 | self.__make_options(params) + options, | 14 | self.__make_options() + options, |
10 | params) | 15 | params) |
11 | 16 | ||
12 | def __make_options(self, params): | 17 | def __make_options(self): |
13 | '''Return generic EDF options.''' | 18 | '''Return generic EDF options.''' |
14 | return [gen.Generator._dist_option('utils', ['uni-medium'], | 19 | return [gen.Generator._dist_option('utils', ['uni-medium'], |
15 | gen.NAMED_UTILIZATIONS, | 20 | gen.NAMED_UTILIZATIONS, |
@@ -26,23 +31,12 @@ class EdfGenerator(gen.Generator): | |||
26 | udist = self._create_dist('utilization', | 31 | udist = self._create_dist('utilization', |
27 | exp_params['utils'], | 32 | exp_params['utils'], |
28 | gen.NAMED_UTILIZATIONS) | 33 | gen.NAMED_UTILIZATIONS) |
29 | tg = tasks.TaskGenerator(period=pdist, util=udist) | ||
30 | 34 | ||
31 | ts = [] | 35 | ts = self._create_taskset(exp_params, pdist, udist) |
32 | tries = 0 | ||
33 | while len(ts) != exp_params['num_tasks'] and tries < 5: | ||
34 | ts = tg.make_task_set(max_tasks = exp_params['num_tasks']) | ||
35 | tries += 1 | ||
36 | if len(ts) != exp_params['num_tasks']: | ||
37 | print("Failed to create task set with parameters: %s" % exp_params) | ||
38 | 36 | ||
39 | self._customize(ts, exp_params) | 37 | self._customize(ts, exp_params) |
40 | 38 | ||
41 | exp_params['task_set'] = ts | 39 | self._write_schedule(dict(exp_params.items() + ('task_set', ts))) |
42 | self._write_schedule(exp_params) | ||
43 | |||
44 | del exp_params['task_set'] | ||
45 | del exp_params['num_tasks'] | ||
46 | self._write_params(exp_params) | 40 | self._write_params(exp_params) |
47 | 41 | ||
48 | def _customize(self, taskset, exp_params): | 42 | def _customize(self, taskset, exp_params): |
@@ -53,7 +47,7 @@ class EdfGenerator(gen.Generator): | |||
53 | class PartitionedGenerator(EdfGenerator): | 47 | class PartitionedGenerator(EdfGenerator): |
54 | def __init__(self, name, templates, options, params): | 48 | def __init__(self, name, templates, options, params): |
55 | super(PartitionedGenerator, self).__init__(name, | 49 | super(PartitionedGenerator, self).__init__(name, |
56 | templates + [gen.TP_PART_TASK], options, params) | 50 | templates + [TP_PART_TASK], options, params) |
57 | 51 | ||
58 | def _customize(self, taskset, exp_params): | 52 | def _customize(self, taskset, exp_params): |
59 | start = 1 if exp_params['release_master'] else 0 | 53 | start = 1 if exp_params['release_master'] else 0 |
@@ -78,5 +72,5 @@ class CedfGenerator(PartitionedGenerator): | |||
78 | 72 | ||
79 | class GedfGenerator(EdfGenerator): | 73 | class GedfGenerator(EdfGenerator): |
80 | def __init__(self, params={}): | 74 | def __init__(self, params={}): |
81 | super(GedfGenerator, self).__init__("GSN-EDF", [gen.TP_GLOB_TASK], | 75 | super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK], |
82 | [], params) | 76 | [], params) |