From 8d323049edd004c25f370468aa30cdf1ba76e735 Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Tue, 22 Jul 2014 07:46:57 +0200 Subject: 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). --- bin/rtspin.c | 35 ++++++++++++++++++++++++++++------- 1 file 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 } } -#define OPTSTR "p:c:wlveo:f:s:q:X:L:Q:" +#define OPTSTR "p:c:wlveo:f:s:q:r:X:L:Q:v" int main(int argc, char** argv) { int ret; @@ -194,6 +194,7 @@ int main(int argc, char** argv) unsigned int priority = LITMUS_LOWEST_PRIORITY; int migrate = 0; int cluster = 0; + int reservation = -1; int opt; int wait = 0; int test_loop = 0; @@ -207,6 +208,9 @@ int main(int argc, char** argv) int cur_job = 0, num_jobs = 0; struct rt_task param; + int verbose = 0; + unsigned int job_no; + /* locking */ int lock_od = -1; int resource_id = 0; @@ -225,6 +229,9 @@ int main(int argc, char** argv) cluster = atoi(optarg); migrate = 1; break; + case 'r': + reservation = atoi(optarg); + break; case 'q': priority = atoi(optarg); if (!litmus_is_valid_fixed_prio(priority)) @@ -265,6 +272,9 @@ int main(int argc, char** argv) if (resource_id <= 0 && strcmp(optarg, "0")) usage("Invalid resource ID."); break; + case 'v': + verbose = 1; + break; case ':': usage("Argument missing."); break; @@ -334,14 +344,19 @@ int main(int argc, char** argv) param.cls = class; param.budget_policy = (want_enforcement) ? PRECISE_ENFORCEMENT : NO_ENFORCEMENT; - if (migrate) - param.cpu = domain_to_first_cpu(cluster); + if (migrate) { + if (reservation >= 0) + param.cpu = reservation; + else + param.cpu = domain_to_first_cpu(cluster); + } ret = set_rt_task_param(gettid(), ¶m); if (ret < 0) bail_out("could not setup rt task params"); init_litmus(); + start = wctime(); ret = task_mode(LITMUS_RT_TASK); if (ret != 0) bail_out("could not become RT task"); @@ -355,14 +370,14 @@ int main(int argc, char** argv) } } + if (wait) { ret = wait_for_ts_release(); if (ret != 0) bail_out("wait_for_ts_release()"); + start = wctime(); } - start = wctime(); - if (file) { /* use times read from the CSV file */ for (cur_job = 0; cur_job < num_jobs; ++cur_job) { @@ -372,8 +387,14 @@ int main(int argc, char** argv) lock_od, cs_length * 0.001); } } else { - /* convert to seconds and scale */ - while (job(wcet_ms * 0.001 * scale, start + duration, + do { + if (verbose) { + get_job_no(&job_no); + printf("rtspin/%d:%u @ %.4fms\n", gettid(), + job_no, (wctime() - start) * 1000); + } + /* convert to seconds and scale */ + } while (job(wcet_ms * 0.001 * scale, start + duration, lock_od, cs_length * 0.001)); } -- cgit v1.2.2