From 91ba319fffa36885abc777c54266860f947fed16 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Sat, 24 Oct 2020 02:42:55 -0400 Subject: Alert to stderr on benchmark deadline miss --- extra.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/extra.h b/extra.h index 990d2e0..a21f5a5 100644 --- a/extra.h +++ b/extra.h @@ -77,7 +77,9 @@ char _rt_shm_name[_ID_SZ] = "/_libextra_barrier-"; #endif /* PAIRED */ #if LITMUS -long unsigned int _rt_period; +lt_t _rt_period; +int _rt_crit; +struct control_page *_rt_cp; #endif static void _rt_load_params_itrl(int argc, char **argv) { @@ -202,9 +204,9 @@ static void _rt_load_params_itrl(int argc, char **argv) { _rt_jobs_complete = 0; mlockall(MCL_CURRENT || MCL_FUTURE); #if LITMUS - _rt_period = strtoul(argv[end], NULL, 10); - unsigned int crit = atoi(argv[end+1]); - unsigned int wait = 0; + _rt_period = ms2ns(strtoul(argv[end], NULL, 10)); + _rt_crit = atoi(argv[end+1]); + unsigned int wait = 1; if (be_migrate_to_domain(_rt_core) < 0) { perror("Unable to migrate to specified CPU"); exit(1); @@ -213,11 +215,11 @@ static void _rt_load_params_itrl(int argc, char **argv) { init_rt_task_param(&rt_param); // Fake exec cost - this value ignored by the MC^2 scheduler rt_param.exec_cost = _rt_period; - rt_param.period = ms2ns(_rt_period); + rt_param.period = _rt_period; rt_param.relative_deadline = 0; rt_param.phase = 0; rt_param.priority = LITMUS_LOWEST_PRIORITY; - rt_param.cls = crit; + rt_param.cls = _rt_crit; rt_param.budget_policy = NO_ENFORCEMENT; rt_param.cpu = _rt_core; rt_param.release_policy = TASK_PERIODIC; @@ -233,6 +235,7 @@ static void _rt_load_params_itrl(int argc, char **argv) { perror("Unable to become real-time task"); exit(1); } + _rt_cp = get_ctrl_page(); if (wait && wait_for_ts_release() != 0) { perror("Unable to wait for taskset release"); exit(1); @@ -412,6 +415,19 @@ out: // Start a job static void _rt_start_loop() { #if LITMUS + lt_t now = litmus_clock(); + if (now > _rt_cp->deadline) { + if (_rt_crit == 0) + fprintf(stderr, "CATASTROPHIC: Level-A"); + else if (_rt_crit == 1) + fprintf(stderr, "HAZARDOUS: Level-B"); + else + fprintf(stderr, "MAJOR: Level-C"); + fprintf(stderr, " task %s tardy %llu ns, " + "relative tardiness %f\n", + _rt_our_prog_name, now - _rt_cp->deadline, + (now - _rt_cp->deadline) / (double)_rt_period); + } if (sleep_next_period() != 0) { perror("Unable to sleep for next period"); } -- cgit v1.2.2