Example #1
0
static int rtems_shell_main_perioduse(
  int   argc,
  char *argv[]
)
{
  /*
   *  When invoked with no arguments, print the report.
   */
  if ( argc == 1 ) {
    rtems_rate_monotonic_report_statistics_with_plugin(
      stdout,
      (rtems_printk_plugin_t)fprintf
    );
    return 0;
  }

  /*
   *  When invoked with the single argument -r, reset the statistics.
   */
  if ( argc == 2 && !strcmp( argv[1], "-r" ) ) {
    printf( "Resetting Period Usage information\n" );
    rtems_rate_monotonic_reset_all_statistics();
    return 0;
  }

  /*
   *  OK.  The user did something wrong.
   */
  fprintf( stderr, "%s: [-r]\n", argv[0] );
  return -1;
}
Example #2
0
rtems_task Task_1_through_5(
  rtems_task_argument argument
)
{
  rtems_id          rmid;
  rtems_id          test_rmid;
  uint32_t          index;
  uint32_t          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 (%" PRIu32 ")\n", pass );

        FLUSH_OUTPUT();

        if ( pass == 10 ) {
          puts( "" );
          rtems_rate_monotonic_report_statistics();

          rtems_rate_monotonic_reset_statistics( rmid );
          puts( "" );
          puts( "TA5 - PERIOD STATISTICS RESET" );
          puts( "" );
          rtems_rate_monotonic_report_statistics();

          rtems_rate_monotonic_reset_all_statistics();
          puts( "" );
          puts( "TA5 - ALL PERIOD STATISTICS RESET" );
          puts( "" );
          rtems_rate_monotonic_report_statistics();

          puts( "" );
          puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" );

          rtems_test_exit( 0 );
        }

      }
      break;
  }
}