source: rtems/testsuites/tmtests/tm29/task1.c @ f68401e

4.115
Last change on this file since f68401e was 9410d011, checked in by Joel Sherrill <joel.sherrill@…>, on 12/07/13 at 16:38:22

tmtests: Make output more uniform

  • Property mode set to 100644
File size: 4.7 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.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
17rtems_name Period_name;
18
19rtems_task Tasks(
20  rtems_task_argument argument
21);
22
23rtems_task Low_task(
24  rtems_task_argument argument
25);
26
27uint32_t   Task_count;
28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  rtems_id          id;
34  uint32_t    index;
35  rtems_status_code status;
36
37  Print_Warning();
38
39  puts( "\n\n*** TIME TEST 29 ***" );
40
41  Period_name = rtems_build_name( 'P', 'R', 'D', ' ' );
42
43  benchmark_timer_initialize();
44    (void) rtems_rate_monotonic_create( Period_name, &id );
45  end_time = benchmark_timer_read();
46
47  put_time(
48    "rtems_rate_monotonic_create: only case",
49    end_time,
50    1,
51    0,
52    CALLING_OVERHEAD_RATE_MONOTONIC_CREATE
53  );
54
55  benchmark_timer_initialize();
56    (void) rtems_rate_monotonic_period( id, 10 );
57  end_time = benchmark_timer_read();
58
59  put_time(
60    "rtems_rate_monotonic_period: initiate period returns to caller",
61    end_time,
62    1,
63    0,
64    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
65  );
66
67  benchmark_timer_initialize();
68    (void) rtems_rate_monotonic_period( id, RTEMS_PERIOD_STATUS );
69  end_time = benchmark_timer_read();
70
71  put_time(
72    "rtems_rate_monotonic_period: obtain status",
73    end_time,
74    1,
75    0,
76    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
77  );
78
79  benchmark_timer_initialize();
80    (void) rtems_rate_monotonic_cancel( id );
81  end_time = benchmark_timer_read();
82
83  put_time(
84    "rtems_rate_monotonic_cancel: only case",
85    end_time,
86    1,
87    0,
88    CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL
89  );
90
91  benchmark_timer_initialize();
92    (void) rtems_rate_monotonic_delete( id );
93  end_time = benchmark_timer_read();
94
95  put_time(
96    "rtems_rate_monotonic_delete: inactive",
97    end_time,
98    1,
99    0,
100    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
101  );
102
103  status = rtems_rate_monotonic_create( Period_name, &id );
104  directive_failed( status, "rtems_rate_monotonic_create" );
105
106  status = rtems_rate_monotonic_period( id, 10 );
107  directive_failed( status, "rtems_rate_monotonic_period" );
108
109  benchmark_timer_initialize();
110    rtems_rate_monotonic_delete( id );
111  end_time = benchmark_timer_read();
112
113  put_time(
114    "rtems_rate_monotonic_delete: active",
115    end_time,
116    1,
117    0,
118    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
119  );
120
121#define LOOP_TASK_PRIORITY ((RTEMS_MAXIMUM_PRIORITY / 2u) + 1u)
122  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
123    status = rtems_task_create(
124      rtems_build_name( 'T', 'E', 'S', 'T' ),
125      LOOP_TASK_PRIORITY,
126      RTEMS_MINIMUM_STACK_SIZE,
127      RTEMS_DEFAULT_MODES,
128      RTEMS_DEFAULT_ATTRIBUTES,
129      &id
130    );
131    directive_failed( status, "rtems_task_create LOOP" );
132
133    status = rtems_task_start( id, Tasks, 0 );
134    directive_failed( status, "rtems_task_start LOOP" );
135  }
136
137#define MIDDLE_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 2u)
138  status = rtems_task_create(
139    rtems_build_name( 'L', 'O', 'W', ' ' ),
140    MIDDLE_PRIORITY,
141    RTEMS_MINIMUM_STACK_SIZE,
142    RTEMS_DEFAULT_MODES,
143    RTEMS_DEFAULT_ATTRIBUTES,
144    &id
145  );
146  directive_failed( status, "rtems_task_create LOW" );
147
148  status = rtems_task_start( id, Low_task, 0 );
149  directive_failed( status, "rtems_task_start LOW" );
150
151  Task_count = 0;
152
153  status = rtems_task_delete( RTEMS_SELF );
154  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
155}
156
157rtems_task Tasks(
158  rtems_task_argument argument
159)
160{
161  rtems_id          id;
162  rtems_status_code status;
163
164  status = rtems_rate_monotonic_create( 1, &id );
165  directive_failed( status, "rtems_rate_monotonic_create" );
166
167  status = rtems_rate_monotonic_period( id, 100 );
168  directive_failed( status, "rtems_rate_monotonic_period" );
169
170  /*
171   *  Give up the processor to allow all tasks to actually
172   *  create and start their period timer before the benchmark
173   *  timer is initialized.
174   */
175
176  (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
177
178  Task_count++;
179
180  if ( Task_count == 1 )
181    benchmark_timer_initialize();
182
183  (void) rtems_rate_monotonic_period( id, 100 );
184}
185
186rtems_task Low_task(
187  rtems_task_argument argument
188)
189{
190  uint32_t   index;
191
192  end_time = benchmark_timer_read();
193
194  benchmark_timer_initialize();
195    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
196      (void) benchmark_timer_empty_function();
197  overhead = benchmark_timer_read();
198
199  put_time(
200    "rtems_rate_monotonic_period: conclude periods caller blocks",
201    end_time,
202    OPERATION_COUNT,
203    overhead,
204    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
205  );
206
207  puts( "*** END OF TEST 29 ***" );
208  rtems_test_exit( 0 );
209}
Note: See TracBrowser for help on using the repository browser.