aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2014-07-22 01:46:57 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2014-07-22 01:46:57 -0400
commit8d323049edd004c25f370468aa30cdf1ba76e735 (patch)
tree414f93efe85092d67b764b01dd82961c69183349
parenta83d1f59605a06fc22b399b38ce4b831d38b6442 (diff)
Add -r (reservation) and -v (verbose) flags to rtspin
The -r flag allows specifying a "virtual CPU" (in addition to a physcial CPU to migrate to) that may be interpreted by a scheduler plugin to refer to a reservation to which the task should be added. The -v flag causes rtspin to output timing information on stdout and can be useful for early-stage plugin debugging (to see that something is happening at all).
-rw-r--r--bin/rtspin.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c
index b4156cc..ea7f192 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -184,7 +184,7 @@ static int job(double exec_time, double program_end, int lock_od, double cs_leng
184 } 184 }
185} 185}
186 186
187#define OPTSTR "p:c:wlveo:f:s:q:X:L:Q:" 187#define OPTSTR "p:c:wlveo:f:s:q:r:X:L:Q:v"
188int main(int argc, char** argv) 188int main(int argc, char** argv)
189{ 189{
190 int ret; 190 int ret;
@@ -194,6 +194,7 @@ int main(int argc, char** argv)
194 unsigned int priority = LITMUS_LOWEST_PRIORITY; 194 unsigned int priority = LITMUS_LOWEST_PRIORITY;
195 int migrate = 0; 195 int migrate = 0;
196 int cluster = 0; 196 int cluster = 0;
197 int reservation = -1;
197 int opt; 198 int opt;
198 int wait = 0; 199 int wait = 0;
199 int test_loop = 0; 200 int test_loop = 0;
@@ -207,6 +208,9 @@ int main(int argc, char** argv)
207 int cur_job = 0, num_jobs = 0; 208 int cur_job = 0, num_jobs = 0;
208 struct rt_task param; 209 struct rt_task param;
209 210
211 int verbose = 0;
212 unsigned int job_no;
213
210 /* locking */ 214 /* locking */
211 int lock_od = -1; 215 int lock_od = -1;
212 int resource_id = 0; 216 int resource_id = 0;
@@ -225,6 +229,9 @@ int main(int argc, char** argv)
225 cluster = atoi(optarg); 229 cluster = atoi(optarg);
226 migrate = 1; 230 migrate = 1;
227 break; 231 break;
232 case 'r':
233 reservation = atoi(optarg);
234 break;
228 case 'q': 235 case 'q':
229 priority = atoi(optarg); 236 priority = atoi(optarg);
230 if (!litmus_is_valid_fixed_prio(priority)) 237 if (!litmus_is_valid_fixed_prio(priority))
@@ -265,6 +272,9 @@ int main(int argc, char** argv)
265 if (resource_id <= 0 && strcmp(optarg, "0")) 272 if (resource_id <= 0 && strcmp(optarg, "0"))
266 usage("Invalid resource ID."); 273 usage("Invalid resource ID.");
267 break; 274 break;
275 case 'v':
276 verbose = 1;
277 break;
268 case ':': 278 case ':':
269 usage("Argument missing."); 279 usage("Argument missing.");
270 break; 280 break;
@@ -334,14 +344,19 @@ int main(int argc, char** argv)
334 param.cls = class; 344 param.cls = class;
335 param.budget_policy = (want_enforcement) ? 345 param.budget_policy = (want_enforcement) ?
336 PRECISE_ENFORCEMENT : NO_ENFORCEMENT; 346 PRECISE_ENFORCEMENT : NO_ENFORCEMENT;
337 if (migrate) 347 if (migrate) {
338 param.cpu = domain_to_first_cpu(cluster); 348 if (reservation >= 0)
349 param.cpu = reservation;
350 else
351 param.cpu = domain_to_first_cpu(cluster);
352 }
339 ret = set_rt_task_param(gettid(), &param); 353 ret = set_rt_task_param(gettid(), &param);
340 if (ret < 0) 354 if (ret < 0)
341 bail_out("could not setup rt task params"); 355 bail_out("could not setup rt task params");
342 356
343 init_litmus(); 357 init_litmus();
344 358
359 start = wctime();
345 ret = task_mode(LITMUS_RT_TASK); 360 ret = task_mode(LITMUS_RT_TASK);
346 if (ret != 0) 361 if (ret != 0)
347 bail_out("could not become RT task"); 362 bail_out("could not become RT task");
@@ -355,14 +370,14 @@ int main(int argc, char** argv)
355 } 370 }
356 } 371 }
357 372
373
358 if (wait) { 374 if (wait) {
359 ret = wait_for_ts_release(); 375 ret = wait_for_ts_release();
360 if (ret != 0) 376 if (ret != 0)
361 bail_out("wait_for_ts_release()"); 377 bail_out("wait_for_ts_release()");
378 start = wctime();
362 } 379 }
363 380
364 start = wctime();
365
366 if (file) { 381 if (file) {
367 /* use times read from the CSV file */ 382 /* use times read from the CSV file */
368 for (cur_job = 0; cur_job < num_jobs; ++cur_job) { 383 for (cur_job = 0; cur_job < num_jobs; ++cur_job) {
@@ -372,8 +387,14 @@ int main(int argc, char** argv)
372 lock_od, cs_length * 0.001); 387 lock_od, cs_length * 0.001);
373 } 388 }
374 } else { 389 } else {
375 /* convert to seconds and scale */ 390 do {
376 while (job(wcet_ms * 0.001 * scale, start + duration, 391 if (verbose) {
392 get_job_no(&job_no);
393 printf("rtspin/%d:%u @ %.4fms\n", gettid(),
394 job_no, (wctime() - start) * 1000);
395 }
396 /* convert to seconds and scale */
397 } while (job(wcet_ms * 0.001 * scale, start + duration,
377 lock_od, cs_length * 0.001)); 398 lock_od, cs_length * 0.001));
378 } 399 }
379 400