From: Petr Benes Date: Sun, 17 Apr 2011 15:04:07 +0000 (+0200) Subject: Test_edf: code refactored, redundant code for multiple tasks is gone X-Git-Url: https://rtime.felk.cvut.cz/gitweb/rtems-pluggable-edf.git/commitdiff_plain/1fc55dea9fc2e3701ec505a332ccae66c59c92bf Test_edf: code refactored, redundant code for multiple tasks is gone --- diff --git a/src/test_edf/task.c b/src/test_edf/task.c index 96b9881..22bffe8 100644 --- a/src/test_edf/task.c +++ b/src/test_edf/task.c @@ -23,20 +23,16 @@ #define T1_SERVER 0 #define T2_SERVER 0 -rtems_task Task_1( - rtems_task_argument argument -) +void test_loop ( rtems_name name, unsigned int period_length, unsigned int max_j, uint32_t server) { - rtems_name name; rtems_id period; rtems_status_code status; char output1[50]; char output2[50]; - unsigned int start, stop, period_length, max_i, max_j; + unsigned int start, stop, max_i; unsigned int i,j,k; void *mem; - name = rtems_build_name( 'P', 'E', 'R', 'A' ); status = rtems_rate_monotonic_create( name, &period ); if ( status != RTEMS_SUCCESSFUL ) { @@ -44,9 +40,8 @@ rtems_task Task_1( exit( 1 ); } - period_length = T1_PER; // duration 3 ticks - max_i = 1000; max_j = T1_DUR; - edf_deadline_init(period_length, T1_SERVER, NULL); + max_i = 1000; + edf_deadline_init(period_length, server, NULL); while ( 1 ) { edf_next_period(); if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) @@ -85,76 +80,28 @@ rtems_task Task_1( } puts( "*** END OF TEST - edf***" ); - exit( 0 ); + exit( 0 ); } +rtems_task Task_1( + rtems_task_argument argument +) +{ + rtems_name name; + name = rtems_build_name( 'P', 'E', 'R', 'A' ); + test_loop(name, T1_PER,T1_DUR,T1_SERVER); +} + rtems_task Task_2( rtems_task_argument argument ) { - rtems_name name; - rtems_id period; - rtems_status_code status; - char output1[50]; - char output2[50]; - unsigned int start, stop, period_length, max_i, max_j; - unsigned int i,j,k; - void *mem; - - name = rtems_build_name( 'P', 'E', 'R', 'B' ); - status = rtems_rate_monotonic_create( name, &period ); - if ( status != RTEMS_SUCCESSFUL ) { - printf( "rtems_monotonic_create failed with status of %d.\n", status ); - exit( 1 ); - } - - period_length = T2_PER; // duration 5 ticks - max_i = 1000; max_j = T2_DUR; - edf_deadline_init(period_length, T2_SERVER, NULL); - while ( 1 ) { - edf_next_period(); - if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) - puts("P2 - Deadline miss"); - - rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); - sprintf(output1,"P2-S ticks:%u prio:%u",start, (unsigned int)_Per_CPU_Information.executing->current_priority); - puts(output1); - - if ( _Watchdog_Ticks_since_boot >= TEST_DURATION ) { - break; - } - - /* active computing */ - - for ( i = 1 ; i < max_i; i++) - { - j = i/12 ; j++; - for ( j = 1; j < max_j; j++) - { - k = j/ 3; - k++; - mem = _Workspace_Allocate (4); - _Workspace_Free(mem); - } - } - - rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); - sprintf(output2,"P2-F ticks:%u",stop); - puts(output2); - } + rtems_name name; + name = rtems_build_name( 'P', 'E', 'R', 'B' ); + test_loop(name, T2_PER,T2_DUR,T2_SERVER); - /* missed period so delete period and SELF */ - status = rtems_rate_monotonic_delete( period ); - edf_deadline_cancel(); - if ( status != RTEMS_SUCCESSFUL ) { - printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status ); - exit( 0 ); - } - - puts( "*** END OF TEST - edf***" ); - exit( 0 ); }