source: rtems/testsuites/tmtests/tm08/task1.c @ e58e29fd

5
Last change on this file since e58e29fd was e58e29fd, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/17 at 06:58:55

Remove coverhd.h

This header file contained timing overhead values which are hard to
maintain.

Update #3254.

  • Property mode set to 100644
File size: 5.0 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 8";
18
19rtems_id Test_task_id;
20
21rtems_task test_task(
22  rtems_task_argument argument
23);
24rtems_task test_task1(
25  rtems_task_argument argument
26);
27void test_init(void);
28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  rtems_status_code status;
34
35  Print_Warning();
36
37  TEST_BEGIN();
38
39  test_init();
40
41  status = rtems_task_delete( RTEMS_SELF );
42  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
43}
44
45void test_init(void)
46{
47  rtems_status_code status;
48
49  status = rtems_task_create(
50    1,
51    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
52    RTEMS_MINIMUM_STACK_SIZE,
53    RTEMS_DEFAULT_MODES,
54    RTEMS_DEFAULT_ATTRIBUTES,
55    &Test_task_id
56  );
57  directive_failed( status, "rtems_task_create" );
58
59  status = rtems_task_start( Test_task_id, test_task, 0 );
60  directive_failed( status, "rtems_task_start" );
61
62  status = rtems_task_create(
63    1,
64    RTEMS_MAXIMUM_PRIORITY - 1u,
65    RTEMS_MINIMUM_STACK_SIZE,
66    RTEMS_DEFAULT_MODES,
67    RTEMS_DEFAULT_ATTRIBUTES,
68    &Test_task_id
69  );
70  directive_failed( status, "rtems_task_create" );
71
72  status = rtems_task_start( Test_task_id, test_task1, 0 );
73  directive_failed( status, "rtems_task_start" );
74}
75
76rtems_task test_task(
77  rtems_task_argument argument
78)
79{
80  rtems_status_code   status;
81  uint32_t      index;
82  rtems_task_priority old_priority;
83  rtems_time_of_day   time;
84  uint32_t      old_mode;
85
86  benchmark_timer_initialize();
87    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
88      (void) benchmark_timer_empty_function();
89  overhead = benchmark_timer_read();
90
91  benchmark_timer_initialize();
92    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
93      (void) rtems_task_set_priority(
94               Test_task_id,
95               RTEMS_CURRENT_PRIORITY,
96               &old_priority
97             );
98  end_time = benchmark_timer_read();
99
100  put_time(
101    "rtems_task_set_priority: obtain current priority",
102    end_time,
103    OPERATION_COUNT,
104    overhead,
105    0
106  );
107
108  benchmark_timer_initialize();
109    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
110      (void) rtems_task_set_priority(
111        Test_task_id,
112        RTEMS_MAXIMUM_PRIORITY - 2u,
113        &old_priority
114      );
115
116  end_time = benchmark_timer_read();
117
118  put_time(
119    "rtems_task_set_priority: returns to caller",
120    end_time,
121    OPERATION_COUNT,
122    overhead,
123    0
124  );
125
126  benchmark_timer_initialize();
127    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
128      (void) rtems_task_mode(
129        RTEMS_CURRENT_MODE,
130        RTEMS_CURRENT_MODE,
131        &old_mode
132      );
133  end_time = benchmark_timer_read();
134
135  put_time(
136    "rtems_task_mode: obtain current mode",
137    end_time,
138    OPERATION_COUNT,
139    overhead,
140    0
141  );
142
143  benchmark_timer_initialize();
144    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
145      (void) rtems_task_mode(
146        RTEMS_INTERRUPT_LEVEL(1),
147        RTEMS_INTERRUPT_MASK,
148        &old_mode
149      );
150      (void) rtems_task_mode(
151        RTEMS_INTERRUPT_LEVEL(0),
152        RTEMS_INTERRUPT_MASK,
153        &old_mode
154      );
155    }
156  end_time = benchmark_timer_read();
157
158  put_time(
159    "rtems_task_mode: no reschedule",
160    end_time,
161    OPERATION_COUNT * 2,
162    overhead,
163    0
164  );
165
166  benchmark_timer_initialize();                 /* must be one host */
167    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
168  end_time = benchmark_timer_read();
169
170  put_time(
171    "rtems_task_mode: reschedule returns to caller",
172    end_time,
173    1,
174    0,
175    0
176  );
177
178  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
179  directive_failed( status, "rtems_task_mode" );
180
181  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
182  directive_failed( status, "rtems_task_set_priority" );
183
184  /* preempted by test_task1 */
185  benchmark_timer_initialize();
186    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
187
188  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
189
190  benchmark_timer_initialize();
191    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
192      (void) rtems_clock_set( &time );
193  end_time = benchmark_timer_read();
194
195  put_time(
196    "rtems_clock_set: only case",
197    end_time,
198    OPERATION_COUNT,
199    overhead,
200    0
201  );
202
203  benchmark_timer_initialize();
204    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
205      (void) rtems_clock_get_tod( &time );
206  end_time = benchmark_timer_read();
207
208  put_time(
209    "rtems_clock_get_tod: only case",
210    end_time,
211    OPERATION_COUNT,
212    overhead,
213    0
214  );
215
216  TEST_END();
217  rtems_test_exit( 0 );
218}
219
220rtems_task test_task1(
221  rtems_task_argument argument
222)
223{
224  end_time = benchmark_timer_read();
225
226  put_time(
227    "rtems_task_mode: reschedule -- preempts caller",
228    end_time,
229    1,
230    0,
231    0
232  );
233
234  (void) rtems_task_suspend( RTEMS_SELF );
235}
Note: See TracBrowser for help on using the repository browser.