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

Last change on this file was a00dff42, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 12, 2019 at 5:37:01 AM

rtems: Add and use rtems_object_get_local_node()

Update #3841.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*  Test_task
2 *
3 *  This task initializes the signal catcher, sends the first signal
4 *  if running on the first node, and loops while waiting for signals.
5 *
6 *  NOTE: The signal catcher is not reentrant and hence RTEMS_NO_ASR must
7 *        be a part of its execution mode.
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 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.org/license/LICENSE.
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include "system.h"
27
28#define SIGNALS_PER_DOT 15
29
30static rtems_timer_service_routine Stop_Test_TSR(
31  rtems_id  ignored_id,
32  void     *ignored_address
33)
34{
35  Stop_Test = true;
36}
37
38rtems_task Test_task(
39  rtems_task_argument argument
40)
41{
42  rtems_status_code status;
43
44  Stop_Test = false;
45
46  signal_caught = 0;
47  signal_count  = 0;
48
49  puts( "rtems_signal_catch: initializing signal catcher" );
50  status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR|RTEMS_NO_PREEMPT );
51  directive_failed( status, "rtems_signal_catch" );
52
53  if (rtems_object_get_local_node() == 1) {
54     remote_node = 2;
55     remote_signal  = RTEMS_SIGNAL_18;
56     expected_signal = RTEMS_SIGNAL_17;
57  }
58  else {
59     remote_node = 1;
60     remote_signal  = RTEMS_SIGNAL_17;
61     expected_signal = RTEMS_SIGNAL_18;
62  }
63  puts_nocr( "Remote task's name is : " );
64  put_name( Task_name[ remote_node ], TRUE );
65
66  puts( "Getting TID of remote task" );
67  do {
68      status = rtems_task_ident(
69          Task_name[ remote_node ],
70          RTEMS_SEARCH_ALL_NODES,
71          &remote_tid
72          );
73  } while ( status != RTEMS_SUCCESSFUL );
74  directive_failed( status, "rtems_task_ident" );
75
76  status = rtems_timer_fire_after(
77    Timer_id[ 1 ],
78    3 * rtems_clock_get_ticks_per_second(),
79    Stop_Test_TSR,
80    NULL
81  );
82  directive_failed( status, "rtems_timer_fire_after" );
83
84  if ( rtems_object_get_local_node() == 1 ) {
85    puts( "Sending signal to remote task" );
86    do {
87      status = rtems_signal_send( remote_tid, remote_signal );
88      if ( status == RTEMS_NOT_DEFINED )
89        continue;
90    } while ( status != RTEMS_SUCCESSFUL );
91    directive_failed( status, "rtems_signal_send" );
92  }
93
94  while ( Stop_Test == FALSE ) {
95    if ( signal_caught ) {
96      signal_caught = 0;
97      if ( ++signal_count >= SIGNALS_PER_DOT ) {
98        signal_count = 0;
99        put_dot( '.' );
100      }
101      status = rtems_signal_send( remote_tid, remote_signal );
102      directive_failed( status, "rtems_signal_send" );
103    }
104  }
105  puts( "\n*** END OF TEST 5 ***" );
106  rtems_test_exit( 0 );
107}
Note: See TracBrowser for help on using the repository browser.