source: rtems/testsuites/tmtests/tm08/task1.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
4 *  On-Line Applications Research Corporation (OAR).
5 *  All rights assigned to U.S. Government, 1994.
6 *
7 *  This material may be reproduced by or for the U.S. Government pursuant
8 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9 *  notice must appear in all copies of this file and its derivatives.
10 *
11 *  $Id$
12 */
13
14#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20rtems_id Test_task_id;
21
22rtems_task test_task(
23  rtems_task_argument argument
24);
25rtems_task test_task1(
26  rtems_task_argument argument
27);
28void test_init();
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35
36  puts( "\n\n*** TIME TEST 8 ***" );
37
38  test_init();
39
40  status = rtems_task_delete( RTEMS_SELF );
41  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
42}
43
44void test_init()
45{
46  rtems_status_code status;
47
48  status = rtems_task_create(
49    1,
50    128,
51    1024,
52    RTEMS_DEFAULT_MODES,
53    RTEMS_DEFAULT_ATTRIBUTES,
54    &Test_task_id
55  );
56  directive_failed( status, "rtems_task_create" );
57
58  status = rtems_task_start( Test_task_id, test_task, 0 );
59  directive_failed( status, "rtems_task_start" );
60
61  status = rtems_task_create(
62    1,
63    254,
64    1024,
65    RTEMS_DEFAULT_MODES,
66    RTEMS_DEFAULT_ATTRIBUTES,
67    &Test_task_id
68  );
69  directive_failed( status, "rtems_task_create" );
70
71  status = rtems_task_start( Test_task_id, test_task1, 0 );
72  directive_failed( status, "rtems_task_start" );
73}
74
75rtems_task test_task(
76  rtems_task_argument argument
77)
78{
79  rtems_status_code   status;
80  rtems_unsigned32    index;
81  rtems_task_priority old_priority;
82  rtems_time_of_day   time;
83  rtems_unsigned32    old_note;
84  rtems_unsigned32    old_mode;
85
86  Timer_initialize();
87    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
88      (void) Empty_function();
89  overhead = Read_timer();
90
91  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 = Read_timer();
99
100  put_time(
101    "rtems_task_set_priority current priority",
102    end_time,
103    OPERATION_COUNT,
104    overhead,
105    CALLING_OVERHEAD_TASK_SET_PRIORITY
106  );
107
108  Timer_initialize();
109    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
110      (void) rtems_task_set_priority( Test_task_id, 253, &old_priority );
111  end_time = Read_timer();
112
113  put_time(
114    "rtems_task_set_priority no preempt",
115    end_time,
116    OPERATION_COUNT,
117    overhead,
118    CALLING_OVERHEAD_TASK_SET_PRIORITY
119  );
120
121  Timer_initialize();
122    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
123      (void) rtems_task_mode(
124        RTEMS_CURRENT_MODE,
125        RTEMS_CURRENT_MODE,
126        &old_mode
127      );
128  end_time = Read_timer();
129
130  put_time(
131    "rtems_task_mode (current)",
132    end_time,
133    OPERATION_COUNT,
134    overhead,
135    CALLING_OVERHEAD_TASK_MODE
136  );
137
138  Timer_initialize();
139    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
140      (void) rtems_task_mode(
141        RTEMS_INTERRUPT_LEVEL(1),
142        RTEMS_INTERRUPT_MASK,
143        &old_mode
144      );
145      (void) rtems_task_mode(
146        RTEMS_INTERRUPT_LEVEL(0),
147        RTEMS_INTERRUPT_MASK,
148        &old_mode
149      );
150    }
151  end_time = Read_timer();
152
153  put_time(
154    "rtems_task_mode (no reschedule)",
155    end_time,
156    OPERATION_COUNT * 2,
157    overhead,
158    CALLING_OVERHEAD_TASK_MODE
159  );
160
161  Timer_initialize();                 /* must be one host */
162    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
163  end_time = Read_timer();
164
165  put_time(
166    "rtems_task_mode (reschedule)",
167    end_time,
168    1,
169    0,
170    CALLING_OVERHEAD_TASK_MODE
171  );
172
173  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
174  directive_failed( status, "rtems_task_mode" );
175
176  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
177  directive_failed( status, "rtems_task_set_priority" );
178
179  /* preempted by test_task1 */
180  Timer_initialize();
181    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
182
183  Timer_initialize();
184    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
185      (void) rtems_task_set_note( Test_task_id, 8, 10 );
186  end_time = Read_timer();
187
188  put_time(
189    "rtems_task_set_note",
190    end_time,
191    OPERATION_COUNT,
192    overhead,
193    CALLING_OVERHEAD_TASK_SET_NOTE
194  );
195
196  Timer_initialize();
197    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
198      (void) rtems_task_get_note( Test_task_id, 8, &old_note );
199  end_time = Read_timer();
200
201  put_time(
202    "rtems_task_set_note",
203    end_time,
204    OPERATION_COUNT,
205    overhead,
206    CALLING_OVERHEAD_TASK_GET_NOTE
207  );
208
209  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
210
211  Timer_initialize();
212    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
213      (void) rtems_clock_set( &time );
214  end_time = Read_timer();
215
216  put_time(
217    "rtems_clock_set",
218    end_time,
219    OPERATION_COUNT,
220    overhead,
221    CALLING_OVERHEAD_CLOCK_SET
222  );
223
224  Timer_initialize();
225    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
226      (void) rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
227  end_time = Read_timer();
228
229  put_time(
230    "rtems_clock_get",
231    end_time,
232    OPERATION_COUNT,
233    overhead,
234    CALLING_OVERHEAD_CLOCK_GET
235  );
236
237  exit( 0 );
238}
239
240rtems_task test_task1(
241  rtems_task_argument argument
242)
243{
244  end_time = Read_timer();
245
246  put_time(
247    "rtems_task_mode (preemptive)",
248    end_time,
249    1,
250    0,
251    CALLING_OVERHEAD_TASK_MODE
252  );
253
254  (void) rtems_task_suspend( RTEMS_SELF );
255}
Note: See TracBrowser for help on using the repository browser.