source: rtems/testsuites/tmtests/tm23/task1.c @ fdeaa64

5
Last change on this file since fdeaa64 was fdeaa64, checked in by Sebastian Huber <sebastian.huber@…>, on 03/03/20 at 12:01:56

config: Remove <rtems/btimer.h> include

The use of CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER does not define
anything, so remove the <rtems/btimer.h> include.

Update #3875.

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