From b4db836c574c3fbe12cfb4999dad58630866a794 Mon Sep 17 00:00:00 2001 From: mgh Date: Wed, 28 Jan 2009 11:37:32 +0000 Subject: [PATCH 1/1] Modified testbench_long_jump to fix time units displayed and improve displayed messages git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1502 35b4ef3e-fd22-0410-ab77-dab3279adceb --- .../test_non_local_jump/testbench_long_jump.c | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src_marte_os/tests/test_non_local_jump/testbench_long_jump.c b/src_marte_os/tests/test_non_local_jump/testbench_long_jump.c index b779537..bffa7b5 100644 --- a/src_marte_os/tests/test_non_local_jump/testbench_long_jump.c +++ b/src_marte_os/tests/test_non_local_jump/testbench_long_jump.c @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// Copyright (C) 2006 - 2008 FRESCOR consortium partners: +// Copyright (C) 2006 - 2009 FRESCOR consortium partners: // // Universidad de Cantabria, SPAIN // University of York, UK @@ -102,7 +102,7 @@ static void *periodic_code(void *thread_arg); /* S T A T I C V A R I A B L E S */ /**********************************/ static fosa_long_jump_context_t context; -static void work_under_a_interruptible_budget(); +static void work_under_an_interruptible_budget(); fosa_abs_time_t before_jump_timestamp; @@ -114,6 +114,10 @@ int main() fosa_thread_id_t periodic_tid; results_t results; + printf("This test measures the time of a long jump\n"); + printf("It displays elapsed time for execution of an operation with a budget of 20ms\n"); + printf("\n"); + memset(&context, 0, sizeof(context) ); @@ -125,19 +129,24 @@ int main() CHK( fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) ); CHK( fosa_thread_attr_init(&periodic_attr) ); - CHK( fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY) ); - CHK( fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, &results) ); + CHK( fosa_thread_attr_set_prio + (&periodic_attr, PERIODIC_THREAD_PRIORITY) ); + CHK( fosa_thread_create + (&periodic_tid, &periodic_attr, periodic_code, &results) ); printf("Main waits for the periodic code to finish...\n"); pthread_join(periodic_tid, NULL); - results.average_jump_interval_ms = results.total_jump_interval_ms/results.number_of_jumps; + results.average_jump_interval_ms = + results.total_jump_interval_ms/results.number_of_jumps; printf("------------ RESULTS -------------\n"); printf("First Time: %6.3f ms\n Max Time: %6.3f ms Iteration %d Min Time: %6.3f ms Iteration %d\n", - results.first_jump_interval_ms, results.max_jump_interval_ms, results.iteration_max_jump_interval, + results.first_jump_interval_ms, results.max_jump_interval_ms, + results.iteration_max_jump_interval, results.min_jump_interval_ms, results.iteration_min_jump_interval); - printf("Average_time: %6.3f ms Total jumps: %d\n", results.average_jump_interval_ms, results.number_of_jumps); + printf("Average_time: %6.3f ms Total jumps: %d\n", + results.average_jump_interval_ms, results.number_of_jumps); printf("End of test\n"); return 0; @@ -179,8 +188,9 @@ static void *periodic_code(void *thread_arg) /*********************************************************/ CHK( fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) ); jump_signal_info.sival_ptr = &context; - CHK( fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, - &jump_timer, jump_handler_thread) ); + CHK( fosa_timer_create_with_receiver + (clock_id, jump_signal, jump_signal_info, + &jump_timer, jump_handler_thread) ); results->number_of_jumps = 0; @@ -217,7 +227,7 @@ static void *periodic_code(void *thread_arg) if (!jumped) { /* HERE COMES THE WORK THAT CAN BE INTERRUPTED */ - work_under_a_interruptible_budget(); + work_under_an_interruptible_budget(); printf("We should not arrive here \n"); exit(1); } @@ -226,8 +236,9 @@ static void *periodic_code(void *thread_arg) fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_jump_timestamp); results->number_of_jumps++; - jump_interval = fosa_abs_time_extract_interval(before_jump_timestamp, after_jump_timestamp); - jump_interval_ms = fosa_rel_time_to_msec(jump_interval); + jump_interval = fosa_abs_time_extract_interval + (before_jump_timestamp, after_jump_timestamp); + jump_interval_ms = fosa_rel_time_to_double(jump_interval)*1.0e6; if (first_time) { @@ -268,9 +279,9 @@ static void *periodic_code(void *thread_arg) } -// ------------------------------------------------------------------------------ +// ---------------------------------------------------------------------------- -static void work_under_a_interruptible_budget() +static void work_under_an_interruptible_budget() { /* This must be measured */ while(1) -- 2.39.2