Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:46

0001 /*  Tasks_Periodic
0002  *
0003  *  This routine serves as a test task for the EDF scheduler
0004  *  implementation.
0005  *
0006  *  Input parameters:
0007  *    argument - task argument
0008  *
0009  *  Output parameters:  NONE
0010  *
0011  *  The license and distribution terms for this file may be
0012  *  found in the file LICENSE in this distribution or at
0013  *  http://www.rtems.org/license/LICENSE.
0014  */
0015 
0016 #ifdef HAVE_CONFIG_H
0017 #include "config.h"
0018 #endif
0019 
0020 #include "system.h"
0021 
0022 rtems_task Tasks_Periodic(
0023   rtems_task_argument argument
0024 )
0025 {
0026   rtems_id          rmid;
0027   rtems_id          test_rmid;
0028   rtems_status_code status;
0029 
0030   int start, stop, now;
0031 
0032   status = rtems_rate_monotonic_create( argument, &rmid );
0033   directive_failed( status, "rtems_rate_monotonic_create" );
0034   put_name( Task_name[ argument ], FALSE );
0035   printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n",
0036           rmid );
0037 
0038   status = rtems_rate_monotonic_ident( argument, &test_rmid );
0039   directive_failed( status, "rtems_rate_monotonic_ident" );
0040   put_name( Task_name[ argument ], FALSE );
0041   printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n",
0042           test_rmid );
0043 
0044   if ( rmid != test_rmid ) {
0045      printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%"
0046              PRIxrtems_id ")\n", rmid, test_rmid );
0047      rtems_test_exit( 0 );
0048   }
0049 
0050   put_name( Task_name[ argument ], FALSE );
0051   printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n",
0052           rmid, Periods[ argument ] );
0053 
0054   status = rtems_task_wake_after( 2 + Phases[argument] );
0055   directive_failed( status, "rtems_task_wake_after" );
0056 
0057   while (FOREVER) {
0058     if (rtems_rate_monotonic_period(rmid, Periods[argument])==RTEMS_TIMEOUT)
0059       printf("P%" PRIdPTR " - Deadline miss\n", argument);
0060 
0061     start = rtems_clock_get_ticks_since_boot();
0062     printf("P%" PRIdPTR "-S ticks:%d\n", argument, start);
0063     if ( start >= 2*HP_LENGTH ) break; /* stop */
0064     /* active computing */
0065 
0066     /* using periodic statistics */
0067     while(FOREVER) {
0068       now = rtems_clock_get_ticks_since_boot();
0069       if (now >= start + Execution[argument]) break;
0070     }
0071     stop = rtems_clock_get_ticks_since_boot();
0072     printf("P%" PRIdPTR "-F ticks:%d\n", argument, stop);
0073   }
0074 
0075   /* delete period and SELF */
0076   status = rtems_rate_monotonic_delete( rmid );
0077   if ( status != RTEMS_SUCCESSFUL ) {
0078     printf("rtems_rate_monotonic_delete failed with status of %d.\n",status);
0079     rtems_test_exit( 0 );
0080   }
0081   fflush(stdout);
0082   TEST_END();
0083   rtems_test_exit( 0 );
0084 }