rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  puts( "\n\n*** LED BLINKER -- timer_server ***" );

  LED_INIT();

  status = rtems_timer_initiate_server(
    1, 
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_ATTRIBUTES
  );

  if ( status != RTEMS_SUCCESSFUL )
    fputs( "timer create server failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer1 create failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer2 create failed\n", stderr );

  Timer_Routine(Timer1, NULL);

  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );

  Timer_Routine(Timer2, NULL);

  status = rtems_task_delete( RTEMS_SELF );
}
Esempio n. 2
0
/*
 *  Test Device Driver Entry Points
 */
rtems_device_driver termios_test_driver_initialize(
  rtems_device_major_number  major,
  rtems_device_minor_number  minor,
  void                      *arg
)
{
  rtems_status_code status;

  rtems_termios_initialize();

  /*
   *  Register Device Names
   */
  (void) rtems_io_register_name( TERMIOS_TEST_DRIVER_DEVICE_NAME, major, 0 );

  status = rtems_timer_create(rtems_build_name('T', 'M', 'R', 'X'), &Rx_Timer);
  if ( status )
    rtems_fatal_error_occurred(1);;

  status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
  if ( status )
    rtems_fatal_error_occurred(1);;

  return RTEMS_SUCCESSFUL;
}
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  puts( "\n\n*** LED BLINKER -- timer ***" );

  LED_INIT();

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer1 create failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer2 create failed\n", stderr );

  Timer_Routine(Timer1, NULL);
  LED_Change_Routine();

  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );

  Timer_Routine(Timer2, NULL);
  LED_Change_Routine();

  while (1) {
    status = rtems_task_wake_after( 10 );
    LED_Change_Routine();
  }

  status = rtems_task_delete( RTEMS_SELF );
}
Esempio n. 4
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day  time;
  rtems_status_code  status;

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

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

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

  status = rtems_timer_initiate_server(
    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed( status, "rtems_timer_initiate_server" );

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

  status = rtems_task_create(
    Task_name[ 1 ],
    1,
    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_start( Task_id[ 1 ], Task_1, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  puts( "INIT - rtems_timer_create - creating timer 1" );
  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create" );
  printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] );

  puts( "INIT - rtems_timer_create - creating timer 2" );
  status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
  directive_failed( status, "rtems_timer_create" );
  printf( "INIT - timer 2 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 2 ] );

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 5
0
File: init.c Progetto: Dipupo/rtems
static void timer_task(rtems_task_argument arg)
{
  test_context *ctx = (test_context *) arg;
  rtems_status_code sc;
  rtems_id timer_id;

  rtems_test_assert(rtems_get_current_processor() == 1);

  sc = rtems_timer_create(SCHEDULER_B, &timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /* (A) */
  wait(ctx, &ctx->timer_barrier_state);

  sc = rtems_timer_fire_after(timer_id, 1, timer_isr, ctx);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_wake_after(1);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_timer_delete(timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /* (C) */
  wait(ctx, &ctx->timer_barrier_state);

  while (true) {
    /* Wait for deletion */
  }
}
Esempio n. 6
0
rtems_task Init( rtems_task_argument ignored )
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  size_t i = 0;

  puts("\n\n*** TEST INTERRUPT CRITICAL SECTION 17 ***");

  build_time(&tod, 4, 12, 2009, 9, 34, 11, 0);
  sc = rtems_clock_set(&tod);
  directive_failed(sc, "rtems_clock_set");

  ++tod.year;

  for (i = 0; i < TIMER_COUNT; ++i) {
    sc = rtems_timer_create(
      rtems_build_name('T', 'I', 'M', '0' + i),
      &timer [i]
    );
    directive_failed(sc, "rtems_timer_create");
  }

  sc = rtems_timer_initiate_server(
    RTEMS_MINIMUM_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed(sc, "rtems_timer_initiate_server");

  sc = rtems_timer_server_fire_after(
    timer [TIMER_NEVER_INTERVAL],
    2,
    never_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_server_fire_after");

  reset_tod_timer();

  sc = rtems_timer_fire_after(
    timer [TIMER_RESET],
    1,
    reset_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_fire_after");

  sc = rtems_timer_server_fire_after(
    timer [TIMER_TRIGGER],
    1,
    trigger_callback,
    NULL
  );
  directive_failed(sc, "rtems_timer_server_fire_after");

  interrupt_critical_section_test_support_initialize(NULL);

  rtems_task_delete(RTEMS_SELF);
}
Esempio n. 7
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day time;
  uint32_t    index;
  rtems_status_code status;

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

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

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

  status = rtems_timer_initiate_server(
    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed( status, "rtems_timer_initiate_server" );

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

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

  for ( index = 1 ; index <= 3 ; index++ ) {
    status = rtems_task_create(
      Task_name[ index ],
      1,
      RTEMS_MINIMUM_STACK_SIZE * 2,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Task_id[ index ]
    );
    directive_failed( status, "rtems_task_create loop" );

    status = rtems_timer_create(
      Timer_name[ index ],
      &Timer_id[ index ]
    );
    directive_failed( status, "rtems_timer_create loop" );
  }

  for ( index = 1 ; index <= 3 ; index++ ) {
    status = rtems_task_start( Task_id[ index ], Task_1_through_3, index );
    directive_failed( status, "rtems_task_start loop" );
  }

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 8
0
static void start_timer(test_context *self)
{
  rtems_status_code sc;

  sc = rtems_timer_create(rtems_build_name('C', 'L', 'S', 'W'), &self->timer);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_timer_fire_after(self->timer, 2, clobber_and_switch_timer, self);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Esempio n. 9
0
static rtems_id createTimer(void) {
	rtems_status_code rc;
	rtems_id timerID = 0;
	rtems_name timerName = rtems_build_name('T','M','R','1');
	
	rc = rtems_timer_create(timerName, &timerID);
	if(rc != RTEMS_SUCCESSFUL) {
		syslog(LOG_INFO, "rtems_timer_create(): %s\n", rtems_status_text(rc));
	}
	return timerID;
}
Esempio n. 10
0
static void test_no_preempt( void )
{
  rtems_status_code sc;
  rtems_id id;

  rtems_test_assert( test_no_preempt_step == 0 );

  sc = rtems_task_delete( Task_id[ 2 ] );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_task_delete( Task_id[ 3 ] );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_task_create(
    rtems_build_name( 'H', 'I', 'G', 'H' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &high_task_id
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_task_create(
    rtems_build_name( 'L', 'O', 'W', ' ' ),
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_NO_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &low_task_id
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_timer_create( rtems_build_name( 'N', 'O', 'P', 'R' ), &id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_timer_fire_after( id, 1, no_preempt_timer, NULL );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_event_transient_receive( RTEMS_WAIT, RTEMS_NO_TIMEOUT );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_timer_delete( id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_task_delete( high_task_id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  sc = rtems_task_delete( low_task_id );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  rtems_test_assert( test_no_preempt_step == 3 );
}
Esempio n. 11
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code     status;
  rtems_id              timer;
  rtems_interval        start;
  rtems_interval        now;

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

  main_task = rtems_task_self();

  /*
   *  Timer used in multiple ways
   */
  status = rtems_timer_create( 1, &timer );
  directive_failed( status, "rtems_timer_create" );

  /*
   *  Get starting time
   */
  start = rtems_clock_get_ticks_since_boot();

  status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES );
  directive_failed( status, "rtems_signal_catch" );
  puts( "rtems_signal_catch - handler installed" );

  /*
   * Test Signal from ISR
   */
  signal_sent = FALSE;

  status = rtems_timer_fire_after( timer, 10, test_signal_from_isr, NULL );
  directive_failed( status, "timer_fire_after failed" );

  while (1) {
    now = rtems_clock_get_ticks_since_boot();
    if ( (now-start) > 100 ) {
      puts( "Signal from ISR did not get processed\n" );
      rtems_test_exit( 0 );
    }
    if ( signal_processed )
      break;
  }

  puts( "Signal sent from ISR has been processed" );
  puts( "*** END OF TEST 38 ***" );
  rtems_test_exit( 0 );
}
Esempio n. 12
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day  time;
  rtems_status_code  status;
  Chain_Control      empty;

   puts( "\n*** RTEMS WATCHDOG ***" );

  puts( "INIT - report on empty watchdog chain" );
  _Chain_Initialize_empty( &empty );
  _Watchdog_Report_chain( "Empty Chain", &empty );

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

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

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

  status = rtems_task_create(
    Task_name[ 1 ],
    1,
    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_start( Task_id[ 1 ], Task_1, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  puts( "INIT - rtems_timer_create - creating timer 1" );
  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create" );

  printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] );

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


  rtems_test_exit( 0 );
}
Esempio n. 13
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code sc;
  rtems_id          timer1;
  struct timespec   uptime;

  TEST_BEGIN();

  sc = rtems_timer_initiate_server(
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed( sc, "rtems_timer_initiate_server" );

  sc = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &timer1);
  directive_failed( sc, "rtems_timer_create" );

  Fired = 0;
  timerRan = false;

  Timer_Routine(timer1, NULL);

  while (1) {
    sc = rtems_task_wake_after( 10 );
    directive_failed( sc, "rtems_task_wake_after" );

    if ( timerRan == true ) {
      timerRan = false;

      sc = rtems_clock_get_uptime( &uptime );
      directive_failed( sc, "rtems_clock_get_uptime" );

      printf( "Timer fired at %" PRIdtime_t "\n", uptime.tv_sec );
    }

    if ( Fired >= 10 ) {
      TEST_END();
      rtems_test_exit( 0 );
    }
    /* technically the following is a critical section */
  }
}
Esempio n. 14
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

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

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

  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_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" );

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

  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create of TM1" );

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 15
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day  time;
  rtems_status_code  status;

  TEST_BEGIN();

  test_watchdog_static_init();

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

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

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

  status = rtems_task_create(
    Task_name[ 1 ],
    1,
    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_start( Task_id[ 1 ], Task_1, 0 );
  directive_failed( status, "rtems_task_start of TA1" );

  puts( "INIT - rtems_timer_create - creating timer 1" );
  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create" );

  printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] );

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


  rtems_test_exit( 0 );
}
Esempio n. 16
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code     sc;
  int                   resets;

  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );

  puts( "Init - Trying to generate timer fire from ISR while firing" );
  puts( "Init - Variation is: " TEST_STRING );

  puts( "Init - There is no way for the test to know if it hits the case" );

  #if defined(SERVER_FIRE_AFTER)
   /* initiate timer server */
    sc = rtems_timer_initiate_server(
      RTEMS_MINIMUM_PRIORITY,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_ATTRIBUTES
    );
    directive_failed( sc, "rtems_timer_initiate_server" );
  #endif

  puts( "Init - rtems_timer_create - OK" );
  sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer);
  directive_failed( sc, "rtems_timer_create" );

  Main_task = rtems_task_self();

  interrupt_critical_section_test_support_initialize( test_release_from_isr );

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

    sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL );
    directive_failed( sc, "rtems_timer_fire_after");
  }

  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
  rtems_test_exit(0);
}
Esempio n. 17
0
rtems_task Delayed_events_task(
  rtems_task_argument argument
)
{
  uint32_t    count;
  uint32_t    previous_mode;
  rtems_status_code status;
  rtems_event_set   events;

  status = rtems_task_mode(
    RTEMS_PREEMPT | RTEMS_TIMESLICE,
    RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK,
    &previous_mode
  );
  directive_failed( status, "rtems_task_mode" );

  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create" );

  while ( Stop_Test == FALSE ) {
    for ( count=DELAYED_EVENT_DOT_COUNT; Stop_Test == FALSE && count; count-- ){
      status = rtems_timer_fire_after(
        Timer_id[ 1 ],
        1,
        Delayed_send_event,
        NULL
      );
      directive_failed( status, "rtems_timer_reset" );

      status = rtems_event_receive(
        RTEMS_EVENT_16,
        RTEMS_DEFAULT_OPTIONS,
        RTEMS_NO_TIMEOUT,
        &events
      );
      directive_failed( status, "rtems_event_receive" );
    }
    put_dot('.');
  }

  Exit_test();
}
Esempio n. 18
0
File: init.c Progetto: gedare/rtems
static void test(void)
{
  test_context *ctx;
  rtems_status_code sc;
  size_t i;

  ctx = &test_instance;

  ctx->master_id = rtems_task_self();

  for (i = 0; i < TASK_COUNT; ++i) {
    sc = rtems_task_create(
      NAME,
      P(i),
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &ctx->task_ids[i]
    );
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    sc = rtems_task_start(ctx->task_ids[i], do_nothing_task, 0);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  }

  sc = rtems_timer_create(NAME, &ctx->timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  for (i = 0; i < TASK_COUNT; ++i) {
    sc = rtems_task_delete(ctx->task_ids[i]);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  }

  sc = rtems_timer_delete(ctx->timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Esempio n. 19
0
File: init.c Progetto: Dipupo/rtems
static rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code sc;
  test_context ctx = {
    .thread = _Thread_Get_executing()
  };

  TEST_BEGIN();

  sc = rtems_timer_create(rtems_build_name('T', 'I', 'M', 'R'), &ctx.timer);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  test_any_satisfy_before_timeout(&ctx);
  test_all_satisfy_before_timeout(&ctx);
  test_timeout_before_all_satisfy(&ctx);

  TEST_END();
  rtems_test_exit(0);
}
Esempio n. 20
0
void *POSIX_Init(
  void *argument
)
{
  rtems_status_code status;

  puts( "\n\n*** POSIX TEST CANCEL 01 ***" );

  status = rtems_timer_create(
    rtems_build_name( 'T', 'M', '1', ' ' ),
    &timer_id
  );
  rtems_test_assert( !status );

  doit( Cancel_duringISR_TSR, "pthread_cancel" );
  doit( SetState_duringISR_TSR, "pthread_setcancelstate" );
  doit( SetType_duringISR_TSR, "pthread_setcanceltype" );

  puts( "*** END OF POSIX TEST CANCEL 01 ***" );
  rtems_test_exit(0);
  return NULL; /* just so the compiler thinks we returned something */
}
Esempio n. 21
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

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

  Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
  Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );

  puts( "Creating Test_task (Global)" );
  status = rtems_task_create(
    Task_name[Multiprocessing_configuration.node],
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_GLOBAL,
    &Task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create" );

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

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

  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
  directive_failed( status, "rtems_timer_create" );

  puts( "Deleting initialization task" );
  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 22
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code     status;
  rtems_id              timer;
  rtems_event_set       out;
  int                   i;
  int                   max;
  uint32_t              iterations = 0;

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

  main_task = rtems_task_self();

  /*
   *  Timer used in multiple ways
   */
  status = rtems_timer_create( 1, &timer );
  directive_failed( status, "rtems_timer_create" );

  status = rtems_task_create(
    0xa5a5a5a5,
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &other_task
  );
  directive_failed( status, "rtems_task_create" );

  /*
   * Test Event send successful from ISR -- receive is forever
   */
  case_hit = FALSE;
  iterations = 0;
  max = 1;

  while (1) {
    if ( case_hit )
      break;
    status = rtems_timer_fire_after( timer, 1, test_event_from_isr, NULL );
    directive_failed( status, "timer_fire_after failed" );

    for (i=0 ; i<max ; i++ )
      if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED )
        break;

    status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 0, &out );
    directive_failed( status, "rtems_event_receive" );
    if ( case_hit == TRUE )
      break;
    max += 2;

    /* with our clock tick, this is about 30 seconds */
    if ( ++iterations >= 4L * 1000L * 30L)
      break;
  }

  printf(
    "Event sent from ISR hitting synchronization point has %soccurred\n",
    (( case_hit == TRUE ) ? "" : "NOT ")
  );

  /*
   * Test Event send successful from ISR -- receive has timeout
   */
  case_hit = FALSE;
  iterations = 0;
  max = 1;

  while (1) {
    if ( case_hit )
      break;
    status = rtems_timer_fire_after(
      timer, 1, test_event_with_timeout_from_isr, NULL );
    directive_failed( status, "timer_fire_after failed" );

    for (i=0 ; i<max ; i++ )
      if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED )
        break;

    status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 10, &out );
    directive_failed( status, "rtems_event_receive" );
    if ( case_hit == TRUE )
      break;
    max += 2;

    /* with our clock tick, this is about 30 seconds */
    if ( ++iterations >= 4L * 1000L * 30L)
      break;
  }

  printf(
    "Event sent from ISR (with timeout) hitting synchronization "
      "point has %soccurred\n",
    (( case_hit == TRUE ) ? "" : "NOT ")
  );

  puts( "*** END OF TEST 39 ***" );
  rtems_test_exit( 0 );
}
Esempio n. 23
0
rtems_task Init(rtems_task_argument argument)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  char region_area [256];
  enum resource_type rt = SEMAPHORE;
  void *new_region_item = NULL;
  size_t i = 0;

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

  for (i = 0; i < TIMER_COUNT; ++i) {
    sc = rtems_timer_create(
      rtems_build_name('T', 'I', 'M', '0' + i),
      &timer [i]
    );
    directive_failed(sc, "rtems_timer_create");
  }

  sc = rtems_timer_initiate_server(
    RTEMS_MINIMUM_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed(sc, "rtems_timer_initiate_server");

  sc = rtems_semaphore_create(
    rtems_build_name('S', 'E', 'M', 'A'),
    0,
    RTEMS_LOCAL | RTEMS_FIFO | RTEMS_COUNTING_SEMAPHORE,
    0,
    &semaphore
  );
  directive_failed(sc, "rtems_semaphore_create");

  sc = rtems_semaphore_create(
    rtems_build_name('M', 'U', 'T', 'X'),
    0,
    RTEMS_LOCAL | RTEMS_FIFO | RTEMS_SIMPLE_BINARY_SEMAPHORE,
    0,
    &mutex
  );
  directive_failed(sc, "rtems_semaphore_create");

  sc = rtems_message_queue_create(
    rtems_build_name('M', 'S', 'G', 'Q'),
    1,
    1,
    RTEMS_LOCAL | RTEMS_FIFO,
    &message_queue
  );
  directive_failed(sc, "rtems_message_queue_create");

  sc = rtems_region_create(
    rtems_build_name('R', 'E', 'G', 'I'),
    region_area,
    sizeof(region_area),
    1,
    RTEMS_LOCAL | RTEMS_FIFO,
    &region
  );
  directive_failed(sc, "rtems_region_create");

  do {
    region_item = new_region_item;
    sc = rtems_region_get_segment(
        region, 1, RTEMS_NO_WAIT, 0, &new_region_item);
  } while (sc == RTEMS_SUCCESSFUL);

  sc = rtems_barrier_create(
    rtems_build_name('B', 'A', 'R', 'R'),
    RTEMS_LOCAL | RTEMS_FIFO,
    2,
    &barrier
  );
  directive_failed(sc, "rtems_barrier_create");

  while (rt <= TASK_WAKE_AFTER) {
    test_case(rt);
    ++rt;
  }

  puts("*** END OF TEST 68 ***");

  rtems_test_exit(0);
}
Esempio n. 24
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. 25
0
void CFE_PSP_Main(  int ModeId, char *StartupFilePath )
{
   uint32            reset_type;
   uint32            reset_subtype;
   rtems_status_code RtemsStatus;
   rtems_name        RtemsTimerName;
   
   /*
   ** Initialize the OS API
   */
   OS_API_Init();

   /* 
   ** Create an interval timer for the 1hz
   */
   RtemsTimerName = rtems_build_name('1',' ','H','Z');
   RtemsStatus = rtems_timer_create(RtemsTimerName, &RtemsTimerId);
   if ( RtemsStatus != RTEMS_SUCCESSFUL )
   {
      printf("CFE_PSP: Error: Cannot create RTEMS 1hz interval timer\n");
   }
   
   /*
   ** Allocate memory for the cFE memory. Note that this is malloced on
   ** the COTS board, but will be a static location in the ETU. 
   */
   printf("Sizeof BSP reserved memory = %d bytes\n",sizeof(CFE_PSP_ReservedMemory_t));

   CFE_PSP_ReservedMemoryPtr = malloc(sizeof(CFE_PSP_ReservedMemory_t));

   if ( CFE_PSP_ReservedMemoryPtr == NULL )
   {
      printf("CFE_PSP: Error: Cannot malloc BSP reserved memory!\n");
   }
   else
   {
      printf("CFE_PSP: Allocated %d bytes for PSP reserved memory at: 0x%08X\n",
              sizeof(CFE_PSP_ReservedMemory_t), (int)CFE_PSP_ReservedMemoryPtr);
   }
   /*
   ** Determine Reset type by reading the hardware reset register.
   */
   reset_type = CFE_ES_POWERON_RESET;
   reset_subtype = CFE_ES_POWER_CYCLE;

   /*
   ** Initialize the reserved memory 
   */
   CFE_PSP_InitProcessorReservedMemory(reset_type);

   /*
   ** Call cFE entry point. This will return when cFE startup
   ** is complete.
   */
   CFE_ES_Main(reset_type,reset_subtype, 1, (uint8 *)StartupFilePath); 

   /*
   ** Setup the timer to fire at 1hz 
   */  
   
   /* CLOCK TICK */ 
   RtemsStatus = rtems_timer_fire_after(RtemsTimerId, 100, CFE_PSP_1hzTimer, NULL );
   if ( RtemsStatus != RTEMS_SUCCESSFUL )
   {
      printf("CFE_PSP: Error: Cannot setup interval timer to fire at 1hz\n");
   }
      
   /*
   ** Return to the shell/monitor
   */
   return; 
   
}
Esempio n. 26
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_id          timer1;
  rtems_id          timer2;

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

  /* build timer name*/

  /* create Timer */
  puts( "Init - create timer 1" );
  status = rtems_timer_create( rtems_build_name('T', 'M', '1', ' '), &timer1 );
  directive_failed( status, "rtems_timer_create #1" );

  puts( "Init - create timer 2" );
  status = rtems_timer_create( rtems_build_name('T', 'M', '2', ' '), &timer2 );
  directive_failed( status, "rtems_timer_create #1" );

  /* Manipulate the time */
  _Watchdog_Ticks_since_boot = (Watchdog_Interval) -15;

  /* initiate timer server */
  puts( "Init - Initiate the timer server" );
  status = rtems_timer_initiate_server(
    RTEMS_MINIMUM_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed( status, "rtems_timer_initiate_server" );

  /* Give the timer server some time to initialize */
  status = rtems_task_wake_after( 10 );
  directive_failed( status, "task wake_after" );

  status = rtems_timer_server_fire_after(
    timer1,
    10,
    TIMER_service_routine,
    (void*) &_timer_passage_1
  );
  directive_failed( status, "rtems_timer_server_fire_after" );

  status = rtems_timer_server_fire_after(
    timer2,
    20,
    TIMER_service_routine,
    (void*) &_timer_passage_2
  );
  directive_failed( status, "rtems_timer_server_fire_after" );

  status = rtems_task_wake_after( 15 );
  directive_failed( status, "task wake_after" );

  if (!_timer_passage_1) {
    puts( "Timer 1 FAILED to fire after wrapping time");
    rtems_test_exit(0);
  }
  puts( "Server Timer 1 fired after wrapping ticks since boot-- OK");

  if (_timer_passage_2) {
    puts( "Timer 2 fired and should not have after wrapping time");
    rtems_test_exit(0);
  }

  puts( "*** END OF TEST 67 ***" );
  rtems_test_exit(0);
}
Esempio n. 27
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int                cpu_num;
  rtems_id           id;
  rtems_status_code  status;
  rtems_interval     per_second;
  rtems_interval     then;
  rtems_id           Timer;

  locked_print_initialize();
  rtems_test_begin_with_plugin(locked_printf_plugin, NULL);

  if ( rtems_get_processor_count() == 1 ) {
    success();
  }

  /* Create/verify semaphore */
  status = rtems_semaphore_create(
    rtems_build_name ('S', 'E', 'M', '1'),
    1,                                             
    RTEMS_LOCAL                   |
    RTEMS_SIMPLE_BINARY_SEMAPHORE |
    RTEMS_PRIORITY,
    1,
    &Semaphore
  );
  directive_failed( status, "rtems_semaphore_create" );

  /* Lock semaphore */
  status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
  directive_failed( status,"rtems_semaphore_obtain of SEM1\n");

  /* Create and Start test task. */
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '1', ' ' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  directive_failed( status, "task create" );

  cpu_num = rtems_get_current_processor();
  locked_printf(" CPU %d start task TA1\n", cpu_num );
  status = rtems_task_start( id, Test_task, 1 );
  directive_failed( status, "task start" );

  /* Create and start TSR */
  locked_printf(" CPU %d create and start timer\n", cpu_num );
  status = rtems_timer_create( rtems_build_name( 'T', 'M', 'R', '1' ), &Timer);
  directive_failed( status, "rtems_timer_create" );

  per_second = rtems_clock_get_ticks_per_second();
  status = rtems_timer_fire_after( Timer, 2 * per_second, TimerMethod, NULL );
  directive_failed( status, "rtems_timer_fire_after");

  /*
   *  Wait long enough that TSR should have fired.
   *
   *  Spin so CPU 0 is consumed.  This forces task to run on CPU 1.
   */
  then = rtems_clock_get_ticks_since_boot() + 4 * per_second;
  while (1) {
    if ( rtems_clock_get_ticks_since_boot() > then )
      break;
    if ( TSRFired && TaskRan )
      break;
  };
  
  /* Validate the timer fired and that the task ran */
  if ( !TSRFired )
    locked_printf( "*** ERROR TSR DID NOT FIRE ***" );

  if ( !TaskRan ) {
    locked_printf( "*** ERROR TASK DID NOT RUN ***" );
    rtems_test_exit(0);
  }

  /* End the program */
  success();
}
Esempio n. 28
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code   status;
  rtems_task_priority previous_priority;

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

  Stop_Test = false;

  status = rtems_timer_create(
    rtems_build_name('S', 'T', 'O', 'P'),
    &timer_id
  );
  directive_failed( status, "rtems_timer_create" );

  status = rtems_timer_fire_after(
    timer_id,
    MAX_LONG_TEST_DURATION * rtems_clock_get_ticks_per_second(),
    Stop_Test_TSR,
    NULL
  );
  directive_failed( status, "rtems_timer_fire_after" );

  Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
  Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );

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

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

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

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

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

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

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

  if ( Multiprocessing_configuration.node == 1 ) {
    puts( "Creating Semaphore (Global)" );
    status = rtems_semaphore_create(
      Semaphore_name[ 1 ],
      1,
      RTEMS_GLOBAL,
      RTEMS_NO_PRIORITY,
      &Semaphore_id[ 1 ]
    );
    directive_failed( status, "rtems_semaphore_create" );

    puts( "Creating Message Queue (Global)" );
    status = rtems_message_queue_create(
      Queue_name[ 1 ],
      1,
      16,
      RTEMS_GLOBAL,
      &Queue_id[ 1 ]
    );
    directive_failed( status, "rtems_message_queue_create" );

    puts( "Creating Partition (Global)" );
    status = rtems_partition_create(
      Partition_name[ 1 ],
      (void *)my_partition,
      0x8000,
      0x3800,
      RTEMS_GLOBAL,
      &Partition_id[ 1 ]
    );
    directive_failed( status, "rtems_partition_create" );
  }

  puts( "Creating Event task (Global)" );
  status = rtems_task_create(
    Task_name[ Multiprocessing_configuration.node ],
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_TIMESLICE,
    RTEMS_GLOBAL,
    &Event_task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create" );

  puts( "Starting Event task (Global)" );
  status = rtems_task_start( Event_task_id[ 1 ], Test_task, 0 );
  directive_failed( status, "rtems_task_start" );

  puts( "Creating Semaphore task (Global)" );
  status = rtems_task_create(
    Semaphore_task_name[ Multiprocessing_configuration.node ],
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_TIMESLICE,
    RTEMS_GLOBAL,
    &Semaphore_task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create" );

  puts( "Starting Semaphore task (Global)" );
  status = rtems_task_start( Semaphore_task_id[ 1 ], Semaphore_task, 0 );
  directive_failed( status, "rtems_task_start" );

  puts( "Creating Message Queue task (Global)" );
  status = rtems_task_create(
    Queue_task_name[ Multiprocessing_configuration.node ],
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_TIMESLICE,
    RTEMS_GLOBAL,
    &Queue_task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create" );

  /* argument is index into Buffers */
  puts( "Starting Message Queue task (Global)" );
  status = rtems_task_start( Queue_task_id[ 1 ], Message_queue_task, 1 );
  directive_failed( status, "rtems_task_start" );

  puts( "Creating Partition task (Global)" );
  status = rtems_task_create(
    Partition_task_name[ Multiprocessing_configuration.node ],
    2,
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_TIMESLICE,
    RTEMS_GLOBAL,
    &Partition_task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_create" );

  puts( "Starting Partition task (Global)" );
  status = rtems_task_start( Partition_task_id[ 1 ], Partition_task, 0 );
  directive_failed( status, "rtems_task_start" );

  status = rtems_task_set_priority( RTEMS_SELF, 2, &previous_priority );
  directive_failed( status, "rtems_task_set_priority" );

  status = rtems_task_ident(
    RTEMS_SELF,
    RTEMS_SEARCH_ALL_NODES,
    &Task_id[ 1 ]
  );
  directive_failed( status, "rtems_task_ident" );

  Delayed_events_task( 1 );
}
Esempio n. 29
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day time;
  uint32_t    index;
  rtems_status_code status;

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

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

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

  /* initiate with bad priority */
  puts( "timer_initiate_server -- INVALID_PRIORITY" );
  status = rtems_timer_initiate_server(
    1000,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_PRIORITY,
    "rtems_timer_initiate_server bad priority"
  );

  puts( "timer_initiate_server -- OK" );
  status = rtems_timer_initiate_server(
    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  directive_failed( status, "rtems_timer_initiate_server" );

  puts( "timer_initiate_server -- already started" );
  status = rtems_timer_initiate_server(
    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_ATTRIBUTES
  );
  fatal_directive_status(
    status,
    RTEMS_INCORRECT_STATE,
    "rtems_timer_initiate_server already started"
  );

  /*
   *  Create test tasks
   */

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

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

  for ( index = 1 ; index <= 3 ; index++ ) {
    status = rtems_task_create(
      Task_name[ index ],
      1,
      RTEMS_MINIMUM_STACK_SIZE * 2,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &Task_id[ index ]
    );
    directive_failed( status, "rtems_task_create loop" );

    status = rtems_timer_create(
      Timer_name[ index ],
      &Timer_id[ index ]
    );
    directive_failed( status, "rtems_timer_create loop" );
  }

  for ( index = 1 ; index <= 3 ; index++ ) {
    status = rtems_task_start( Task_id[ index ], Task_1_through_3, index );
    directive_failed( status, "rtems_task_start loop" );
  }

  status = rtems_task_delete( RTEMS_SELF );
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
Esempio n. 30
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day     time;
  rtems_status_code     status;
  rtems_interrupt_level level;
  rtems_mode            level_mode_body;
  rtems_mode            level_mode_macro;
  bool                  in_isr;
  rtems_id              timer;
  int                   i;

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

  test_isr_level();
  test_isr_locks();
  test_interrupt_locks();

  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
  status = rtems_clock_set( &time );
  directive_failed( status, "rtems_clock_set" );

  /*
   *  Timer used in multiple ways
   */
  status = rtems_timer_create( 1, &timer );
  directive_failed( status, "rtems_timer_create" );

  /*
   *  Test clock tick from outside ISR
   */
  status = rtems_clock_tick();
  directive_failed( status, "rtems_clock_tick" );
  puts( "clock_tick from task level" );

  /*
   *  Now do a dispatch directly out of a clock tick that is
   *  called from a task.  We need to create a task that will
   *  block so we have one to unblock.  Then we schedule a TSR
   *  to run in the clock tick but it has to be careful to
   *  make sure it is not called from an ISR and that the
   *  dispatching critical section is managed properly to
   *  make the dispatch happen.
   */

  blocked_task_status = -1;

  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '1', ' ' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &blocked_task_id
  );
  directive_failed( status, "rtems_task_create" );

  status = rtems_task_start( blocked_task_id, blocked_task, 0 );
  directive_failed( status, "rtems_task_start" );

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

  status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL );
  directive_failed( status, "timer_fire_after failed" );

  /* we expect to be preempted from this call */
  for ( i=0 ; i<100 && blocked_task_status != 3 ; i++ ) {
    status = rtems_clock_tick();
    directive_failed( status, "rtems_clock_tick" );
  }
  switch ( blocked_task_status ) {
     case -1:
       puts(
         "clock_tick with task preempt -- task blocked, timer did not fire"
       );
       rtems_test_exit(0);
       break;
     case 1:
       puts( "clock_tick with task preempt -- timer fired case 1" );
       rtems_test_exit(0);
       break;
     case 2:
       puts( "clock_tick with task preempt -- timer fired case 2" );
       rtems_test_exit(0);
       break;
     case 3:
       puts( "clock_tick from task level with preempt -- OK" );
       break;
  }

  /*
   *  Test interrupt inline versions
   */
  test_interrupt_inline();

  /*
   *  Test interrupt bodies
   */
  puts( "interrupt is in progress (use body)" );
  in_isr = rtems_interrupt_is_in_progress();
  if ( in_isr ) {
    puts( "interrupt reported to be is in progress (body)" );
    rtems_test_exit( 0 );
  }

  puts( "interrupt disable (use body)" );
  _Thread_Disable_dispatch();
  level = rtems_interrupt_disable();
  _Thread_Enable_dispatch();

  puts( "interrupt disable (use body)" );
  _Thread_Disable_dispatch();
  level = rtems_interrupt_disable();
  _Thread_Enable_dispatch();

  puts( "interrupt flash (use body)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_flash( level );
  _Thread_Enable_dispatch();

  puts( "interrupt enable (use body)" );
  _Thread_Disable_dispatch();
  rtems_interrupt_enable( level );
  _Thread_Enable_dispatch();

  puts( "interrupt level mode (use body)" );
  level_mode_body = rtems_interrupt_level_body( level );
  level_mode_macro = RTEMS_INTERRUPT_LEVEL(level);
  if ( level_mode_macro == level_mode_body ) {
    puts("test seems to work");
  }

  /*
   * Test ISR in progress from actual ISR
   */
  isr_in_progress_body   = -1;
  isr_in_progress_inline = -1;

  status = rtems_timer_fire_after( timer, 10, test_isr_in_progress, NULL );
  directive_failed( status, "timer_fire_after failed" );

  status = rtems_task_wake_after( 100 );
  directive_failed( status, "wake_after failed" );

  check_isr_worked( "inline", isr_in_progress_body );

  check_isr_worked( "body", isr_in_progress_body );

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