1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * COPYRIGHT (c) 1989-2013. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms, with or without |
---|
8 | * modification, are permitted provided that the following conditions |
---|
9 | * are met: |
---|
10 | * 1. Redistributions of source code must retain the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer. |
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer in the |
---|
14 | * documentation and/or other materials provided with the distribution. |
---|
15 | * |
---|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
26 | * POSSIBILITY OF SUCH DAMAGE. |
---|
27 | */ |
---|
28 | |
---|
29 | #ifdef HAVE_CONFIG_H |
---|
30 | #include "config.h" |
---|
31 | #endif |
---|
32 | |
---|
33 | #include <rtems/btimer.h> |
---|
34 | |
---|
35 | #define CONFIGURE_INIT |
---|
36 | #include "system.h" |
---|
37 | |
---|
38 | const char rtems_test_name[] = "TIME TEST 19"; |
---|
39 | |
---|
40 | rtems_asr Process_asr_for_pass_1( |
---|
41 | rtems_signal_set signals |
---|
42 | ); |
---|
43 | |
---|
44 | rtems_asr Process_asr_for_pass_2( |
---|
45 | rtems_signal_set signals |
---|
46 | ); |
---|
47 | |
---|
48 | rtems_task Task_1( |
---|
49 | rtems_task_argument argument |
---|
50 | ); |
---|
51 | |
---|
52 | rtems_task Task_2( |
---|
53 | rtems_task_argument argument |
---|
54 | ); |
---|
55 | |
---|
56 | rtems_task Task_3( |
---|
57 | rtems_task_argument argument |
---|
58 | ); |
---|
59 | |
---|
60 | rtems_task Init( |
---|
61 | rtems_task_argument argument |
---|
62 | ) |
---|
63 | { |
---|
64 | rtems_status_code status; |
---|
65 | |
---|
66 | Print_Warning(); |
---|
67 | |
---|
68 | TEST_BEGIN(); |
---|
69 | |
---|
70 | status = rtems_task_create( |
---|
71 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
72 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
73 | RTEMS_MINIMUM_STACK_SIZE, |
---|
74 | RTEMS_DEFAULT_MODES, |
---|
75 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
76 | &Task_id[ 1 ] |
---|
77 | ); |
---|
78 | directive_failed( status, "rtems_task_create of TASK1" ); |
---|
79 | |
---|
80 | status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); |
---|
81 | directive_failed( status, "rtems_task_start of TASK1" ); |
---|
82 | |
---|
83 | status = rtems_task_create( |
---|
84 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
85 | (RTEMS_MAXIMUM_PRIORITY / 2), |
---|
86 | RTEMS_MINIMUM_STACK_SIZE, |
---|
87 | RTEMS_DEFAULT_MODES, |
---|
88 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
89 | &Task_id[ 2 ] |
---|
90 | ); |
---|
91 | directive_failed( status, "rtems_task_create of TASK2" ); |
---|
92 | |
---|
93 | status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); |
---|
94 | directive_failed( status, "rtems_task_start of TASK2" ); |
---|
95 | |
---|
96 | status = rtems_task_create( |
---|
97 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
98 | (RTEMS_MAXIMUM_PRIORITY / 2u) - 1u, |
---|
99 | RTEMS_MINIMUM_STACK_SIZE, |
---|
100 | RTEMS_DEFAULT_MODES, |
---|
101 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
102 | &Task_id[ 3 ] |
---|
103 | ); |
---|
104 | directive_failed( status, "rtems_task_create of TASK3" ); |
---|
105 | |
---|
106 | status = rtems_task_start( Task_id[ 3 ], Task_3, 0 ); |
---|
107 | directive_failed( status, "rtems_task_start of TASK3" ); |
---|
108 | |
---|
109 | rtems_task_exit(); |
---|
110 | } |
---|
111 | |
---|
112 | rtems_asr Process_asr_for_pass_1( |
---|
113 | rtems_signal_set signals |
---|
114 | ) |
---|
115 | { |
---|
116 | end_time = benchmark_timer_read(); |
---|
117 | |
---|
118 | put_time( |
---|
119 | "rtems_signal_send: signal to self", |
---|
120 | end_time, |
---|
121 | 1, |
---|
122 | 0, |
---|
123 | 0 |
---|
124 | ); |
---|
125 | |
---|
126 | benchmark_timer_initialize(); |
---|
127 | } |
---|
128 | |
---|
129 | rtems_asr Process_asr_for_pass_2( |
---|
130 | rtems_signal_set signals |
---|
131 | ) |
---|
132 | { |
---|
133 | rtems_status_code status; |
---|
134 | |
---|
135 | status = rtems_task_resume( Task_id[ 3 ] ); |
---|
136 | directive_failed( status, "rtems_task_resume" ); |
---|
137 | |
---|
138 | benchmark_timer_initialize(); |
---|
139 | } |
---|
140 | |
---|
141 | rtems_task Task_1( |
---|
142 | rtems_task_argument argument |
---|
143 | ) |
---|
144 | { |
---|
145 | rtems_status_code status; |
---|
146 | |
---|
147 | benchmark_timer_initialize(); |
---|
148 | (void) rtems_signal_catch( Process_asr_for_pass_1, RTEMS_DEFAULT_MODES ); |
---|
149 | end_time = benchmark_timer_read(); |
---|
150 | |
---|
151 | put_time( |
---|
152 | "rtems_signal_catch: only case", |
---|
153 | end_time, |
---|
154 | 1, |
---|
155 | 0, |
---|
156 | 0 |
---|
157 | ); |
---|
158 | |
---|
159 | benchmark_timer_initialize(); |
---|
160 | rtems_signal_send( Task_id[ 2 ], 1 ); |
---|
161 | end_time = benchmark_timer_read(); |
---|
162 | |
---|
163 | put_time( |
---|
164 | "rtems_signal_send: returns to caller", |
---|
165 | end_time, |
---|
166 | 1, |
---|
167 | 0, |
---|
168 | 0 |
---|
169 | ); |
---|
170 | |
---|
171 | benchmark_timer_initialize(); |
---|
172 | (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 ); |
---|
173 | |
---|
174 | /* end time is done is RTEMS_ASR */ |
---|
175 | |
---|
176 | end_time = benchmark_timer_read(); |
---|
177 | |
---|
178 | put_time( |
---|
179 | "rtems_signal: exit ASR overhead returns to calling task", |
---|
180 | end_time, |
---|
181 | 1, |
---|
182 | 0, |
---|
183 | 0 |
---|
184 | ); |
---|
185 | |
---|
186 | status = rtems_signal_catch( Process_asr_for_pass_2, RTEMS_NO_PREEMPT ); |
---|
187 | directive_failed( status, "rtems_signal_catch" ); |
---|
188 | |
---|
189 | benchmark_timer_initialize(); |
---|
190 | (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 ); |
---|
191 | } |
---|
192 | |
---|
193 | /* avoid warnings for no prototype */ |
---|
194 | rtems_asr Process_asr_for_task_2( |
---|
195 | rtems_signal_set signals |
---|
196 | ); |
---|
197 | |
---|
198 | rtems_asr Process_asr_for_task_2( |
---|
199 | rtems_signal_set signals |
---|
200 | ) |
---|
201 | { |
---|
202 | ; |
---|
203 | } |
---|
204 | |
---|
205 | rtems_task Task_2( |
---|
206 | rtems_task_argument argument |
---|
207 | ) |
---|
208 | { |
---|
209 | rtems_status_code status; |
---|
210 | |
---|
211 | status = rtems_signal_catch( Process_asr_for_task_2, RTEMS_DEFAULT_MODES ); |
---|
212 | directive_failed( status, "rtems_signal_catch" ); |
---|
213 | |
---|
214 | (void) rtems_task_suspend( RTEMS_SELF ); |
---|
215 | } |
---|
216 | |
---|
217 | rtems_task Task_3( |
---|
218 | rtems_task_argument argument |
---|
219 | ) |
---|
220 | { |
---|
221 | (void) rtems_task_suspend( RTEMS_SELF ); |
---|
222 | |
---|
223 | end_time = benchmark_timer_read(); |
---|
224 | |
---|
225 | put_time( |
---|
226 | "rtems_signal: exit ASR overhead returns to preempting task", |
---|
227 | end_time, |
---|
228 | 1, |
---|
229 | 0, |
---|
230 | 0 |
---|
231 | ); |
---|
232 | |
---|
233 | TEST_END(); |
---|
234 | rtems_test_exit( 0 ); |
---|
235 | } |
---|