diff options
author | Jeremy Erickson <jerickso@cs.unc.edu> | 2010-11-02 12:37:14 -0400 |
---|---|---|
committer | Jeremy Erickson <jerickso@cs.unc.edu> | 2010-11-02 12:37:14 -0400 |
commit | 2701b0022c6c409d2172753aed48d616e789b98c (patch) | |
tree | b3a12e39e8f882374f78508ab2733594244fb256 | |
parent | e9c900fae35e4e4730469e189ff17bf30518346a (diff) |
Updated Mixed Criticality stuffwip-mc-jerickso
-rw-r--r-- | bin/rt_launch.c | 20 | ||||
-rw-r--r-- | bin/rtspin.c | 18 | ||||
-rw-r--r-- | include/litmus.h | 11 | ||||
-rw-r--r-- | src/litmus.c | 8 | ||||
-rw-r--r-- | src/task.c | 9 |
5 files changed, 49 insertions, 17 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 3863031..f3fda65 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
@@ -29,11 +29,12 @@ int launch(void *task_info_p) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | void usage(char *error) { | 31 | void usage(char *error) { |
32 | fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p cpu][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" | 32 | fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p cpu][-c hrt | srt | be][-r criticality] wcet period program [arg1 arg2 ...]\n" |
33 | "\t-w\tSynchronous release\n" | 33 | "\t-w\tSynchronous release\n" |
34 | "\t-v\tVerbose\n" | 34 | "\t-v\tVerbose\n" |
35 | "\t-p\tcpu (or initial cpu)\n" | 35 | "\t-p\tcpu (or initial cpu)\n" |
36 | "\t-c\tClass\n" | 36 | "\t-c\tClass\n" |
37 | "\t-r\tCriticality\n" | ||
37 | "\twcet, period in ms\n" | 38 | "\twcet, period in ms\n" |
38 | "\tprogram to be launched\n", | 39 | "\tprogram to be launched\n", |
39 | error); | 40 | error); |
@@ -41,13 +42,14 @@ void usage(char *error) { | |||
41 | } | 42 | } |
42 | 43 | ||
43 | 44 | ||
44 | #define OPTSTR "p:c:vw" | 45 | #define OPTSTR "p:c:r:vw" |
45 | 46 | ||
46 | int main(int argc, char** argv) | 47 | int main(int argc, char** argv) |
47 | { | 48 | { |
48 | int ret; | 49 | int ret; |
49 | lt_t wcet; | 50 | lt_t wcet; |
50 | lt_t period; | 51 | lt_t period; |
52 | int criticality = 0; | ||
51 | int migrate = 0; | 53 | int migrate = 0; |
52 | int cpu = 0; | 54 | int cpu = 0; |
53 | int opt; | 55 | int opt; |
@@ -73,6 +75,17 @@ int main(int argc, char** argv) | |||
73 | if (class == -1) | 75 | if (class == -1) |
74 | usage("Unknown task class."); | 76 | usage("Unknown task class."); |
75 | break; | 77 | break; |
78 | case 'r': | ||
79 | criticality = atoi(optarg); | ||
80 | if (criticality > 1){ | ||
81 | if (criticality > 3){ | ||
82 | class = RT_CLASS_BEST_EFFORT; | ||
83 | } | ||
84 | else{ | ||
85 | class = RT_CLASS_SOFT; | ||
86 | } | ||
87 | } | ||
88 | break; | ||
76 | 89 | ||
77 | case ':': | 90 | case ':': |
78 | usage("Argument missing."); | 91 | usage("Argument missing."); |
@@ -107,7 +120,8 @@ int main(int argc, char** argv) | |||
107 | if (ret < 0) | 120 | if (ret < 0) |
108 | bail_out("could not migrate to target partition"); | 121 | bail_out("could not migrate to target partition"); |
109 | } | 122 | } |
110 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | 123 | ret = __create_rt_task(launch, &info, cpu, wcet, period, |
124 | criticality, class); | ||
111 | 125 | ||
112 | 126 | ||
113 | if (ret < 0) | 127 | if (ret < 0) |
diff --git a/bin/rtspin.c b/bin/rtspin.c index f291869..cfd5853 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
@@ -30,7 +30,7 @@ static double wctime() | |||
30 | void usage(char *error) { | 30 | void usage(char *error) { |
31 | fprintf(stderr, "Error: %s\n", error); | 31 | fprintf(stderr, "Error: %s\n", error); |
32 | fprintf(stderr, | 32 | fprintf(stderr, |
33 | "Usage: rt_spin [-w] [-p PARTITION] [-c CLASS] WCET PERIOD DURATION\n" | 33 | "Usage: rt_spin [-w] [-p PARTITION] [-c CLASS] [-r CRITICALITY] WCET PERIOD DURATION\n" |
34 | " rt_spin -l\n"); | 34 | " rt_spin -l\n"); |
35 | exit(1); | 35 | exit(1); |
36 | } | 36 | } |
@@ -133,7 +133,7 @@ static int job(double exec_time) | |||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | #define OPTSTR "p:c:wld:v" | 136 | #define OPTSTR "p:c:r:wld:v" |
137 | 137 | ||
138 | int main(int argc, char** argv) | 138 | int main(int argc, char** argv) |
139 | { | 139 | { |
@@ -143,6 +143,7 @@ int main(int argc, char** argv) | |||
143 | double wcet_ms, period_ms; | 143 | double wcet_ms, period_ms; |
144 | int migrate = 0; | 144 | int migrate = 0; |
145 | int cpu = 0; | 145 | int cpu = 0; |
146 | int criticality = 0; | ||
146 | int opt; | 147 | int opt; |
147 | int wait = 0; | 148 | int wait = 0; |
148 | int test_loop = 0; | 149 | int test_loop = 0; |
@@ -167,6 +168,17 @@ int main(int argc, char** argv) | |||
167 | if (class == -1) | 168 | if (class == -1) |
168 | usage("Unknown task class."); | 169 | usage("Unknown task class."); |
169 | break; | 170 | break; |
171 | case 'r': | ||
172 | criticality = atoi(optarg); | ||
173 | if (criticality > 1){ | ||
174 | if (criticality > 3){ | ||
175 | class = RT_CLASS_BEST_EFFORT; | ||
176 | } | ||
177 | else{ | ||
178 | class = RT_CLASS_SOFT; | ||
179 | } | ||
180 | } | ||
181 | break; | ||
170 | case 'l': | 182 | case 'l': |
171 | test_loop = 1; | 183 | test_loop = 1; |
172 | break; | 184 | break; |
@@ -221,7 +233,7 @@ int main(int argc, char** argv) | |||
221 | bail_out("could not migrate to target partition"); | 233 | bail_out("could not migrate to target partition"); |
222 | } | 234 | } |
223 | 235 | ||
224 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, NO_ENFORCEMENT, migrate); | 236 | ret = sporadic_task_ns(wcet, period, 0, cpu, criticality, class, NO_ENFORCEMENT, migrate); |
225 | 237 | ||
226 | if (ret < 0) | 238 | if (ret < 0) |
227 | bail_out("could not setup rt task params"); | 239 | bail_out("could not setup rt task params"); |
diff --git a/include/litmus.h b/include/litmus.h index b798c92..2b58d82 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -31,18 +31,18 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); | |||
31 | /* times are given in ms */ | 31 | /* times are given in ms */ |
32 | int sporadic_task( | 32 | int sporadic_task( |
33 | lt_t e, lt_t p, lt_t phase, | 33 | lt_t e, lt_t p, lt_t phase, |
34 | int partition, task_class_t cls, | 34 | int partition, int criticality, task_class_t cls, |
35 | budget_policy_t budget_policy, int set_cpu_set); | 35 | budget_policy_t budget_policy, int set_cpu_set); |
36 | 36 | ||
37 | /* times are given in ns */ | 37 | /* times are given in ns */ |
38 | int sporadic_task_ns( | 38 | int sporadic_task_ns( |
39 | lt_t e, lt_t p, lt_t phase, | 39 | lt_t e, lt_t p, lt_t phase, |
40 | int cpu, task_class_t cls, | 40 | int cpu, int criticality, task_class_t cls, |
41 | budget_policy_t budget_policy, int set_cpu_set); | 41 | budget_policy_t budget_policy, int set_cpu_set); |
42 | 42 | ||
43 | /* budget enforcement off by default in these macros */ | 43 | /* budget enforcement off by default in these macros */ |
44 | #define sporadic_global(e, p) \ | 44 | #define sporadic_global(e, p) \ |
45 | sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) | 45 | sporadic_task(e, p, 0, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) |
46 | #define sporadic_partitioned(e, p, cpu) \ | 46 | #define sporadic_partitioned(e, p, cpu) \ |
47 | sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) | 47 | sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) |
48 | 48 | ||
@@ -82,9 +82,10 @@ void exit_litmus(void); | |||
82 | typedef int (*rt_fn_t)(void*); | 82 | typedef int (*rt_fn_t)(void*); |
83 | 83 | ||
84 | /* These two functions configure the RT task to use enforced exe budgets */ | 84 | /* These two functions configure the RT task to use enforced exe budgets */ |
85 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); | 85 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
86 | int criticality); | ||
86 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | 87 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
87 | int period, task_class_t cls); | 88 | int period, int criticality, task_class_t cls); |
88 | 89 | ||
89 | /* per-task modes */ | 90 | /* per-task modes */ |
90 | enum rt_task_mode_t { | 91 | enum rt_task_mode_t { |
diff --git a/src/litmus.c b/src/litmus.c index f71f337..2c4bc42 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -42,15 +42,16 @@ int be_migrate_to(int target_cpu) | |||
42 | } | 42 | } |
43 | 43 | ||
44 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 44 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
45 | int cpu, task_class_t cls, | 45 | int cpu, int criticality, task_class_t cls, |
46 | budget_policy_t budget_policy, int set_cpu_set) | 46 | budget_policy_t budget_policy, int set_cpu_set) |
47 | { | 47 | { |
48 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, | 48 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, |
49 | cpu, cls, budget_policy, set_cpu_set); | 49 | cpu, criticality, cls, budget_policy, |
50 | set_cpu_set); | ||
50 | } | 51 | } |
51 | 52 | ||
52 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | 53 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, |
53 | int cpu, task_class_t cls, | 54 | int cpu, int criticality, task_class_t cls, |
54 | budget_policy_t budget_policy, int set_cpu_set) | 55 | budget_policy_t budget_policy, int set_cpu_set) |
55 | { | 56 | { |
56 | struct rt_task param; | 57 | struct rt_task param; |
@@ -58,6 +59,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
58 | param.exec_cost = e; | 59 | param.exec_cost = e; |
59 | param.period = p; | 60 | param.period = p; |
60 | param.cpu = cpu; | 61 | param.cpu = cpu; |
62 | param.crit = criticality; | ||
61 | param.cls = cls; | 63 | param.cls = cls; |
62 | param.phase = phase; | 64 | param.phase = phase; |
63 | param.budget_policy = budget_policy; | 65 | param.budget_policy = budget_policy; |
@@ -41,11 +41,12 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, | |||
41 | } | 41 | } |
42 | 42 | ||
43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, | 43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
44 | task_class_t class) | 44 | int criticality, task_class_t class) |
45 | { | 45 | { |
46 | struct rt_task params; | 46 | struct rt_task params; |
47 | params.cpu = cpu; | 47 | params.cpu = cpu; |
48 | params.period = period; | 48 | params.period = period; |
49 | params.crit = criticality; | ||
49 | params.exec_cost = wcet; | 50 | params.exec_cost = wcet; |
50 | params.cls = class; | 51 | params.cls = class; |
51 | params.phase = 0; | 52 | params.phase = 0; |
@@ -56,8 +57,10 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, | |||
56 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | 57 | (rt_setup_fn_t) set_rt_task_param, ¶ms); |
57 | } | 58 | } |
58 | 59 | ||
59 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { | 60 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
60 | return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD); | 61 | int criticality) { |
62 | return __create_rt_task(rt_prog, arg, cpu, wcet, period, criticality, | ||
63 | RT_CLASS_HARD); | ||
61 | } | 64 | } |
62 | 65 | ||
63 | 66 | ||