source: rtems/testsuites/sptests/sp12/init.c @ 7f6a24ab

4.104.114.84.9
Last change on this file since 7f6a24ab was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 28, 1995 at 3:30:29 PM

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is a user initialization task 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:
10 *    argument - task argument
11 *
12 *  Output parameters:  NONE
13 *
14 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
15 *  On-Line Applications Research Corporation (OAR).
16 *  All rights assigned to U.S. Government, 1994.
17 *
18 *  This material may be reproduced by or for the U.S. Government pursuant
19 *  to the copyright license under the clause at DFARS 252.227-7013.  This
20 *  notice must appear in all copies of this file and its derivatives.
21 *
22 *  $Id$
23 */
24
25#include "system.h"
26#undef EXTERN
27#define EXTERN
28#include "conftbl.h"
29#include "gvar.h"
30
31rtems_task Init(
32  rtems_task_argument argument
33)
34{
35  rtems_status_code status;
36
37  puts( "\n\n*** TEST 12 ***" );
38
39  Task_name[ 1 ]          = rtems_build_name( 'T', 'A', '1', ' ' );
40  Task_name[ 2 ]          = rtems_build_name( 'T', 'A', '2', ' ' );
41  Task_name[ 3 ]          = rtems_build_name( 'T', 'A', '3', ' ' );
42  Task_name[ 4 ]          = rtems_build_name( 'T', 'A', '4', ' ' );
43  Task_name[ 5 ]          = rtems_build_name( 'T', 'A', '5', ' ' );
44
45  Priority_task_name[ 1 ] = rtems_build_name( 'P', 'R', 'I', '1' );
46  Priority_task_name[ 2 ] = rtems_build_name( 'P', 'R', 'I', '2' );
47  Priority_task_name[ 3 ] = rtems_build_name( 'P', 'R', 'I', '3' );
48  Priority_task_name[ 4 ] = rtems_build_name( 'P', 'R', 'I', '4' );
49  Priority_task_name[ 5 ] = rtems_build_name( 'P', 'R', 'I', '5' );
50
51  Semaphore_name[ 1 ]     = rtems_build_name( 'S', 'M', '1', ' ' );
52  Semaphore_name[ 2 ]     = rtems_build_name( 'S', 'M', '2', ' ' );
53  Semaphore_name[ 3 ]     = rtems_build_name( 'S', 'M', '3', ' ' );
54
55  status = rtems_semaphore_create(
56    Semaphore_name[ 1 ],
57    1,
58    RTEMS_DEFAULT_ATTRIBUTES,
59    RTEMS_NO_PRIORITY,
60    &Semaphore_id[ 1 ]
61  );
62  directive_failed( status, "rtems_semaphore_create of SM1" );
63
64  status = rtems_semaphore_create(
65    Semaphore_name[ 2 ],
66    0,
67    RTEMS_PRIORITY,
68    RTEMS_NO_PRIORITY,
69    &Semaphore_id[ 2 ]
70  );
71  directive_failed( status, "rtems_semaphore_create of SM2" );
72
73  status = rtems_semaphore_create(
74    Semaphore_name[ 3 ],
75    1,
76    RTEMS_DEFAULT_ATTRIBUTES,
77    RTEMS_NO_PRIORITY,
78    &Semaphore_id[ 3 ]
79  );
80  directive_failed( status, "rtems_semaphore_create of SM3" );
81
82  puts( "INIT - Forward priority queue test" );
83  Priority_test_driver( 0 );
84
85  puts( "INIT - Backward priority queue test" );
86  Priority_test_driver( 32 );
87
88pause();
89
90  puts( "INIT - Binary Semaphore and Priority Inheritance Test" );
91
92  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
93  directive_failed( status, "rtems_semaphore_delete of SM2" );
94
95  puts( "INIT - rtems_semaphore_create - allocated binary semaphore" );
96  status = rtems_semaphore_create(
97    Semaphore_name[ 2 ],
98    0,
99    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
100    RTEMS_NO_PRIORITY,
101    &Semaphore_id[ 2 ]
102  );
103  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
104
105  puts( "INIT - rtems_semaphore_release - allocated binary semaphore" );
106  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
107  directive_failed( status, "rtems_semaphore_release of SM2" );
108
109  puts( "INIT - rtems_semaphore_delete - allocated binary semaphore" );
110  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
111  directive_failed( status, "rtems_semaphore_delete of SM2" );
112
113  status = rtems_semaphore_create(
114    Semaphore_name[ 2 ],
115    1,
116    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
117    RTEMS_NO_PRIORITY,
118    &Semaphore_id[ 2 ]
119  );
120  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
121
122  Priority_test_driver( 64 );
123
124pause();
125
126  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
127  directive_failed( status, "rtems_semaphore_delete of SM2" );
128
129  status = rtems_semaphore_create(
130    Semaphore_name[ 2 ],
131    0,
132    RTEMS_PRIORITY,
133    RTEMS_NO_PRIORITY,
134    &Semaphore_id[ 2 ]
135  );
136  directive_failed( status, "rtems_semaphore_create of priority SM2" );
137
138  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
139  directive_failed( status, "rtems_semaphore_release of SM2" );
140
141  status = rtems_task_create(
142    Task_name[ 1 ],
143    4,
144    2048,
145    RTEMS_DEFAULT_MODES,
146    RTEMS_DEFAULT_ATTRIBUTES,
147    &Task_id[ 1 ]
148  );
149  directive_failed( status, "rtems_task_create of TA1" );
150
151  status = rtems_task_create(
152    Task_name[ 2 ],
153    4,
154    2048,
155    RTEMS_DEFAULT_MODES,
156    RTEMS_DEFAULT_ATTRIBUTES,
157    &Task_id[ 2 ]
158  );
159  directive_failed( status, "rtems_task_create of TA2" );
160
161  status = rtems_task_create(
162    Task_name[ 3 ],
163    4,
164    2048,
165    RTEMS_DEFAULT_MODES,
166    RTEMS_DEFAULT_ATTRIBUTES,
167    &Task_id[ 3 ]
168  );
169  directive_failed( status, "rtems_task_create of TA3" );
170
171  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
172  directive_failed( status, "rtems_task_start of TA1" );
173
174  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
175  directive_failed( status, "rtems_task_start of TA2" );
176
177  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
178  directive_failed( status, "rtems_task_start of TA3" );
179
180  status = rtems_task_delete( RTEMS_SELF );
181  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
182}
Note: See TracBrowser for help on using the repository browser.