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