1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | #include <inttypes.h> |
---|
18 | |
---|
19 | const char rtems_test_name[] = "SMP 1"; |
---|
20 | |
---|
21 | void Loop() { |
---|
22 | volatile int i; |
---|
23 | |
---|
24 | for (i=0; i<300000; i++); |
---|
25 | } |
---|
26 | |
---|
27 | rtems_task Init( |
---|
28 | rtems_task_argument argument |
---|
29 | ) |
---|
30 | { |
---|
31 | uint32_t i; |
---|
32 | char ch; |
---|
33 | uint32_t cpu_self; |
---|
34 | rtems_id id; |
---|
35 | rtems_status_code status; |
---|
36 | bool allDone; |
---|
37 | |
---|
38 | cpu_self = rtems_get_current_processor(); |
---|
39 | |
---|
40 | /* XXX - Delay a bit to allow debug messages from |
---|
41 | * startup to print. This may need to go away when |
---|
42 | * debug messages go away. |
---|
43 | */ |
---|
44 | Loop(); |
---|
45 | |
---|
46 | TEST_BEGIN(); |
---|
47 | |
---|
48 | locked_print_initialize(); |
---|
49 | |
---|
50 | /* Initialize the TaskRan array */ |
---|
51 | for ( i=0; i<rtems_get_processor_count() ; i++ ) { |
---|
52 | TaskRan[i] = false; |
---|
53 | } |
---|
54 | |
---|
55 | /* Create and start tasks for each processor */ |
---|
56 | for ( i=0; i< rtems_get_processor_count() ; i++ ) { |
---|
57 | if ( i != cpu_self ) { |
---|
58 | ch = '0' + i; |
---|
59 | |
---|
60 | status = rtems_task_create( |
---|
61 | rtems_build_name( 'T', 'A', ch, ' ' ), |
---|
62 | 1, |
---|
63 | RTEMS_MINIMUM_STACK_SIZE, |
---|
64 | RTEMS_DEFAULT_MODES, |
---|
65 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
66 | &id |
---|
67 | ); |
---|
68 | directive_failed( status, "task create" ); |
---|
69 | |
---|
70 | locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_self, ch); |
---|
71 | status = rtems_task_start( id, Test_task, i+1 ); |
---|
72 | directive_failed( status, "task start" ); |
---|
73 | |
---|
74 | Loop(); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | /* Wait on the all tasks to run */ |
---|
79 | while (1) { |
---|
80 | allDone = true; |
---|
81 | for ( i=0; i<rtems_get_processor_count() ; i++ ) { |
---|
82 | if ( i != cpu_self && TaskRan[i] == false) |
---|
83 | allDone = false; |
---|
84 | } |
---|
85 | if (allDone) { |
---|
86 | TEST_END(); |
---|
87 | rtems_test_exit( 0 ); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | } |
---|