Beispiel #1
0
rtems_task Test_task(
  rtems_task_argument argument
)
{
  locked_printf( "Shut down from CPU %d\n", bsp_smp_processor_id() );
  locked_printf( "*** END OF TEST SMP05 ***\n" );
  rtems_test_exit(0);
}
Beispiel #2
0
rtems_task Init(
    rtems_task_argument argument
)
{
    int                i;
    char               ch;
    rtems_id           id;
    rtems_status_code  status;
    bool               allDone;

    /* XXX - Delay a bit to allow debug messages from
     * startup to print.  This may need to go away when
     * debug messages go away.
     */
    locked_print_initialize();

    /* Put start of test message */
    locked_printf( "\n\n***  SMPatomic03 TEST ***\n" );

    /* Initialize the TaskRan array */
    for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
        TaskRan[i] = false;
    }

    /* Create and start tasks for each processor */
    for ( i=1; i< rtems_smp_get_processor_count() ; i++ ) {
        ch = '0' + i;

        status = rtems_task_create(
                     rtems_build_name( 'T', 'A', ch, ' ' ),
                     1,
                     RTEMS_MINIMUM_STACK_SIZE,
                     RTEMS_DEFAULT_MODES,
                     RTEMS_DEFAULT_ATTRIBUTES,
                     &id
                 );
        directive_failed( status, "task create" );

        status = rtems_task_start( id, Test_task, i+1 );
        directive_failed( status, "task start" );
    }

    /* Wait on the all tasks to run */
    while (1) {
        allDone = true;
        for ( i=1; i<rtems_smp_get_processor_count() ; i++ ) {
            if (TaskRan[i] == false)
                allDone = false;
        }
        if (allDone) {
            locked_printf( "\n\n*** END OF TEST SMPatomic03 ***\n" );
            rtems_test_exit( 0 );
        }
    }
}
Beispiel #3
0
rtems_task Test_task(
  rtems_task_argument task_index
)
{
  uint32_t          cpu_num;
  char              name[5];
  char             *p;

  /* Get the task name */
  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

   /* Get the CPU Number */
  cpu_num = rtems_smp_get_current_processor();

  /* Print that the task is up and running. */
  Loop();
  locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);

  /* Set the flag that the task is up and running */
  TaskRan[cpu_num] = true;


  /* Drop into a loop which will keep this task on
   * running on the cpu.
   */
  while(1);
}
Beispiel #4
0
rtems_task Test_task(
  rtems_task_argument argument
)
{
  locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_get_current_processor() );
  success();
}
Beispiel #5
0
rtems_task Test_task(
  rtems_task_argument unused
)
{
  rtems_id          tid;
  rtems_time_of_day time;
  uint32_t    task_index;
  rtems_status_code status;
  int               cpu_num;
  char              name[5];
  char             *p;

  /* Get the task name */
  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
  task_index = task_number( tid );
  for ( ; ; ) {

    /* Get the CPU Number */
    cpu_num = bsp_smp_processor_id();

    status = rtems_clock_get_tod( &time );
    if ( time.second >= 35 ) {
      locked_printf( "*** END OF SMP08 TEST ***" );
      rtems_test_exit( 0 );
    }

    PrintTaskInfo( p, &time );
    status = rtems_task_wake_after(
      task_index * 5 * rtems_clock_get_ticks_per_second() );
  }
}
Beispiel #6
0
rtems_task Init(
  rtems_task_argument argument
)
{
  uint32_t           i;
  char               ch;
  uint32_t           cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  TEST_BEGIN();

  locked_print_initialize();

  for ( killtime=0; killtime<1000000; killtime++ )
    ;
  
  for ( i=0; i<rtems_get_processor_count() -1; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      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 %" PRIu32 " start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  locked_printf(" kill 10 clock ticks\n" );
  while ( rtems_clock_get_ticks_since_boot() < 10 )
    ;

  rtems_cpu_usage_report();

  TEST_END();
  rtems_test_exit(0);
}
Beispiel #7
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_time_of_day time;
  int               i;
  char              ch[4];
  rtems_id          id;
 
  locked_print_initialize();
  locked_printf( "\n\n*** SMP08 TEST ***\n" );

  time.year   = 1988;
  time.month  = 12;
  time.day    = 31;
  time.hour   = 9;
  time.minute = 0;
  time.second = 0;
  time.ticks  = 0;

  status = rtems_clock_set( &time );

  /* Create/verify synchronisation 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" );

  /* Show that the init task is running on this cpu */
  PrintTaskInfo( "Init", &time );

  for ( i=1; i <= rtems_smp_get_processor_count() *3; i++ ) {

    sprintf(ch, "%02" PRId32, i );
    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch[0], ch[1] ),
      2,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    directive_failed( status, "task create" );

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  /* FIXME: Task deletion currently not supported */
  (void) rtems_task_suspend( RTEMS_SELF );
}
Beispiel #8
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int                i;
  char               ch;
  int                cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  locked_print_initialize();
  locked_printf( "\n\n*** TEST SMP09 ***\n" );

  for ( killtime=0; killtime<1000000; killtime++ )
    ;
  
  for ( i=0; i<rtems_smp_get_number_of_processors() -1; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    directive_failed( status, "task create" );

    cpu_num = bsp_smp_processor_id();
    locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  locked_printf(" kill 10 clock ticks\n" );
  while ( rtems_clock_get_ticks_since_boot() < 10 )
    ;

  rtems_cpu_usage_report();

  locked_printf( "*** END OF TEST SMP09 ***" );
  rtems_test_exit(0);
}
Beispiel #9
0
void PrintTaskInfo(
  const char *task_name
)
{
  int               cpu_num;

  cpu_num = bsp_smp_processor_id();

  locked_printf("  CPU %d running task %s\n", cpu_num, task_name );
}
Beispiel #10
0
rtems_task Test_task(
  rtems_task_argument do_exit
)
{
  int               cpu_num;
  char              name[5];
  char             *p;

  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

  cpu_num = bsp_smp_processor_id();
  locked_printf(" CPU %d running Task %s\n", cpu_num, name);

  Ran = true;

  if ( do_exit ) {
    locked_printf( "*** END OF TEST SMP06 ***\n" );
    rtems_test_exit(0);
  }
  while(1)
    ;
}
Beispiel #11
0
rtems_task Test_task(
  rtems_task_argument argument
)
{
  uint32_t          cpu_num;
  rtems_status_code sc;
  char              name[5];
  char             *p;

  /* Get the task name */
  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

   /* Get the CPU Number */
  cpu_num = rtems_get_current_processor();

  /* Print that the task is up and running. */
  locked_printf(" CPU %" PRIu32 " runnng Task %s and blocking\n", cpu_num, name);

  sc = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
  directive_failed( sc,"obtain in test task");

  if ( !TSRFired )
    locked_printf( "*** ERROR TSR DID NOT FIRE BUT TEST TASK AWAKE***" );

  TaskRan = true;

  /* Print that the task is up and running. */
  locked_printf(
    " CPU %" PRIu32 " running Task %s after semaphore release\n", 
    cpu_num, 
    name
  );

  /* FIXME: Task deletion currently not supported */
  (void) rtems_task_suspend( RTEMS_SELF );
}
Beispiel #12
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int                i;
  char               ch;
  int                cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  locked_print_initialize();
  locked_printf( "\n\n*** TEST SMP05 ***\n" );

  for ( i=0; i<rtems_smp_get_number_of_processors() ; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    directive_failed( status, "task create" );

    cpu_num = bsp_smp_processor_id();
    locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  while (1)
    ;
}
Beispiel #13
0
void PrintTaskInfo(
  const char         *task_name,
  rtems_time_of_day  *_tb 
)
{
  uint32_t cpu_num;

  cpu_num = rtems_smp_get_current_processor();

  /* Print the cpu number and task name */
  locked_printf(
    "  CPU %" PRIu32 " running task %s - rtems_clock_get_tod "
    "%02" PRId32 ":%02" PRId32 ":%02" PRId32 "   %02" PRId32 
        "/%02" PRId32 "/%04" PRId32 "\n",
    cpu_num,
    task_name,
    _tb->hour, _tb->minute, _tb->second, 
    _tb->month, _tb->day, _tb->year
  ); 
}
Beispiel #14
0
rtems_task Init(
  rtems_task_argument argument
)
{
  uint32_t           i;
  char               ch;
  uint32_t           cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  locked_print_initialize();
  rtems_test_begin();

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

  for ( i=0; i<rtems_get_processor_count() ; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      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 %" PRIu32 " start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  while (1)
    ;
}
Beispiel #15
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();
}
Beispiel #16
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int                cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  locked_print_initialize();
  locked_printf( "\n\n*** TEST SMP06 ***\n" );
  locked_printf( "rtems_clock_tick - so this task has run longer\n" );
  status = rtems_clock_tick();
  directive_failed( status, "clock tick" );

  rtems_test_assert( rtems_smp_get_number_of_processors()  > 1 );

  cpu_num = bsp_smp_processor_id();

  /*
   * Create a task at equal priority.
   */
  Ran = false;
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '1', ' ' ),
    2,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  directive_failed( status, "task create" );

  locked_printf(" CPU %d start task TA1\n", cpu_num );

  status = rtems_task_start( id, Test_task, 0 );
  directive_failed( status, "task start" );

  while ( Ran == false )
    ;

  /*
   * Create a task at greater priority.
   */
  Ran = false;
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', '2', ' ' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  directive_failed( status, "task create" );

  cpu_num = bsp_smp_processor_id();
  locked_printf(" CPU %d start task TA2\n", cpu_num );

  status = rtems_task_start( id, Test_task, 1 );
  directive_failed( status, "task start" );

  while ( 1 )
    ;
}
Beispiel #17
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int               i;
  char              ch;
  int               cpu_num;
  rtems_id          id;
  rtems_status_code status;
  char              str[80];

  locked_print_initialize();
  locked_printf( "\n\n***  SMP02 TEST ***\n" );

  /* Create/verify synchronisation 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");

  for ( i=1; i < rtems_smp_get_number_of_processors(); i++ ){

    /* Create and start tasks for each CPU */
    ch = '0' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );

    cpu_num = bsp_smp_processor_id();
    locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);
    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, str );
  }

  /*
   * Release the semaphore, allowing the blocked tasks to start.
   */
  status = rtems_semaphore_release( Semaphore );
  directive_failed( status,"rtems_semaphore_release of SEM1\n");
  

  /* 
   * Wait for log full. print the log and end the program.
   */  
  while (Log_index < LOG_SIZE)
    ;
 
  for (i=0; i< LOG_SIZE; i++) {
    if ( Log[i].IsLocked ) {
      locked_printf(
        " CPU %d Task TA%" PRIu32 " Obtain\n", 
        Log[i].cpu_num,
        Log[i].task_index
      );
    } else {
      locked_printf(
        " CPU %d Task TA%" PRIu32 " Release\n", 
        Log[i].cpu_num,
        Log[i].task_index
      );
    }
  }

  locked_printf( "*** END OF TEST SMP02 ***\n" );
  rtems_test_exit( 0 );
}
Beispiel #18
0
rtems_task Init(
  rtems_task_argument argument
)
{
  int               i;
  char              ch = '0';
  rtems_id          id;
  rtems_status_code status;

  Loop();
  locked_print_initialize();

  locked_printf( "\n\n***  SMP03 TEST ***\n" );

  /* Initialize the TaskRan array */
  TaskRan[0] = true;
  for ( i=1; i<rtems_smp_get_number_of_processors() ; i++ ) {
    TaskRan[i] = false;
  }

  /* Show that the init task is running on this cpu */
  PrintTaskInfo( "Init" );

  /* for each remaining cpu create and start a task */
  for ( i=1; i < rtems_smp_get_number_of_processors(); i++ ){

    ch = '0' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      CONFIGURE_INIT_TASK_PRIORITY + (2*i),
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_PREEMPT,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    status = rtems_task_start( id, Test_task, i );
    
    /* Allow task to start before starting next task.
     * This is necessary on some simulators.
     */ 
    while (TaskRan[i] == false)
      ;
  }

  /* Create/Start an aditional task with the highest priority */
  status = rtems_task_create(
    rtems_build_name( 'T', 'A', ch, ' ' ),
    3,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  status = rtems_task_start(id,Test_task,rtems_smp_get_number_of_processors());

  /* Wait on all tasks to run */
  while (1) {
    TestFinished = true;
    for ( i=1; i < (rtems_smp_get_number_of_processors()+1) ; i++ ) {
      if (TaskRan[i] == false)
        TestFinished = false;
    }
    if (TestFinished) {
      locked_printf( "*** END OF TEST SMP03 ***\n" );
      rtems_test_exit( 0 );
    }
  }

  rtems_test_exit( 0 );    
}