source: rtems/testsuites/tmtests/tm08/task1.c @ 4074e70b

4.104.114.95
Last change on this file since 4074e70b was 4074e70b, checked in by Joel Sherrill <joel.sherrill@…>, on 08/31/08 at 16:47:18

2008-08-31 Joel Sherrill <joel.sherrill@…>

  • tm01/task1.c, tm02/task1.c, tm03/task1.c, tm04/task1.c, tm05/task1.c, tm06/task1.c, tm07/task1.c, tm08/task1.c, tm09/task1.c, tm10/task1.c, tm11/task1.c, tm12/task1.c, tm13/task1.c, tm14/task1.c, tm15/task1.c, tm16/task1.c, tm17/task1.c, tm18/task1.c, tm19/task1.c, tm20/task1.c, tm21/task1.c, tm22/task1.c, tm23/task1.c, tm24/task1.c, tm25/task1.c, tm26/task1.c, tm27/task1.c, tm28/task1.c, tm29/task1.c, tmck/task1.c, tmoverhd/testtask.c: Rename timer driver methods to follow RTEMS programming conventions.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-1999.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 */
12
13#define CONFIGURE_INIT
14#include "system.h"
15
16rtems_id Test_task_id;
17
18rtems_task test_task(
19  rtems_task_argument argument
20);
21rtems_task test_task1(
22  rtems_task_argument argument
23);
24void test_init();
25
26rtems_task Init(
27  rtems_task_argument argument
28)
29{
30  rtems_status_code status;
31
32  Print_Warning();
33
34  puts( "\n\n*** TIME TEST 8 ***" );
35
36  test_init();
37
38  status = rtems_task_delete( RTEMS_SELF );
39  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
40}
41
42void test_init()
43{
44  rtems_status_code status;
45
46  status = rtems_task_create(
47    1,
48    128,
49    RTEMS_MINIMUM_STACK_SIZE,
50    RTEMS_DEFAULT_MODES,
51    RTEMS_DEFAULT_ATTRIBUTES,
52    &Test_task_id
53  );
54  directive_failed( status, "rtems_task_create" );
55
56  status = rtems_task_start( Test_task_id, test_task, 0 );
57  directive_failed( status, "rtems_task_start" );
58
59  status = rtems_task_create(
60    1,
61    254,
62    RTEMS_MINIMUM_STACK_SIZE,
63    RTEMS_DEFAULT_MODES,
64    RTEMS_DEFAULT_ATTRIBUTES,
65    &Test_task_id
66  );
67  directive_failed( status, "rtems_task_create" );
68
69  status = rtems_task_start( Test_task_id, test_task1, 0 );
70  directive_failed( status, "rtems_task_start" );
71}
72
73rtems_task test_task(
74  rtems_task_argument argument
75)
76{
77  rtems_status_code   status;
78  uint32_t      index;
79  rtems_task_priority old_priority;
80  rtems_time_of_day   time;
81  uint32_t      old_note;
82  uint32_t      old_mode;
83
84  benchmark_timerinitialize();
85    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
86      (void) benchmark_timerempty_function();
87  overhead = benchmark_timerread();
88
89  benchmark_timerinitialize();
90    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
91      (void) rtems_task_set_priority(
92               Test_task_id,
93               RTEMS_CURRENT_PRIORITY,
94               &old_priority
95             );
96  end_time = benchmark_timerread();
97
98  put_time(
99    "rtems_task_set_priority: obtain current priority",
100    end_time,
101    OPERATION_COUNT,
102    overhead,
103    CALLING_OVERHEAD_TASK_SET_PRIORITY
104  );
105
106  benchmark_timerinitialize();
107    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
108      (void) rtems_task_set_priority( Test_task_id, 253, &old_priority );
109  end_time = benchmark_timerread();
110
111  put_time(
112    "rtems_task_set_priority: returns to caller",
113    end_time,
114    OPERATION_COUNT,
115    overhead,
116    CALLING_OVERHEAD_TASK_SET_PRIORITY
117  );
118
119  benchmark_timerinitialize();
120    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
121      (void) rtems_task_mode(
122        RTEMS_CURRENT_MODE,
123        RTEMS_CURRENT_MODE,
124        &old_mode
125      );
126  end_time = benchmark_timerread();
127
128  put_time(
129    "rtems_task_mode: obtain current mode",
130    end_time,
131    OPERATION_COUNT,
132    overhead,
133    CALLING_OVERHEAD_TASK_MODE
134  );
135
136  benchmark_timerinitialize();
137    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
138      (void) rtems_task_mode(
139        RTEMS_INTERRUPT_LEVEL(1),
140        RTEMS_INTERRUPT_MASK,
141        &old_mode
142      );
143      (void) rtems_task_mode(
144        RTEMS_INTERRUPT_LEVEL(0),
145        RTEMS_INTERRUPT_MASK,
146        &old_mode
147      );
148    }
149  end_time = benchmark_timerread();
150
151  put_time(
152    "rtems_task_mode: no reschedule",
153    end_time,
154    OPERATION_COUNT * 2,
155    overhead,
156    CALLING_OVERHEAD_TASK_MODE
157  );
158
159  benchmark_timerinitialize();                 /* must be one host */
160    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
161  end_time = benchmark_timerread();
162
163  put_time(
164    "rtems_task_mode: reschedule -- returns to caller",
165    end_time,
166    1,
167    0,
168    CALLING_OVERHEAD_TASK_MODE
169  );
170
171  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
172  directive_failed( status, "rtems_task_mode" );
173
174  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
175  directive_failed( status, "rtems_task_set_priority" );
176
177  /* preempted by test_task1 */
178  benchmark_timerinitialize();
179    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
180
181  benchmark_timerinitialize();
182    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
183      (void) rtems_task_set_note( Test_task_id, 8, 10 );
184  end_time = benchmark_timerread();
185
186  put_time(
187    "rtems_task_set_note",
188    end_time,
189    OPERATION_COUNT,
190    overhead,
191    CALLING_OVERHEAD_TASK_SET_NOTE
192  );
193
194  benchmark_timerinitialize();
195    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
196      (void) rtems_task_get_note( Test_task_id, 8, &old_note );
197  end_time = benchmark_timerread();
198
199  put_time(
200    "rtems_task_get_note",
201    end_time,
202    OPERATION_COUNT,
203    overhead,
204    CALLING_OVERHEAD_TASK_GET_NOTE
205  );
206
207  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
208
209  benchmark_timerinitialize();
210    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
211      (void) rtems_clock_set( &time );
212  end_time = benchmark_timerread();
213
214  put_time(
215    "rtems_clock_set",
216    end_time,
217    OPERATION_COUNT,
218    overhead,
219    CALLING_OVERHEAD_CLOCK_SET
220  );
221
222  benchmark_timerinitialize();
223    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
224      (void) rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
225  end_time = benchmark_timerread();
226
227  put_time(
228    "rtems_clock_get",
229    end_time,
230    OPERATION_COUNT,
231    overhead,
232    CALLING_OVERHEAD_CLOCK_GET
233  );
234
235  puts( "*** END OF TEST 8 ***" );
236  rtems_test_exit( 0 );
237}
238
239rtems_task test_task1(
240  rtems_task_argument argument
241)
242{
243  end_time = benchmark_timerread();
244
245  put_time(
246    "rtems_task_mode: reschedule -- preempts caller",
247    end_time,
248    1,
249    0,
250    CALLING_OVERHEAD_TASK_MODE
251  );
252
253  (void) rtems_task_suspend( RTEMS_SELF );
254}
Note: See TracBrowser for help on using the repository browser.