From 4a2b128f0db282896552ba3dc311c0241ea819e4 Mon Sep 17 00:00:00 2001 From: Mac Mollison Date: Fri, 14 Jan 2011 12:15:02 -0500 Subject: Remove loop_length features A large amount of code was devoted to computing the duration of one complete run of the spin loop, and related auxiliary featues. This code was (essentially) obsoleted when we started using the POSIX clock_gettime() function to control how long spinning occurs. This patch removes this obsolete code. --- bin/rtspin.c | 100 ++--------------------------------------------------------- 1 file changed, 2 insertions(+), 98 deletions(-) diff --git a/bin/rtspin.c b/bin/rtspin.c index 3e22ffe..01855ab 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c @@ -112,8 +112,6 @@ static void get_exec_times(const char *file, const int column, #define NUMS 4096 static int num[NUMS]; -static double loop_length = 1.0; -static char* progname; static int loop_once(void) { @@ -125,18 +123,11 @@ static int loop_once(void) static int loop_for(double exec_time, double emergency_exit) { - double t = 0; int tmp = 0; -/* while (t + loop_length < exec_time) { - tmp += loop_once(); - t += loop_length; - } -*/ double start = cputime(); double now = cputime(); - while (now + loop_length < start + exec_time) { + while (now < start + exec_time) { tmp += loop_once(); - t += loop_length; now = cputime(); if (emergency_exit && wctime() > emergency_exit) { /* Oops --- this should only be possible if the execution time tracking @@ -150,64 +141,6 @@ static int loop_for(double exec_time, double emergency_exit) return tmp; } -static void fine_tune(double interval) -{ - double start, end, delta; - - start = wctime(); - loop_for(interval, 0); - end = wctime(); - delta = (end - start - interval) / interval; - if (delta != 0) - loop_length = loop_length / (1 - delta); -} - -static void configure_loop(void) -{ - double start; - - /* prime cache */ - loop_once(); - loop_once(); - loop_once(); - - /* measure */ - start = wctime(); - loop_once(); /* hope we didn't get preempted */ - loop_length = wctime(); - loop_length -= start; - - /* fine tune */ - fine_tune(0.1); - fine_tune(0.1); - fine_tune(0.1); -} - -static void show_loop_length(void) -{ - printf("%s/%d: loop_length=%f (%ldus)\n", - progname, getpid(), loop_length, - (long) (loop_length * 1000000)); -} - -static void debug_delay_loop(void) -{ - double start, end, delay; - show_loop_length(); - while (1) { - for (delay = 0.5; delay > 0.01; delay -= 0.01) { - start = wctime(); - loop_for(delay, 0); - end = wctime(); - printf("%6.4fs: looped for %10.8fs, delta=%11.8fs, error=%7.4f%%\n", - delay, - end - start, - end - start - delay, - 100 * (end - start - delay) / delay); - } - } -} - static int job(double exec_time, double program_end) { if (wctime() > program_end) @@ -221,7 +154,7 @@ static int job(double exec_time, double program_end) #define OPTSTR "p:c:wld:veo:f:s:" -int main(int argc, char** argv) +int main(int argc, char** argv) { int ret; lt_t wcet; @@ -231,9 +164,6 @@ int main(int argc, char** argv) int cpu = 0; int opt; int wait = 0; - int test_loop = 0; - int skip_config = 0; - int verbose = 0; int column = 1; const char *file = NULL; int want_enforcement = 0; @@ -243,8 +173,6 @@ int main(int argc, char** argv) task_class_t class = RT_CLASS_HARD; int cur_job, num_jobs; - progname = argv[0]; - while ((opt = getopt(argc, argv, OPTSTR)) != -1) { switch (opt) { case 'w': @@ -262,18 +190,6 @@ int main(int argc, char** argv) case 'e': want_enforcement = 1; break; - case 'l': - test_loop = 1; - break; - case 'd': - /* manually configure delay per loop iteration - * unit: microseconds */ - loop_length = atof(optarg) / 1000000; - skip_config = 1; - break; - case 'v': - verbose = 1; - break; case 'o': column = atoi(optarg); break; @@ -293,15 +209,6 @@ int main(int argc, char** argv) } } - - if (!skip_config) - configure_loop(); - - if (test_loop) { - debug_delay_loop(); - return 0; - } - if (file) { get_exec_times(file, column, &num_jobs, &exec_times); @@ -354,9 +261,6 @@ int main(int argc, char** argv) if (ret < 0) bail_out("could not setup rt task params"); - if (verbose) - show_loop_length(); - init_litmus(); ret = task_mode(LITMUS_RT_TASK); -- cgit v1.2.2