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() ); } }
rtems_task Test_task( rtems_task_argument unused ) { rtems_id tid; rtems_time_of_day time; uint32_t task_index; rtems_status_code status; 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 ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); task_index = task_number( tid ); for ( ; ; ) { status = rtems_clock_get_tod( &time ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); if ( time.second >= 35 ) { TEST_END(); rtems_test_exit( 0 ); } PrintTaskInfo( p, &time ); status = rtems_task_wake_after( task_index * 5 * rtems_clock_get_ticks_per_second() ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); } }
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 ); }
rtems_task Test_task( rtems_task_argument task_index ) { char task_name[5]; /* Show that this task is running on cpu X */ sprintf( task_name, "TA%" PRIu32, task_index ); PrintTaskInfo( task_name ); TaskRan[task_index] = true; /* Wait for the test to end without giving up this processor */ while(1) ; }
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 ); }