[7e02305] | 1 | /* |
---|
| 2 | * Copyright (c) 2012 Deng Hengyi. |
---|
| 3 | * |
---|
| 4 | * This test case is to test atomic load operation. |
---|
| 5 | * |
---|
| 6 | * The license and distribution terms for this file may be |
---|
| 7 | * found in the file LICENSE in this distribution or at |
---|
| 8 | * http://www.rtems.com/license/LICENSE. |
---|
| 9 | * |
---|
| 10 | */ |
---|
| 11 | #ifdef HAVE_CONFIG_H |
---|
| 12 | #include "config.h" |
---|
| 13 | #endif |
---|
| 14 | |
---|
| 15 | #define CONFIGURE_INIT |
---|
| 16 | #include "system.h" |
---|
| 17 | |
---|
| 18 | rtems_task Init( |
---|
| 19 | rtems_task_argument argument |
---|
| 20 | ) |
---|
| 21 | { |
---|
| 22 | int i; |
---|
| 23 | char ch; |
---|
| 24 | rtems_id id; |
---|
| 25 | rtems_status_code status; |
---|
| 26 | bool allDone; |
---|
| 27 | |
---|
| 28 | /* XXX - Delay a bit to allow debug messages from |
---|
| 29 | * startup to print. This may need to go away when |
---|
| 30 | * debug messages go away. |
---|
| 31 | */ |
---|
| 32 | locked_print_initialize(); |
---|
| 33 | |
---|
| 34 | /* Put start of test message */ |
---|
| 35 | locked_printf( "\n\n*** SMPatomic01 TEST ***\n" ); |
---|
| 36 | |
---|
| 37 | /* Initialize the TaskRan array */ |
---|
| 38 | for ( i=0; i<rtems_smp_get_number_of_processors() ; i++ ) { |
---|
| 39 | TaskRan[i] = false; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | /* Create and start tasks for each processor */ |
---|
| 43 | for ( i=1; i< rtems_smp_get_number_of_processors() ; i++ ) { |
---|
| 44 | ch = '0' + i; |
---|
| 45 | |
---|
| 46 | status = rtems_task_create( |
---|
| 47 | rtems_build_name( 'T', 'A', ch, ' ' ), |
---|
| 48 | 1, |
---|
| 49 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 50 | RTEMS_DEFAULT_MODES, |
---|
| 51 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 52 | &id |
---|
| 53 | ); |
---|
| 54 | directive_failed( status, "task create" ); |
---|
| 55 | |
---|
| 56 | status = rtems_task_start( id, Test_task, i+1 ); |
---|
| 57 | directive_failed( status, "task start" ); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* Wait on the all tasks to run */ |
---|
| 61 | while (1) { |
---|
| 62 | allDone = true; |
---|
| 63 | for ( i=1; i<rtems_smp_get_number_of_processors() ; i++ ) { |
---|
| 64 | if (TaskRan[i] == false) |
---|
| 65 | allDone = false; |
---|
| 66 | } |
---|
| 67 | if (allDone) { |
---|
| 68 | locked_printf( "\n\n*** END OF TEST SMPatomic01 ***\n" ); |
---|
| 69 | rtems_test_exit( 0 ); |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | } |
---|