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.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #define CONFIGURE_INIT |
---|
17 | #include "system.h" |
---|
18 | |
---|
19 | #include <stdio.h> |
---|
20 | |
---|
21 | void Loop() { |
---|
22 | volatile int i; |
---|
23 | |
---|
24 | for (i=0; i<300000; i++); |
---|
25 | } |
---|
26 | |
---|
27 | void PrintTaskInfo( |
---|
28 | const char *task_name |
---|
29 | ) |
---|
30 | { |
---|
31 | int cpu_num; |
---|
32 | |
---|
33 | cpu_num = bsp_smp_processor_id(); |
---|
34 | |
---|
35 | locked_printf(" CPU %d running task %s\n", cpu_num, task_name ); |
---|
36 | } |
---|
37 | |
---|
38 | rtems_task Init( |
---|
39 | rtems_task_argument argument |
---|
40 | ) |
---|
41 | { |
---|
42 | int i; |
---|
43 | char ch = '0'; |
---|
44 | rtems_id id; |
---|
45 | rtems_status_code status; |
---|
46 | |
---|
47 | Loop(); |
---|
48 | locked_print_initialize(); |
---|
49 | |
---|
50 | locked_printf( "\n\n*** SMP03 TEST ***\n" ); |
---|
51 | |
---|
52 | |
---|
53 | /* Show that the init task is running on this cpu */ |
---|
54 | PrintTaskInfo( "Init" ); |
---|
55 | |
---|
56 | /* for each remaining cpu create and start a task */ |
---|
57 | for ( i=1; i < rtems_smp_get_number_of_processors(); i++ ){ |
---|
58 | |
---|
59 | ch = '0' + i; |
---|
60 | |
---|
61 | status = rtems_task_create( |
---|
62 | rtems_build_name( 'T', 'A', ch, ' ' ), |
---|
63 | CONFIGURE_INIT_TASK_PRIORITY + (2*i), |
---|
64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
65 | RTEMS_PREEMPT, |
---|
66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
67 | &id |
---|
68 | ); |
---|
69 | status = rtems_task_start( id, Test_task, i ); |
---|
70 | |
---|
71 | Loop(); |
---|
72 | } |
---|
73 | |
---|
74 | /* Create/Start an aditional task with the highest priority */ |
---|
75 | status = rtems_task_create( |
---|
76 | rtems_build_name( 'T', 'A', ch, ' ' ), |
---|
77 | 3, |
---|
78 | RTEMS_MINIMUM_STACK_SIZE, |
---|
79 | RTEMS_PREEMPT, |
---|
80 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
81 | &id |
---|
82 | ); |
---|
83 | TestFinished = false; |
---|
84 | status = rtems_task_start(id,Test_task,rtems_smp_get_number_of_processors()); |
---|
85 | |
---|
86 | /* Wait on the last task to run */ |
---|
87 | while(!TestFinished) |
---|
88 | ; |
---|
89 | |
---|
90 | /* End the test */ |
---|
91 | Loop(); |
---|
92 | locked_printf( "*** END OF TEST SMP03 ***\n" ); |
---|
93 | Loop(); |
---|
94 | rtems_test_exit( 0 ); |
---|
95 | } |
---|