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

5
Last change on this file since ca056e3 was 596bfe3b, checked in by Joel Sherrill <joel@…>, on 03/21/16 at 00:43:23

mptests/*/*.c: Fix warnings

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