1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* Test_task |
---|
4 | * |
---|
5 | * This task initializes the signal catcher, sends the first signal |
---|
6 | * if running on the first node, and loops while waiting for signals. |
---|
7 | * |
---|
8 | * NOTE: The signal catcher is not reentrant and hence RTEMS_NO_ASR must |
---|
9 | * be a part of its execution mode. |
---|
10 | * |
---|
11 | * Input parameters: |
---|
12 | * argument - task argument |
---|
13 | * |
---|
14 | * Output parameters: NONE |
---|
15 | * |
---|
16 | * COPYRIGHT (c) 1989-2009. |
---|
17 | * On-Line Applications Research Corporation (OAR). |
---|
18 | * |
---|
19 | * Redistribution and use in source and binary forms, with or without |
---|
20 | * modification, are permitted provided that the following conditions |
---|
21 | * are met: |
---|
22 | * 1. Redistributions of source code must retain the above copyright |
---|
23 | * notice, this list of conditions and the following disclaimer. |
---|
24 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
25 | * notice, this list of conditions and the following disclaimer in the |
---|
26 | * documentation and/or other materials provided with the distribution. |
---|
27 | * |
---|
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
38 | * POSSIBILITY OF SUCH DAMAGE. |
---|
39 | */ |
---|
40 | |
---|
41 | #ifdef HAVE_CONFIG_H |
---|
42 | #include "config.h" |
---|
43 | #endif |
---|
44 | |
---|
45 | #include "system.h" |
---|
46 | |
---|
47 | #define SIGNALS_PER_DOT 15 |
---|
48 | |
---|
49 | static rtems_timer_service_routine Stop_Test_TSR( |
---|
50 | rtems_id ignored_id, |
---|
51 | void *ignored_address |
---|
52 | ) |
---|
53 | { |
---|
54 | Stop_Test = true; |
---|
55 | } |
---|
56 | |
---|
57 | rtems_task Test_task( |
---|
58 | rtems_task_argument argument |
---|
59 | ) |
---|
60 | { |
---|
61 | rtems_status_code status; |
---|
62 | |
---|
63 | Stop_Test = false; |
---|
64 | |
---|
65 | signal_caught = 0; |
---|
66 | signal_count = 0; |
---|
67 | |
---|
68 | puts( "rtems_signal_catch: initializing signal catcher" ); |
---|
69 | status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR|RTEMS_NO_PREEMPT ); |
---|
70 | directive_failed( status, "rtems_signal_catch" ); |
---|
71 | |
---|
72 | if (rtems_object_get_local_node() == 1) { |
---|
73 | remote_node = 2; |
---|
74 | remote_signal = RTEMS_SIGNAL_18; |
---|
75 | expected_signal = RTEMS_SIGNAL_17; |
---|
76 | } |
---|
77 | else { |
---|
78 | remote_node = 1; |
---|
79 | remote_signal = RTEMS_SIGNAL_17; |
---|
80 | expected_signal = RTEMS_SIGNAL_18; |
---|
81 | } |
---|
82 | puts_nocr( "Remote task's name is : " ); |
---|
83 | put_name( Task_name[ remote_node ], TRUE ); |
---|
84 | |
---|
85 | puts( "Getting TID of remote task" ); |
---|
86 | do { |
---|
87 | status = rtems_task_ident( |
---|
88 | Task_name[ remote_node ], |
---|
89 | RTEMS_SEARCH_ALL_NODES, |
---|
90 | &remote_tid |
---|
91 | ); |
---|
92 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
93 | directive_failed( status, "rtems_task_ident" ); |
---|
94 | |
---|
95 | status = rtems_timer_fire_after( |
---|
96 | Timer_id[ 1 ], |
---|
97 | 3 * rtems_clock_get_ticks_per_second(), |
---|
98 | Stop_Test_TSR, |
---|
99 | NULL |
---|
100 | ); |
---|
101 | directive_failed( status, "rtems_timer_fire_after" ); |
---|
102 | |
---|
103 | if ( rtems_object_get_local_node() == 1 ) { |
---|
104 | puts( "Sending signal to remote task" ); |
---|
105 | do { |
---|
106 | status = rtems_signal_send( remote_tid, remote_signal ); |
---|
107 | if ( status == RTEMS_NOT_DEFINED ) |
---|
108 | continue; |
---|
109 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
110 | directive_failed( status, "rtems_signal_send" ); |
---|
111 | } |
---|
112 | |
---|
113 | while ( Stop_Test == FALSE ) { |
---|
114 | if ( signal_caught ) { |
---|
115 | signal_caught = 0; |
---|
116 | if ( ++signal_count >= SIGNALS_PER_DOT ) { |
---|
117 | signal_count = 0; |
---|
118 | put_dot( '.' ); |
---|
119 | } |
---|
120 | status = rtems_signal_send( remote_tid, remote_signal ); |
---|
121 | directive_failed( status, "rtems_signal_send" ); |
---|
122 | } |
---|
123 | } |
---|
124 | puts( "\n*** END OF TEST 5 ***" ); |
---|
125 | rtems_test_exit( 0 ); |
---|
126 | } |
---|