X-Git-Url: http://rtime.felk.cvut.cz/gitweb/rtems-pluggable-edf.git/blobdiff_plain/3670b5643daad3877116868adb7640ac5c4f34c2..b78e60b8f69ae6a4f1fe3e0f71c9eadffb1722e2:/src/test_edf/task.c diff --git a/src/test_edf/task.c b/src/test_edf/task.c index 7152ca4..27a10eb 100644 --- a/src/test_edf/task.c +++ b/src/test_edf/task.c @@ -1,4 +1,21 @@ +#include #include "system.h" +#include "app_def.h" +#include +#include +#include +#include +#include +#include +#include + + +#define TEST_DURATION 130 + +#define T1_DUR 400000000 +#define T2_DUR 600000000 +#define T1_PER 7 +#define T2_PER 10 rtems_task Task_1( rtems_task_argument argument @@ -9,27 +26,29 @@ rtems_task Task_1( rtems_status_code status; char output1[50]; char output2[50]; - unsigned32 start, stop, period_length, max_i, max_j; - unsigned32 i,j,k,l; + unsigned int start, stop, period_length, max_i, max_j; + unsigned int i,j,k; name = rtems_build_name( 'P', 'E', 'R', 'A' ); 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 = 7; - max_i = 10000; max_j = 4000; + period_length = T1_PER; // duration 3 ticks + max_i = 10000; max_j = T1_DUR; + edf_deadline_init(period_length); while ( 1 ) { if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) puts("P1 - Deadline miss"); - + edf_next_period(); rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); - sprintf(output1,"P1-S ticks:%d",start); + sprintf(output1,"P1-S ticks:%u",start); puts(output1); - if ( start >= 30 ) break; + if ( start >= TEST_DURATION ) break; /* active computing */ for ( i = 1 ; i < max_i; i++) @@ -43,21 +62,25 @@ rtems_task Task_1( } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); - sprintf(output2,"P1-F ticks:%d",stop); + sprintf(output2,"P1-F ticks:%u",stop); puts(output2); } /* 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 ); - rtems_test_exit( 0 ); + exit( 0 ); } puts( "*** END OF TEST - edf***" ); - rtems_test_exit( 0 ); + exit( 0 ); } + + + rtems_task Task_2( rtems_task_argument argument ) @@ -67,8 +90,8 @@ rtems_task Task_2( rtems_status_code status; char output1[50]; char output2[50]; - unsigned32 start, stop, period_length, max_i, max_j; - unsigned32 i,j,k,l; + unsigned int start, stop, period_length, max_i, max_j; + unsigned int i,j,k; name = rtems_build_name( 'P', 'E', 'R', 'B' ); status = rtems_rate_monotonic_create( name, &period ); @@ -77,17 +100,18 @@ rtems_task Task_2( exit( 1 ); } - period_length = 10; - max_i = 10000; max_j = 6000; + period_length = T2_PER; // duration 5 ticks + max_i = 10000; max_j = T2_DUR; + edf_deadline_init(period_length); while ( 1 ) { if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) puts("P2 - Deadline miss"); - + edf_next_period(); rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); - sprintf(output1,"P2-S ticks:%d",start); + sprintf(output1,"P2-S ticks:%u",start); puts(output1); - if ( _Watchdog_Ticks_since_boot >= 30 ) { + if ( _Watchdog_Ticks_since_boot >= TEST_DURATION ) { break; } @@ -104,17 +128,19 @@ rtems_task Task_2( } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); - sprintf(output2,"P2-F ticks:%d",stop); + sprintf(output2,"P2-F ticks:%u",stop); puts(output2); } /* 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 ); - rtems_test_exit( 0 ); + exit( 0 ); } puts( "*** END OF TEST - edf***" ); - rtems_test_exit( 0 ); + exit( 0 ); } +