aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2015-09-18 07:44:28 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-16 10:33:18 -0400
commit13559d16bcd773dcea0fdcb69a60a2fe15ad9fd8 (patch)
tree35f57ee1bc94b9ecf990c7386886b79aaf2ee4b9
parentbe24daf0a97247fa3e97ef63e5e4b0efb3d7ec20 (diff)
Add -R (create sporadic reservation) flag to rt_launch
-rw-r--r--bin/rt_launch.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c
index c468b68..ed26a1a 100644
--- a/bin/rt_launch.c
+++ b/bin/rt_launch.c
@@ -13,7 +13,8 @@ const char *usage_msg =
13 " -w wait for synchronous release\n" 13 " -w wait for synchronous release\n"
14 " -v verbose (prints PID)\n" 14 " -v verbose (prints PID)\n"
15 " -p CPU physical partition or cluster to assign to\n" 15 " -p CPU physical partition or cluster to assign to\n"
16 " -r VCPU virtual CPU to attach to (irrelevant to most plugins)\n" 16 " -r VCPU virtual CPU or reservation to attach to (irrelevant to most plugins)\n"
17 " -R create sporadic reservation for task (with VCPU=PID)\n"
17 " -d DEADLINE relative deadline, implicit by default (in ms)\n" 18 " -d DEADLINE relative deadline, implicit by default (in ms)\n"
18 " -o OFFSET offset (also known as phase), zero by default (in ms)\n" 19 " -o OFFSET offset (also known as phase), zero by default (in ms)\n"
19 " -q PRIORITY priority to use (ignored by EDF plugins, highest=1, lowest=511)\n" 20 " -q PRIORITY priority to use (ignored by EDF plugins, highest=1, lowest=511)\n"
@@ -28,7 +29,7 @@ void usage(char *error) {
28 exit(1); 29 exit(1);
29} 30}
30 31
31#define OPTSTR "wp:q:c:er:b:o:d:vh" 32#define OPTSTR "wp:q:c:er:b:o:d:vhR"
32 33
33int main(int argc, char** argv) 34int main(int argc, char** argv)
34{ 35{
@@ -45,6 +46,7 @@ int main(int argc, char** argv)
45 int wait; 46 int wait;
46 int want_enforcement; 47 int want_enforcement;
47 int verbose; 48 int verbose;
49 int create_reservation;
48 task_class_t class; 50 task_class_t class;
49 struct rt_task param; 51 struct rt_task param;
50 52
@@ -52,13 +54,14 @@ int main(int argc, char** argv)
52 verbose = 0; 54 verbose = 0;
53 offset_ms = 0; 55 offset_ms = 0;
54 deadline_ms = 0; 56 deadline_ms = 0;
55 priority = LITMUS_LOWEST_PRIORITY; 57 priority = LITMUS_NO_PRIORITY;
56 want_enforcement = 1; /* safety: default to enforcement */ 58 want_enforcement = 1; /* safety: default to enforcement */
57 wait = 0; /* don't wait for task system release */ 59 wait = 0; /* don't wait for task system release */
58 class = RT_CLASS_SOFT; /* ignored by most plugins */ 60 class = RT_CLASS_SOFT; /* ignored by most plugins */
59 migrate = 0; /* assume global unless -p is specified */ 61 migrate = 0; /* assume global unless -p is specified */
60 cluster = -1; /* where to migrate to, invalid by default */ 62 cluster = -1; /* where to migrate to, invalid by default */
61 reservation = -1; /* set if task should attach to virtual CPU */ 63 reservation = -1; /* set if task should attach to virtual CPU */
64 create_reservation = 0;
62 65
63 while ((opt = getopt(argc, argv, OPTSTR)) != -1) { 66 while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
64 switch (opt) { 67 switch (opt) {
@@ -85,6 +88,10 @@ int main(int argc, char** argv)
85 case 'r': 88 case 'r':
86 reservation = atoi(optarg); 89 reservation = atoi(optarg);
87 break; 90 break;
91 case 'R':
92 create_reservation = 1;
93 reservation = getpid();
94 break;
88 case 'o': 95 case 'o':
89 offset_ms = atof(optarg); 96 offset_ms = atof(optarg);
90 break; 97 break;
@@ -144,7 +151,7 @@ int main(int argc, char** argv)
144 param.period = period; 151 param.period = period;
145 param.phase = offset; 152 param.phase = offset;
146 param.relative_deadline = deadline; 153 param.relative_deadline = deadline;
147 param.priority = priority; 154 param.priority = priority == LITMUS_NO_PRIORITY ? LITMUS_LOWEST_PRIORITY : priority;
148 param.cls = class; 155 param.cls = class;
149 param.budget_policy = (want_enforcement) ? 156 param.budget_policy = (want_enforcement) ?
150 PRECISE_ENFORCEMENT : NO_ENFORCEMENT; 157 PRECISE_ENFORCEMENT : NO_ENFORCEMENT;
@@ -158,6 +165,21 @@ int main(int argc, char** argv)
158 if (ret < 0) 165 if (ret < 0)
159 bail_out("could not setup rt task params"); 166 bail_out("could not setup rt task params");
160 167
168 if (create_reservation) {
169 struct reservation_config config;
170 memset(&config, 0, sizeof(config));
171 config.id = gettid();
172 config.cpu = domain_to_first_cpu(cluster);
173 config.priority = priority;
174 config.polling_params.budget = wcet;
175 config.polling_params.period = period;
176 config.polling_params.offset = offset;
177 config.polling_params.relative_deadline = deadline;
178 ret = reservation_create(SPORADIC_POLLING, &config);
179 if (ret < 0)
180 bail_out("failed to create reservation");
181 }
182
161 init_litmus(); 183 init_litmus();
162 184
163 ret = task_mode(LITMUS_RT_TASK); 185 ret = task_mode(LITMUS_RT_TASK);