source:
rtems/testsuites/smptests/smp01/init.c
@
e049eea
Last change on this file since e049eea was e049eea, checked in by Joel Sherrill <joel.sherrill@…>, on 06/28/11 at 21:08:48 | |
---|---|
|
|
File size: 1.9 KB |
Line | |
---|---|
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 | void Loop() { |
20 | volatile int i; |
21 | |
22 | for (i=0; i<300000; i++); |
23 | } |
24 | |
25 | rtems_task Init( |
26 | rtems_task_argument argument |
27 | ) |
28 | { |
29 | int i; |
30 | char ch; |
31 | int cpu_num; |
32 | rtems_id id; |
33 | rtems_status_code status; |
34 | bool allDone; |
35 | |
36 | /* XXX - Delay a bit to allow debug messages from |
37 | * startup to print. This may need to go away when |
38 | * debug messages go away. |
39 | */ |
40 | Loop(); |
41 | locked_print_initialize(); |
42 | |
43 | /* Put start of test message */ |
44 | locked_printf( "\n\n*** SMP01 TEST ***\n" ); |
45 | |
46 | /* Initialize the TaskRan array */ |
47 | for ( i=0; i<rtems_smp_get_number_of_processors() ; i++ ) { |
48 | TaskRan[i] = false; |
49 | } |
50 | |
51 | /* Create and start tasks for each processor */ |
52 | for ( i=1; i< rtems_smp_get_number_of_processors() ; i++ ) { |
53 | ch = '0' + i; |
54 | |
55 | status = rtems_task_create( |
56 | rtems_build_name( 'T', 'A', ch, ' ' ), |
57 | 1, |
58 | RTEMS_MINIMUM_STACK_SIZE, |
59 | RTEMS_DEFAULT_MODES, |
60 | RTEMS_DEFAULT_ATTRIBUTES, |
61 | &id |
62 | ); |
63 | directive_failed( status, "task create" ); |
64 | |
65 | cpu_num = bsp_smp_processor_id(); |
66 | (" CPU %d start task TA%c\n", cpu_num, ch); |
67 | status = rtems_task_start( id, Test_task, i+1 ); |
68 | directive_failed( status, "task start" ); |
69 | |
70 | Loop(); |
71 | } |
72 | |
73 | /* Wait on the all tasks to run */ |
74 | while (1) { |
75 | allDone = true; |
76 | for ( i=1; i<rtems_smp_get_number_of_processors() ; i++ ) { |
77 | if (TaskRan[i] == false) |
78 | allDone = false; |
79 | } |
80 | if (allDone) { |
81 | Loop(); |
82 | locked_printf( "*** END OF TEST SMP01 ***" ); |
83 | rtems_test_exit( 0 ); |
84 | } |
85 | } |
86 | |
87 | } |
Note: See TracBrowser
for help on using the repository browser.