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 | #if !defined(OPERATION_COUNT) |
---|
30 | #define OPERATION_COUNT 100 |
---|
31 | #endif |
---|
32 | |
---|
33 | #ifdef HAVE_CONFIG_H |
---|
34 | #include "config.h" |
---|
35 | #endif |
---|
36 | |
---|
37 | #include <rtems/btimer.h> |
---|
38 | |
---|
39 | #define CONFIGURE_INIT |
---|
40 | #include "system.h" |
---|
41 | |
---|
42 | const char rtems_test_name[] = "TIME TEST 21"; |
---|
43 | |
---|
44 | uint8_t Region_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT; |
---|
45 | uint8_t Partition_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT; |
---|
46 | |
---|
47 | rtems_task Task_1( |
---|
48 | rtems_task_argument argument |
---|
49 | ); |
---|
50 | |
---|
51 | rtems_task Init( |
---|
52 | rtems_task_argument argument |
---|
53 | ) |
---|
54 | { |
---|
55 | rtems_id id; |
---|
56 | rtems_status_code status; |
---|
57 | |
---|
58 | Print_Warning(); |
---|
59 | |
---|
60 | TEST_BEGIN(); |
---|
61 | |
---|
62 | status = rtems_task_create( |
---|
63 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
64 | RTEMS_MAXIMUM_PRIORITY - 5u, |
---|
65 | RTEMS_MINIMUM_STACK_SIZE, |
---|
66 | RTEMS_DEFAULT_MODES, |
---|
67 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
68 | &id |
---|
69 | ); |
---|
70 | directive_failed( status, "rtems_task_create of TASK1" ); |
---|
71 | |
---|
72 | status = rtems_task_start( id, Task_1, 0 ); |
---|
73 | directive_failed( status, "rtems_task_start of TASK1" ); |
---|
74 | |
---|
75 | rtems_task_exit(); |
---|
76 | } |
---|
77 | |
---|
78 | rtems_task Task_1( |
---|
79 | rtems_task_argument argument |
---|
80 | ) |
---|
81 | { |
---|
82 | uint32_t index; |
---|
83 | rtems_id id; |
---|
84 | rtems_status_code status; |
---|
85 | |
---|
86 | for( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
87 | status = rtems_task_create ( |
---|
88 | index, |
---|
89 | RTEMS_MAXIMUM_PRIORITY - 1u, |
---|
90 | RTEMS_MINIMUM_STACK_SIZE, |
---|
91 | RTEMS_DEFAULT_MODES, |
---|
92 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
93 | &id |
---|
94 | ); |
---|
95 | directive_failed( status, "rtems_task_create" ); |
---|
96 | |
---|
97 | status = rtems_message_queue_create( |
---|
98 | index, |
---|
99 | 1, /* only going to ident this queue */ |
---|
100 | MESSAGE_SIZE, |
---|
101 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
102 | &id |
---|
103 | ); |
---|
104 | directive_failed( status, "rtems_message_queue_create" ); |
---|
105 | |
---|
106 | status = rtems_semaphore_create( |
---|
107 | index, |
---|
108 | OPERATION_COUNT, |
---|
109 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
110 | RTEMS_NO_PRIORITY, |
---|
111 | &id |
---|
112 | ); |
---|
113 | directive_failed( status, "rtems_semaphore_create" ); |
---|
114 | |
---|
115 | status = rtems_region_create( |
---|
116 | index, |
---|
117 | Region_area, |
---|
118 | 2048, |
---|
119 | 16, |
---|
120 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
121 | &id |
---|
122 | ); |
---|
123 | directive_failed( status, "rtems_region_create" ); |
---|
124 | |
---|
125 | status = rtems_partition_create( |
---|
126 | index, |
---|
127 | Partition_area, |
---|
128 | 2048, |
---|
129 | 128, |
---|
130 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
131 | &id |
---|
132 | ); |
---|
133 | directive_failed( status, "rtems_partition_create" ); |
---|
134 | |
---|
135 | status = rtems_port_create( |
---|
136 | index, |
---|
137 | Partition_area, |
---|
138 | Region_area, |
---|
139 | 0xff, |
---|
140 | &id |
---|
141 | ); |
---|
142 | directive_failed( status, "rtems_port_create" ); |
---|
143 | |
---|
144 | status = rtems_timer_create( index, &id ); |
---|
145 | directive_failed( status, "rtems_timer_create" ); |
---|
146 | |
---|
147 | status = rtems_rate_monotonic_create( index, &id ); |
---|
148 | directive_failed( status, "rtems_rate_monotonic_create" ); |
---|
149 | } |
---|
150 | |
---|
151 | benchmark_timer_initialize(); |
---|
152 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
153 | (void) benchmark_timer_empty_function(); |
---|
154 | overhead = benchmark_timer_read(); |
---|
155 | |
---|
156 | benchmark_timer_initialize(); |
---|
157 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
158 | (void) rtems_task_ident( index, RTEMS_SEARCH_ALL_NODES, &id ); |
---|
159 | end_time = benchmark_timer_read(); |
---|
160 | |
---|
161 | put_time( |
---|
162 | "rtems_task_ident: only case", |
---|
163 | end_time, |
---|
164 | OPERATION_COUNT, |
---|
165 | overhead, |
---|
166 | 0 |
---|
167 | ); |
---|
168 | |
---|
169 | benchmark_timer_initialize(); |
---|
170 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
171 | (void) rtems_message_queue_ident( index, RTEMS_SEARCH_ALL_NODES, &id ); |
---|
172 | end_time = benchmark_timer_read(); |
---|
173 | |
---|
174 | put_time( |
---|
175 | "rtems_message_queue_ident: only case", |
---|
176 | end_time, |
---|
177 | OPERATION_COUNT, |
---|
178 | overhead, |
---|
179 | 0 |
---|
180 | ); |
---|
181 | |
---|
182 | benchmark_timer_initialize(); |
---|
183 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
184 | (void) rtems_semaphore_ident( index, RTEMS_SEARCH_ALL_NODES, &id ); |
---|
185 | end_time = benchmark_timer_read(); |
---|
186 | |
---|
187 | put_time( |
---|
188 | "rtems_semaphore_ident: only case", |
---|
189 | end_time, |
---|
190 | OPERATION_COUNT, |
---|
191 | overhead, |
---|
192 | 0 |
---|
193 | ); |
---|
194 | |
---|
195 | benchmark_timer_initialize(); |
---|
196 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
197 | (void) rtems_partition_ident( index, RTEMS_SEARCH_ALL_NODES, &id ); |
---|
198 | end_time = benchmark_timer_read(); |
---|
199 | |
---|
200 | put_time( |
---|
201 | "rtems_partition_ident: only case", |
---|
202 | end_time, |
---|
203 | OPERATION_COUNT, |
---|
204 | overhead, |
---|
205 | 0 |
---|
206 | ); |
---|
207 | |
---|
208 | benchmark_timer_initialize(); |
---|
209 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
210 | (void) rtems_region_ident( index, &id ); |
---|
211 | end_time = benchmark_timer_read(); |
---|
212 | |
---|
213 | put_time( |
---|
214 | "rtems_region_ident: only case", |
---|
215 | end_time, |
---|
216 | OPERATION_COUNT, |
---|
217 | overhead, |
---|
218 | 0 |
---|
219 | ); |
---|
220 | |
---|
221 | benchmark_timer_initialize(); |
---|
222 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
223 | (void) rtems_port_ident( index, &id ); |
---|
224 | end_time = benchmark_timer_read(); |
---|
225 | |
---|
226 | put_time( |
---|
227 | "rtems_port_ident: only case", |
---|
228 | end_time, |
---|
229 | OPERATION_COUNT, |
---|
230 | overhead, |
---|
231 | 0 |
---|
232 | ); |
---|
233 | |
---|
234 | benchmark_timer_initialize(); |
---|
235 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
236 | (void) rtems_timer_ident( index, &id ); |
---|
237 | end_time = benchmark_timer_read(); |
---|
238 | |
---|
239 | put_time( |
---|
240 | "rtems_timer_ident: only case", |
---|
241 | end_time, |
---|
242 | OPERATION_COUNT, |
---|
243 | overhead, |
---|
244 | 0 |
---|
245 | ); |
---|
246 | |
---|
247 | benchmark_timer_initialize(); |
---|
248 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
249 | (void) rtems_rate_monotonic_ident( index, &id ); |
---|
250 | end_time = benchmark_timer_read(); |
---|
251 | |
---|
252 | put_time( |
---|
253 | "rtems_rate_monotonic_ident: only case", |
---|
254 | end_time, |
---|
255 | OPERATION_COUNT, |
---|
256 | overhead, |
---|
257 | 0 |
---|
258 | ); |
---|
259 | |
---|
260 | TEST_END(); |
---|
261 | rtems_test_exit( 0 ); |
---|
262 | } |
---|