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

4.115
Last change on this file since d1c5c01f was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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