source: rtems/testsuites/tmtests/tm23/task1.c @ 2ead50a

4.115
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on 03/21/14 at 15:48:01

tmtests: convert to test.h

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