示例#1
0
文件: task1.c 项目: Avanznow/rtems
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  rtems_task_priority the_priority;
  rtems_task_priority previous_priority;

  rtems_test_pause();

  status = rtems_task_set_priority(
    RTEMS_SELF,
    RTEMS_CURRENT_PRIORITY,
    &the_priority
  );
  directive_failed( status, "rtems_task_set_priority" );
  printf(
    "TA1 - rtems_task_set_priority - get initial "
       "priority of self: %02" PRIdrtems_task_priority "\n",
    the_priority
  );

  while( FOREVER ) {
    if ( --the_priority == 0 ) {
      puts( "TA1 - rtems_task_suspend - suspend TA2" );
      status = rtems_task_suspend( Task_id[ 2 ] );
      directive_failed( status, "rtems_task_suspend" );

      puts( "TA1 - rtems_task_set_priority - set priority of TA2 ( blocked )" );
      status = rtems_task_set_priority( Task_id[ 2 ], 5, &previous_priority );
      directive_failed( status, "rtems_task_set_priority" );

      status = rtems_task_delete( Task_id[ 2 ] );
      directive_failed( status, "rtems_task_delete of TA2" );

      status = rtems_task_delete( RTEMS_SELF );
      directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
    }

    printf(
      "TA1 - rtems_task_set_priority - set TA2's priority: "
          "%02" PRIdrtems_task_priority "\n",
      the_priority
    );
    status = rtems_task_set_priority(
               Task_id[ 2 ],
               the_priority,
               &previous_priority
    );
    directive_failed( status, "rtems_task_set_priority" );
  }
}
示例#2
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id                 tmid;
  rtems_id                 tmid2;
  rtems_time_of_day        time;
  rtems_status_code        status;
  rtems_timer_information  info;

/* Get id */

  puts( "TA1 - rtems_timer_ident - identing timer 1" );
  status = rtems_timer_ident( Timer_name[ 1 ], &tmid );
  directive_failed( status, "rtems_timer_ident" );
  printf( "TA1 - timer 1 has id (0x%" PRIxrtems_id ")\n", tmid );

  puts( "TA1 - rtems_timer_ident - identing timer 2" );
  status = rtems_timer_ident( Timer_name[ 2 ], &tmid2 );
  directive_failed( status, "rtems_timer_ident" );
  printf( "TA1 - timer 2 has id (0x%" PRIxrtems_id ")\n", tmid2 );

/* make sure insertion does not unintentionally fire a timer per PR147 */

  TSR_fired = 0;

  puts( "TA1 - rtems_timer_server_fire_after - 1 second" );
  status = rtems_timer_server_fire_after(
    tmid, rtems_clock_get_ticks_per_second(), Should_not_fire_TSR, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_task_wake_after - 1/2 second" );
  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() / 2 );
  directive_failed( status, "rtems_timer_server_fire_after" );

  directive_failed( status, "rtems_timer_server_fire_after" );
  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 1/2 second" );
  status = rtems_timer_server_fire_after(
    tmid2, rtems_clock_get_ticks_per_second() / 2, Should_not_fire_TSR, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  if ( TSR_fired ) {
    puts( "TA1 - TSR fired and should not have!" );
    rtems_test_exit(1);
  }

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

  puts( "TA1 - rtems_timer_cancel - timer 2" );
  status = rtems_timer_cancel( tmid2 );
  directive_failed( status, "rtems_timer_cancel" );


/* now check that rescheduling an active timer works OK. */
  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 30 seconds" );
  status = rtems_timer_server_fire_after(
    tmid, 30 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
  status = rtems_timer_server_fire_after(
    tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  status = rtems_timer_get_information( tmid, &info );
  printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    info.start_time + info.initial );
  printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    schedule_time() );

  puts( "TA1 - rtems_task_wake_after - 1 second" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_timer_wake_after" );

  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
  status = rtems_timer_server_fire_after(
    tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  status = rtems_timer_get_information( tmid, &info );
  directive_failed( status, "rtems_timer_get_information" );
  printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    info.start_time + info.initial );
  printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    schedule_time() );
  rtems_test_assert( (info.start_time + info.initial) == schedule_time() );

  puts( "TA1 - rtems_task_wake_after - 1 second" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_timer_wake_after" );

  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
  status = rtems_timer_server_fire_after(
    tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  status = rtems_timer_get_information( tmid, &info );
  directive_failed( status, "rtems_timer_get_information" );
  printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    info.start_time + info.initial );
  printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
    schedule_time() );
  rtems_test_assert( (info.start_time + info.initial) == schedule_time() );

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

  puts( "TA1 - rtems_timer_cancel - timer 2" );
  status = rtems_timer_cancel( tmid2 );
  directive_failed( status, "rtems_timer_cancel" );

/* after which is allowed to fire */

  Print_time();

  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_after(
    tmid,
    3 * rtems_clock_get_ticks_per_second(),
    Delayed_resume,
    NULL
  );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
  status = rtems_task_suspend( RTEMS_SELF );
  directive_failed( status, "rtems_task_suspend" );

  Print_time();

/* after which is reset and allowed to fire */

  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_after(
    tmid,
    3 * rtems_clock_get_ticks_per_second(),
    Delayed_resume,
    NULL
  );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_task_wake_after - 1 second" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  Print_time();

  puts( "TA1 - rtems_timer_reset - timer 1" );
  status = rtems_timer_reset( tmid );
  directive_failed( status, "rtems_timer_reset" );

  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
  status = rtems_task_suspend( RTEMS_SELF );
  directive_failed( status, "rtems_task_suspend" );

  Print_time();

  rtems_test_pause();

  /*
   *  Reset the time since we do not know how long the user waited
   *  before pressing <cr> at the pause.  This insures that the
   *  actual output matches the screen.
   */

  build_time( &time, 12, 31, 1988, 9, 0, 7, 0 );

  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

/* after which is canceled */

  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_after(
    tmid,
    3 * rtems_clock_get_ticks_per_second(),
    Delayed_resume,
    NULL
  );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

/* when which is allowed to fire */

  Print_time();

  status = rtems_clock_get_tod( &time );
  directive_failed( status, "rtems_clock_get_tod" );

  time.second += 3;

  puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_when( tmid, &time, Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
  status = rtems_task_suspend( RTEMS_SELF );
  directive_failed( status, "rtems_task_suspend" );

  Print_time();

/* when which is canceled */

  status = rtems_clock_get_tod( &time );
  directive_failed( status, "rtems_clock_get_tod" );

  time.second += 3;

  puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_when( tmid, &time, Delayed_resume, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  puts( "TA1 - rtems_task_wake_after - 1 second" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  Print_time();

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

/* TOD timer insert with non empty TOD timer chain */

  status = rtems_clock_get_tod( &time );
  directive_failed( status, "rtems_clock_get_tod" );

  time.second += 3;

  puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" );
  status = rtems_timer_server_fire_when( tmid, &time, Do_nothing, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  puts( "TA1 - rtems_timer_server_fire_when - timer 2 in 3 seconds" );
  status = rtems_timer_server_fire_when( tmid2, &time, Do_nothing, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  puts( "TA1 - rtems_task_wake_after - 1 second" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_timer_server_fire_when - timer 2 in 3 seconds" );
  status = rtems_timer_server_fire_when( tmid2, &time, Do_nothing, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

  puts( "TA1 - rtems_timer_cancel - timer 2" );
  status = rtems_timer_cancel( tmid2 );
  directive_failed( status, "rtems_timer_cancel" );

/* TOD chain processing with time wrap */

  time.second = 30;

  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  time.second = 31;

  puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 1 seconds" );
  status = rtems_timer_server_fire_when( tmid, &time, Do_nothing, NULL );
  directive_failed( status, "rtems_timer_server_fire_when" );

  time.second = 29;

  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 1 tick" );
  status = rtems_timer_server_fire_after( tmid2, 1, Do_nothing, NULL );
  directive_failed( status, "rtems_timer_server_fire_after" );

  puts( "TA1 - rtems_task_wake_after - 1 tick" );
  status = rtems_task_wake_after( 1 );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_timer_cancel - timer 1" );
  status = rtems_timer_cancel( tmid );
  directive_failed( status, "rtems_timer_cancel" );

/* delete */
  puts( "TA1 - rtems_task_wake_after - YIELD (only task at priority)" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - timer_deleting - timer 1" );
  status = rtems_timer_delete( tmid );
  directive_failed( status, "rtems_timer_delete" );

  puts( "*** END OF TEST 31 *** " );
  rtems_test_exit( 0 );
}
示例#3
0
文件: testtask.c 项目: Avanznow/rtems
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_name                 name RTEMS_GCC_NOWARN_UNUSED;
  uint32_t                   index RTEMS_GCC_NOWARN_UNUSED;
  rtems_id                   id RTEMS_GCC_NOWARN_UNUSED;
  rtems_task_priority        in_priority RTEMS_GCC_NOWARN_UNUSED;
  rtems_task_priority        out_priority RTEMS_GCC_NOWARN_UNUSED;
  rtems_mode                 in_mode RTEMS_GCC_NOWARN_UNUSED;
  rtems_mode                 mask RTEMS_GCC_NOWARN_UNUSED;
  rtems_mode                 out_mode RTEMS_GCC_NOWARN_UNUSED;
  rtems_time_of_day          time RTEMS_GCC_NOWARN_UNUSED;
  rtems_interval             timeout RTEMS_GCC_NOWARN_UNUSED;
  rtems_signal_set           signals RTEMS_GCC_NOWARN_UNUSED;
  void                      *address_1 RTEMS_GCC_NOWARN_UNUSED;
  rtems_event_set            events RTEMS_GCC_NOWARN_UNUSED;
  long                       buffer[ 4 ] RTEMS_GCC_NOWARN_UNUSED;
  uint32_t                   count RTEMS_GCC_NOWARN_UNUSED;
  rtems_device_major_number  major RTEMS_GCC_NOWARN_UNUSED;
  rtems_device_minor_number  minor RTEMS_GCC_NOWARN_UNUSED;
  uint32_t                   io_result RTEMS_GCC_NOWARN_UNUSED;
  uint32_t                   error RTEMS_GCC_NOWARN_UNUSED;
  rtems_clock_get_options    options RTEMS_GCC_NOWARN_UNUSED;

  name        = rtems_build_name( 'N', 'A', 'M', 'E' );
  in_priority = 250;
  in_mode     = RTEMS_NO_PREEMPT;
  mask        = RTEMS_PREEMPT_MASK;
  timeout     = 100;
  signals     = RTEMS_SIGNAL_1 | RTEMS_SIGNAL_3;
  major       = 10;
  minor       = 0;
  error       = 100;
  options     = 0;

/* rtems_shutdown_executive */

  benchmark_timer_initialize();
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
      (void) rtems_shutdown_executive( error );
  end_time = benchmark_timer_read();

  put_time(
    "overhead: rtems_shutdown_executive",
    end_time,
    OPERATION_COUNT,
    overhead,
    0
  );

/* rtems_task_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_create(
               name,
               in_priority,
               RTEMS_MINIMUM_STACK_SIZE,
               RTEMS_DEFAULT_MODES,
               RTEMS_DEFAULT_ATTRIBUTES,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_ident( name, RTEMS_SEARCH_ALL_NODES, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_start */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_start( id, Task_1, 0 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_start",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_restart */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_restart( id, 0 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_restart",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_suspend */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_suspend( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_suspend",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_resume */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_resume( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_resume",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_set_priority */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_set_priority( id, in_priority, &out_priority );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_set_priority",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_mode */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_mode( in_mode, mask, &out_mode );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_mode",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_wake_when */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_wake_when( time );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_wake_when",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_task_wake_after */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_task_wake_after( timeout );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_task_wake_after",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_interrupt_catch */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_interrupt_catch( Isr_handler, 5, address_1 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_interrupt_catch",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_clock_get */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_clock_get( options, time );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_clock_get",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_clock_set */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_clock_set( time );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_clock_set",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_clock_tick */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
           (void) rtems_clock_tick();
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_clock_tick",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

rtems_test_pause();

/* rtems_timer_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_create( name, &id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_ident( name, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_fire_after */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_fire_after(
               id,
               timeout,
               Timer_handler,
               NULL
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_fire_after",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_fire_when */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_fire_when(
               id,
               time,
               Timer_handler,
               NULL
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_fire_when",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_reset */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_reset( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_reset",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_timer_cancel */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_timer_cancel( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_timer_cancel",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_semaphore_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_semaphore_create(
               name,
               128,
               RTEMS_DEFAULT_ATTRIBUTES,
               RTEMS_NO_PRIORITY,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_semaphore_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_semaphore_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_semaphore_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_semaphore_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_semaphore_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_semaphore_ident( name, RTEMS_SEARCH_ALL_NODES, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_semaphore_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_semaphore_obtain */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_semaphore_obtain( id, RTEMS_DEFAULT_OPTIONS, timeout );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_semaphore_obtain",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_semaphore_release */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_semaphore_release( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_semaphore_release",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_create(
               name,
               128,
               RTEMS_DEFAULT_ATTRIBUTES,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_ident(
              name,
              RTEMS_SEARCH_ALL_NODES,
              id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_send */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_send( id, (long (*)[4])buffer );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_send",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_urgent */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_urgent( id, (long (*)[4])buffer );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_urgent",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_broadcast */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_broadcast(
               id,
               (long (*)[4])buffer,
               &count
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_broadcast",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_receive */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_receive(
               id,
               (long (*)[4])buffer,
               RTEMS_DEFAULT_OPTIONS,
               timeout
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_receive",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_message_queue_flush */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_message_queue_flush( id, &count );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_message_queue_flush",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

rtems_test_pause();

/* rtems_event_send */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_event_send( id, events );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_event_send",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_event_receive */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_event_receive(
               RTEMS_EVENT_16,
               RTEMS_DEFAULT_OPTIONS,
               timeout,
               &events
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_event_receive",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_signal_catch */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_signal_catch( Asr_handler, RTEMS_DEFAULT_MODES );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_signal_catch",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_signal_send */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_signal_send( id, signals );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_signal_send",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_partition_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_partition_create(
               name,
               Memory_area,
               2048,
               128,
               RTEMS_DEFAULT_ATTRIBUTES,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_partition_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_partition_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_partition_ident( name, RTEMS_SEARCH_ALL_NODES, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_partition_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_partition_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_partition_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_partition_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_partition_get_buffer */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_partition_get_buffer( id, address_1 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_partition_get_buffer",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_partition_return_buffer */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_partition_return_buffer( id, address_1 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_partition_return_buffer",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_region_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_region_create(
               name,
               Memory_area,
               2048,
               128,
               RTEMS_DEFAULT_ATTRIBUTES,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_region_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_region_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_region_ident( name, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_region_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_region_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_region_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_region_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_region_get_segment */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_region_get_segment(
               id,
               243,
               RTEMS_DEFAULT_OPTIONS,
               timeout,
               &address_1
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_region_get_segment",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_region_return_segment */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_region_return_segment( id, address_1 );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_region_return_segment",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_port_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_port_create(
               name,
               Internal_port_area,
               External_port_area,
               0xff,
               &id
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_port_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_port_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_port_ident( name, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_port_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_port_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_port_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_port_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_port_external_to_internal */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_port_external_to_internal(
               id,
               &External_port_area[ 7 ],
               address_1
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_port_external_to_internal",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_port_internal_to_external */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_port_internal_to_external(
               id,
               &Internal_port_area[ 7 ],
               address_1
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_port_internal_to_external",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

rtems_test_pause();

/* rtems_io_initialize */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_initialize(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_initialize",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_io_open */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_open(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_open",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_io_close */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_close(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_close",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_io_read */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_read(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_read",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_io_write */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_write(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_write",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_io_control */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_io_control(
               major,
               minor,
               address_1,
               &io_result
            );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_io_control",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_fatal_error_occurred */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_fatal_error_occurred( error );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_fatal_error_occurred",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_rate_monotonic_create */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_rate_monotonic_create( name, &id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_rate_monotonic_create",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_rate_monotonic_ident */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_rate_monotonic_ident( name, id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_rate_monotonic_ident",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_rate_monotonic_delete */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_rate_monotonic_delete( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_rate_monotonic_delete",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_rate_monotonic_cancel */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_rate_monotonic_cancel( id );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_rate_monotonic_cancel",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_rate_monotonic_period */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_rate_monotonic_period( id, timeout );
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_rate_monotonic_period",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

/* rtems_multiprocessing_announce */

      benchmark_timer_initialize();
         for ( index = 1 ; index <= OPERATION_COUNT ; index ++ )
            (void) rtems_multiprocessing_announce();
      end_time = benchmark_timer_read();

      put_time(
         "overhead: rtems_multiprocessing_announce",
         end_time,
         OPERATION_COUNT,
         overhead,
         0
      );

  TEST_END();

  rtems_test_exit( 0 );
}
示例#4
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  uint32_t   index;

  check_read_timer();
rtems_test_pause();

  benchmark_timer_initialize();
  end_time = benchmark_timer_read();

  put_time(
    "NULL timer stopped at",
    end_time,
    1,
    0,
    0
  );

  benchmark_timer_initialize();
  for ( index = 1 ; index <= 1000 ; index++ )
    (void) benchmark_timer_empty_function();
  end_time = benchmark_timer_read();

  put_time(
    "LOOP (1000) timer stopped at",
    end_time,
    1,
    0,
    0
  );

  benchmark_timer_initialize();
  for ( index = 1 ; index <= 10000 ; index++ )
    (void) benchmark_timer_empty_function();
  end_time = benchmark_timer_read();

  put_time(
    "LOOP (10000) timer stopped at",
    end_time,
    1,
    0,
    0
  );

  benchmark_timer_initialize();
  for ( index = 1 ; index <= 50000 ; index++ )
    (void) benchmark_timer_empty_function();
  end_time = benchmark_timer_read();

  put_time(
    "LOOP (50000) timer stopped at",
    end_time,
    1,
    0,
    0
  );

  benchmark_timer_initialize();
  for ( index = 1 ; index <= 100000 ; index++ )
    (void) benchmark_timer_empty_function();
  end_time = benchmark_timer_read();

  put_time(
    "LOOP (100000) timer stopped at",
    end_time,
    1,
    0,
    0
  );

  puts( "*** END OF TIME CHECKER ***" );
  rtems_test_exit( 0 );
}
示例#5
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id          qid;
  uint32_t          index;
  uint32_t          count;
  rtems_status_code status;
  size_t            size;
  size_t            queue_size;
  unsigned char    *cp;

  status = rtems_message_queue_ident(
    Queue_name[ 1 ],
    RTEMS_SEARCH_ALL_NODES,
    &qid
  );
  printf(
    "TA1 - rtems_message_queue_ident - qid => %08" PRIxrtems_id "\n",
     qid
  );
  directive_failed( status, "rtems_message_queue_ident" );

  Fill_buffer( "BUFFER 1 TO Q 1", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1" );
  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  Fill_buffer( "BUFFER 2 TO Q 1", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1" );
  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5*rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  Fill_buffer( "BUFFER 3 TO Q 1", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 1" );
  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5*rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

rtems_test_pause();

  Fill_buffer( "BUFFER 1 TO Q 2", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 2" );
  status = rtems_message_queue_send( Queue_id[ 2 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  puts_nocr( "TA1 - rtems_message_queue_receive - receive from queue 1 - " );
  puts     ( "10 second timeout" );
  status = rtems_message_queue_receive(
    Queue_id[ 1 ],
    buffer,
    &size,
    RTEMS_DEFAULT_OPTIONS,
    10 * rtems_clock_get_ticks_per_second()
  );
  directive_failed( status, "rtems_message_queue_receive" );
  puts_nocr( "TA1 - buffer received: " );
  Put_buffer( buffer );
  new_line;

  puts( "TA1 - rtems_task_delete - delete TA2" );
  status = rtems_task_delete( Task_id[ 2 ] );
  directive_failed( status, "rtems_task_delete" );

  Fill_buffer( "BUFFER 1 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5*rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

rtems_test_pause();

  Fill_buffer( "BUFFER 2 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  Fill_buffer( "BUFFER 3 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  Fill_buffer( "BUFFER 4 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 4 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  Fill_buffer( "BUFFER 5 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_urgent - BUFFER 5 TO Q 3" );
  status = rtems_message_queue_urgent( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_urgent" );

  for ( index = 1 ; index <= 4 ; index++ ) {
    puts(
      "TA1 - rtems_message_queue_receive - receive from queue 3 - "
        "RTEMS_WAIT FOREVER"
    );
    status = rtems_message_queue_receive(
      Queue_id[ 3 ],
      buffer,
      &size,
      RTEMS_DEFAULT_OPTIONS,
      RTEMS_NO_TIMEOUT
    );
    directive_failed( status, "rtems_message_queue_receive" );
    puts_nocr( "TA1 - buffer received: " );
    Put_buffer( buffer );
    new_line;
  }

  Fill_buffer( "BUFFER 3 TO Q 2", buffer );
  puts( "TA1 - rtems_message_queue_urgent - BUFFER 3 TO Q 2" );
  status = rtems_message_queue_urgent( Queue_id[ 2 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_urgent" );

  puts(
    "TA1 - rtems_message_queue_receive - receive from queue 2 - "
      "RTEMS_WAIT FOREVER"
  );
  status = rtems_message_queue_receive(
    Queue_id[ 2 ],
    buffer,
    &size,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT
  );
  directive_failed( status, "rtems_message_queue_receive" );
  puts_nocr( "TA1 - buffer received: " );
  Put_buffer( buffer );
  new_line;

rtems_test_pause();

  puts( "TA1 - rtems_message_queue_delete - delete queue 1" );
  status = rtems_message_queue_delete( Queue_id[ 1 ] );
  directive_failed( status, "rtems_message_queue_delete" );

  Fill_buffer( "BUFFER 3 TO Q 2", buffer );
  puts( "TA1 - rtems_message_queue_urgent - BUFFER 3 TO Q 2" );
  status = rtems_message_queue_urgent( Queue_id[ 2 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_urgent" );

  puts( "TA1 - rtems_message_queue_delete - delete queue 2" );
  status = rtems_message_queue_delete( Queue_id[ 2 ] );
  directive_failed( status, "rtems_message_queue_delete" );

  puts( "TA1 - rtems_message_queue_get_number_pending - check Q 3" );
  status = rtems_message_queue_get_number_pending( Queue_id[ 3 ], &count );
  directive_failed( status, "rtems_message_queue_get_number_pending" );
  printf( "TA1 - %" PRIu32 " messages are pending on Q 3\n", count );

  puts( "TA1 - rtems_message_queue_flush - empty Q 3" );
  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
  directive_failed( status, "rtems_message_queue_flush" );
  printf( "TA1 - %" PRIu32 " messages were flushed from Q 3\n", count );

  Fill_buffer( "BUFFER 1 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  Fill_buffer( "BUFFER 2 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  /* this broadcast should have no effect on the queue */
  Fill_buffer( "NO BUFFER TO Q1", (long *)buffer );
  puts( "TA1 - rtems_message_queue_broadcast - NO BUFFER TO Q1" );
  status = rtems_message_queue_broadcast(
    Queue_id[ 1 ],
    (long (*)[4])buffer,
    16,
    &count
  );
  printf( "TA1 - number of tasks awakened = %" PRIu32 "\n", count );

  puts( "TA1 - rtems_message_queue_get_number_pending - check Q 3" );
  status = rtems_message_queue_get_number_pending( Queue_id[ 3 ], &count );
  directive_failed( status, "rtems_message_queue_get_number_pending" );
  printf( "TA1 - %" PRIu32 " messages are pending on Q 3\n", count );

  Fill_buffer( "BUFFER 3 TO Q 3", buffer );
  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 3" );
  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
  directive_failed( status, "rtems_message_queue_send" );

  puts( "TA1 - rtems_message_queue_flush - Q 3" );
  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
  printf( "TA1 - %" PRIu32 " messages were flushed from Q 3\n", count );

  puts( "TA1 - rtems_message_queue_send until all message buffers consumed" );
  while ( FOREVER ) {
    status = rtems_message_queue_send( Queue_id[ 3 ], buffer, MESSAGE_SIZE );
    if ( status == RTEMS_TOO_MANY ) break;
    directive_failed( status, "rtems_message_queue_send loop" );
  }

  puts( "TA1 - all message buffers consumed" );
  puts( "TA1 - rtems_message_queue_flush - Q 3" );
  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
  printf( "TA1 - %" PRIu32 " messages were flushed from Q 3\n", count );

rtems_test_pause();

  puts( "TA1 - create message queue of 20 bytes on queue 1" );
  status = rtems_message_queue_create(
    Queue_name[ 1 ],
    100,
    20,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Queue_id[ 1 ]
  );
  directive_failed( status, "rtems_message_queue_create of Q1; 20 bytes each" );
  status = rtems_message_queue_send( Queue_id[ 1 ], big_send_buffer, 40 );
  fatal_directive_status(status,
    RTEMS_INVALID_SIZE,
    "expected RTEMS_INVALID_SIZE"
  );

  puts( "TA1 - rtems_message_queue_delete - delete queue 1" );
  status = rtems_message_queue_delete( Queue_id[ 1 ] );
  directive_failed( status, "rtems_message_queue_delete" );

rtems_test_pause();

  puts( "TA1 - rtems_message_queue_create - variable sizes " );
  for (queue_size = 1; queue_size < 1030; queue_size++) {
    status = rtems_message_queue_create(
      Queue_name[ 1 ],
      2,            /* just 2 msgs each */
      queue_size,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Queue_id[ 1 ]
    );
    if (status != RTEMS_SUCCESSFUL) {
      printf("TA1 - msq que size: %zu\n", queue_size);
      directive_failed( status, "rtems_message_queue_create of Q1" );
    }

    status = rtems_message_queue_delete( Queue_id[ 1 ] );
    directive_failed( status, "rtems_message_queue_delete" );
  }

  puts( "TA1 - rtems_message_queue_create and send - variable sizes " );
  for (queue_size = 1; queue_size < 1030; queue_size++) {
    status = rtems_message_queue_create(
      Queue_name[ 1 ],
      2,            /* just 2 msgs each */
      queue_size,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Queue_id[ 1 ]
    );
    directive_failed( status, "rtems_message_queue_create of Q1" );

    dope_buffer(big_send_buffer, sizeof(big_send_buffer), queue_size);
    memset(big_receive_buffer, 'Z', sizeof(big_receive_buffer));

    /* send a msg too big */
    status = rtems_message_queue_send(
      Queue_id[ 1 ],
      big_send_buffer,
      queue_size + 1
    );
    fatal_directive_status(
      status,
      RTEMS_INVALID_SIZE,
      "rtems_message_queue_send too large"
    );

    /* send a msg that is just right */
    status = rtems_message_queue_send(
      Queue_id[ 1 ],
      big_send_buffer,
      queue_size);
    directive_failed(status, "rtems_message_queue_send exact size");

    /* now read and verify the message just sent */
    status = rtems_message_queue_receive(
      Queue_id[ 1 ],
      big_receive_buffer,
      &size,
      RTEMS_DEFAULT_OPTIONS,
      1 * rtems_clock_get_ticks_per_second()
    );
   directive_failed(status, "rtems_message_queue_receive exact size");
   if (size != queue_size) {
     puts("TA1 - exact size size match failed");
     rtems_test_exit(1);
   }

   if (memcmp(big_send_buffer, big_receive_buffer, size) != 0) {
     puts("TA1 - exact size data match failed");
     rtems_test_exit(1);
   }

   for (cp = (big_receive_buffer + size);
        cp < (big_receive_buffer + sizeof(big_receive_buffer));
        cp++)
    if (*cp != 'Z') {
      puts("TA1 - exact size overrun match failed");
      rtems_test_exit(1);
    }

    /* all done with this one; delete it */
    status = rtems_message_queue_delete( Queue_id[ 1 ] );
    directive_failed( status, "rtems_message_queue_delete" );
  }

  puts( "*** END OF TEST 13 ***" );
  rtems_test_exit( 0 );
}
示例#6
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  void                   *address_1;
  void                   *address_2;
  void                   *address_3;
  void                   *address_4;
  void                   *address_5;
  void                   *address_6;
  void                   *address_7;
  void                   *address_8;
  rtems_id                region_id;
  Heap_Information_block  region_info;
  uintptr_t               segment_size;
  rtems_status_code       status;

  /* Obtain the region id */
  status = rtems_region_ident(Region_name[ 1 ], &region_id);
  printf( "TA1 - rtems_region_ident - 0x%08" PRIxrtems_id "\n", region_id );
  directive_failed(status, "rtems_region_ident of RN01");

  /* Get a 64 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    64,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_1 );
  new_line;

  /* Get the size of segment_1 */
  puts_nocr( "TA1 - rtems_region_get_segment_size from - " );
  Put_address_from_area_1( address_1 );
  new_line;
  status = rtems_region_get_segment_size(region_id, address_1, &segment_size);
  directive_failed(status, "rtems_region_get_segment_size of segment 1");
  printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size );

  /* Get a 128 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    128,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_2
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_2 );
  new_line;

  /* Get a 256 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 256 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    256,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_3
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_3 );
  new_line;

  /* Get a 512 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 512 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    512,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_4
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_4 );
  new_line;

  /* Get a 1024 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 1024 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    1024,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_5
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_5 );
  new_line;

  /* Get a 2048 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 2048 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    2048,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_6
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_6 );
  new_line;

  /* Get a 4096 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 4096 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    4096,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_7
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_7 );
  new_line;

  /* Get a 8192 byte segment from the region */
  puts(
    "TA1 - rtems_region_get_segment - wait on 8192 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    8192,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_8
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_8 );
  new_line;

  /* Get the size of segment_8 */
  puts_nocr( "TA1 - rtems_region_get_segment_size from - " );
  Put_address_from_area_1( address_8 );
  new_line;
  status = rtems_region_get_segment_size(region_id, address_8, &segment_size);
  directive_failed(status, "rtems_region_get_segment_size of segment 8");
  printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size );

  /* Get information about the region */
  printf(
    "TA1 - rtems_region_get_information - 0x%08" PRIxrtems_id "\n",
    region_id
  );
  status = rtems_region_get_information(region_id, &region_info);
  directive_failed(status, "rtems_region_get_information of RN01");
  printf(
    "TA1 - got information - free = %" PRIu32 ", used = %" PRIu32 "\n",
    region_info.Free.number,
    region_info.Used.number
  );

  printf(
    "TA1 - rtems_region_get_free_information - 0x%08" PRIxrtems_id "\n",
    region_id
  );
  status = rtems_region_get_free_information(region_id, &region_info);
  directive_failed(status, "rtems_region_get_free_information of RN01");
  printf(
    "TA1 - got free information - free = %" PRIu32 ", used = %" PRIu32 "\n",
    region_info.Free.number,
    region_info.Used.number
  );

rtems_test_pause();

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_3 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_3 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_3 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_4 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_4 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_4 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_1 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_1 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_1 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_2 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_2 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_2 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_7 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_7 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_7 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_6 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_6 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_6 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_8 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_8 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_8 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_5 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_5 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_5 = 0;

  puts( "TA1 - rtems_region_delete - walks heap if debug enabled" );
  rtems_region_delete(Region_id[ 1 ]);

  puts( "*** END OF TEST 25 ***" );
  rtems_test_exit( 0 );
}
示例#7
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  puts( "\n\n*** TEST 12 ***" );

  Task_name[ 1 ]          = rtems_build_name( 'T', 'A', '1', ' ' );
  Task_name[ 2 ]          = rtems_build_name( 'T', 'A', '2', ' ' );
  Task_name[ 3 ]          = rtems_build_name( 'T', 'A', '3', ' ' );
  Task_name[ 4 ]          = rtems_build_name( 'T', 'A', '4', ' ' );
  Task_name[ 5 ]          = rtems_build_name( 'T', 'A', '5', ' ' );

  Priority_task_name[ 1 ] = rtems_build_name( 'P', 'R', 'I', '1' );
  Priority_task_name[ 2 ] = rtems_build_name( 'P', 'R', 'I', '2' );
  Priority_task_name[ 3 ] = rtems_build_name( 'P', 'R', 'I', '3' );
  Priority_task_name[ 4 ] = rtems_build_name( 'P', 'R', 'I', '4' );
  Priority_task_name[ 5 ] = rtems_build_name( 'P', 'R', 'I', '5' );

  Semaphore_name[ 1 ]     = rtems_build_name( 'S', 'M', '1', ' ' );
  Semaphore_name[ 2 ]     = rtems_build_name( 'S', 'M', '2', ' ' );
  Semaphore_name[ 3 ]     = rtems_build_name( 'S', 'M', '3', ' ' );

  status = rtems_semaphore_create(
    Semaphore_name[ 1 ],
    1,
    RTEMS_DEFAULT_ATTRIBUTES,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 1 ]
  );
  directive_failed( status, "rtems_semaphore_create of SM1" );

  status = rtems_semaphore_create(
    Semaphore_name[ 2 ],
    0,
    RTEMS_PRIORITY,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 2 ]
  );
  directive_failed( status, "rtems_semaphore_create of SM2" );

  status = rtems_semaphore_create(
    Semaphore_name[ 3 ],
    1,
    RTEMS_DEFAULT_ATTRIBUTES,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 3 ]
  );
  directive_failed( status, "rtems_semaphore_create of SM3" );

  puts( "INIT - Forward priority queue test" );
  Priority_test_driver( 0 );

  puts( "INIT - Backward priority queue test" );
  Priority_test_driver( (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u );

rtems_test_pause();

  puts( "INIT - Binary Semaphore and Priority Inheritance Test" );

  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_delete of SM2 #1" );

  puts( "INIT - rtems_semaphore_create - allocated binary semaphore" );
  status = rtems_semaphore_create(
    Semaphore_name[ 2 ],
    0,
    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 2 ]
  );
  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );

  puts( "INIT - rtems_semaphore_release - allocated binary semaphore" );
  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_release of SM2" );

  puts( "INIT - rtems_semaphore_delete - allocated binary semaphore" );
  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_delete of SM2 #2" );

  status = rtems_semaphore_create(
    Semaphore_name[ 2 ],
    1,
    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 2 ]
  );
  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );

  Priority_test_driver( PRIORITY_INHERIT_BASE_PRIORITY );

rtems_test_pause();

  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_delete of SM2 #3" );

  status = rtems_semaphore_create(
    Semaphore_name[ 2 ],
    0,
    RTEMS_PRIORITY,
    RTEMS_NO_PRIORITY,
    &Semaphore_id[ 2 ]
  );
  directive_failed( status, "rtems_semaphore_create of priority SM2" );

  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_release of SM2" );

  status = rtems_task_create(
    Task_name[ 1 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create of TA1" );

  status = rtems_task_create(
    Task_name[ 2 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 2 ]
  );
  directive_failed( status, "rtems_task_create of TA2" );

  status = rtems_task_create(
    Task_name[ 3 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 3 ]
  );
  directive_failed( status, "rtems_task_create of TA3" );

  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
  directive_failed( status, "rtems_task_start of TA2" );

  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
  directive_failed( status, "rtems_task_start of TA3" );

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id           rnid;
  void              *segment_address_1;
  void              *segment_address_2;
  void              *segment_address_3;
  void              *segment_address_4;
  rtems_status_code  status;

  status = rtems_region_ident( Region_name[ 1 ], &rnid );
  printf( "TA1 - rtems_region_ident - rnid => %08" PRIxrtems_id "\n", rnid );
  directive_failed( status, "rtems_region_ident of RN1" );

  puts(
    "TA1 - rtems_region_get_segment - wait on 100 byte segment from region 2"
  );
  status = rtems_region_get_segment(
    Region_id[ 2 ],
    100,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &segment_address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 2 - " );
  Put_address_from_area_2( segment_address_1 );
  new_line;

  puts( "TA1 - rtems_region_get_segment - wait on 3K segment from region 3" );
  status = rtems_region_get_segment(
    Region_id[ 3 ],
    3072,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &segment_address_2
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 3 - " );
  Put_address_from_area_3( segment_address_2 );
  new_line;

  puts_nocr( "TA1 - rtems_region_get_segment - get 3080 byte segment " );
  puts     ( "from region 1 - NO_WAIT" );
  status = rtems_region_get_segment(
    Region_id[ 1 ],
    3080,
    RTEMS_NO_WAIT,
    RTEMS_NO_TIMEOUT,
    &segment_address_3
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( segment_address_3 );
  new_line;

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  directive_failed( status, "rtems_task_wake_after" );

rtems_test_pause();

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( segment_address_3 );
  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_3 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait 10 seconds for 3K "
      "segment from region 1"
  );
  status = rtems_region_get_segment(
    Region_id[ 1 ],
    3072,
    RTEMS_DEFAULT_OPTIONS,
    10 * rtems_clock_get_ticks_per_second(),
    &segment_address_4
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( segment_address_4 );
  new_line;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 2 - "
  );
  Put_address_from_area_2( segment_address_1 );
  new_line;
  status = rtems_region_return_segment( Region_id[ 2 ], segment_address_1 );
  directive_failed( status, "rtems_region_return_segment" );

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_task_delete - delete TA3" );
  status = rtems_task_delete( Task_id[ 3 ] );
  directive_failed( status, "rtems_task_delete of TA3" );

rtems_test_pause();

  status = rtems_task_create(
    Task_name[ 4 ],
    BASE_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 4 ]
  );
  directive_failed( status, "rtems_task_create of TA4" );

  status = rtems_task_create(
    Task_name[ 5 ],
    BASE_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 5 ]
  );
  directive_failed( status, "rtems_task_create of TA5" );

  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
  directive_failed( status, "rtems_task_start of TA4" );

  status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
  directive_failed( status, "rtems_task_start of TA5" );

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( segment_address_4 );
  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_4 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts_nocr( "TA1 - rtems_region_get_segment - wait 10 seconds for 3K " );
  puts     ( "segment from region 1");
  status = rtems_region_get_segment(
    Region_id[ 1 ],
    3072,
    RTEMS_DEFAULT_OPTIONS,
    10 * rtems_clock_get_ticks_per_second(),
    &segment_address_4
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( segment_address_4 );
  new_line;

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_task_delete - delete TA4" );
  status = rtems_task_delete( Task_id[ 4 ] );
  directive_failed( status, "rtems_task_delete of TA4" );

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( segment_address_4 );
  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_4 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;

  puts( "TA1 - rtems_task_wake_after - yield processor" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );

  puts( "TA1 - rtems_region_delete - delete region 1" );
  status = rtems_region_delete( Region_id[ 1 ] );
  directive_failed( status, "rtems_region_delete" );

  puts( "TA1 - rtems_region_get_segment - get 3K segment from region 4" );
  status = rtems_region_get_segment(
    Region_id[ 4 ],
    3072,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &segment_address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 4 - " );
  Put_address_from_area_4( segment_address_1 );
  new_line;

  puts(
   "TA1 - rtems_region_get_segment - attempt to get 3K segment from region 4"
  );
  status =  rtems_region_get_segment(
    Region_id[ 4 ],
    3072,
    RTEMS_NO_WAIT,
    RTEMS_NO_TIMEOUT,
    &segment_address_2
  );
  fatal_directive_status(
    status,
    RTEMS_UNSATISFIED,
    "rtems_task_get_segment with no memory left"
  );
  puts( "TA1 - rtems_task_get_segment - RTEMS_UNSATISFIED" );

  puts( "TA1 - rtems_region_extend - extend region 4 by 4K" );
  status = rtems_region_extend(
    Region_id[ 4 ],
    &Area_4[4096],
    4096
  );
  directive_failed( status, "rtems_region_extend" );

  puts(
   "TA1 - rtems_region_get_segment - attempt to get 3K segment from region 4"
  );
  status = rtems_region_get_segment(
    Region_id[ 4 ],
    3072,
    RTEMS_NO_WAIT,
    RTEMS_NO_TIMEOUT,
    &segment_address_3
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got 3K segment from region 4 - " );
  Put_address_from_area_4( segment_address_3 );
  new_line;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 4 - "
  );
  Put_address_from_area_4( segment_address_1 );
  status = rtems_region_return_segment( Region_id[ 4 ], segment_address_1 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 4 - "
  );
  Put_address_from_area_4( segment_address_3 );
  status = rtems_region_return_segment( Region_id[ 4 ], segment_address_3 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;

  puts( "TA1 - rtems_region_delete - delete region 4" );
  status = rtems_region_delete( Region_id[ 4 ] );
  directive_failed( status, "rtems_region_delete" );

  puts( "*** END OF TEST 16 ***" );
  rtems_test_exit( 0 );
}
示例#9
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id          smid;
  rtems_status_code status;

  status = rtems_semaphore_ident(
    Semaphore_name[ 1 ],
    RTEMS_SEARCH_ALL_NODES,
    &smid
  );
  printf( "TA1 - rtems_semaphore_ident - smid => %08" PRIxrtems_id "\n", smid );
  directive_failed( status, "rtems_semaphore_ident of SM1" );

  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM2" );
  status = rtems_semaphore_obtain(
    Semaphore_id[ 2 ],
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT
  );
  directive_failed( status, "rtems_semaphore_obtain of SM2" );
  puts( "TA1 - got SM2" );

  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM3" );
  status = rtems_semaphore_obtain(
    Semaphore_id[ 3 ],
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT
  );
  directive_failed( status, "rtems_semaphore_obtain of SM3" );
  puts( "TA1 - got SM3" );

  puts( "TA1 - rtems_semaphore_obtain - get SM1 - RTEMS_NO_WAIT" );
  status = rtems_semaphore_obtain(
    Semaphore_id[ 1 ],
    RTEMS_NO_WAIT,
    RTEMS_NO_TIMEOUT
  );
  directive_failed( status, "rtems_semaphore_obtain of SM1" );
  puts( "TA1 - got SM1" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

rtems_test_pause();

  puts( "TA1 - rtems_semaphore_release - release SM1" );
  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
  directive_failed( status, "rtems_semaphore_release of SM1" );

  puts(
    "TA1 - rtems_semaphore_obtain - waiting for SM1 with 10 second timeout"
  );
  status = rtems_semaphore_obtain(
    Semaphore_id[ 1 ],
    RTEMS_DEFAULT_OPTIONS,
    10 * rtems_clock_get_ticks_per_second()
  );
  directive_failed( status, "rtems_semaphore_obtain of SM1" );
  puts( "TA1 - got SM1" );

  puts( "TA1 - rtems_semaphore_release - release SM2" );
  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
  directive_failed( status, "rtems_semaphore_release of SM2" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

rtems_test_pause();

  puts( "TA1 - rtems_task_delete - delete TA3" );
  status = rtems_task_delete( Task_id[ 3 ] );
  directive_failed( status, "rtems_task_delete of TA3" );

  status = rtems_task_create(
    Task_name[ 4 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 4 ]
  );
  directive_failed( status, "rtems_task_create of TA4" );

  status = rtems_task_create(
    Task_name[ 5 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 5 ]
   );
  directive_failed( status, "rtems_task_create of TA5" );

  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
  directive_failed( status, "rtems_task_start of TA4" );

  status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
  directive_failed( status, "rtems_task_start of TA5" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_task_delete - delete TA4" );
  status = rtems_task_delete( Task_id[ 4 ] );
  directive_failed( status, "rtems_task_delete of TA4" );

  puts( "TA1 - rtems_semaphore_release - release SM1" );
  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
  directive_failed( status, "rtems_semaphore_release on SM1" );

  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
  status = rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_semaphore_delete - delete SM1" );
  status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
  directive_failed( status, "rtems_semaphore_delete of SM1" );

  puts( "TA1 - rtems_semaphore_delete - delete SM3" );
  status = rtems_semaphore_delete( Semaphore_id[ 3 ] );
  directive_failed( status, "rtems_semaphore_delete of SM3" );

  puts( "TA1 - rtems_task_delete - delete self" );
  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of TA1" );
}
示例#10
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_event_set   eventout;
  rtems_time_of_day time;
  rtems_status_code status;
  uint32_t          index;

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_16 to TA2" );
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_16 );
  directive_failed( status, "rtems_event_send" );

  puts(
    "TA1 - rtems_event_receive - waiting forever on "
      "RTEMS_EVENT_14 and RTEMS_EVENT_15"
  );
  status = rtems_event_receive(
    RTEMS_EVENT_14 | RTEMS_EVENT_15,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive" );
  printf(
    "TA1 - RTEMS_EVENT_14 and RTEMS_EVENT_15 received - "
      "eventout => %08" PRIxrtems_event_set "\n",
    eventout
  );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to TA2" );
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_18 );
  directive_failed( status, "rtems_event_send" );

  puts(
    "TA1 - rtems_event_receive - waiting with 10 second timeout "
      "on RTEMS_EVENT_14"
  );
  status = rtems_event_receive(
    RTEMS_EVENT_14,
    RTEMS_DEFAULT_OPTIONS,
    10 * rtems_clock_get_ticks_per_second(),
    &eventout
  );
  directive_failed( status, "rtems_event_receive" );
  printf(
    "TA1 - RTEMS_EVENT_14 received - eventout => "
      "%08" PRIxrtems_event_set "\n",
    eventout
  );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_19 to TA2" );
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_19 );
  directive_failed( status, "rtems_event_send" );

  status = rtems_clock_get_tod( &time );
  directive_failed( status, "rtems_clock_get_tod" );
  print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" );

rtems_test_pause();

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    5 * rtems_clock_get_ticks_per_second(),
    TA1_send_18_to_self_5_seconds,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 5 seconds" );

  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_18"  );
  status = rtems_event_receive(
    RTEMS_EVENT_18,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive of 18" );
  printf(
    "TA1 - RTEMS_EVENT_18 received - eventout => %08" PRIxrtems_event_set "\n",
    eventout
  );

  status = rtems_clock_get_tod( &time );
  directive_failed( status, "TA1 rtems_clock_get_tod" );
  print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_3 to self" );
  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_3 );
  directive_failed( status, "rtems_event_send" );

  puts(
    "TA1 - rtems_event_receive - RTEMS_EVENT_3 or "
      "RTEMS_EVENT_22 - NO_WAIT and ANY"
  );
  status = rtems_event_receive(
    RTEMS_EVENT_3 | RTEMS_EVENT_22,
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive of 3 and 22" );
  printf(
    "TA1 - RTEMS_EVENT_3 received - eventout => %08" PRIxrtems_event_set "\n",
    eventout
  );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" );
  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 );
  directive_failed( status, "rtems_event_send" );

  puts (
  "TA1 - rtems_event_receive - RTEMS_EVENT_4 or "
      "RTEMS_EVENT_5 - forever and ANY"
  );
  status = rtems_event_receive(
    RTEMS_EVENT_4 | RTEMS_EVENT_5,
    RTEMS_EVENT_ANY,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive" );
  printf(
    "TA1 - RTEMS_EVENT_4 received - eventout => %08" PRIxrtems_event_set "\n",
    eventout 
  );

rtems_test_pause();

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    5 * rtems_clock_get_ticks_per_second(),
    TA1_send_18_to_self_5_seconds,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 5 seconds" );

  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_18");
  status = rtems_timer_cancel( Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_cancel" );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_8 to self after 60 seconds");
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    60 * rtems_clock_get_ticks_per_second(),
    TA1_send_8_to_self_60_seconds,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_9 to self after 60 seconds");
  status = rtems_timer_fire_after(
    Timer_id[ 2 ],
    60 * rtems_clock_get_ticks_per_second(),
    TA1_send_9_to_self_60_seconds,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );

  puts(
    "TA1 - rtems_event_send - send RTEMS_EVENT_10 to self after 60 seconds"
  );
  status = rtems_timer_fire_after(
    Timer_id[ 3 ],
    60 * rtems_clock_get_ticks_per_second(),
    TA1_send_10_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );

  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_8" );
  status = rtems_timer_cancel( Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_cancel" );

  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );

  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_1 every second" );
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    rtems_clock_get_ticks_per_second(),
    TA1_send_1_to_self_every_second,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 1 second" );

  for ( index = 0; index < 3; index++ ) {

    status = rtems_event_receive(
      RTEMS_EVENT_1,
      RTEMS_EVENT_ANY,
      RTEMS_NO_TIMEOUT,
      &eventout
    );
    directive_failed( status, "rtems_event_receive" );

    status = rtems_clock_get_tod( &time );
    directive_failed( status, "rtems_clock_get_tod" );

    printf(
      "TA1 - RTEMS_EVENT_1 received - eventout => %08"
        PRIxrtems_event_set " - ",
       eventout
    );
    print_time( "at ", &time, "\n" );

    if ( index < 2 ) {
      status = rtems_timer_reset( Timer_id[ 1 ] );
      directive_failed( status, "rtems_timer_reset" );
    };

  }

  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_1" );
  status = rtems_timer_cancel( Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_cancel" );

rtems_test_pause();

  time.day = 13;
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
  status = rtems_timer_fire_when(
    Timer_id[ 1 ],
    &time,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 1 day" );

  time.hour = 7;
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
  status = rtems_timer_fire_when(
    Timer_id[ 2 ],
    &time,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 1 day" );

  time.hour = 8;   /* so code below has correct time/date */
  time.day = 14;
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
  status = rtems_timer_fire_when(
    Timer_id[ 3 ],
    &time,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 2 days" );

  puts("TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 1 day");
  status = rtems_timer_cancel( Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_cancel" );

  puts(
    "TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 2 days"
  );
  status = rtems_timer_cancel( Timer_id[ 3 ] );
  directive_failed( status, "rtems_timer_cancel" );

  puts(
    "TA1 - rtems_event_send - resending RTEMS_EVENT_11 to self in 2 days"
  );
  status = rtems_timer_fire_when(
    Timer_id[ 3 ],
    &time,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 2 days" );

  time.day = 15;
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
  status = rtems_clock_set( &time );
  directive_failed( status, "TA1 rtems_clock_set" );

  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_11" );
  status = rtems_event_receive(
    RTEMS_EVENT_11,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive" );
  printf(
    "TA1 - RTEMS_EVENT_11 received - eventout => %08" PRIxrtems_event_set "\n",
     eventout
  );

rtems_test_pause();

  puts( "TA1 - rtems_event_send/rtems_event_receive combination" );
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    10,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 10 ticks" );

  status = rtems_event_receive(
    RTEMS_EVENT_11,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  directive_failed( status, "rtems_event_receive" );

  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );

  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  time.day = 13;
  puts( "TA1 - rtems_event_receive all outstanding events" );
  status  = rtems_event_receive(
    RTEMS_ALL_EVENTS,
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
    0,
    &eventout
  );
  fatal_directive_status(
    status,
    RTEMS_UNSATISFIED,
    "rtems_event_receive all events"
  );

  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_10 to self in 1 day" );
  status = rtems_timer_fire_when(
    Timer_id[ 1 ],
    &time,
    TA1_send_10_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 1 day" );

  time.day = 14;
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
  status = rtems_timer_fire_when(
    Timer_id[ 2 ],
    &time,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_when 2 days" );

  build_time( &time, 2, 12, 1988, 7, 15, 0, 0 );

  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
  puts( "TA1 - set time backwards" );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  status  = rtems_event_receive(
    RTEMS_ALL_EVENTS,
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  if ( eventout )
    printf( "ERROR -0x%08" PRIxrtems_event_set " events received\n", eventout );
  else
    puts( "TA1 - no events received" );
  fatal_directive_status(
    status,
    RTEMS_UNSATISFIED,
    "rtems_event_receive all events"
  );

  build_time( &time, 2, 14, 1988, 7, 15, 0, 0 );

  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
  puts( "TA1 - set time forwards (leave a timer)" );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  status  = rtems_event_receive(
    RTEMS_ALL_EVENTS,
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  if ( eventout == RTEMS_EVENT_10 )
    puts( "TA1 - RTEMS_EVENT_10 received" );
  else
    printf( "ERROR -0x%08" PRIxrtems_event_set " events received\n", eventout );
  directive_failed( status, "rtems_event_receive all events" );

  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 100 ticks");
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    100,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 100 ticks" );

  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 200 ticks");
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    200,
    TA1_send_11_to_self,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after 200 ticks" );

  /***** *****/
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" );
  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 );
  directive_failed( status, "rtems_event_send" );

  eventout = 0;
  puts(
    "TA1 - rtems_event_receive - RTEMS_EVENT_4 AND RTEMS_EVENT_5 - UNSATISFIED"
  );
  status  = rtems_event_receive(
    RTEMS_EVENT_4 | RTEMS_EVENT_5,
    RTEMS_NO_WAIT | RTEMS_EVENT_ALL,
    RTEMS_NO_TIMEOUT,
    &eventout
  );
  fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive" );
  /***** *****/

  puts( "*** END OF TEST 11 ***" );
  rtems_test_exit( 0 );
}
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_mode        previous_mode;
  rtems_status_code status;

  puts( "TA1 - rtems_signal_catch - RTEMS_INTERRUPT_LEVEL( 3 )" );
  status = rtems_signal_catch( Process_asr, RTEMS_INTERRUPT_LEVEL(3) );
  directive_failed( status, "rtems_signal_catch" );

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_16 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_16 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_0 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_0 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_signal_catch - RTEMS_NO_ASR" );
  status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR );
  directive_failed( status, "rtems_signal_catch" );

  FLUSH_OUTPUT();

rtems_test_pause();

  puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_1 to self" );
  status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
  directive_failed( status, "rtems_signal_send" );

  puts( "TA1 - rtems_task_mode - disable ASRs" );
  status = rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &previous_mode );
  directive_failed( status, "rtems_task_mode" );

  Timer_got_this_id = 0;
  Timer_got_this_pointer = NULL;

  puts( "TA1 - sending signal to RTEMS_SELF from timer" );
  status = rtems_timer_fire_after(
    Timer_id[ 1 ],
    rtems_clock_get_ticks_per_second() / 2,
    Signal_3_to_task_1,
    (void *) Task_1
  );
  directive_failed( status, "rtems_timer_fire_after" );

  puts( "TA1 - waiting for signal to arrive" );

  Signals_sent = FALSE;
  Asr_fired    = FALSE;

  while ( Signals_sent == FALSE )
    ;

  if ( Timer_got_this_id == Timer_id[ 1 ] &&
       Timer_got_this_pointer == Task_1 )
    puts( "TA1 - timer routine got the correct arguments" );
  else
    printf(
      "TA1 - timer got (0x%" PRIxrtems_id ", %p) instead of (0x%" PRIxrtems_id ", %p)!!!!\n",
      Timer_got_this_id,
      Timer_got_this_pointer,
      Timer_id[ 1 ],
      Task_1
    );

  puts( "TA1 - rtems_task_mode - enable ASRs" );
  FLUSH_OUTPUT();
  status = rtems_task_mode( RTEMS_ASR, RTEMS_ASR_MASK, &previous_mode );
  directive_failed( status, "rtems_task_mode" );

  status = rtems_task_wake_after(2 * rtems_clock_get_ticks_per_second());
  directive_failed( status, "rtems_task_wake_after" );

  puts( "TA1 - rtems_signal_catch - asraddr of NULL" );
  status = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
  directive_failed( status, "rtems_signal_catch" );

  puts( "TA1 - rtems_task_delete - delete self" );
  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
示例#12
0
rtems_task Task_1(
  rtems_task_argument argument
)
{
  void              *address_1;
  void              *address_2;
  void              *address_3;
  void              *address_4;
  void              *address_5;
  void              *address_6;
  void              *address_7;
  void              *address_8;
  rtems_status_code  status;
  rtems_id           region_id;

  status = rtems_region_ident(Region_name[ 1 ], &region_id);
  printf( "TA1 - rtems_region_ident - 0x%08x\n", region_id );
  directive_failed(status, "rtems_region_ident of RN01");

  puts(
    "TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    64,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_1 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    128,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_2
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_2 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 256 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    256,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_3
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_3 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 512 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    512,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_4
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_4 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 1024 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    1024,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_5
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_5 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 2048 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    2048,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_6
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_6 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 4096 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    4096,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_7
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_7 );
  new_line;

  puts(
    "TA1 - rtems_region_get_segment - wait on 8192 byte segment from region 1"
  );
  rtems_region_get_segment(
    Region_id[ 1 ],
    8192,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &address_8
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts_nocr( "TA1 - got segment from region 1 - " );
  Put_address_from_area_1( address_8 );
  new_line;

rtems_test_pause();

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_3 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_3 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_3 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_4 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_4 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_4 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_1 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_1 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_1 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_2 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_2 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_2 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_7 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_7 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_7 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_6 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_6 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_6 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_8 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_8 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_8 = 0;

  puts_nocr(
    "TA1 - rtems_region_return_segment - return segment to region 1 - "
  );
  Put_address_from_area_1( address_5 );
  status = rtems_region_return_segment( Region_id[ 1 ], address_5 );
  directive_failed( status, "rtems_region_return_segment" );
  new_line;
  address_5 = 0;

  puts( "TA1 - rtems_region_delete - walks heap if debug enabled" );
  rtems_region_delete(Region_id[ 1 ]);

  puts( "*** END OF TEST 25 ***" );
  rtems_test_exit( 0 );
}