source: rtems/testsuites/itrontests/itrontask03/init.c @ 06380cfe

4.104.114.84.9
Last change on this file since 06380cfe was 06380cfe, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 15, 1999 at 9:25:53 PM

+ Added check that a task could be sent to a dormant state

then sta_tsk used to restart the task to its initial state.

+ Added calls to ref_tsk to yellow paths for suspended and

ready but not running tasks.

+ Fixed output file to correctly state test name
+ Added priority of preempt to the header file. Allows ref_tsk verification.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#define TEST_INIT
21#include "system.h"
22#include <stdio.h>
23#include <assert.h>
24
25void ITRON_Init( void )
26{
27  ER                status;
28  T_CTSK            pk_ctsk;
29  T_RTSK            pk_rtsk;
30
31  pk_ctsk.exinf    = NULL;
32  pk_ctsk.tskatr   = TA_HLNG;
33  pk_ctsk.stksz    = RTEMS_MINIMUM_STACK_SIZE; 
34  pk_ctsk.itskpri  = PREEMPT_PRIORITY; 
35  pk_ctsk.task     = Preempt_task;
36
37  puts( "\n\n*** ITRON TASK TEST 3 ***" );
38
39  /*
40   *  Create and start the Preempt task the first time.
41   *  Verify that it is dormant when it comes back.
42   */
43
44  puts( "INIT - Create and Start PREEMPT" );
45  status = chg_pri( TSK_SELF, (PREEMPT_PRIORITY+2) );
46  directive_failed( status, "chg_pri of SELF" );
47 
48  status = cre_tsk(  PREEMPT_TASK_ID, &pk_ctsk );
49  directive_failed( status, "cre_tsk of RTEMS_PREEMPT" );
50
51  status  = sta_tsk( PREEMPT_TASK_ID, 0 );
52  directive_failed( status, "sta_tsk of RTEMS_PREEMPT" );
53  puts( "INIT - rot_rdq - no tasks at this priority" );
54  status = rot_rdq( 1 );
55  directive_failed( status, "rot_rdq" );
56
57  puts( "INIT - ref_tsk PREEMPT - Validate DORMANT STATE" );
58  status = ref_tsk( &pk_rtsk, PREEMPT_TASK_ID );
59  directive_failed( status, "INIT - ref_tsk of RTEMS_PREEMPT");
60  assert( pk_rtsk.tskstat == TTS_DMT );
61 
62  /*
63   * Restart the Preempt Task.
64   */
65
66  status  = sta_tsk( PREEMPT_TASK_ID, 0 );
67  directive_failed( status, "sta_tsk of RTEMS_PREEMPT" );
68  puts( "INIT - rot_rdq - yielding processor" );
69  status = rot_rdq( 1 );
70  directive_failed( status, "rot_rdq" );
71  puts( "INIT - ref_tsk PREEMPT - Validate no longer exists" );
72  status = ref_tsk( &pk_rtsk, PREEMPT_TASK_ID );
73  assert( status == E_NOEXS );
74
75  status = chg_pri( TSK_SELF, PREEMPT_PRIORITY );
76  directive_failed( status, "chg_pri of SELF" );
77 
78  /*
79   * XXX
80   */
81       
82  pk_ctsk.itskpri  = 3; 
83  pk_ctsk.task     = Task_1;
84  status = cre_tsk( TA1_ID, &pk_ctsk );
85  directive_failed( status, "cre_tsk of TA1" );
86
87  pk_ctsk.task     = Task_2;
88  status = cre_tsk( TA2_ID, &pk_ctsk );
89  directive_failed( status, "cre_tsk of TA2" );
90
91  pk_ctsk.task     = Task_3;
92  status = cre_tsk( TA3_ID, &pk_ctsk );
93  directive_failed( status, "cre_tsk of TA3" );
94
95  status  = sta_tsk( TA1_ID, 0 );
96  directive_failed( status, "sta_tsk of TA1" );
97  status  = sta_tsk( TA2_ID, 0 );
98  directive_failed( status, "sta_tsk of TA2" );
99  status  = sta_tsk( TA3_ID, 0 );
100  directive_failed( status, "sta_tsk of TA3" );
101  puts( "INIT - ref_tsk TA1 - Validate READY STATE" );
102  status = ref_tsk( &pk_rtsk, TA1_ID);
103  directive_failed( status, "INIT - ref_tsk of TA1");
104  assert( pk_rtsk.tskstat == TTS_RDY );
105
106  puts( "INIT - suspending TA2 while middle task on a ready chain" );
107  status = sus_tsk( TA2_ID  );
108  directive_failed( status, "sus_tsk of TA2" );
109  status = ref_tsk( &pk_rtsk, TA2_ID);
110  directive_failed( status, "INIT - ref_tsk of TA2");
111  assert( pk_rtsk.tskstat == TTS_SUS );
112
113  status = ter_tsk( TA1_ID );
114  directive_failed( status, "ter_tsk of TA1" );
115  status = del_tsk( TA1_ID );
116  directive_failed( status, "del_tsk of TA1" );
117  status = ter_tsk( TA2_ID );
118  directive_failed( status, "ter_tsk of TA2" );
119  status = ter_tsk( TA3_ID );
120  directive_failed( status, "ter_tsk of TA3" );
121
122  pk_ctsk.itskpri  = 1; 
123  pk_ctsk.task     = Task_1;
124  status = cre_tsk( TA1_ID, &pk_ctsk );
125  directive_failed( status, "cre_tsk of TA1 at priority 1" );
126
127  status  = sta_tsk( TA1_ID, 0 );
128  directive_failed( status, "sta_tsk of TA1" );
129  status  = sta_tsk( TA2_ID, 0 );
130  directive_failed( status, "sta_tsk of TA2" );
131  status  = sta_tsk( TA3_ID, 0 );
132  directive_failed( status, "sta_tsk of TA3" );
133 
134  exd_tsk();
135  assert(0);
136}
137
138
139
140
141
142
Note: See TracBrowser for help on using the repository browser.