1 | /* Test_task |
---|
2 | * |
---|
3 | * This task continuously sends an event to its counterpart on the |
---|
4 | * other node, and then waits for it to send an event. The copy |
---|
5 | * running on node one send the first event. |
---|
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.com/license/LICENSE. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifdef HAVE_CONFIG_H |
---|
23 | #include "config.h" |
---|
24 | #endif |
---|
25 | |
---|
26 | #include "system.h" |
---|
27 | |
---|
28 | #define DOT_COUNT 100 |
---|
29 | |
---|
30 | rtems_timer_service_routine Stop_Test_TSR( |
---|
31 | rtems_id ignored_id, |
---|
32 | void *ignored_address |
---|
33 | ) |
---|
34 | { |
---|
35 | Stop_Test = true; |
---|
36 | } |
---|
37 | |
---|
38 | rtems_task Test_task( |
---|
39 | rtems_task_argument argument |
---|
40 | ) |
---|
41 | { |
---|
42 | rtems_status_code status; |
---|
43 | uint32_t count; |
---|
44 | uint32_t remote_node; |
---|
45 | rtems_id remote_tid; |
---|
46 | rtems_event_set event_out; |
---|
47 | |
---|
48 | Stop_Test = false; |
---|
49 | |
---|
50 | remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; |
---|
51 | puts_nocr( "Remote task's name is : " ); |
---|
52 | put_name( Task_name[ remote_node ], TRUE ); |
---|
53 | |
---|
54 | puts( "Getting TID of remote task" ); |
---|
55 | do { |
---|
56 | status = rtems_task_ident( |
---|
57 | Task_name[ remote_node ], |
---|
58 | RTEMS_SEARCH_ALL_NODES, |
---|
59 | &remote_tid |
---|
60 | ); |
---|
61 | } while ( !rtems_is_status_successful( status ) ); |
---|
62 | |
---|
63 | if ( Multiprocessing_configuration.node == 1 ) { |
---|
64 | puts( "Sending first event to remote task" ); |
---|
65 | status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); |
---|
66 | directive_failed( status, "rtems_event_send" ); |
---|
67 | } |
---|
68 | |
---|
69 | status = rtems_timer_fire_after( |
---|
70 | Timer_id[ 1 ], |
---|
71 | 5 * rtems_clock_get_ticks_per_second(), |
---|
72 | Stop_Test_TSR, |
---|
73 | NULL |
---|
74 | ); |
---|
75 | directive_failed( status, "rtems_timer_fire_after" ); |
---|
76 | |
---|
77 | while ( true ) { |
---|
78 | for ( count=DOT_COUNT ; count && (Stop_Test == false) ; count-- ) { |
---|
79 | status = rtems_event_receive( |
---|
80 | RTEMS_EVENT_16, |
---|
81 | RTEMS_DEFAULT_OPTIONS, |
---|
82 | rtems_clock_get_ticks_per_second(), |
---|
83 | &event_out |
---|
84 | ); |
---|
85 | if ( status == RTEMS_TIMEOUT ) { |
---|
86 | printf("\nTA1 - RTEMS_TIMEOUT .. probably OK if the other node exits"); |
---|
87 | Stop_Test = true; |
---|
88 | break; |
---|
89 | } else |
---|
90 | directive_failed( status, "rtems_event_receive" ); |
---|
91 | |
---|
92 | status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); |
---|
93 | directive_failed( status, "rtems_event_send" ); |
---|
94 | } |
---|
95 | if ( Stop_Test ) |
---|
96 | break; |
---|
97 | put_dot('.'); |
---|
98 | } |
---|
99 | |
---|
100 | /* |
---|
101 | * Wait a bit before shutting down so we don't screw up the other node |
---|
102 | * when our MPCI shuts down |
---|
103 | */ |
---|
104 | |
---|
105 | rtems_task_wake_after(10); |
---|
106 | |
---|
107 | puts( "\n*** END OF TEST 7 ***" ); |
---|
108 | rtems_test_exit( 0 ); |
---|
109 | } |
---|