source: rtems/testsuites/tmtests/tm26/task1.c @ 459f770

4.104.114.84.95
Last change on this file since 459f770 was 459f770, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 5, 1995 at 11:55:00 PM

added calls to _Thread_Disable_dispatch to match requirements
for invocation of _Thread_Handler

  • Property mode set to 100644
File size: 9.2 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 <rtems.h>
15#include "system.h"
16#include "fptest.h"
17#include <coverhd.h>
18#include <tmacros.h>
19#include <timesys.h>
20
21#undef EXTERN
22#define EXTERN
23#include "gvar.h"
24#include "conftbl.h"
25#undef EXTERN
26#define EXTERN extern
27
28/* TEST DATA */
29rtems_id Semaphore_id;
30
31Objects_Locations location;   /* uses internal RTEMS type */
32
33Thread_Control *Middle_tcb;   /* uses internal RTEMS type */
34
35rtems_task High_task(
36  rtems_task_argument argument
37);
38
39rtems_task Middle_task(
40  rtems_task_argument argument
41);
42
43rtems_task Low_task(
44  rtems_task_argument argument
45);
46
47rtems_task Floating_point_task_1(
48  rtems_task_argument argument
49);
50
51rtems_task Floating_point_task_2(
52  rtems_task_argument argument
53);
54
55void complete_test( void );
56
57rtems_task null_task(
58  rtems_task_argument argument
59)
60{
61}
62
63rtems_task Init(
64  rtems_task_argument argument
65)
66{
67  rtems_unsigned32  index;
68  rtems_id          task_id;
69  rtems_status_code status;
70
71  puts( "\n\n*** TIME TEST 26 ***" );
72
73  status = rtems_task_create(
74    rtems_build_name( 'F', 'P', '1', ' ' ),
75    201,
76    2048,
77    RTEMS_DEFAULT_MODES,
78    RTEMS_FLOATING_POINT,
79    &task_id
80  );
81  directive_failed( status, "rtems_task_create of FP1" );
82
83  status = rtems_task_start( task_id, Floating_point_task_1, 0 );
84  directive_failed( status, "rtems_task_start of FP1" );
85
86  status = rtems_task_create(
87    rtems_build_name( 'F', 'P', '2', ' ' ),
88    202,
89    2048,
90    RTEMS_DEFAULT_MODES,
91    RTEMS_FLOATING_POINT,
92    &task_id
93  );
94  directive_failed( status, "rtems_task_create of FP2" );
95
96  status = rtems_task_start( task_id, Floating_point_task_2, 0 );
97  directive_failed( status, "rtems_task_start of FP2" );
98
99  status = rtems_task_create(
100    rtems_build_name( 'L', 'O', 'W', ' ' ),
101    200,
102    2048,
103    RTEMS_DEFAULT_MODES,
104    RTEMS_DEFAULT_ATTRIBUTES,
105    &task_id
106  );
107  directive_failed( status, "rtems_task_create of LOW" );
108
109  status = rtems_task_start( task_id, Low_task, 0 );
110  directive_failed( status, "rtems_task_start of LOW" );
111
112  status = rtems_task_create(
113    rtems_build_name( 'M', 'I', 'D', ' ' ),
114    128,
115    2048,
116    RTEMS_DEFAULT_MODES,
117    RTEMS_DEFAULT_ATTRIBUTES,
118    &task_id
119  );
120  directive_failed( status, "rtems_task_create of MIDDLE" );
121
122  status = rtems_task_start( task_id, Middle_task, 0 );
123  directive_failed( status, "rtems_task_start of MIDDLE" );
124
125  status = rtems_task_create(
126    rtems_build_name( 'H', 'I', 'G', 'H' ),
127    5,
128    2048,
129    RTEMS_DEFAULT_MODES,
130    RTEMS_DEFAULT_ATTRIBUTES,
131    &task_id
132  );
133  directive_failed( status, "rtems_task_create of HIGH" );
134
135  status = rtems_task_start( task_id, High_task, 0 );
136  directive_failed( status, "rtems_task_start of HIGH" );
137
138  status = rtems_semaphore_create(
139    rtems_build_name( 'S', 'E', 'M', '1' ),
140    OPERATION_COUNT,
141    RTEMS_DEFAULT_ATTRIBUTES,
142    &Semaphore_id
143  );
144  directive_failed( status, "rtems_semaphore_create" );
145
146  for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
147    status = rtems_task_create(
148      rtems_build_name( 'N', 'U', 'L', 'L' ),
149      254,
150      1024,
151      RTEMS_DEFAULT_MODES,
152      RTEMS_DEFAULT_ATTRIBUTES,
153      &task_id
154    );
155    directive_failed( status, "rtems_task_create LOOP" );
156
157    status = rtems_task_start( task_id, null_task, 0 );
158    directive_failed( status, "rtems_task_start LOOP" );
159  }
160
161  status = rtems_task_delete( RTEMS_SELF );
162  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
163}
164
165rtems_task High_task(
166  rtems_task_argument argument
167)
168{
169  Timer_initialize();
170    _Thread_Disable_dispatch();
171  end_time = Read_timer();
172
173  put_time(
174    "THREAD_DISABLE_DISPATCH",
175    end_time,
176    1,
177    0,
178    0
179  );
180
181
182  Timer_initialize();
183    _Thread_Enable_dispatch();
184  end_time = Read_timer();
185
186  put_time(
187    "THREAD_ENABLE_DISPATCH",
188    end_time,
189    1,
190    0,
191    0
192  );
193
194  Timer_initialize();
195    _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED );
196  end_time = Read_timer();
197
198  put_time(
199    "THREAD_SET_STATE",
200    end_time,
201    1,
202    0,
203    0
204  );
205
206  _Context_Switch_necessary = TRUE;
207
208  Timer_initialize();
209    _Thread_Dispatch();           /* dispatches Middle_task */
210}
211
212rtems_task Middle_task(
213  rtems_task_argument argument
214)
215{
216  end_time = Read_timer();
217
218  put_time(
219    "THREAD_DISPATCH (NO FP)",
220    end_time,
221    1,
222    0,
223    0
224  );
225
226  _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED );
227
228  Middle_tcb   = _Thread_Executing;
229
230  _Thread_Executing =
231        (Thread_Control *) _Thread_Ready_chain[200].first;
232
233  /* do not force context switch */
234
235  _Context_Switch_necessary = FALSE;
236
237  _Thread_Disable_dispatch();
238
239  Timer_initialize();
240    _Context_Switch( &Middle_tcb->Registers, &_Thread_Executing->Registers );
241}
242
243rtems_task Low_task(
244  rtems_task_argument argument
245)
246{
247  Thread_Control *executing;
248
249  end_time = Read_timer();
250
251  put_time(
252    "CONTEXT_SWITCH (NO FP)",
253    end_time,
254    1,
255    0,
256    0
257  );
258
259  executing    = _Thread_Executing;
260
261  _Thread_Executing =
262        (Thread_Control *) _Thread_Ready_chain[201].first;
263
264  /* do not force context switch */
265
266  _Context_Switch_necessary = FALSE;
267
268  _Thread_Disable_dispatch();
269
270  Timer_initialize();
271    _Context_Restore_fp( &_Thread_Executing->fp_context );
272    _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
273}
274
275rtems_task Floating_point_task_1(
276  rtems_task_argument argument
277)
278{
279  Thread_Control *executing;
280  FP_DECLARE;
281
282  end_time = Read_timer();
283
284  put_time(
285    "CONTEXT_SWITCH (restore 1st FP)",
286    end_time,
287    1,
288    0,
289    0
290  );
291
292  executing = _Thread_Executing;
293
294  _Thread_Executing =
295        (Thread_Control *) _Thread_Ready_chain[202].first;
296
297  /* do not force context switch */
298
299  _Context_Switch_necessary = FALSE;
300
301  _Thread_Disable_dispatch();
302
303  Timer_initialize();
304    _Context_Save_fp( &executing->fp_context );
305    _Context_Restore_fp( &_Thread_Executing->fp_context );
306    _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
307  /* switch to Floating_point_task_2 */
308
309  end_time = Read_timer();
310
311  put_time(
312    "CONTEXT_SWITCH (used->init FP)",
313    end_time,
314    1,
315    0,
316    0
317  );
318
319  FP_LOAD( 1.0 );
320
321  executing = _Thread_Executing;
322
323  _Thread_Executing =
324       (Thread_Control *) _Thread_Ready_chain[202].first;
325
326  /* do not force context switch */
327
328  _Context_Switch_necessary = FALSE;
329
330  _Thread_Disable_dispatch();
331
332  Timer_initialize();
333    _Context_Save_fp( &executing->fp_context );
334    _Context_Restore_fp( &_Thread_Executing->fp_context );
335    _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
336  /* switch to Floating_point_task_2 */
337}
338
339rtems_task Floating_point_task_2(
340  rtems_task_argument argument
341)
342{
343  Thread_Control *executing;
344  FP_DECLARE;
345
346  end_time = Read_timer();
347
348  put_time(
349    "CONTEXT_SWITCH (init->init FP)",
350    end_time,
351    1,
352    0,
353    0
354  );
355
356  executing = _Thread_Executing;
357
358  _Thread_Executing =
359       (Thread_Control *) _Thread_Ready_chain[201].first;
360
361  FP_LOAD( 1.0 );
362
363  /* do not force context switch */
364
365  _Context_Switch_necessary = FALSE;
366
367  _Thread_Disable_dispatch();
368
369  Timer_initialize();
370    _Context_Save_fp( &executing->fp_context );
371    _Context_Restore_fp( &_Thread_Executing->fp_context );
372    _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
373  /* switch to Floating_point_task_1 */
374
375  end_time = Read_timer();
376
377  put_time(
378    "CONTEXT_SWITCH (used->used FP)",
379    end_time,
380    1,
381    0,
382    0
383  );
384
385  complete_test();
386}
387
388void complete_test( void )
389{
390  rtems_unsigned32  index;
391  rtems_id          task_id;
392
393  Timer_initialize();
394    _Thread_Resume( Middle_tcb );
395  end_time = Read_timer();
396
397  put_time(
398    "THREAD_RESUME",
399    end_time,
400    1,
401    0,
402    0
403  );
404
405  _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE );
406
407  Timer_initialize();
408    _Thread_Unblock( Middle_tcb );
409  end_time = Read_timer();
410
411  put_time(
412    "THREAD_UNBLOCK",
413    end_time,
414    1,
415    0,
416    0
417  );
418
419  _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE );
420
421  Timer_initialize();
422    _Thread_Ready( Middle_tcb );
423  end_time = Read_timer();
424
425  put_time(
426    "THREAD_READY",
427    end_time,
428    1,
429    0,
430    0
431  );
432
433  Timer_initialize();
434    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
435      (void) Empty_function();
436  overhead = Read_timer();
437
438  task_id = Middle_tcb->Object.id;
439
440  Timer_initialize();
441    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
442      (void) _Thread_Get( task_id, &location );
443  end_time = Read_timer();
444
445  put_time(
446    "THREAD_GET",
447    end_time,
448    OPERATION_COUNT,
449    0,
450    0
451  );
452
453  Timer_initialize();
454    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
455      (void) _Semaphore_Get( Semaphore_id, &location );
456  end_time = Read_timer();
457
458  put_time(
459    "SEMAPHORE_GET",
460    end_time,
461    OPERATION_COUNT,
462    0,
463    0
464  );
465
466  Timer_initialize();
467    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
468      (void) _Thread_Get( 0x3, &location );
469  end_time = Read_timer();
470
471  put_time(
472    "THREAD_GET invalid id",
473    end_time,
474    OPERATION_COUNT,
475    0,
476    0
477  );
478  exit( 0 );
479}
480
Note: See TracBrowser for help on using the repository browser.