From e9ece8bc6650a3fc3d9a7496ccd3350851985159 Mon Sep 17 00:00:00 2001 From: mgh Date: Wed, 28 Jan 2009 10:33:33 +0000 Subject: [PATCH 1/1] Changed test_fosa_non_local_jump.c to improve displayed messages git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1501 35b4ef3e-fd22-0410-ab77-dab3279adceb --- .../test_non_local_jump/test_fosa_long_jump.c | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src_marte_os/tests/test_non_local_jump/test_fosa_long_jump.c b/src_marte_os/tests/test_non_local_jump/test_fosa_long_jump.c index 698a68c..1d1ffa7 100644 --- a/src_marte_os/tests/test_non_local_jump/test_fosa_long_jump.c +++ b/src_marte_os/tests/test_non_local_jump/test_fosa_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 @@ -81,7 +81,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(); int main() @@ -104,8 +104,10 @@ int main() /* We create a new thread with a given 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, NULL) ); + CHK( fosa_thread_attr_set_prio + (&periodic_attr, PERIODIC_THREAD_PRIORITY) ); + CHK( fosa_thread_create + (&periodic_tid, &periodic_attr, periodic_code, NULL) ); printf("Main goes to sleep...\n"); @@ -152,10 +154,13 @@ 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) ); + printf("Start periodic work with budget=1400ms\n"); + /* Periodic loop */ /*****************/ while (1) @@ -188,7 +193,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(); CHK( fosa_timer_disarm(jump_timer, NULL) ); printf("NOT JUMPPED\n"); } @@ -205,15 +210,17 @@ static void *periodic_code(void *thread_arg) /* Now we measure the time duration of the block */ /*************************************************/ - CHK( fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_activation_time) ); - elapsed_time = fosa_abs_time_extract_interval(activation_time, after_activation_time); - printf("Execution time: %ld msec\n", fosa_rel_time_to_msec(after_activation_time) ); + CHK( fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_activation_time) ); + elapsed_time = fosa_abs_time_extract_interval + (activation_time, after_activation_time); + printf("Execution time: %ld msec\n", + fosa_rel_time_to_msec(elapsed_time) ); /* And we program the next loop */ activation_time = fosa_abs_time_incr(activation_time, period); activation_time_tspec = fosa_abs_time_to_timespec(activation_time); - clock_nanosleep(FOSA_CLOCK_REALTIME, TIMER_ABSTIME, &activation_time_tspec, - NULL); + clock_nanosleep(FOSA_CLOCK_REALTIME, TIMER_ABSTIME, + &activation_time_tspec,NULL); } return NULL; @@ -222,25 +229,26 @@ static void *periodic_code(void *thread_arg) // ------------------------------------------------------------------------------ -static void work_under_a_interruptible_budget() +static void work_under_an_interruptible_budget() { static int i = 0; fosa_rel_time_t exec_time = fosa_msec_to_rel_time(1000); // 1 sec i++; - printf("Start regular work\n"); + printf("Start regular work (eat 1s)\n"); fosa_eat(&exec_time); /* Once in every 5 executions we work over the budget */ if (i % 5 == 0) { - fosa_eat(&exec_time); - fosa_eat(&exec_time); - fosa_eat(&exec_time); - fosa_eat(&exec_time); - fosa_eat(&exec_time); - fosa_eat(&exec_time); + printf("Eat additional time (6s more) \n"); + fosa_eat(&exec_time); + fosa_eat(&exec_time); + fosa_eat(&exec_time); + fosa_eat(&exec_time); + fosa_eat(&exec_time); + fosa_eat(&exec_time); } printf("End regular work\n"); -- 2.39.2