source:
rtems/testsuites/smptests/smp02/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: 2.4 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 | #include <stdio.h> |
20 | |
21 | rtems_task Init( |
22 | rtems_task_argument argument |
23 | ) |
24 | { |
25 | int i; |
26 | char ch; |
27 | int cpu_num; |
28 | rtems_id id; |
29 | rtems_status_code status; |
30 | char str[80]; |
31 | |
32 | locked_print_initialize(); |
33 | locked_printf( "\n\n*** SMP02 TEST ***\n" ); |
34 | |
35 | /* Create/verify synchronisation semaphore */ |
36 | status = rtems_semaphore_create( |
37 | rtems_build_name ('S', 'E', 'M', '1'), |
38 | 1, |
39 | RTEMS_LOCAL | |
40 | RTEMS_SIMPLE_BINARY_SEMAPHORE | |
41 | RTEMS_PRIORITY, |
42 | 1, |
43 | &Semaphore); |
44 | directive_failed( status, "rtems_semaphore_create" ); |
45 | |
46 | /* Lock semaphore */ |
47 | status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0); |
48 | directive_failed( status,"rtems_semaphore_obtain of SEM1\n"); |
49 | |
50 | for ( i=1; i < CONFIGURE_SMP_MAXIMUM_PROCESSORS; i++ ){ |
51 | |
52 | /* Create and start tasks for each CPU */ |
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 | |
64 | cpu_num = bsp_smp_processor_id(); |
65 | locked_printf(" CPU %d start task TA%c\n", cpu_num, ch); |
66 | status = rtems_task_start( id, Test_task, i+1 ); |
67 | locked_printf(str, "rtems_task_start TA%d", i+1); |
68 | directive_failed( status, str ); |
69 | } |
70 | |
71 | /* |
72 | * Release the semaphore, allowing the blocked tasks to start. |
73 | */ |
74 | status = rtems_semaphore_release( Semaphore ); |
75 | directive_failed( status,"rtems_semaphore_release of SEM1\n"); |
76 | |
77 | |
78 | /* |
79 | * Wait for log full. print the log and end the program. |
80 | */ |
81 | while (Log_index < LOG_SIZE) |
82 | ; |
83 | |
84 | for (i=0; i< LOG_SIZE; i++) { |
85 | if ( Log[i].IsLocked ) { |
86 | locked_printf( |
87 | " CPU %d Task TA%" PRIu32 " Obtain\n", |
88 | Log[i].cpu_num, |
89 | Log[i].task_index |
90 | ); |
91 | } else { |
92 | locked_printf( |
93 | " CPU %d Task TA%" PRIu32 " Release\n", |
94 | Log[i].cpu_num, |
95 | Log[i].task_index |
96 | ); |
97 | } |
98 | } |
99 | |
100 | locked_printf( "*** END OF TEST SMP02 ***\n" ); |
101 | rtems_test_exit( 0 ); |
102 | } |
Note: See TracBrowser
for help on using the repository browser.