1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | rtems_device_major_number _STUB_major = 1; |
---|
18 | |
---|
19 | rtems_id Region_id; |
---|
20 | rtems_name Region_name; |
---|
21 | uint8_t Region_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT; |
---|
22 | |
---|
23 | #define PARTITION_SIZE 2048 |
---|
24 | #define PARTITION_ELEMENT_SIZE 128 |
---|
25 | #define PARTITION_BUFFER_POINTERS \ |
---|
26 | ((PARTITION_SIZE / PARTITION_ELEMENT_SIZE) + 2) |
---|
27 | |
---|
28 | rtems_id Partition_id; |
---|
29 | rtems_name Partition_name; |
---|
30 | uint8_t Partition_area[ PARTITION_SIZE ] CPU_STRUCTURE_ALIGNMENT; |
---|
31 | |
---|
32 | void *Buffer_address_1; |
---|
33 | void *Buffer_address_2; |
---|
34 | void *Buffer_address_3; |
---|
35 | void *Buffer_address_4; |
---|
36 | |
---|
37 | uint32_t buffer_count; |
---|
38 | |
---|
39 | void *Buffer_addresses[ PARTITION_BUFFER_POINTERS ]; |
---|
40 | |
---|
41 | rtems_task Task_1( |
---|
42 | rtems_task_argument argument |
---|
43 | ); |
---|
44 | |
---|
45 | rtems_task Task_2( |
---|
46 | rtems_task_argument argument |
---|
47 | ); |
---|
48 | |
---|
49 | rtems_task Init( |
---|
50 | rtems_task_argument argument |
---|
51 | ) |
---|
52 | { |
---|
53 | rtems_status_code status; |
---|
54 | |
---|
55 | Print_Warning(); |
---|
56 | |
---|
57 | puts( "\n\n*** TIME TEST 20 ***" ); |
---|
58 | |
---|
59 | status = rtems_task_create( |
---|
60 | rtems_build_name( 'T', 'I', 'M', '1' ), |
---|
61 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
62 | RTEMS_MINIMUM_STACK_SIZE, |
---|
63 | RTEMS_DEFAULT_MODES, |
---|
64 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
65 | &Task_id[ 1 ] |
---|
66 | ); |
---|
67 | directive_failed( status, "rtems_task_create of TASK1" ); |
---|
68 | |
---|
69 | status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); |
---|
70 | directive_failed( status, "rtems_task_start of TASK1" ); |
---|
71 | |
---|
72 | status = rtems_task_create( |
---|
73 | rtems_build_name( 'T', 'I', 'M', '2' ), |
---|
74 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 2u, |
---|
75 | RTEMS_MINIMUM_STACK_SIZE, |
---|
76 | RTEMS_DEFAULT_MODES, |
---|
77 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
78 | &Task_id[ 2 ] |
---|
79 | ); |
---|
80 | directive_failed( status, "rtems_task_create of TASK2" ); |
---|
81 | |
---|
82 | status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); |
---|
83 | directive_failed( status, "rtems_task_start of TASK2" ); |
---|
84 | |
---|
85 | status = rtems_task_delete( RTEMS_SELF ); |
---|
86 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
87 | } |
---|
88 | |
---|
89 | rtems_task Task_1( |
---|
90 | rtems_task_argument argument |
---|
91 | ) |
---|
92 | { |
---|
93 | uint32_t index; |
---|
94 | rtems_mode previous_mode; |
---|
95 | rtems_task_priority previous_priority; |
---|
96 | rtems_status_code status; |
---|
97 | |
---|
98 | Partition_name = rtems_build_name( 'P', 'A', 'R', 'T' ); |
---|
99 | |
---|
100 | benchmark_timer_initialize(); |
---|
101 | rtems_partition_create( |
---|
102 | Partition_name, |
---|
103 | Partition_area, |
---|
104 | PARTITION_SIZE, |
---|
105 | 128, |
---|
106 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
107 | &Partition_id |
---|
108 | ); |
---|
109 | end_time = benchmark_timer_read(); |
---|
110 | |
---|
111 | put_time( |
---|
112 | "rtems_partition_create", |
---|
113 | end_time, |
---|
114 | 1, |
---|
115 | 0, |
---|
116 | CALLING_OVERHEAD_PARTITION_CREATE |
---|
117 | ); |
---|
118 | |
---|
119 | Region_name = rtems_build_name( 'R', 'E', 'G', 'N' ); |
---|
120 | |
---|
121 | benchmark_timer_initialize(); |
---|
122 | rtems_region_create( |
---|
123 | Region_name, |
---|
124 | Region_area, |
---|
125 | 2048, |
---|
126 | 16, |
---|
127 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
128 | &Region_id |
---|
129 | ); |
---|
130 | end_time = benchmark_timer_read(); |
---|
131 | |
---|
132 | put_time( |
---|
133 | "rtems_region_create", |
---|
134 | end_time, |
---|
135 | 1, |
---|
136 | 0, |
---|
137 | CALLING_OVERHEAD_REGION_CREATE |
---|
138 | ); |
---|
139 | |
---|
140 | benchmark_timer_initialize(); |
---|
141 | (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_1 ); |
---|
142 | end_time = benchmark_timer_read(); |
---|
143 | |
---|
144 | put_time( |
---|
145 | "rtems_partition_get_buffer: available", |
---|
146 | end_time, |
---|
147 | 1, |
---|
148 | 0, |
---|
149 | CALLING_OVERHEAD_PARTITION_GET_BUFFER |
---|
150 | ); |
---|
151 | |
---|
152 | buffer_count = 0; |
---|
153 | while ( FOREVER ) { |
---|
154 | |
---|
155 | status = rtems_partition_get_buffer( |
---|
156 | Partition_id, |
---|
157 | &Buffer_addresses[ buffer_count ] |
---|
158 | ); |
---|
159 | |
---|
160 | if ( status == RTEMS_UNSATISFIED ) break; |
---|
161 | |
---|
162 | buffer_count++; |
---|
163 | |
---|
164 | rtems_test_assert( buffer_count < PARTITION_BUFFER_POINTERS ); |
---|
165 | } |
---|
166 | |
---|
167 | benchmark_timer_initialize(); |
---|
168 | (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_2 ); |
---|
169 | end_time = benchmark_timer_read(); |
---|
170 | |
---|
171 | put_time( |
---|
172 | "rtems_partition_get_buffer: not available", |
---|
173 | end_time, |
---|
174 | 1, |
---|
175 | 0, |
---|
176 | CALLING_OVERHEAD_PARTITION_GET_BUFFER |
---|
177 | ); |
---|
178 | |
---|
179 | benchmark_timer_initialize(); |
---|
180 | (void) rtems_partition_return_buffer( Partition_id, Buffer_address_1 ); |
---|
181 | end_time = benchmark_timer_read(); |
---|
182 | |
---|
183 | put_time( |
---|
184 | "rtems_partition_return_buffer", |
---|
185 | end_time, |
---|
186 | 1, |
---|
187 | 0, |
---|
188 | CALLING_OVERHEAD_PARTITION_RETURN_BUFFER |
---|
189 | ); |
---|
190 | |
---|
191 | for ( index = 0 ; index < buffer_count ; index++ ) { |
---|
192 | |
---|
193 | status = rtems_partition_return_buffer( |
---|
194 | Partition_id, |
---|
195 | Buffer_addresses[ index ] |
---|
196 | ); |
---|
197 | directive_failed( status, "rtems_partition_return_buffer" ); |
---|
198 | |
---|
199 | } |
---|
200 | |
---|
201 | benchmark_timer_initialize(); |
---|
202 | (void) rtems_partition_delete( Partition_id ); |
---|
203 | end_time = benchmark_timer_read(); |
---|
204 | |
---|
205 | put_time( |
---|
206 | "rtems_partition_delete", |
---|
207 | end_time, |
---|
208 | 1, |
---|
209 | 0, |
---|
210 | CALLING_OVERHEAD_PARTITION_DELETE |
---|
211 | ); |
---|
212 | |
---|
213 | status = rtems_region_get_segment( |
---|
214 | Region_id, |
---|
215 | 400, |
---|
216 | RTEMS_DEFAULT_OPTIONS, |
---|
217 | RTEMS_NO_TIMEOUT, |
---|
218 | &Buffer_address_2 |
---|
219 | ); |
---|
220 | directive_failed( status, "region_get_segment" ); |
---|
221 | |
---|
222 | benchmark_timer_initialize(); |
---|
223 | (void) rtems_region_get_segment( |
---|
224 | Region_id, |
---|
225 | 400, |
---|
226 | RTEMS_DEFAULT_OPTIONS, |
---|
227 | RTEMS_NO_TIMEOUT, |
---|
228 | &Buffer_address_3 |
---|
229 | ); |
---|
230 | end_time = benchmark_timer_read(); |
---|
231 | |
---|
232 | put_time( |
---|
233 | "rtems_region_get_segment: available", |
---|
234 | end_time, |
---|
235 | 1, |
---|
236 | 0, |
---|
237 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
238 | ); |
---|
239 | |
---|
240 | benchmark_timer_initialize(); |
---|
241 | (void) rtems_region_get_segment( |
---|
242 | Region_id, |
---|
243 | 1700, |
---|
244 | RTEMS_NO_WAIT, |
---|
245 | RTEMS_NO_TIMEOUT, |
---|
246 | &Buffer_address_4 |
---|
247 | ); |
---|
248 | end_time = benchmark_timer_read(); |
---|
249 | |
---|
250 | put_time( |
---|
251 | "rtems_region_get_segment: not available -- NO_WAIT", |
---|
252 | end_time, |
---|
253 | 1, |
---|
254 | 0, |
---|
255 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
256 | ); |
---|
257 | |
---|
258 | status = rtems_region_return_segment( Region_id, Buffer_address_3 ); |
---|
259 | directive_failed( status, "rtems_region_return_segment" ); |
---|
260 | |
---|
261 | benchmark_timer_initialize(); |
---|
262 | (void) rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
263 | end_time = benchmark_timer_read(); |
---|
264 | |
---|
265 | put_time( |
---|
266 | "rtems_region_return_segment: no waiting tasks", |
---|
267 | end_time, |
---|
268 | 1, |
---|
269 | 0, |
---|
270 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
271 | ); |
---|
272 | |
---|
273 | status = rtems_region_get_segment( |
---|
274 | Region_id, |
---|
275 | 400, |
---|
276 | RTEMS_DEFAULT_OPTIONS, |
---|
277 | RTEMS_NO_TIMEOUT, |
---|
278 | &Buffer_address_1 |
---|
279 | ); |
---|
280 | directive_failed( status, "rtems_region_get_segment" ); |
---|
281 | |
---|
282 | benchmark_timer_initialize(); |
---|
283 | (void) rtems_region_get_segment( |
---|
284 | Region_id, |
---|
285 | 1700, |
---|
286 | RTEMS_DEFAULT_OPTIONS, |
---|
287 | RTEMS_NO_TIMEOUT, |
---|
288 | &Buffer_address_2 |
---|
289 | ); |
---|
290 | |
---|
291 | /* execute Task_2 */ |
---|
292 | |
---|
293 | end_time = benchmark_timer_read(); |
---|
294 | |
---|
295 | put_time( |
---|
296 | "rtems_region_return_segment: task readied -- preempts caller", |
---|
297 | end_time, |
---|
298 | 1, |
---|
299 | 0, |
---|
300 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
301 | ); |
---|
302 | |
---|
303 | status = rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
304 | directive_failed( status, "rtems_region_return_segment" ); |
---|
305 | |
---|
306 | status = rtems_task_mode( |
---|
307 | RTEMS_NO_PREEMPT, |
---|
308 | RTEMS_PREEMPT_MASK, |
---|
309 | &previous_mode |
---|
310 | ); |
---|
311 | directive_failed( status, "rtems_task_mode" ); |
---|
312 | |
---|
313 | status = rtems_task_set_priority( |
---|
314 | RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1u, &previous_priority ); |
---|
315 | directive_failed( status, "rtems_task_set_priority" ); |
---|
316 | |
---|
317 | status = rtems_region_get_segment( |
---|
318 | Region_id, |
---|
319 | 400, |
---|
320 | RTEMS_DEFAULT_OPTIONS, |
---|
321 | RTEMS_NO_TIMEOUT, |
---|
322 | &Buffer_address_1 |
---|
323 | ); |
---|
324 | directive_failed( status, "rtems_region_return_segment" ); |
---|
325 | |
---|
326 | status = rtems_region_get_segment( |
---|
327 | Region_id, |
---|
328 | 1700, |
---|
329 | RTEMS_DEFAULT_OPTIONS, |
---|
330 | RTEMS_NO_TIMEOUT, |
---|
331 | &Buffer_address_2 |
---|
332 | ); |
---|
333 | directive_failed( status, "rtems_region_get_segment" ); |
---|
334 | |
---|
335 | /* execute Task_2 */ |
---|
336 | |
---|
337 | status = rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
338 | directive_failed( status, "rtems_region_return_segment" ); |
---|
339 | |
---|
340 | benchmark_timer_initialize(); |
---|
341 | (void) rtems_region_delete( Region_id ); |
---|
342 | end_time = benchmark_timer_read(); |
---|
343 | |
---|
344 | put_time( |
---|
345 | "rtems_region_delete", |
---|
346 | end_time, |
---|
347 | 1, |
---|
348 | 0, |
---|
349 | CALLING_OVERHEAD_REGION_DELETE |
---|
350 | ); |
---|
351 | |
---|
352 | benchmark_timer_initialize(); |
---|
353 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
354 | (void) benchmark_timer_empty_function(); |
---|
355 | overhead = benchmark_timer_read(); |
---|
356 | |
---|
357 | benchmark_timer_initialize(); |
---|
358 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
359 | (void) rtems_io_initialize( _STUB_major, 0, NULL ); |
---|
360 | end_time = benchmark_timer_read(); |
---|
361 | |
---|
362 | put_time( |
---|
363 | "rtems_io_initialize", |
---|
364 | end_time, |
---|
365 | OPERATION_COUNT, |
---|
366 | overhead, |
---|
367 | CALLING_OVERHEAD_IO_INITIALIZE |
---|
368 | ); |
---|
369 | |
---|
370 | benchmark_timer_initialize(); |
---|
371 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
372 | (void) rtems_io_open( _STUB_major, 0, NULL ); |
---|
373 | end_time = benchmark_timer_read(); |
---|
374 | |
---|
375 | put_time( |
---|
376 | "rtems_io_open", |
---|
377 | end_time, |
---|
378 | OPERATION_COUNT, |
---|
379 | overhead, |
---|
380 | CALLING_OVERHEAD_IO_OPEN |
---|
381 | ); |
---|
382 | |
---|
383 | benchmark_timer_initialize(); |
---|
384 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
385 | (void) rtems_io_close( _STUB_major, 0, NULL ); |
---|
386 | end_time = benchmark_timer_read(); |
---|
387 | |
---|
388 | put_time( |
---|
389 | "rtems_io_close", |
---|
390 | end_time, |
---|
391 | OPERATION_COUNT, |
---|
392 | overhead, |
---|
393 | CALLING_OVERHEAD_IO_CLOSE |
---|
394 | ); |
---|
395 | |
---|
396 | benchmark_timer_initialize(); |
---|
397 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
398 | (void) rtems_io_read( _STUB_major, 0, NULL ); |
---|
399 | end_time = benchmark_timer_read(); |
---|
400 | |
---|
401 | put_time( |
---|
402 | "rtems_io_read", |
---|
403 | end_time, |
---|
404 | OPERATION_COUNT, |
---|
405 | overhead, |
---|
406 | CALLING_OVERHEAD_IO_READ |
---|
407 | ); |
---|
408 | |
---|
409 | benchmark_timer_initialize(); |
---|
410 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
411 | (void) rtems_io_write( _STUB_major, 0, NULL ); |
---|
412 | end_time = benchmark_timer_read(); |
---|
413 | |
---|
414 | put_time( |
---|
415 | "rtems_io_write", |
---|
416 | end_time, |
---|
417 | OPERATION_COUNT, |
---|
418 | overhead, |
---|
419 | CALLING_OVERHEAD_IO_WRITE |
---|
420 | ); |
---|
421 | |
---|
422 | benchmark_timer_initialize(); |
---|
423 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
424 | (void) rtems_io_control( _STUB_major, 0, NULL ); |
---|
425 | end_time = benchmark_timer_read(); |
---|
426 | |
---|
427 | put_time( |
---|
428 | "rtems_io_control", |
---|
429 | end_time, |
---|
430 | OPERATION_COUNT, |
---|
431 | overhead, |
---|
432 | CALLING_OVERHEAD_IO_CONTROL |
---|
433 | ); |
---|
434 | |
---|
435 | puts( "*** END OF TEST 20 ***" ); |
---|
436 | rtems_test_exit( 0 ); |
---|
437 | } |
---|
438 | |
---|
439 | rtems_task Task_2( |
---|
440 | rtems_task_argument argument |
---|
441 | ) |
---|
442 | { |
---|
443 | rtems_status_code status; |
---|
444 | |
---|
445 | end_time = benchmark_timer_read(); |
---|
446 | |
---|
447 | put_time( |
---|
448 | "rtems_region_get_segment: not available -- caller blocks", |
---|
449 | end_time, |
---|
450 | 1, |
---|
451 | 0, |
---|
452 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
453 | ); |
---|
454 | |
---|
455 | benchmark_timer_initialize(); |
---|
456 | (void) rtems_region_return_segment( Region_id, Buffer_address_1 ); |
---|
457 | |
---|
458 | /* preempt back to Task_1 */ |
---|
459 | |
---|
460 | benchmark_timer_initialize(); |
---|
461 | (void) rtems_region_return_segment( Region_id, Buffer_address_1 ); |
---|
462 | end_time = benchmark_timer_read(); |
---|
463 | |
---|
464 | put_time( |
---|
465 | "rtems_region_return_segment: task readied -- returns to caller", |
---|
466 | end_time, |
---|
467 | 1, |
---|
468 | 0, |
---|
469 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
470 | ); |
---|
471 | |
---|
472 | status = rtems_task_delete( RTEMS_SELF ); |
---|
473 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
474 | } |
---|