source: rtems/c/src/tests/tmtests/tm08/task1.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 19, 1995 at 2:53:29 PM

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • 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#define TEST_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();
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()
44{
45  rtems_status_code status;
46
47  status = rtems_task_create(
48    1,
49    128,
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    254,
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  rtems_unsigned32    index;
80  rtems_task_priority old_priority;
81  rtems_time_of_day   time;
82  rtems_unsigned32    old_note;
83  rtems_unsigned32    old_mode;
84
85  Timer_initialize();
86    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
87      (void) Empty_function();
88  overhead = Read_timer();
89
90  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 = Read_timer();
98
99  put_time(
100    "rtems_task_set_priority current priority",
101    end_time,
102    OPERATION_COUNT,
103    overhead,
104    CALLING_OVERHEAD_TASK_SET_PRIORITY
105  );
106
107  Timer_initialize();
108    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
109      (void) rtems_task_set_priority( Test_task_id, 253, &old_priority );
110  end_time = Read_timer();
111
112  put_time(
113    "rtems_task_set_priority no preempt",
114    end_time,
115    OPERATION_COUNT,
116    overhead,
117    CALLING_OVERHEAD_TASK_SET_PRIORITY
118  );
119
120  Timer_initialize();
121    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
122      (void) rtems_task_mode(
123        RTEMS_CURRENT_MODE,
124        RTEMS_CURRENT_MODE,
125        &old_mode
126      );
127  end_time = Read_timer();
128
129  put_time(
130    "rtems_task_mode (current)",
131    end_time,
132    OPERATION_COUNT,
133    overhead,
134    CALLING_OVERHEAD_TASK_MODE
135  );
136
137  Timer_initialize();
138    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
139      (void) rtems_task_mode(
140        RTEMS_INTERRUPT_LEVEL(1),
141        RTEMS_INTERRUPT_MASK,
142        &old_mode
143      );
144      (void) rtems_task_mode(
145        RTEMS_INTERRUPT_LEVEL(0),
146        RTEMS_INTERRUPT_MASK,
147        &old_mode
148      );
149    }
150  end_time = Read_timer();
151
152  put_time(
153    "rtems_task_mode (no reschedule)",
154    end_time,
155    OPERATION_COUNT * 2,
156    overhead,
157    CALLING_OVERHEAD_TASK_MODE
158  );
159
160  Timer_initialize();                 /* must be one host */
161    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
162  end_time = Read_timer();
163
164  put_time(
165    "rtems_task_mode (reschedule)",
166    end_time,
167    1,
168    0,
169    CALLING_OVERHEAD_TASK_MODE
170  );
171
172  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
173  directive_failed( status, "rtems_task_mode" );
174
175  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
176  directive_failed( status, "rtems_task_set_priority" );
177
178  /* preempted by test_task1 */
179  Timer_initialize();
180    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
181
182  Timer_initialize();
183    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
184      (void) rtems_task_set_note( Test_task_id, 8, 10 );
185  end_time = Read_timer();
186
187  put_time(
188    "rtems_task_set_note",
189    end_time,
190    OPERATION_COUNT,
191    overhead,
192    CALLING_OVERHEAD_TASK_SET_NOTE
193  );
194
195  Timer_initialize();
196    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
197      (void) rtems_task_get_note( Test_task_id, 8, &old_note );
198  end_time = Read_timer();
199
200  put_time(
201    "rtems_task_set_note",
202    end_time,
203    OPERATION_COUNT,
204    overhead,
205    CALLING_OVERHEAD_TASK_GET_NOTE
206  );
207
208  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
209
210  Timer_initialize();
211    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
212      (void) rtems_clock_set( &time );
213  end_time = Read_timer();
214
215  put_time(
216    "rtems_clock_set",
217    end_time,
218    OPERATION_COUNT,
219    overhead,
220    CALLING_OVERHEAD_CLOCK_SET
221  );
222
223  Timer_initialize();
224    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
225      (void) rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
226  end_time = Read_timer();
227
228  put_time(
229    "rtems_clock_get",
230    end_time,
231    OPERATION_COUNT,
232    overhead,
233    CALLING_OVERHEAD_CLOCK_GET
234  );
235
236  puts( "*** END OF TEST 8 ***" );
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.