diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-11-03 18:48:42 -0400 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-11-03 18:49:17 -0400 |
| commit | dc76d9b4db47afd82f7dd87a996a014d4d934da3 (patch) | |
| tree | 9b299b466b3fc98e5cbd6d599ebe2b7bf4dfe30b | |
| parent | f96fd2faac2baed4d5d1d1b8ea124714e5cbce56 (diff) | |
| parent | 866221a5efb5e4a44633ce8b12e2f76bbc48164b (diff) | |
Merge branch 'wip-mcrit-mac' into wip-mc
Conflicts:
bin/rtspin.c
This patch provides necessary changes to liblitmus for the mixed criticality
plugin.
| -rw-r--r-- | bin/rt_launch.c | 13 | ||||
| -rw-r--r-- | bin/rtspin.c | 9 | ||||
| -rw-r--r-- | include/litmus.h | 4 | ||||
| -rw-r--r-- | src/litmus.c | 18 | ||||
| -rw-r--r-- | src/task.c | 5 |
5 files changed, 40 insertions, 9 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 3863031..39242a4 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][-m 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-m\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,7 +42,7 @@ void usage(char *error) { | |||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | 44 | ||
| 44 | #define OPTSTR "p:c:vw" | 45 | #define OPTSTR "p:c:vwm:" |
| 45 | 46 | ||
| 46 | int main(int argc, char** argv) | 47 | int main(int argc, char** argv) |
| 47 | { | 48 | { |
| @@ -51,6 +52,7 @@ int main(int argc, char** argv) | |||
| 51 | int migrate = 0; | 52 | int migrate = 0; |
| 52 | int cpu = 0; | 53 | int cpu = 0; |
| 53 | int opt; | 54 | int opt; |
| 55 | crit_level_t crit; | ||
| 54 | int verbose = 0; | 56 | int verbose = 0; |
| 55 | int wait = 0; | 57 | int wait = 0; |
| 56 | startup_info_t info; | 58 | startup_info_t info; |
| @@ -68,6 +70,11 @@ int main(int argc, char** argv) | |||
| 68 | cpu = atoi(optarg); | 70 | cpu = atoi(optarg); |
| 69 | migrate = 1; | 71 | migrate = 1; |
| 70 | break; | 72 | break; |
| 73 | case 'm': | ||
| 74 | crit = str2crit(optarg); | ||
| 75 | if (crit == -1) | ||
| 76 | usage("Unknown criticality level."); | ||
| 77 | break; | ||
| 71 | case 'c': | 78 | case 'c': |
| 72 | class = str2class(optarg); | 79 | class = str2class(optarg); |
| 73 | if (class == -1) | 80 | if (class == -1) |
| @@ -107,7 +114,7 @@ int main(int argc, char** argv) | |||
| 107 | if (ret < 0) | 114 | if (ret < 0) |
| 108 | bail_out("could not migrate to target partition"); | 115 | bail_out("could not migrate to target partition"); |
| 109 | } | 116 | } |
| 110 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | 117 | ret = __create_rt_task(launch, &info, cpu, crit, wcet, period, class); |
| 111 | 118 | ||
| 112 | 119 | ||
| 113 | if (ret < 0) | 120 | if (ret < 0) |
diff --git a/bin/rtspin.c b/bin/rtspin.c index 33919b1..f864172 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -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:ve" | 136 | #define OPTSTR "p:c:wld:vem" |
| 137 | 137 | ||
| 138 | int main(int argc, char** argv) | 138 | int main(int argc, char** argv) |
| 139 | { | 139 | { |
| @@ -151,6 +151,7 @@ int main(int argc, char** argv) | |||
| 151 | int want_enforcement = 0; | 151 | int want_enforcement = 0; |
| 152 | double duration, start; | 152 | double duration, start; |
| 153 | task_class_t class = RT_CLASS_HARD; | 153 | task_class_t class = RT_CLASS_HARD; |
| 154 | crit_level_t crit = CRIT_LEVEL_C; | ||
| 154 | 155 | ||
| 155 | progname = argv[0]; | 156 | progname = argv[0]; |
| 156 | 157 | ||
| @@ -170,6 +171,10 @@ int main(int argc, char** argv) | |||
| 170 | break; | 171 | break; |
| 171 | case 'e': | 172 | case 'e': |
| 172 | want_enforcement = 1; | 173 | want_enforcement = 1; |
| 174 | case 'm': | ||
| 175 | crit = str2crit(optarg); | ||
| 176 | if (crit == -1) | ||
| 177 | usage("Unknown criticality level."); | ||
| 173 | break; | 178 | break; |
| 174 | case 'l': | 179 | case 'l': |
| 175 | test_loop = 1; | 180 | test_loop = 1; |
| @@ -225,7 +230,7 @@ int main(int argc, char** argv) | |||
| 225 | bail_out("could not migrate to target partition"); | 230 | bail_out("could not migrate to target partition"); |
| 226 | } | 231 | } |
| 227 | 232 | ||
| 228 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, | 233 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, crit, |
| 229 | want_enforcement ? PRECISE_ENFORCEMENT | 234 | want_enforcement ? PRECISE_ENFORCEMENT |
| 230 | : NO_ENFORCEMENT, | 235 | : NO_ENFORCEMENT, |
| 231 | migrate); | 236 | migrate); |
diff --git a/include/litmus.h b/include/litmus.h index b798c92..632b9e1 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
| @@ -38,6 +38,7 @@ int sporadic_task( | |||
| 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 | crit_level_t crit, | ||
| 41 | budget_policy_t budget_policy, int set_cpu_set); | 42 | budget_policy_t budget_policy, int set_cpu_set); |
| 42 | 43 | ||
| 43 | /* budget enforcement off by default in these macros */ | 44 | /* budget enforcement off by default in these macros */ |
| @@ -83,7 +84,7 @@ typedef int (*rt_fn_t)(void*); | |||
| 83 | 84 | ||
| 84 | /* These two functions configure the RT task to use enforced exe budgets */ | 85 | /* 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); | 86 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); |
| 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, crit_level_t crit, int wcet, |
| 87 | int period, task_class_t cls); | 88 | int period, task_class_t cls); |
| 88 | 89 | ||
| 89 | /* per-task modes */ | 90 | /* per-task modes */ |
| @@ -95,6 +96,7 @@ int task_mode(int target_mode); | |||
| 95 | 96 | ||
| 96 | void show_rt_param(struct rt_task* tp); | 97 | void show_rt_param(struct rt_task* tp); |
| 97 | task_class_t str2class(const char* str); | 98 | task_class_t str2class(const char* str); |
| 99 | crit_level_t str2crit(const char* str); | ||
| 98 | 100 | ||
| 99 | /* non-preemptive section support */ | 101 | /* non-preemptive section support */ |
| 100 | void enter_np(void); | 102 | void enter_np(void); |
diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..84e844c 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 */ |
| @@ -46,11 +60,12 @@ int sporadic_task(lt_t e, lt_t p, lt_t phase, | |||
| 46 | budget_policy_t budget_policy, int set_cpu_set) | 60 | budget_policy_t budget_policy, int set_cpu_set) |
| 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, CRIT_LEVEL_C, budget_policy, set_cpu_set); |
| 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, |
| 68 | crit_level_t crit, | ||
| 54 | budget_policy_t budget_policy, int set_cpu_set) | 69 | budget_policy_t budget_policy, int set_cpu_set) |
| 55 | { | 70 | { |
| 56 | struct rt_task param; | 71 | struct rt_task param; |
| @@ -65,6 +80,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
| 65 | param.period = p; | 80 | param.period = p; |
| 66 | param.cpu = cpu; | 81 | param.cpu = cpu; |
| 67 | param.cls = cls; | 82 | param.cls = cls; |
| 83 | param.crit = crit; | ||
| 68 | param.phase = phase; | 84 | param.phase = phase; |
| 69 | param.budget_policy = budget_policy; | 85 | param.budget_policy = budget_policy; |
| 70 | 86 | ||
| @@ -40,11 +40,12 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, | |||
| 40 | return rt_task; | 40 | return rt_task; |
| 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, crit_level_t crit, int wcet, int period, |
| 44 | task_class_t class) | 44 | 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.crit = crit; | ||
| 48 | params.period = period; | 49 | params.period = period; |
| 49 | params.exec_cost = wcet; | 50 | params.exec_cost = wcet; |
| 50 | params.cls = class; | 51 | params.cls = class; |
| @@ -57,7 +58,7 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, | |||
| 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 | return __create_rt_task(rt_prog, arg, cpu, CRIT_LEVEL_C, wcet, period, RT_CLASS_HARD); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | 64 | ||
