示例#1
0
文件: init.c 项目: chch1028/rtems
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 );
}
示例#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 );
        }
    }
}
示例#3
0
文件: init.c 项目: Avanznow/rtems
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);
}
示例#4
0
文件: init.c 项目: 0871087123/rtems
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);
}
示例#5
0
void locked_printk(const char *fmt, ...) {
  va_list           ap;       /* points to each unnamed argument in turn */
  rtems_status_code sc;


  locked_print_initialize();

  /* Lock semaphore without releasing the cpu */
  do {
    sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
  } while (sc != RTEMS_SUCCESSFUL );

  va_start(ap, fmt); /* make ap point to 1st unnamed arg */
  vprintk(fmt, ap);
  va_end(ap);        /* clean up when done */

  /* Release the semaphore  */
  sc = rtems_semaphore_release( locked_print_semaphore );
} 
示例#6
0
文件: init.c 项目: greenmeent/rtems
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)
    ;
}
示例#7
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)
    ;
}
示例#8
0
文件: init.c 项目: Avanznow/rtems
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();
}
示例#9
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 )
    ;
}
示例#10
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 );
}
示例#11
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 );    
}