aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2013-01-11 04:26:33 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-01-11 04:26:33 -0500
commit102b50373d656e42abbd1c953ce908e52f6e8706 (patch)
tree31f5b9accd4b8b1d3463300f8cc7b6b2fe55d0ce
parent642049ba7d30b24fb9927a22d44d6b84139668dc (diff)
rt_launch: add support for -q <priority>
This mirrors the option in rtspin.
-rw-r--r--bin/rt_launch.c18
-rw-r--r--include/litmus.h6
-rw-r--r--src/task.c10
3 files changed, 21 insertions, 13 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c
index 3863031..16d6ed7 100644
--- a/bin/rt_launch.c
+++ b/bin/rt_launch.c
@@ -29,7 +29,7 @@ int launch(void *task_info_p) {
29} 29}
30 30
31void usage(char *error) { 31void 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][-q prio][-c hrt | srt | be] 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"
@@ -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:vwq:"
45 45
46int main(int argc, char** argv) 46int main(int argc, char** argv)
47{ 47{
@@ -55,6 +55,7 @@ int main(int argc, char** argv)
55 int wait = 0; 55 int wait = 0;
56 startup_info_t info; 56 startup_info_t info;
57 task_class_t class = RT_CLASS_HARD; 57 task_class_t class = RT_CLASS_HARD;
58 unsigned int priority = LITMUS_LOWEST_PRIORITY;
58 59
59 while ((opt = getopt(argc, argv, OPTSTR)) != -1) { 60 while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
60 switch (opt) { 61 switch (opt) {
@@ -68,6 +69,11 @@ int main(int argc, char** argv)
68 cpu = atoi(optarg); 69 cpu = atoi(optarg);
69 migrate = 1; 70 migrate = 1;
70 break; 71 break;
72 case 'q':
73 priority = atoi(optarg);
74 if (!litmus_is_valid_fixed_prio(priority))
75 usage("Invalid priority.");
76 break;
71 case 'c': 77 case 'c':
72 class = str2class(optarg); 78 class = str2class(optarg);
73 if (class == -1) 79 if (class == -1)
@@ -87,7 +93,7 @@ int main(int argc, char** argv)
87 signal(SIGUSR1, SIG_IGN); 93 signal(SIGUSR1, SIG_IGN);
88 94
89 if (argc - optind < 3) 95 if (argc - optind < 3)
90 usage("Arguments missing."); 96 usage("Arguments missing.");
91 wcet = ms2lt(atoi(argv[optind + 0])); 97 wcet = ms2lt(atoi(argv[optind + 0]));
92 period = ms2lt(atoi(argv[optind + 1])); 98 period = ms2lt(atoi(argv[optind + 1]));
93 if (wcet <= 0) 99 if (wcet <= 0)
@@ -107,13 +113,13 @@ 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, priority, class);
117
111 118
112
113 if (ret < 0) 119 if (ret < 0)
114 bail_out("could not create rt child process"); 120 bail_out("could not create rt child process");
115 else if (verbose) 121 else if (verbose)
116 printf("%d\n", ret); 122 printf("%d\n", ret);
117 123
118 return 0; 124 return 0;
119} 125}
diff --git a/include/litmus.h b/include/litmus.h
index 3777088..2b6a1dd 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -98,9 +98,9 @@ void exit_litmus(void);
98typedef int (*rt_fn_t)(void*); 98typedef int (*rt_fn_t)(void*);
99 99
100/* These two functions configure the RT task to use enforced exe budgets */ 100/* These two functions configure the RT task to use enforced exe budgets */
101int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); 101int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet, lt_t period, unsigned int prio);
102int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, 102int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet,
103 int period, task_class_t cls); 103 lt_t period, unsigned int priority, task_class_t cls);
104 104
105/* per-task modes */ 105/* per-task modes */
106enum rt_task_mode_t { 106enum rt_task_mode_t {
diff --git a/src/task.c b/src/task.c
index 4d237bd..ed1c6aa 100644
--- a/src/task.c
+++ b/src/task.c
@@ -40,8 +40,8 @@ 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
43int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, 43int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet, lt_t period,
44 task_class_t class) 44 unsigned int priority, task_class_t class)
45{ 45{
46 struct rt_task params; 46 struct rt_task params;
47 params.cpu = cpu; 47 params.cpu = cpu;
@@ -49,6 +49,7 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period,
49 params.exec_cost = wcet; 49 params.exec_cost = wcet;
50 params.cls = class; 50 params.cls = class;
51 params.phase = 0; 51 params.phase = 0;
52 params.priority = priority;
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;
54 55
@@ -56,8 +57,9 @@ 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, &params); 57 (rt_setup_fn_t) set_rt_task_param, &params);
57} 58}
58 59
59int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { 60int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet, lt_t period,
60 return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD); 61 unsigned int priority) {
62 return __create_rt_task(rt_prog, arg, cpu, wcet, period, priority, RT_CLASS_HARD);
61} 63}
62 64
63 65