source: rtems/testsuites/mptests/mp06/task1.c @ a319ebef

4.104.114.9
Last change on this file since a319ebef was a319ebef, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 2:41:37 PM

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • mp03/delay.c, mp06/task1.c, mp06/node2/mp06-node2.scn, mp07/task1.c: Updating and fixing while running them on psim.
  • Property mode set to 100644
File size: 3.9 KB
Line 
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-1999.
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#include "system.h"
23
24#define DOT_COUNT 25
25
26/*PAGE
27 *
28 *  Stop_Test_TSR
29 */
30
31rtems_timer_service_routine Stop_Test_TSR(
32  rtems_id  ignored_id,
33  void     *ignored_address
34)
35{
36  Stop_Test = true;
37}
38
39/*PAGE
40 *
41 *  Event_set_table
42 */
43
44rtems_event_set Event_set_table[] = {
45  RTEMS_EVENT_0,
46  RTEMS_EVENT_1,
47  RTEMS_EVENT_2,
48  RTEMS_EVENT_3,
49  RTEMS_EVENT_4,
50  RTEMS_EVENT_5,
51  RTEMS_EVENT_6,
52  RTEMS_EVENT_7,
53  RTEMS_EVENT_8,
54  RTEMS_EVENT_9,
55  RTEMS_EVENT_10,
56  RTEMS_EVENT_11,
57  RTEMS_EVENT_12,
58  RTEMS_EVENT_13,
59  RTEMS_EVENT_14,
60  RTEMS_EVENT_15,
61  RTEMS_EVENT_16,
62  RTEMS_EVENT_17,
63  RTEMS_EVENT_18,
64  RTEMS_EVENT_19,
65  RTEMS_EVENT_20,
66  RTEMS_EVENT_21,
67  RTEMS_EVENT_22,
68  RTEMS_EVENT_23,
69  RTEMS_EVENT_24,
70  RTEMS_EVENT_25,
71  RTEMS_EVENT_26,
72  RTEMS_EVENT_27,
73  RTEMS_EVENT_28,
74  RTEMS_EVENT_29,
75  RTEMS_EVENT_30,
76  RTEMS_EVENT_31
77};
78
79/*PAGE
80 *
81 *  Test_task
82 */
83
84rtems_task Test_task(
85  rtems_task_argument argument
86)
87{
88  rtems_status_code status;
89  uint32_t    count;
90  uint32_t    remote_node;
91  rtems_id          remote_tid;
92  rtems_event_set   event_out;
93  rtems_event_set   event_for_this_iteration;
94
95  Stop_Test = false;
96
97  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
98  puts_nocr( "Remote task's name is : " );
99  put_name( Task_name[ remote_node ], TRUE );
100
101  puts( "Getting TID of remote task" );
102  do {
103      status = rtems_task_ident(
104          Task_name[ remote_node ],
105          RTEMS_SEARCH_ALL_NODES,
106          &remote_tid
107          );
108  } while ( status != RTEMS_SUCCESSFUL );
109  directive_failed( status, "rtems_task_ident FAILED!!" );
110
111  if ( Multiprocessing_configuration.node == 1 )
112    puts( "Sending events to remote task" );
113  else
114    puts( "Receiving events from remote task" );
115
116  status = rtems_timer_fire_after(
117    Timer_id[ 1 ],
118    5 * TICKS_PER_SECOND,
119    Stop_Test_TSR,
120    NULL
121  );
122  directive_failed( status, "rtems_timer_fire_after" );
123
124  count = 0;
125
126  for ( ; ; ) {
127    if ( Stop_Test == true )
128      break;
129
130    event_for_this_iteration = Event_set_table[ count % 32 ];
131
132    if ( Multiprocessing_configuration.node == 1 ) {
133      status = rtems_event_send( remote_tid, event_for_this_iteration );
134      directive_failed( status, "rtems_event_send" );
135
136      status = rtems_task_wake_after( 1 );
137      directive_failed( status, "rtems_task_wake_after" );
138    } else {
139      status = rtems_event_receive(
140        event_for_this_iteration,
141        RTEMS_DEFAULT_OPTIONS,
142        1 * TICKS_PER_SECOND,
143        &event_out
144      );
145      if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) {
146        if ( Multiprocessing_configuration.node == 2 )
147          puts( "\nCorrect behavior if the other node exitted." );
148        else
149          puts( "\nERROR... node 1 died" );
150        break;
151      } else
152        directive_failed( status, "rtems_event_receive" );
153    }
154
155    if ( (count % DOT_COUNT) == 0 )
156      put_dot('.');
157
158    count++;
159  }
160
161  putchar( '\n' );
162
163  if ( Multiprocessing_configuration.node == 2 ) {
164    /* Flush events */
165    puts( "Flushing RTEMS_EVENT_16" );
166    (void) rtems_event_receive(RTEMS_EVENT_16, RTEMS_NO_WAIT, 0, &event_out);
167
168    puts( "Waiting for RTEMS_EVENT_16" );
169    status = rtems_event_receive(
170      RTEMS_EVENT_16,
171      RTEMS_DEFAULT_OPTIONS,
172      1 * TICKS_PER_SECOND,
173      &event_out
174    );
175    fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" );
176    puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" );
177  }
178  puts( "*** END OF TEST 6 ***" );
179  rtems_test_exit( 0 );
180}
Note: See TracBrowser for help on using the repository browser.