source: rtems/testsuites/mptests/mp07/task1.c

Last change on this file was 42d4ebe, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:01:34

testsuites/mptests/*: Change license to BSD-2.

Updates #3053.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*  Test_task
4 *
5 *  This task continuously sends an event to its counterpart on the
6 *  other node, and then waits for it to send an event.  The copy
7 *  running on node one send the first event.
8 *
9 *  Input parameters:
10 *    argument - task argument
11 *
12 *  Output parameters:  NONE
13 *
14 *  COPYRIGHT (c) 1989-2009.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#include "system.h"
44
45#define DOT_COUNT 100
46
47static rtems_timer_service_routine Stop_Test_TSR(
48  rtems_id  ignored_id,
49  void     *ignored_address
50)
51{
52  Stop_Test = true;
53}
54
55rtems_task Test_task(
56  rtems_task_argument argument
57)
58{
59  rtems_status_code status;
60  uint32_t    count;
61  uint32_t    remote_node;
62  rtems_id          remote_tid;
63  rtems_event_set   event_out;
64
65  Stop_Test = false;
66
67  remote_node = (rtems_object_get_local_node() == 1) ? 2 : 1;
68  puts_nocr( "Remote task's name is : " );
69  put_name( Task_name[ remote_node ], TRUE );
70
71  puts( "Getting TID of remote task" );
72  do {
73    status = rtems_task_ident(
74      Task_name[ remote_node ],
75      RTEMS_SEARCH_ALL_NODES,
76      &remote_tid
77    );
78  } while ( !rtems_is_status_successful( status ) );
79
80  if ( rtems_object_get_local_node() == 1 ) {
81    puts( "Sending first event to remote task" );
82    status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
83    directive_failed( status, "rtems_event_send" );
84  }
85
86  status = rtems_timer_fire_after(
87    Timer_id[ 1 ],
88    5 * rtems_clock_get_ticks_per_second(),
89    Stop_Test_TSR,
90    NULL
91  );
92  directive_failed( status, "rtems_timer_fire_after" );
93
94  while ( true ) {
95    for ( count=DOT_COUNT ; count && (Stop_Test == false) ; count-- ) {
96      status = rtems_event_receive(
97        RTEMS_EVENT_16,
98        RTEMS_DEFAULT_OPTIONS,
99        rtems_clock_get_ticks_per_second(),
100        &event_out
101      );
102      if ( status == RTEMS_TIMEOUT ) {
103        printf("\nTA1 - RTEMS_TIMEOUT .. probably OK if the other node exits");
104        Stop_Test = true;
105        break;
106      } else
107        directive_failed( status, "rtems_event_receive" );
108
109      status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
110      directive_failed( status, "rtems_event_send" );
111    }
112    if ( Stop_Test )
113       break;
114    put_dot('.');
115  }
116
117  /*
118   * Wait a bit before shutting down so we don't screw up the other node
119   * when our MPCI shuts down
120   */
121
122  rtems_task_wake_after(10);
123
124  puts( "\n*** END OF TEST 7 ***" );
125  rtems_test_exit( 0 );
126}
Note: See TracBrowser for help on using the repository browser.