source: rtems/testsuites/mptests/mp07/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: 2.6 KB
Line 
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.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 100
27
28static rtems_timer_service_routine Stop_Test_TSR(
29  rtems_id  ignored_id,
30  void     *ignored_address
31)
32{
33  Stop_Test = true;
34}
35
36rtems_task Test_task(
37  rtems_task_argument argument
38)
39{
40  rtems_status_code status;
41  uint32_t    count;
42  uint32_t    remote_node;
43  rtems_id          remote_tid;
44  rtems_event_set   event_out;
45
46  Stop_Test = false;
47
48  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
49  puts_nocr( "Remote task's name is : " );
50  put_name( Task_name[ remote_node ], TRUE );
51
52  puts( "Getting TID of remote task" );
53  do {
54    status = rtems_task_ident(
55      Task_name[ remote_node ],
56      RTEMS_SEARCH_ALL_NODES,
57      &remote_tid
58    );
59  } while ( !rtems_is_status_successful( status ) );
60
61  if ( Multiprocessing_configuration.node == 1 ) {
62    puts( "Sending first event to remote task" );
63    status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
64    directive_failed( status, "rtems_event_send" );
65  }
66
67  status = rtems_timer_fire_after(
68    Timer_id[ 1 ],
69    5 * rtems_clock_get_ticks_per_second(),
70    Stop_Test_TSR,
71    NULL
72  );
73  directive_failed( status, "rtems_timer_fire_after" );
74
75  while ( true ) {
76    for ( count=DOT_COUNT ; count && (Stop_Test == false) ; count-- ) {
77      status = rtems_event_receive(
78        RTEMS_EVENT_16,
79        RTEMS_DEFAULT_OPTIONS,
80        rtems_clock_get_ticks_per_second(),
81        &event_out
82      );
83      if ( status == RTEMS_TIMEOUT ) {
84        printf("\nTA1 - RTEMS_TIMEOUT .. probably OK if the other node exits");
85        Stop_Test = true;
86        break;
87      } else
88        directive_failed( status, "rtems_event_receive" );
89
90      status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
91      directive_failed( status, "rtems_event_send" );
92    }
93    if ( Stop_Test )
94       break;
95    put_dot('.');
96  }
97
98  /*
99   * Wait a bit before shutting down so we don't screw up the other node
100   * when our MPCI shuts down
101   */
102
103  rtems_task_wake_after(10);
104
105  puts( "\n*** END OF TEST 7 ***" );
106  rtems_test_exit( 0 );
107}
Note: See TracBrowser for help on using the repository browser.