diff options
author | Jeremy Erickson <jerickso@cs.unc.edu> | 2011-01-22 21:27:09 -0500 |
---|---|---|
committer | Jeremy Erickson <jerickso@cs.unc.edu> | 2011-01-22 21:27:09 -0500 |
commit | 95992f287406fe7db96431b912e41d81acbbbf66 (patch) | |
tree | 90aa3e611aa88bfb77b1a5696c5146c3530f3dba | |
parent | 4a2b128f0db282896552ba3dc311c0241ea819e4 (diff) |
Added crit
-rw-r--r-- | bin/rt_launch.c | 10 | ||||
-rw-r--r-- | bin/rtspin.c | 10 | ||||
-rw-r--r-- | include/litmus.h | 16 | ||||
-rw-r--r-- | src/litmus.c | 22 | ||||
-rw-r--r-- | src/task.c | 9 |
5 files changed, 51 insertions, 16 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 3863031..bb6668f 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
@@ -41,7 +41,7 @@ void usage(char *error) { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | 43 | ||
44 | #define OPTSTR "p:c:vw" | 44 | #define OPTSTR "p:c:vwm:" |
45 | 45 | ||
46 | int main(int argc, char** argv) | 46 | int main(int argc, char** argv) |
47 | { | 47 | { |
@@ -50,6 +50,7 @@ int main(int argc, char** argv) | |||
50 | lt_t period; | 50 | lt_t period; |
51 | int migrate = 0; | 51 | int migrate = 0; |
52 | int cpu = 0; | 52 | int cpu = 0; |
53 | int crit = CRIT_LEVEL_B; | ||
53 | int opt; | 54 | int opt; |
54 | int verbose = 0; | 55 | int verbose = 0; |
55 | int wait = 0; | 56 | int wait = 0; |
@@ -73,6 +74,11 @@ int main(int argc, char** argv) | |||
73 | if (class == -1) | 74 | if (class == -1) |
74 | usage("Unknown task class."); | 75 | usage("Unknown task class."); |
75 | break; | 76 | break; |
77 | case 'm': | ||
78 | crit = str2crit(optarg); | ||
79 | if (crit == -1) | ||
80 | usage("Unknown criticality level."); | ||
81 | break; | ||
76 | 82 | ||
77 | case ':': | 83 | case ':': |
78 | usage("Argument missing."); | 84 | usage("Argument missing."); |
@@ -107,7 +113,7 @@ int main(int argc, char** argv) | |||
107 | if (ret < 0) | 113 | if (ret < 0) |
108 | bail_out("could not migrate to target partition"); | 114 | bail_out("could not migrate to target partition"); |
109 | } | 115 | } |
110 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | 116 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class, crit); |
111 | 117 | ||
112 | 118 | ||
113 | if (ret < 0) | 119 | if (ret < 0) |
diff --git a/bin/rtspin.c b/bin/rtspin.c index 01855ab..5c5d8aa 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
@@ -152,7 +152,7 @@ static int job(double exec_time, double program_end) | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | #define OPTSTR "p:c:wld:veo:f:s:" | 155 | #define OPTSTR "p:c:wld:veo:f:s:m:" |
156 | 156 | ||
157 | int main(int argc, char** argv) | 157 | int main(int argc, char** argv) |
158 | { | 158 | { |
@@ -163,6 +163,7 @@ int main(int argc, char** argv) | |||
163 | int migrate = 0; | 163 | int migrate = 0; |
164 | int cpu = 0; | 164 | int cpu = 0; |
165 | int opt; | 165 | int opt; |
166 | int crit = CRIT_LEVEL_B; | ||
166 | int wait = 0; | 167 | int wait = 0; |
167 | int column = 1; | 168 | int column = 1; |
168 | const char *file = NULL; | 169 | const char *file = NULL; |
@@ -187,6 +188,11 @@ int main(int argc, char** argv) | |||
187 | if (class == -1) | 188 | if (class == -1) |
188 | usage("Unknown task class."); | 189 | usage("Unknown task class."); |
189 | break; | 190 | break; |
191 | case 'm': | ||
192 | crit = str2crit(optarg); | ||
193 | if (crit == -1) | ||
194 | usage("Unknown criticality level."); | ||
195 | break; | ||
190 | case 'e': | 196 | case 'e': |
191 | want_enforcement = 1; | 197 | want_enforcement = 1; |
192 | break; | 198 | break; |
@@ -257,7 +263,7 @@ int main(int argc, char** argv) | |||
257 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, | 263 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, |
258 | want_enforcement ? PRECISE_ENFORCEMENT | 264 | want_enforcement ? PRECISE_ENFORCEMENT |
259 | : NO_ENFORCEMENT, | 265 | : NO_ENFORCEMENT, |
260 | migrate); | 266 | migrate, crit); |
261 | if (ret < 0) | 267 | if (ret < 0) |
262 | bail_out("could not setup rt task params"); | 268 | bail_out("could not setup rt task params"); |
263 | 269 | ||
diff --git a/include/litmus.h b/include/litmus.h index 2a26a4a..bf72f0c 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -32,19 +32,21 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); | |||
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, task_class_t cls, |
35 | budget_policy_t budget_policy, int set_cpu_set); | 35 | budget_policy_t budget_policy, int set_cpu_set, int crit); |
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, task_class_t cls, |
41 | budget_policy_t budget_policy, int set_cpu_set); | 41 | budget_policy_t budget_policy, int set_cpu_set, int crit); |
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, RT_CLASS_SOFT, NO_ENFORCEMENT, 0, \ |
46 | CRIT_LEVEL_B) | ||
46 | #define sporadic_partitioned(e, p, cpu) \ | 47 | #define sporadic_partitioned(e, p, cpu) \ |
47 | sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) | 48 | sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1 \ |
49 | CRIT_LEVEL_B) | ||
48 | 50 | ||
49 | /* file descriptor attached shared objects support */ | 51 | /* file descriptor attached shared objects support */ |
50 | typedef enum { | 52 | typedef enum { |
@@ -82,9 +84,10 @@ void exit_litmus(void); | |||
82 | typedef int (*rt_fn_t)(void*); | 84 | typedef int (*rt_fn_t)(void*); |
83 | 85 | ||
84 | /* These two functions configure the RT task to use enforced exe budgets */ | 86 | /* 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); | 87 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
88 | int crit); | ||
86 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | 89 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
87 | int period, task_class_t cls); | 90 | int period, task_class_t cls, int crit); |
88 | 91 | ||
89 | /* per-task modes */ | 92 | /* per-task modes */ |
90 | enum rt_task_mode_t { | 93 | enum rt_task_mode_t { |
@@ -95,6 +98,7 @@ int task_mode(int target_mode); | |||
95 | 98 | ||
96 | void show_rt_param(struct rt_task* tp); | 99 | void show_rt_param(struct rt_task* tp); |
97 | task_class_t str2class(const char* str); | 100 | task_class_t str2class(const char* str); |
101 | crit_level_t str2crit(const char* str); | ||
98 | 102 | ||
99 | /* non-preemptive section support */ | 103 | /* non-preemptive section support */ |
100 | void enter_np(void); | 104 | void enter_np(void); |
diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..ad795a8 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -29,6 +29,20 @@ task_class_t str2class(const char* str) | |||
29 | return -1; | 29 | return -1; |
30 | } | 30 | } |
31 | 31 | ||
32 | crit_level_t str2crit(const char* str) | ||
33 | { | ||
34 | if (!strcmp(str, "a") || !strcmp(str, "A")) | ||
35 | return CRIT_LEVEL_A; | ||
36 | else if (!strcmp(str, "b") || !strcmp(str,"B")) | ||
37 | return CRIT_LEVEL_B; | ||
38 | else if (!strcmp(str, "c") || !strcmp(str,"C")) | ||
39 | return CRIT_LEVEL_C; | ||
40 | else if (!strcmp(str, "d") || !strcmp(str,"D")) | ||
41 | return CRIT_LEVEL_D; | ||
42 | else | ||
43 | return -1; | ||
44 | } | ||
45 | |||
32 | #define NS_PER_MS 1000000 | 46 | #define NS_PER_MS 1000000 |
33 | 47 | ||
34 | /* only for best-effort execution: migrate to target_cpu */ | 48 | /* only for best-effort execution: migrate to target_cpu */ |
@@ -43,15 +57,16 @@ int be_migrate_to(int target_cpu) | |||
43 | 57 | ||
44 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 58 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
45 | int cpu, task_class_t cls, | 59 | int cpu, task_class_t cls, |
46 | budget_policy_t budget_policy, int set_cpu_set) | 60 | budget_policy_t budget_policy, int set_cpu_set, int crit) |
47 | { | 61 | { |
48 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, | 62 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, |
49 | cpu, cls, budget_policy, set_cpu_set); | 63 | cpu, cls, budget_policy, set_cpu_set, crit); |
50 | } | 64 | } |
51 | 65 | ||
52 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | 66 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, |
53 | int cpu, task_class_t cls, | 67 | int cpu, task_class_t cls, |
54 | budget_policy_t budget_policy, int set_cpu_set) | 68 | budget_policy_t budget_policy, int set_cpu_set, |
69 | int crit) | ||
55 | { | 70 | { |
56 | struct rt_task param; | 71 | struct rt_task param; |
57 | int ret; | 72 | int ret; |
@@ -64,6 +79,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
64 | param.exec_cost = e; | 79 | param.exec_cost = e; |
65 | param.period = p; | 80 | param.period = p; |
66 | param.cpu = cpu; | 81 | param.cpu = cpu; |
82 | param.crit = crit; | ||
67 | param.cls = cls; | 83 | param.cls = cls; |
68 | param.phase = phase; | 84 | param.phase = phase; |
69 | param.budget_policy = budget_policy; | 85 | param.budget_policy = budget_policy; |
@@ -41,13 +41,14 @@ 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 | task_class_t class, int crit) |
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.exec_cost = wcet; | 49 | params.exec_cost = wcet; |
50 | params.cls = class; | 50 | params.cls = class; |
51 | params.crit = crit; | ||
51 | params.phase = 0; | 52 | params.phase = 0; |
52 | /* enforce budget for tasks that might not use sleep_next_period() */ | 53 | /* enforce budget for tasks that might not use sleep_next_period() */ |
53 | params.budget_policy = QUANTUM_ENFORCEMENT; | 54 | params.budget_policy = QUANTUM_ENFORCEMENT; |
@@ -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 crit) { |
62 | return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD, | ||
63 | crit); | ||
61 | } | 64 | } |
62 | 65 | ||
63 | 66 | ||