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_id Timer_id[ OPERATION_COUNT+1 ]; |
---|
18 | |
---|
19 | rtems_time_of_day time_of_day; |
---|
20 | |
---|
21 | void null_delay( |
---|
22 | rtems_id ignored_id, |
---|
23 | void *ignored_address |
---|
24 | ); |
---|
25 | |
---|
26 | rtems_task Low_task( |
---|
27 | rtems_task_argument argument |
---|
28 | ); |
---|
29 | |
---|
30 | rtems_task Middle_tasks( |
---|
31 | rtems_task_argument argument |
---|
32 | ); |
---|
33 | |
---|
34 | rtems_task High_task( |
---|
35 | rtems_task_argument argument |
---|
36 | ); |
---|
37 | |
---|
38 | int operation_count = OPERATION_COUNT; |
---|
39 | |
---|
40 | rtems_task Init( |
---|
41 | rtems_task_argument argument |
---|
42 | ) |
---|
43 | { |
---|
44 | |
---|
45 | rtems_task_priority priority; |
---|
46 | int index; |
---|
47 | rtems_id id; |
---|
48 | rtems_task_entry task_entry; |
---|
49 | rtems_status_code status; |
---|
50 | |
---|
51 | Print_Warning(); |
---|
52 | |
---|
53 | puts( "\n\n*** TIME TEST 23 ***" ); |
---|
54 | |
---|
55 | benchmark_timer_initialize(); |
---|
56 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
57 | (void) benchmark_timer_empty_function(); |
---|
58 | overhead = benchmark_timer_read(); |
---|
59 | |
---|
60 | priority = 2; |
---|
61 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 ) |
---|
62 | operation_count = RTEMS_MAXIMUM_PRIORITY - 2; |
---|
63 | |
---|
64 | for( index=1 ; index <= operation_count ; index++ ) { |
---|
65 | status = rtems_task_create( |
---|
66 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
67 | priority, |
---|
68 | RTEMS_MINIMUM_STACK_SIZE, |
---|
69 | RTEMS_DEFAULT_MODES, |
---|
70 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
71 | &id |
---|
72 | ); |
---|
73 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
74 | |
---|
75 | if ( index == 1 ) task_entry = High_task; |
---|
76 | else if ( index == operation_count ) task_entry = Low_task; |
---|
77 | else task_entry = Middle_tasks; |
---|
78 | |
---|
79 | status = rtems_task_start( id, task_entry, 0 ); |
---|
80 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
81 | |
---|
82 | priority++; |
---|
83 | } |
---|
84 | |
---|
85 | status = rtems_task_delete( RTEMS_SELF ); |
---|
86 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
87 | } |
---|
88 | |
---|
89 | void null_delay( |
---|
90 | rtems_id ignored_id, |
---|
91 | void *ignored_address |
---|
92 | ) |
---|
93 | { |
---|
94 | } |
---|
95 | |
---|
96 | rtems_task High_task( |
---|
97 | rtems_task_argument argument |
---|
98 | ) |
---|
99 | { |
---|
100 | uint32_t index; |
---|
101 | rtems_status_code status; |
---|
102 | int i; |
---|
103 | |
---|
104 | benchmark_timer_initialize(); |
---|
105 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
106 | (void) benchmark_timer_empty_function(); |
---|
107 | overhead = benchmark_timer_read(); |
---|
108 | |
---|
109 | benchmark_timer_initialize(); |
---|
110 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
111 | (void) rtems_timer_create( index, &Timer_id[ index ] ); |
---|
112 | end_time = benchmark_timer_read(); |
---|
113 | |
---|
114 | put_time( |
---|
115 | "rtems_timer_create", |
---|
116 | end_time, |
---|
117 | OPERATION_COUNT, |
---|
118 | overhead, |
---|
119 | CALLING_OVERHEAD_TIMER_CREATE |
---|
120 | ); |
---|
121 | |
---|
122 | benchmark_timer_initialize(); |
---|
123 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
124 | (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
125 | end_time = benchmark_timer_read(); |
---|
126 | |
---|
127 | put_time( |
---|
128 | "rtems_timer_fire_after: inactive", |
---|
129 | end_time, |
---|
130 | OPERATION_COUNT, |
---|
131 | overhead, |
---|
132 | CALLING_OVERHEAD_TIMER_FIRE_AFTER |
---|
133 | ); |
---|
134 | |
---|
135 | benchmark_timer_initialize(); |
---|
136 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
137 | (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
138 | end_time = benchmark_timer_read(); |
---|
139 | |
---|
140 | put_time( |
---|
141 | "rtems_timer_fire_after: active", |
---|
142 | end_time, |
---|
143 | OPERATION_COUNT, |
---|
144 | overhead, |
---|
145 | CALLING_OVERHEAD_TIMER_FIRE_AFTER |
---|
146 | ); |
---|
147 | |
---|
148 | benchmark_timer_initialize(); |
---|
149 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
150 | (void) rtems_timer_cancel( Timer_id[ index ] ); |
---|
151 | end_time = benchmark_timer_read(); |
---|
152 | |
---|
153 | put_time( |
---|
154 | "rtems_timer_cancel: active", |
---|
155 | end_time, |
---|
156 | OPERATION_COUNT, |
---|
157 | overhead, |
---|
158 | CALLING_OVERHEAD_TIMER_CANCEL |
---|
159 | ); |
---|
160 | |
---|
161 | for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) |
---|
162 | benchmark_timer_initialize(); |
---|
163 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
164 | (void) rtems_timer_cancel( Timer_id[ index ] ); |
---|
165 | end_time = benchmark_timer_read(); |
---|
166 | |
---|
167 | put_time( |
---|
168 | "rtems_timer_cancel: inactive", |
---|
169 | end_time, |
---|
170 | OPERATION_COUNT, |
---|
171 | overhead, |
---|
172 | CALLING_OVERHEAD_TIMER_CANCEL |
---|
173 | ); |
---|
174 | |
---|
175 | for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) |
---|
176 | benchmark_timer_initialize(); |
---|
177 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
178 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
179 | end_time = benchmark_timer_read(); |
---|
180 | |
---|
181 | put_time( |
---|
182 | "rtems_timer_reset: inactive", |
---|
183 | end_time, |
---|
184 | OPERATION_COUNT, |
---|
185 | overhead, |
---|
186 | CALLING_OVERHEAD_TIMER_RESET |
---|
187 | ); |
---|
188 | |
---|
189 | benchmark_timer_initialize(); |
---|
190 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
191 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
192 | end_time = benchmark_timer_read(); |
---|
193 | |
---|
194 | put_time( |
---|
195 | "rtems_timer_reset: active", |
---|
196 | end_time, |
---|
197 | OPERATION_COUNT, |
---|
198 | overhead, |
---|
199 | CALLING_OVERHEAD_TIMER_RESET |
---|
200 | ); |
---|
201 | |
---|
202 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
203 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
204 | |
---|
205 | build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 ); |
---|
206 | |
---|
207 | status = rtems_clock_set( &time_of_day ); |
---|
208 | directive_failed( status, "rtems_clock_set" ); |
---|
209 | |
---|
210 | time_of_day.year = 1989; |
---|
211 | |
---|
212 | benchmark_timer_initialize(); |
---|
213 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
214 | (void) rtems_timer_fire_when( |
---|
215 | Timer_id[ index ], &time_of_day, null_delay, NULL ); |
---|
216 | end_time = benchmark_timer_read(); |
---|
217 | |
---|
218 | put_time( |
---|
219 | "rtems_timer_fire_when: inactive", |
---|
220 | end_time, |
---|
221 | OPERATION_COUNT, |
---|
222 | overhead, |
---|
223 | CALLING_OVERHEAD_TIMER_FIRE_WHEN |
---|
224 | ); |
---|
225 | |
---|
226 | benchmark_timer_initialize(); |
---|
227 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
228 | (void) rtems_timer_fire_when( |
---|
229 | Timer_id[ index ], &time_of_day, null_delay, NULL ); |
---|
230 | end_time = benchmark_timer_read(); |
---|
231 | |
---|
232 | put_time( |
---|
233 | "rtems_timer_fire_when: active", |
---|
234 | end_time, |
---|
235 | OPERATION_COUNT, |
---|
236 | overhead, |
---|
237 | CALLING_OVERHEAD_TIMER_FIRE_WHEN |
---|
238 | ); |
---|
239 | |
---|
240 | benchmark_timer_initialize(); |
---|
241 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
242 | (void) rtems_timer_delete( Timer_id[ index ] ); |
---|
243 | end_time = benchmark_timer_read(); |
---|
244 | |
---|
245 | put_time( |
---|
246 | "rtems_timer_delete: active", |
---|
247 | end_time, |
---|
248 | OPERATION_COUNT, |
---|
249 | overhead, |
---|
250 | CALLING_OVERHEAD_TIMER_DELETE |
---|
251 | ); |
---|
252 | |
---|
253 | benchmark_timer_initialize(); |
---|
254 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
255 | status = rtems_timer_create( index, &Timer_id[ index ] ); |
---|
256 | directive_failed( status, "rtems_timer_create" ); |
---|
257 | |
---|
258 | status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
259 | directive_failed( status, "rtems_timer_fire_after" ); |
---|
260 | |
---|
261 | status = rtems_timer_cancel( Timer_id[ index ] ); |
---|
262 | directive_failed( status, "rtems_timer_cancel" ); |
---|
263 | } |
---|
264 | |
---|
265 | benchmark_timer_initialize(); |
---|
266 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
267 | (void) rtems_timer_delete( Timer_id[ index ] ); |
---|
268 | end_time = benchmark_timer_read(); |
---|
269 | |
---|
270 | put_time( |
---|
271 | "rtems_timer_delete: inactive", |
---|
272 | end_time, |
---|
273 | OPERATION_COUNT, |
---|
274 | overhead, |
---|
275 | CALLING_OVERHEAD_TIMER_DELETE |
---|
276 | ); |
---|
277 | |
---|
278 | benchmark_timer_initialize(); |
---|
279 | (void) rtems_task_wake_when( &time_of_day ); |
---|
280 | } |
---|
281 | |
---|
282 | rtems_task Middle_tasks( |
---|
283 | rtems_task_argument argument |
---|
284 | ) |
---|
285 | { |
---|
286 | (void) rtems_task_wake_when( &time_of_day ); |
---|
287 | } |
---|
288 | |
---|
289 | rtems_task Low_task( |
---|
290 | rtems_task_argument argument |
---|
291 | ) |
---|
292 | { |
---|
293 | end_time = benchmark_timer_read(); |
---|
294 | |
---|
295 | put_time( |
---|
296 | "rtems_task_wake_when", |
---|
297 | end_time, |
---|
298 | operation_count, |
---|
299 | 0, |
---|
300 | CALLING_OVERHEAD_TASK_WAKE_WHEN |
---|
301 | ); |
---|
302 | |
---|
303 | puts( "*** END OF TEST 23 ***" ); |
---|
304 | rtems_test_exit( 0 ); |
---|
305 | } |
---|