diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-11 20:56:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-11 20:56:45 +0000 |
commit | 0d6aee4e35fc675f975a679dc1fd58d873d093e1 (patch) | |
tree | 29413772e49aa1f3749be945f3f9e19fe375a0ff /testsuites/sptests/spedfsched02/task1.c | |
parent | 2011-09-11 Petr Benes <benesp16@fel.cvut.cz> (diff) | |
download | rtems-0d6aee4e35fc675f975a679dc1fd58d873d093e1.tar.bz2 |
2011-09-11 Petr Benes <benesp16@fel.cvut.cz>
PR 1897/testing
* Makefile.am, configure.ac: Add tests for Earliest Deadline First
(EDF) Scheduling Algorithm implementation.
* spedfsched01/.cvsignore, spedfsched01/Makefile.am,
spedfsched01/init.c, spedfsched01/spedfsched01.doc,
spedfsched01/spedfsched01.scn, spedfsched01/system.h,
spedfsched01/task1.c, spedfsched02/.cvsignore,
spedfsched02/Makefile.am, spedfsched02/getall.c, spedfsched02/init.c,
spedfsched02/spedfsched02.doc, spedfsched02/spedfsched02.scn,
spedfsched02/system.h, spedfsched02/task1.c, spedfsched03/.cvsignore,
spedfsched03/Makefile.am, spedfsched03/edfparams.h,
spedfsched03/init.c, spedfsched03/spedfsched03.doc,
spedfsched03/spedfsched03.scn, spedfsched03/system.h,
spedfsched03/tasks_aperiodic.c, spedfsched03/tasks_periodic.c: New
files.
Diffstat (limited to 'testsuites/sptests/spedfsched02/task1.c')
-rw-r--r-- | testsuites/sptests/spedfsched02/task1.c | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/testsuites/sptests/spedfsched02/task1.c b/testsuites/sptests/spedfsched02/task1.c new file mode 100644 index 0000000000..e516eaeafe --- /dev/null +++ b/testsuites/sptests/spedfsched02/task1.c @@ -0,0 +1,158 @@ +/* Task_1_through_6 + * + * This routine serves as a test task for the EDF scheduling + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include "system.h" + +/* + runtime of TA6 should be shorter than TA5 + */ +#define TA6_ITERATIONS 10 +#define TA6_PERIOD_FACTOR 10 + +uint32_t Periods[7] = { 0, 2, 2, 2, 2, 100, 0 }; +uint32_t Iterations[7] = { 0, 50, 50, 50, 50, 1, TA6_ITERATIONS }; +rtems_task_priority Priorities[7] = { 0, 2, 2, 2, 2, 100, 1 }; + +rtems_task Task_1_through_6( + rtems_task_argument argument +) +{ + rtems_id rmid; + rtems_id test_rmid; + int index; + int pass; + uint32_t failed; + rtems_status_code status; + + status = rtems_rate_monotonic_create( argument, &rmid ); + directive_failed( status, "rtems_rate_monotonic_create" ); + put_name( Task_name[ argument ], FALSE ); + printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n", + rmid ); + + status = rtems_rate_monotonic_ident( argument, &test_rmid ); + directive_failed( status, "rtems_rate_monotonic_ident" ); + put_name( Task_name[ argument ], FALSE ); + printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n", + test_rmid ); + + if ( rmid != test_rmid ) { + printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n", + rmid, test_rmid ); + rtems_test_exit( 0 ); + } + + put_name( Task_name[ argument ], FALSE ); + printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n", + rmid, Periods[ argument ] ); + + status = rtems_task_wake_after( 2 ); + directive_failed( status, "rtems_task_wake_after" ); + + switch ( argument ) { + case 1: + case 2: + case 3: + case 4: + while ( FOREVER ) { + status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); + directive_failed( status, "rtems_rate_monotonic_period" ); + + Count.count[ argument ]++; + } + break; + case 5: + pass = 0; + failed = 0; + + status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); + directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" ); + + Get_all_counters(); + + while ( FOREVER ) { + + status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); + directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); + + Get_all_counters(); + + for( index = 1 ; index <= 4 ; index++ ) { + if ( Temporary_count.count[ index ] != Iterations[ index ] ) { + puts_nocr( "FAIL -- " ); + put_name ( Task_name[ index ], FALSE ); + printf ( " Actual=%" PRIu32 ", Expected=%" PRIu32 "\n", + Temporary_count.count[ index ], + Iterations[ index ] + ); + failed += 1; + } + } + + if ( failed == 5 ) + rtems_test_exit( 0 ); + + pass += 1; + + printf( "TA5 - PERIODS CHECK OK (%d)\n", pass ); + + fflush( stdout ); + + if ( pass == 10 ) { + puts( "*** END OF TEST EDF SCHEDULER 2 ***" ); + rtems_test_exit( 0 ); + } + + } + break; + case 6: + /* test changing periods */ + { + uint32_t time[TA6_ITERATIONS+1]; + rtems_interval period; + + period = 1*TA6_PERIOD_FACTOR; + status = rtems_rate_monotonic_period( rmid, period); + directive_failed( status, "rtems_rate_monotonic_period of TA6" ); + time[0] = _Watchdog_Ticks_since_boot; /* timestamp */ + /*printf("%d - %d\n", period, time[0]);*/ + + for (index = 1; index <= TA6_ITERATIONS; index++) + { + period = (index+1)*TA6_PERIOD_FACTOR; + status = rtems_rate_monotonic_period( rmid, period); + directive_failed( status, "rtems_rate_monotonic_period of TA6" ); + time[index] = _Watchdog_Ticks_since_boot; /* timestamp */ + /*printf("%d - %d\n", period, time[index]);*/ + } + + for (index = 1; index <= TA6_ITERATIONS; index++) + { + rtems_interval meas = time[index] - time[index-1]; + period = index*TA6_PERIOD_FACTOR; + printf( "TA6 - Actual: %" PRIdrtems_interval " Expected: %" + PRIdrtems_interval, meas, period ); + if (period == meas) printf(" - OK\n"); + else printf(" - FAILED\n"); + } + } + rtems_task_suspend(RTEMS_SELF); + break; + } +} |