1 | /* Test_task |
---|
2 | * |
---|
3 | * This task tests global event operations. If running on node one, it |
---|
4 | * continuously sends events. If running on node two, it continuously |
---|
5 | * receives events. |
---|
6 | * |
---|
7 | * Input parameters: |
---|
8 | * argument - task argument |
---|
9 | * |
---|
10 | * Output parameters: NONE |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989-2009. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifdef HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include "system.h" |
---|
25 | |
---|
26 | #define DOT_COUNT 25 |
---|
27 | |
---|
28 | /*PAGE |
---|
29 | * |
---|
30 | * Stop_Test_TSR |
---|
31 | */ |
---|
32 | |
---|
33 | rtems_timer_service_routine Stop_Test_TSR( |
---|
34 | rtems_id ignored_id, |
---|
35 | void *ignored_address |
---|
36 | ) |
---|
37 | { |
---|
38 | Stop_Test = true; |
---|
39 | } |
---|
40 | |
---|
41 | /*PAGE |
---|
42 | * |
---|
43 | * Event_set_table |
---|
44 | */ |
---|
45 | |
---|
46 | rtems_event_set Event_set_table[] = { |
---|
47 | RTEMS_EVENT_0, |
---|
48 | RTEMS_EVENT_1, |
---|
49 | RTEMS_EVENT_2, |
---|
50 | RTEMS_EVENT_3, |
---|
51 | RTEMS_EVENT_4, |
---|
52 | RTEMS_EVENT_5, |
---|
53 | RTEMS_EVENT_6, |
---|
54 | RTEMS_EVENT_7, |
---|
55 | RTEMS_EVENT_8, |
---|
56 | RTEMS_EVENT_9, |
---|
57 | RTEMS_EVENT_10, |
---|
58 | RTEMS_EVENT_11, |
---|
59 | RTEMS_EVENT_12, |
---|
60 | RTEMS_EVENT_13, |
---|
61 | RTEMS_EVENT_14, |
---|
62 | RTEMS_EVENT_15, |
---|
63 | RTEMS_EVENT_16, |
---|
64 | RTEMS_EVENT_17, |
---|
65 | RTEMS_EVENT_18, |
---|
66 | RTEMS_EVENT_19, |
---|
67 | RTEMS_EVENT_20, |
---|
68 | RTEMS_EVENT_21, |
---|
69 | RTEMS_EVENT_22, |
---|
70 | RTEMS_EVENT_23, |
---|
71 | RTEMS_EVENT_24, |
---|
72 | RTEMS_EVENT_25, |
---|
73 | RTEMS_EVENT_26, |
---|
74 | RTEMS_EVENT_27, |
---|
75 | RTEMS_EVENT_28, |
---|
76 | RTEMS_EVENT_29, |
---|
77 | RTEMS_EVENT_30, |
---|
78 | RTEMS_EVENT_31 |
---|
79 | }; |
---|
80 | |
---|
81 | /*PAGE |
---|
82 | * |
---|
83 | * Test_task |
---|
84 | */ |
---|
85 | |
---|
86 | rtems_task Test_task( |
---|
87 | rtems_task_argument argument |
---|
88 | ) |
---|
89 | { |
---|
90 | rtems_status_code status; |
---|
91 | uint32_t count; |
---|
92 | uint32_t remote_node; |
---|
93 | rtems_id remote_tid; |
---|
94 | rtems_event_set event_out; |
---|
95 | rtems_event_set event_for_this_iteration; |
---|
96 | |
---|
97 | Stop_Test = false; |
---|
98 | |
---|
99 | remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; |
---|
100 | puts_nocr( "Remote task's name is : " ); |
---|
101 | put_name( Task_name[ remote_node ], TRUE ); |
---|
102 | |
---|
103 | puts( "Getting TID of remote task" ); |
---|
104 | do { |
---|
105 | status = rtems_task_ident( |
---|
106 | Task_name[ remote_node ], |
---|
107 | RTEMS_SEARCH_ALL_NODES, |
---|
108 | &remote_tid |
---|
109 | ); |
---|
110 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
111 | directive_failed( status, "rtems_task_ident FAILED!!" ); |
---|
112 | |
---|
113 | if ( Multiprocessing_configuration.node == 1 ) |
---|
114 | puts( "Sending events to remote task" ); |
---|
115 | else |
---|
116 | puts( "Receiving events from remote task" ); |
---|
117 | |
---|
118 | status = rtems_timer_fire_after( |
---|
119 | Timer_id[ 1 ], |
---|
120 | 5 * rtems_clock_get_ticks_per_second(), |
---|
121 | Stop_Test_TSR, |
---|
122 | NULL |
---|
123 | ); |
---|
124 | directive_failed( status, "rtems_timer_fire_after" ); |
---|
125 | |
---|
126 | count = 0; |
---|
127 | |
---|
128 | for ( ; ; ) { |
---|
129 | if ( Stop_Test == true ) |
---|
130 | break; |
---|
131 | |
---|
132 | event_for_this_iteration = Event_set_table[ count % 32 ]; |
---|
133 | |
---|
134 | if ( Multiprocessing_configuration.node == 1 ) { |
---|
135 | status = rtems_event_send( remote_tid, event_for_this_iteration ); |
---|
136 | directive_failed( status, "rtems_event_send" ); |
---|
137 | |
---|
138 | status = rtems_task_wake_after( 1 ); |
---|
139 | directive_failed( status, "rtems_task_wake_after" ); |
---|
140 | } else { |
---|
141 | status = rtems_event_receive( |
---|
142 | event_for_this_iteration, |
---|
143 | RTEMS_DEFAULT_OPTIONS, |
---|
144 | 1 * rtems_clock_get_ticks_per_second(), |
---|
145 | &event_out |
---|
146 | ); |
---|
147 | if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) { |
---|
148 | if ( Multiprocessing_configuration.node == 2 ) |
---|
149 | puts( "\nCorrect behavior if the other node exitted." ); |
---|
150 | else |
---|
151 | puts( "\nERROR... node 1 died" ); |
---|
152 | break; |
---|
153 | } else |
---|
154 | directive_failed( status, "rtems_event_receive" ); |
---|
155 | } |
---|
156 | |
---|
157 | if ( (count % DOT_COUNT) == 0 ) |
---|
158 | put_dot('.'); |
---|
159 | |
---|
160 | count++; |
---|
161 | } |
---|
162 | |
---|
163 | putchar( '\n' ); |
---|
164 | |
---|
165 | if ( Multiprocessing_configuration.node == 2 ) { |
---|
166 | /* Flush events */ |
---|
167 | puts( "Flushing RTEMS_EVENT_16" ); |
---|
168 | (void) rtems_event_receive(RTEMS_EVENT_16, RTEMS_NO_WAIT, 0, &event_out); |
---|
169 | |
---|
170 | puts( "Waiting for RTEMS_EVENT_16" ); |
---|
171 | status = rtems_event_receive( |
---|
172 | RTEMS_EVENT_16, |
---|
173 | RTEMS_DEFAULT_OPTIONS, |
---|
174 | 1 * rtems_clock_get_ticks_per_second(), |
---|
175 | &event_out |
---|
176 | ); |
---|
177 | fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" ); |
---|
178 | puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" ); |
---|
179 | } |
---|
180 | puts( "*** END OF TEST 6 ***" ); |
---|
181 | rtems_test_exit( 0 ); |
---|
182 | } |
---|