Esempio n. 1
0
static void restart_task(rtems_task_argument arg)
{
  rtems_status_code sc;

  if (arg == 0) {
    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 2);

    rtems_task_restart(RTEMS_SELF, 1);
  } else if (arg == 1) {
    rtems_id scheduler_id;

    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 2);

    sc = rtems_task_get_scheduler(RTEMS_SELF, &scheduler_id);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    sc = rtems_task_set_scheduler(RTEMS_SELF, scheduler_id, 4);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 4);

    rtems_task_restart(RTEMS_SELF, 2);
  } else {
    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 4);

    rtems_task_resume(master_id);
  }

  rtems_test_assert(0);
}
Esempio n. 2
0
rtems_timer_service_routine test_release_from_isr(
  rtems_id  timer,
  void     *arg
)
{
  (void) rtems_task_restart( Secondary_task_id, 1 );
}
Esempio n. 3
0
rtems_task Task01( rtems_task_argument ignored )
{
  rtems_status_code status;

  /* Start up TA02, yield so it can run */
  if ( sem_exe == 0 ) {
    status = rtems_task_start( Task_id[1], Task02, 0 );
    directive_failed( status, "rtems_task_start of TA02" );
  } else {
    status = rtems_task_restart( Task_id[1], 0 );
    directive_failed( status, "rtems_task_restart of TA02" );
  }
  rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );

  /* Benchmark code */
  for ( ; count < BENCHMARKS ; ) {
    if ( sem_exe == 1 ) {
      rtems_semaphore_obtain( sem_id, RTEMS_WAIT, 0 );
    }
    rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );

    if ( sem_exe == 1 ) {
      rtems_semaphore_release( sem_id );
    }
    rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  }

  /* Should never reach here */
  rtems_test_assert( false );
}
rtems_task Init(
    rtems_task_argument ignored
)
{
    rtems_status_code    status;
    rtems_id             task_id;

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

    puts( "Init - rtems_task_create - delay task - OK" );
    status = rtems_task_create(
                 rtems_build_name( 'T', 'A', '1', ' ' ),
                 1,
                 RTEMS_MINIMUM_STACK_SIZE,
                 RTEMS_DEFAULT_OPTIONS,
                 RTEMS_DEFAULT_ATTRIBUTES,
                 &task_id
             );
    directive_failed( status, "rtems_task_create" );

    puts( "Init - rtems_task_start - delay task - OK" );
    status = rtems_task_start( task_id, Delay_task, 0 );
    directive_failed( status, "rtems_task_start" );

    puts( "Init - rtems_task_wake_after - let delay task block - OK" );
    status = rtems_task_wake_after( RTEMS_MILLISECONDS_TO_TICKS(1000) );
    directive_failed( status, "rtems_task_wake_after" );

    puts( "Init - rtems_task_restart - delay task - OK" );
    status = rtems_task_restart( task_id, 0 );
    directive_failed( status, "rtems_task_restart" );

    puts( "*** END OF TEST 57 ***" );
    rtems_test_exit(0);
}
rtems_task Low_task(
  rtems_task_argument argument
)
{
  task_index = 1;

  benchmark_timer_initialize();
  (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
}
Esempio n. 6
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code     sc;
  int                   resets;

  puts(
    "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n"
    "Init - Trying to generate timeout of a thread while another is blocking\n"
    "Init -   on the same thread queue\n"
    "Init - There is no way for the test to know if it hits the case"
  );

  puts( "Init - rtems_semaphore_create - OK" );
  sc = rtems_semaphore_create(
    rtems_build_name( 'S', 'M', '1', ' ' ),
    0,
    RTEMS_DEFAULT_ATTRIBUTES,
    RTEMS_NO_PRIORITY,
    &Semaphore
  );
  directive_failed( sc, "rtems_semaphore_create of SM1" );

  puts( "Init - rtems_task_create - OK" );
  sc = rtems_task_create(
    rtems_build_name( 'B', 'L', 'C', 'K' ),
    BLOCKER_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_NO_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Secondary_task_id
  );
  directive_failed( sc, "rtems_task_create" );

  sc = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
  directive_failed( sc, "rtems_task_start" );

  Main_task = rtems_task_self();

  interrupt_critical_section_test_support_initialize( NULL );

  for (resets=0 ; resets<10 ;) {
    if ( interrupt_critical_section_test_support_delay() )
      resets++;

    sc = rtems_task_restart( Secondary_task_id, 1 );
    directive_failed( sc, "rtems_task_restart" );

    sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
    fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
  }

  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
  rtems_test_exit(0);
}
rtems_task Middle_tasks(
  rtems_task_argument argument
)
{
  task_index++;

  if ( argument != 0 )
    (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
  else
    (void) rtems_task_suspend( RTEMS_SELF );
}
Esempio n. 8
0
rtems_task First_FP_task(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_id          tid;
  rtems_time_of_day time;
  uint32_t    task_index;
  INTEGER_DECLARE;
  FP_DECLARE;

  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
  directive_failed( status, "rtems_task_ident" );

  task_index = task_number( tid );

  INTEGER_LOAD( INTEGER_factors[ task_index ] );
  FP_LOAD( FP_factors[ task_index ] );

  put_name( Task_name[ task_index ], FALSE );
  printf(
    " - integer base = (0x%" PRIx32 ")\n",
    INTEGER_factors[ task_index ]
  );
  put_name( Task_name[ task_index ], FALSE );
  #if ( RTEMS_HAS_HARDWARE_FP == 1 )
    printf( " - float base = (%g)\n", FP_factors[ task_index ] );
  #else
    printf( " - float base = (NA)\n" );
  #endif

  if ( argument == 0 ) {
    status = rtems_task_restart( RTEMS_SELF, 1 );
    directive_failed( status, "rtems_task_restart of RTEMS_SELF" );
  } else {
    build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
    status = rtems_clock_set( &time );
    directive_failed( status, "rtems_clock_set" );

    status = rtems_task_delete( RTEMS_SELF );
    directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
  }
}
Esempio n. 9
0
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 );
}
Esempio n. 10
0
File: task1.c Progetto: gedare/rtems
rtems_task Task_1(
  rtems_task_argument argument
)
{
  rtems_id            self_id;
  rtems_task_priority previous_priority;
  rtems_status_code   status;

  /* bad Id */
  status = rtems_task_is_suspended( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_set_priority with illegal id"
  );
  puts( "TA1 - rtems_task_is_suspended - RTEMS_INVALID_ID" );

  /* bad Id */
  status = rtems_task_delete( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_delete with illegal id"
  );
  puts( "TA1 - rtems_task_delete - RTEMS_INVALID_ID" );

  /* NULL param */
  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_task_ident NULL param"
  );
  puts( "TA1 - rtems_task_ident - RTEMS_INVALID_ADDRESS" );

  /* OK */
  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &self_id );
  directive_failed( status, "rtems_task_ident of self" );
  if ( self_id != Task_id[ 1 ] ) {
    puts( "ERROR - rtems_task_ident - incorrect ID returned!" );
  }
  puts( "TA1 - rtems_task_ident - current task RTEMS_SUCCESSFUL" );

  status = rtems_task_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_task_ident with illegal name (local)"
  );
  puts( "TA1 - rtems_task_ident - global RTEMS_INVALID_NAME" );

  status = rtems_task_ident( 100, 1, &Junk_id );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_task_ident with illegal name (global)"
  );
  puts( "TA1 - rtems_task_ident - local RTEMS_INVALID_NAME" );

  /*
   *  This one case is different if MP is enabled/disabled.
   */

  status = rtems_task_ident( 100, 2, &Junk_id );
#if defined(RTEMS_MULTIPROCESSING)
  fatal_directive_status(
    status,
    RTEMS_INVALID_NODE,
    "rtems_task_ident with illegal node"
  );
#else
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_task_ident with illegal node"
  );
#endif
  puts( "TA1 - rtems_task_ident - RTEMS_INVALID_NODE" );

  status = rtems_task_restart( 100, 0 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_restart with illegal id"
  );
  puts( "TA1 - rtems_task_restart - RTEMS_INVALID_ID" );

  status = rtems_task_resume( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_resume with illegal id"
  );
  puts( "TA1 - rtems_task_resume - RTEMS_INVALID_ID" );

  status = rtems_task_resume( RTEMS_SELF );
  fatal_directive_status(
    status,
    RTEMS_INCORRECT_STATE,
    "rtems_task_resume of ready task"
  );
  puts( "TA1 - rtems_task_resume - RTEMS_INCORRECT_STATE" );

  /* NULL param */
  status = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_task_set_priority with NULL param"
  );
  puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ADDRESS" );

  /* bad priority */
  status = rtems_task_set_priority(
    RTEMS_SELF,
    UINT32_C(0x80000000),
    &previous_priority
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_task_set_priority with illegal priority"
  );
  puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_PRIORITY" );

  /* bad Id */
  status = rtems_task_set_priority( 100, 8, &previous_priority );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_set_priority with illegal id"
  );
  puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ID" );

  status = rtems_task_start( 100, Task_1, 0 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_start with illegal id"
  );
  puts( "TA1 - rtems_task_start - RTEMS_INVALID_ID" );

  /* already started */
  status = rtems_task_start( RTEMS_SELF, Task_1, 0 );
  fatal_directive_status(
    status,
    RTEMS_INCORRECT_STATE,
    "rtems_task_start of ready task"
  );
  puts( "TA1 - rtems_task_start - RTEMS_INCORRECT_STATE" );

  /* bad Id */
  status = rtems_task_suspend( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_task_suspend with illegal id"
  );
  puts( "TA1 - rtems_task_suspend - RTEMS_INVALID_ID" );

  /* NULL param */
  status = rtems_task_mode( RTEMS_SELF, 0, NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_task_mode with NULL param"
  );
  puts( "TA1 - rtems_task_mode - RTEMS_INVALID_ADDRESS" );
 
  TEST_END();

  rtems_test_exit( 0 );
}
Esempio n. 11
0
rtems_task Init( rtems_task_argument ignored )
{
  rtems_status_code    status;
  rtems_attribute      sem_attr;
  rtems_task_priority  pri;
  rtems_mode           prev_mode;

  Print_Warning();

  TEST_BEGIN();

  sem_attr =  RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY;

  sem_name = rtems_build_name( 'S','0',' ',' ' );
  status = rtems_semaphore_create(
    sem_name,
    1,
    sem_attr,
    0,
    &sem_id
  );
  directive_failed( status, "rtems_semaphore_create of S0" );

  Task_name[0] = rtems_build_name( 'T','A','0','1' );
  status = rtems_task_create(
    Task_name[0],
    30,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[0]
  );
  directive_failed( status, "rtems_task_create of TA01" );

  Task_name[1] = rtems_build_name( 'T','A','0','2' );
  status = rtems_task_create(
    Task_name[1],
    30,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[1]
  );
  directive_failed( status , "rtems_task_create of TA02\n" );

  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &prev_mode );
  /* Lower own priority so TA01 can start up and run */
  rtems_task_set_priority( RTEMS_SELF, 40, &pri);

  /* Get time of benchmark with no semaphore shuffling */
  sem_exe = 0;
  status = rtems_task_start( Task_id[0], Task01, 0 );
  directive_failed( status, "rtems_task_start of TA01" );

  /* Get time of benchmark with semaphore shuffling */
  sem_exe = 1;
  status = rtems_task_restart( Task_id[0], 0 );
  directive_failed( status, "rtems_task_restart of TA01" );

  /* Should never reach here */
  rtems_test_assert( false );
}
Esempio n. 12
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  printf(
   "\n\n*** TEST 10 -- NODE %d ***\n",
   Multiprocessing_configuration.node
  );

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

  Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );

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

  if ( Multiprocessing_configuration.node == 1 ) {
    puts( "Creating Message Queue (Global)" );
    status = rtems_message_queue_create(
      Queue_name[ 1 ],
      3,
      16,
      RTEMS_GLOBAL,
      &Queue_id[ 1 ]
    );
    directive_failed( status, "rtems_message_queue_create" );

    puts( "Creating Semaphore (Global)" );
    status = rtems_semaphore_create(
      Semaphore_name[ 1 ],
      0,
      RTEMS_GLOBAL | RTEMS_PRIORITY,
      RTEMS_NO_PRIORITY,
      &Semaphore_id[ 1 ]
    );
    directive_failed( status, "rtems_semaphore_create" );

    status = rtems_task_wake_after( 10 * TICKS_PER_SECOND );
    directive_failed( status, "rtems_task_wake_after" );

  } else {

    puts( "Creating Test_task 1 (local)" );
    status = rtems_task_create(
      Task_name[ 1 ],
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_TIMESLICE,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Task_id[ 1 ]
    );
    directive_failed( status, "rtems_task_create" );

    puts( "Starting Test_task 1 (local)" );
    status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
    directive_failed( status, "rtems_task_start" );

    puts( "Creating Test_task 2 (local)" );
    status = rtems_task_create(
      Task_name[ 2 ],
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_TIMESLICE,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Task_id[ 2 ]
    );
    directive_failed( status, "rtems_task_create" );

    puts( "Starting Test_task 2 (local)" );
    status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
    directive_failed( status, "rtems_task_start" );

    puts( "Creating Test_task 3 (local)" );
    status = rtems_task_create(
      Task_name[ 3 ],
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_TIMESLICE,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Task_id[ 3 ]
    );
    directive_failed( status, "rtems_task_create" );

    puts( "Starting Test_task 3 (local)" );
    status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
    directive_failed( status, "rtems_task_start" );

    puts( "Sleeping for 1 seconds ..." );
    status = rtems_task_wake_after( TICKS_PER_SECOND );
    directive_failed( status, "rtems_task_wake_after" );

    puts( "Deleting Test_task2" );
    status = rtems_task_delete( Task_id[ 2 ] );
    directive_failed( status, "rtems_task_delete of Task 2" );

    puts( "Deleting Test_task1" );
    status = rtems_task_delete( Task_id[ 1 ] );
    directive_failed( status, "rtems_task_delete of Task 1" );

    puts( "Restarting Test_task3" );
    status = rtems_task_restart( Task_id[ 3 ], 1 );
    directive_failed( status, "rtems_task_restart of Task 3" );

  }
  puts( "*** END OF TEST 10 ***" );
  rtems_test_exit( 0 );
}
Esempio n. 13
0
static void test(void)
{
  rtems_status_code sc;
  rtems_id id;

  master_task = rtems_task_self();

#ifdef BSP_INITIAL_EXTENSION
  sc = rtems_extension_create(
    rtems_build_name(' ', 'B', 'S', 'P'),
    &initial_bsp,
    &id
  );
  assert(sc == RTEMS_SUCCESSFUL);
#undef BSP_INITIAL_EXTENSION
#endif

  sc = rtems_extension_create(
    rtems_build_name('T', 'E', 'S', 'T'),
    &initial_test,
    &id
  );
  assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_extension_create(
    rtems_build_name('2', ' ', ' ', ' '),
    &two,
    &id
  );
  assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_extension_create(
    rtems_build_name('3', ' ', ' ', ' '),
    &three,
    &id
  );
  assert(sc == RTEMS_SUCCESSFUL);

  active_extensions = 4;
  assert(counter == 14);
  counter = 16;

  sc = rtems_task_create(
    rtems_build_name('W', 'O', 'R', 'K'),
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_start(id, worker, 0);
  assert(sc == RTEMS_SUCCESSFUL);

  wait_for_worker();

  sc = rtems_task_restart(id, 0);
  assert(sc == RTEMS_SUCCESSFUL);

  wait_for_worker();

  sc = rtems_task_delete(id);
  assert(sc == RTEMS_SUCCESSFUL);

  /* Process zombies to trigger delete extensions */
  sc = rtems_task_create(
    rtems_build_name('N', 'U', 'L', 'L'),
    2,
    SIZE_MAX,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  assert(sc == RTEMS_UNSATISFIED);
}
Esempio n. 14
0
void Screen1()
{
    uint32_t            notepad_value;
    rtems_id            self_id;
    rtems_task_priority previous_priority;
    rtems_status_code   status;

    /* bad Id */
    status = rtems_task_is_suspended( 100 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_set_priority with illegal id"
    );
    puts( "TA1 - rtems_task_is_suspended - RTEMS_INVALID_ID" );

    /* bad Id */
    status = rtems_task_delete( 100 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_delete with illegal id"
    );
    puts( "TA1 - rtems_task_delete - RTEMS_INVALID_ID" );

    /* NULL return */
    status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_FIRST, NULL );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ADDRESS,
        "rtems_task_get_note with NULL param"
    );
    puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ADDRESS" );

    /* note too high */
    status = rtems_task_get_note( RTEMS_SELF, 100, &notepad_value );
    fatal_directive_status(
        status,
        RTEMS_INVALID_NUMBER,
        "rtems_task_get_note with illegal notepad"
    );
    puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_NUMBER" );

    /* bad Id */
    status = rtems_task_get_note( 100, RTEMS_NOTEPAD_LAST, &notepad_value );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_get_note with illegal id"
    );
    puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ID" );

    /* unused Id so invalid now */
    status = rtems_task_get_note(
                 _RTEMS_tasks_Information.maximum_id,
                 RTEMS_NOTEPAD_LAST,
                 &notepad_value
             );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_get_note with illegal id"
    );
    puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ID" );

    status = rtems_task_get_note(
                 _RTEMS_tasks_Information.minimum_id + (3L<<OBJECTS_API_START_BIT),
                 RTEMS_NOTEPAD_LAST,
                 &notepad_value
             );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_get_note with illegal id"
    );

    status = rtems_task_get_note(
                 rtems_build_id( OBJECTS_CLASSIC_API, 2, 1, 1 ),
                 RTEMS_NOTEPAD_LAST,
                 &notepad_value
             );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_get_note with non-task ID"
    );

    /* NULL param */
    status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, NULL );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ADDRESS,
        "rtems_task_ident NULL param"
    );
    puts( "TA1 - rtems_task_ident - RTEMS_INVALID_ADDRESS" );

    /* OK */
    status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &self_id );
    directive_failed( status, "rtems_task_ident of self" );
    if ( self_id != Task_id[ 1 ] ) {
        puts( "ERROR - rtems_task_ident - incorrect ID returned!" );
    }
    puts( "TA1 - rtems_task_ident - current task RTEMS_SUCCESSFUL" );

    status = rtems_task_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id );
    fatal_directive_status(
        status,
        RTEMS_INVALID_NAME,
        "rtems_task_ident with illegal name (local)"
    );
    puts( "TA1 - rtems_task_ident - global RTEMS_INVALID_NAME" );

    status = rtems_task_ident( 100, 1, &Junk_id );
    fatal_directive_status(
        status,
        RTEMS_INVALID_NAME,
        "rtems_task_ident with illegal name (global)"
    );
    puts( "TA1 - rtems_task_ident - local RTEMS_INVALID_NAME" );

    /*
     *  This one case is different if MP is enabled/disabled.
     */

    status = rtems_task_ident( 100, 2, &Junk_id );
#if defined(RTEMS_MULTIPROCESSING)
    fatal_directive_status(
        status,
        RTEMS_INVALID_NODE,
        "rtems_task_ident with illegal node"
    );
#else
    fatal_directive_status(
        status,
        RTEMS_INVALID_NAME,
        "rtems_task_ident with illegal node"
    );
#endif
    puts( "TA1 - rtems_task_ident - RTEMS_INVALID_NODE" );

    status = rtems_task_restart( 100, 0 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_restart with illegal id"
    );
    puts( "TA1 - rtems_task_restart - RTEMS_INVALID_ID" );

    status = rtems_task_resume( 100 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_resume with illegal id"
    );
    puts( "TA1 - rtems_task_resume - RTEMS_INVALID_ID" );

    status = rtems_task_resume( RTEMS_SELF );
    fatal_directive_status(
        status,
        RTEMS_INCORRECT_STATE,
        "rtems_task_resume of ready task"
    );
    puts( "TA1 - rtems_task_resume - RTEMS_INCORRECT_STATE" );

    /* NULL param */
    status = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, NULL );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ADDRESS,
        "rtems_task_set_priority with NULL param"
    );
    puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ADDRESS" );

    /* bad priority */
    status = rtems_task_set_priority( RTEMS_SELF, 512, &previous_priority );
    fatal_directive_status(
        status,
        RTEMS_INVALID_PRIORITY,
        "rtems_task_set_priority with illegal priority"
    );
    puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_PRIORITY" );

    /* bad Id */
    status = rtems_task_set_priority( 100, 8, &previous_priority );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_set_priority with illegal id"
    );
    puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ID" );

    status = rtems_task_set_note(
                 RTEMS_SELF,
                 RTEMS_NOTEPAD_LAST+10,
                 notepad_value
             );
    fatal_directive_status(
        status,
        RTEMS_INVALID_NUMBER,
        "rtems_task_set_note with illegal notepad"
    );
    puts( "TA1 - rtems_task_set_note - RTEMS_INVALID_NUMBER" );

    status = rtems_task_set_note( 100, RTEMS_NOTEPAD_LAST, notepad_value );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_set_note with illegal id"
    );
    puts( "TA1 - rtems_task_set_note - RTEMS_INVALID_ID" );

    status = rtems_task_start( 100, Task_1, 0 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_start with illegal id"
    );
    puts( "TA1 - rtems_task_start - RTEMS_INVALID_ID" );

    /* already started */
    status = rtems_task_start( RTEMS_SELF, Task_1, 0 );
    fatal_directive_status(
        status,
        RTEMS_INCORRECT_STATE,
        "rtems_task_start of ready task"
    );
    puts( "TA1 - rtems_task_start - RTEMS_INCORRECT_STATE" );

    /* bad Id */
    status = rtems_task_suspend( 100 );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ID,
        "rtems_task_suspend with illegal id"
    );
    puts( "TA1 - rtems_task_suspend - RTEMS_INVALID_ID" );

    /* NULL param */
    status = rtems_task_mode( RTEMS_SELF, 0, NULL );
    fatal_directive_status(
        status,
        RTEMS_INVALID_ADDRESS,
        "rtems_task_mode with NULL param"
    );
    puts( "TA1 - rtems_task_mode - RTEMS_INVALID_ADDRESS" );
}
Esempio n. 15
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

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

  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', ' ' );
  Task_name[ 6 ]       =  rtems_build_name( 'T', 'A', '6', ' ' );
  Task_name[ 7 ]       =  rtems_build_name( 'T', 'A', '7', ' ' );
  Task_name[ 8 ]       =  rtems_build_name( 'T', 'A', '8', ' ' );
  Task_name[ 9 ]       =  rtems_build_name( 'T', 'A', '9', ' ' );
  Task_name[ 10 ]      =  rtems_build_name( 'T', 'A', 'A', ' ' );

  Timer_name[ 1 ]      =  rtems_build_name( 'T', 'M', '1', ' ' );

  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', ' ' );

  Queue_name[ 1 ]      =  rtems_build_name( 'M', 'Q', '1', ' ' );
  Queue_name[ 2 ]      =  rtems_build_name( 'M', 'Q', '2', ' ' );

  Partition_name[ 1 ]  =  rtems_build_name( 'P', 'T', '1', ' ' );

  Region_name[ 1 ]     =  rtems_build_name( 'R', 'N', '1', ' ' );

  Port_name[ 1 ]       =  rtems_build_name( 'D', 'P', '1', ' ' );

  Period_name[ 1 ]     =  rtems_build_name( 'T', 'M', '1', ' ' );

  /* priority of 0 error */
  status = rtems_task_create(
     Task_name[1],
     0,
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 1 ]
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_task_create with illegal priority"
  );
  puts( "INIT - rtems_task_create - priority of 0 - RTEMS_INVALID_PRIORITY" );

  /* priority > 255 error */
  status = rtems_task_create(
     Task_name[1],
     257,
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 1 ]
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_task_create with illegal priority"
  );
  puts(
    "INIT - rtems_task_create - priority too high - RTEMS_INVALID_PRIORITY"
  );

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

  status = rtems_task_restart( Task_id[ 1 ], 0 );
  fatal_directive_status(
    status,
    RTEMS_INCORRECT_STATE,
    "rtems_task_restart of DORMANT task"
  );
  puts( "INIT - rtems_task_restart - RTEMS_INCORRECT_STATE" );

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

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 16
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_id          id;

  TEST_BEGIN();

  Extension_name[ 1 ] =  rtems_build_name( 'E', 'X', 'T', '1' );
  Extension_name[ 2 ] =  rtems_build_name( 'E', 'X', 'T', '2' );

  puts  ( "rtems_extension_create - bad id pointer -- RTEMS_INVALID_ADDRESS" );
  status = rtems_extension_create( 0xa5a5a5a5, &Extensions, NULL );
  fatal_directive_status(
    status, RTEMS_INVALID_ADDRESS, "rtems_extension_create" );

  puts  ( "rtems_extension_create - bad name -- RTEMS_INVALID_NAME" );
  status = rtems_extension_create( 0, &Extensions, &id );
  fatal_directive_status(
    status, RTEMS_INVALID_NAME, "rtems_extension_create #1" );

  puts( "rtems_extension_create - first one -- OK" );
  status = rtems_extension_create(
    Extension_name[ 1 ],
    &Extensions,
    &Extension_id[ 1 ]
  );
  directive_failed( status, "rtems_extension_create" );

  puts( "rtems_extension_create - second one-- OK" );
  status = rtems_extension_create(
    Extension_name[ 2 ],
    &Extensions,
    &Extension_id[ 2 ]
  );
  directive_failed( status, "rtems_extension_create #2" );

  puts  ( "rtems_extension_create -- RTEMS_TOO_MANY" );
  status = rtems_extension_create( 0xa5a5a5a5, &Extensions, &id );
  fatal_directive_status( status, RTEMS_TOO_MANY, "rtems_extension_create" );

  puts( "rtems_extension_delete - second one -- OK" );
  status = rtems_extension_delete( Extension_id[ 2 ] );
  directive_failed( status, "rtems_extension_delete #2" );

  puts( "rtems_extension_delete - second one again -- RTEMS_INVALID_ID" );
  status = rtems_extension_delete( Extension_id[ 2 ] );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_extension_delete #2 bad"
  );

  puts  ( "rtems_extension_ident -- OK" );
  status = rtems_extension_ident( Extension_name[1], &id );
  directive_failed( status, "rtems_extension_ident" );

  puts  ( "rtems_extension_ident - bad name -- RTEMS_INVALID_NAME" );
  status = rtems_extension_ident( Extension_name[2], &id );
  fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_extension_ident" );

  puts  ( "rtems_extension_ident - bad name -- RTEMS_INVALID_ADDRESS" );
  status = rtems_extension_ident( Extension_name[2], NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_extension_ident"
  );

  puts( "rtems_extension_create - harmless -- OK" );
  status = rtems_extension_create(
    Extension_name[ 2 ],
    &Harmless_extensions,
    &Extension_id[ 2 ]
  );
  directive_failed( status, "rtems_extension_create #3" );

  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', ' ' );

  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" );
  assert_extension_counts( &Task_created[ 0 ], 0x2 );

  status = rtems_task_create(
    Task_name[ 2 ],
    4,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 2 ]
  );
  directive_failed( status, "rtems_task_create of TA2" );
  assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 );

#define TA3_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 4u)
  status = rtems_task_create(
    Task_name[ 3 ],
    TA3_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 3 ]
  );
  directive_failed( status, "rtems_task_create of TA3" );
  assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 );

#define TA4_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u)
  status = rtems_task_create(
    Task_name[ 4 ],
    TA4_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Task_id[ 4 ]
  );
  directive_failed( status, "rtems_task_create of TA4" );
  assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 );

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

  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
  directive_failed( status, "rtems_task_start of TA2" );
  assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 );

  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
  directive_failed( status, "rtems_task_start of TA3" );
  assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 );

  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
  directive_failed( status, "rtems_task_start of TA4" );
  assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 );

  status = rtems_task_restart( Task_id[ 2 ], 0 );
  directive_failed( status, "rtems_task_restart of TA3" );
  assert_extension_counts( &Task_restarted[ 0 ], 0x0 );

  status = rtems_task_set_note( rtems_task_self(), RTEMS_NOTEPAD_4, 32 );
  directive_failed( status, "task_set_node of Self id" );
  printf( "INIT - rtems_task_set_note - set my (id) RTEMS_NOTEPAD_4 " );
  puts  ( "to TA1's priority: 04" );

  status = rtems_task_set_note( RTEMS_SELF, RTEMS_NOTEPAD_4, 32 );
  directive_failed( status, "task_set_node of Self 0" );
  printf( "INIT - rtems_task_set_note - set my (SELF) RTEMS_NOTEPAD_4 " );
  puts  ( "to TA1's priority: 04" );

  status = rtems_task_set_note( Task_id[ 1 ], RTEMS_NOTEPAD_8, 4 );
  directive_failed( status, "task_set_node of TA1" );
  printf( "INIT - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8 " );
  puts  ( "to TA1's priority: 04" );

  status = rtems_task_set_note( Task_id[ 2 ], RTEMS_NOTEPAD_8, 4 );
  directive_failed( status, "task_set_node of TA2" );
  printf( "INIT - rtems_task_set_note - set TA2's RTEMS_NOTEPAD_8 " );
  puts  ( "to TA2's priority: 04");

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 17
0
File: init.c Progetto: gedare/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  
  TEST_BEGIN();

  Task_id[ 0 ] = rtems_task_self();

  Task_name[ 1 ]       =  rtems_build_name( 'T', 'A', '1', ' ' );

  /* priority of 0 error */
  status = rtems_task_create(
     Task_name[1],
     0,
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 1 ]
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_task_create with illegal priority"
  );
  puts( "INIT - rtems_task_create - priority of 0 - RTEMS_INVALID_PRIORITY" );

  /* priority > 255 error */
  status = rtems_task_create(
     Task_name[1],
     UINT32_C(0x80000000),
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
     RTEMS_DEFAULT_ATTRIBUTES,
     &Task_id[ 1 ]
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_task_create with illegal priority"
  );
  puts(
    "INIT - rtems_task_create - priority too high - RTEMS_INVALID_PRIORITY"
  );

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

  status = rtems_task_restart( Task_id[ 1 ], 0 );
  fatal_directive_status(
    status,
    RTEMS_INCORRECT_STATE,
    "rtems_task_restart of DORMANT task"
  );
  puts( "INIT - rtems_task_restart - RTEMS_INCORRECT_STATE" );

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

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