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 24"; |
---|
43 | |
---|
44 | uint32_t Task_count; |
---|
45 | |
---|
46 | rtems_task Tasks( |
---|
47 | rtems_task_argument argument |
---|
48 | ); |
---|
49 | |
---|
50 | rtems_task High_task( |
---|
51 | rtems_task_argument argument |
---|
52 | ); |
---|
53 | |
---|
54 | rtems_task Init( |
---|
55 | rtems_task_argument argument |
---|
56 | ) |
---|
57 | { |
---|
58 | rtems_id id; |
---|
59 | uint32_t index; |
---|
60 | rtems_status_code status; |
---|
61 | |
---|
62 | Print_Warning(); |
---|
63 | |
---|
64 | TEST_BEGIN(); |
---|
65 | |
---|
66 | status = rtems_task_create( |
---|
67 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
68 | 1, |
---|
69 | RTEMS_MINIMUM_STACK_SIZE, |
---|
70 | RTEMS_DEFAULT_MODES, |
---|
71 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
72 | &id |
---|
73 | ); |
---|
74 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
75 | |
---|
76 | status = rtems_task_start( id, High_task, 0 ); |
---|
77 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
78 | |
---|
79 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
80 | status = rtems_task_create( |
---|
81 | rtems_build_name( 'R', 'E', 'S', 'T' ), |
---|
82 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
83 | RTEMS_MINIMUM_STACK_SIZE, |
---|
84 | RTEMS_DEFAULT_MODES, |
---|
85 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
86 | &id |
---|
87 | ); |
---|
88 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
89 | |
---|
90 | status = rtems_task_start( id, Tasks, 0 ); |
---|
91 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
92 | } |
---|
93 | rtems_task_exit(); |
---|
94 | } |
---|
95 | |
---|
96 | rtems_task High_task( |
---|
97 | rtems_task_argument argument |
---|
98 | ) |
---|
99 | { |
---|
100 | uint32_t index; |
---|
101 | |
---|
102 | benchmark_timer_initialize(); |
---|
103 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
104 | (void) benchmark_timer_empty_function(); |
---|
105 | overhead = benchmark_timer_read(); |
---|
106 | |
---|
107 | benchmark_timer_initialize(); |
---|
108 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
109 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
110 | end_time = benchmark_timer_read(); |
---|
111 | |
---|
112 | put_time( |
---|
113 | "rtems_task_wake_after: yield returns to caller", |
---|
114 | end_time, |
---|
115 | OPERATION_COUNT, |
---|
116 | overhead, |
---|
117 | 0 |
---|
118 | ); |
---|
119 | |
---|
120 | Task_count = 0; |
---|
121 | |
---|
122 | rtems_task_exit(); |
---|
123 | } |
---|
124 | |
---|
125 | rtems_task Tasks( |
---|
126 | rtems_task_argument argument |
---|
127 | ) |
---|
128 | { |
---|
129 | Task_count++; |
---|
130 | |
---|
131 | if ( Task_count == 1 ) |
---|
132 | benchmark_timer_initialize(); |
---|
133 | else if ( Task_count == OPERATION_COUNT ) { |
---|
134 | end_time = benchmark_timer_read(); |
---|
135 | |
---|
136 | put_time( |
---|
137 | "rtems_task_wake_after: yields preempts caller", |
---|
138 | end_time, |
---|
139 | OPERATION_COUNT, |
---|
140 | overhead, |
---|
141 | 0 |
---|
142 | ); |
---|
143 | |
---|
144 | TEST_END(); |
---|
145 | rtems_test_exit( 0 ); |
---|
146 | } |
---|
147 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
148 | } |
---|