source: rtems/testsuites/sptests/sp12/init.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 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.2 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     &Semaphore_id[ 1 ]
60  );
61  directive_failed( status, "rtems_semaphore_create of SM1" );
62
63  status = rtems_semaphore_create(
64    Semaphore_name[ 2 ],
65    0,
66    RTEMS_PRIORITY,
67    &Semaphore_id[ 2 ]
68  );
69  directive_failed( status, "rtems_semaphore_create of SM2" );
70
71  status = rtems_semaphore_create(
72    Semaphore_name[ 3 ],
73    1,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    &Semaphore_id[ 3 ]
76  );
77  directive_failed( status, "rtems_semaphore_create of SM3" );
78
79  puts( "INIT - Forward priority queue test" );
80  Priority_test_driver( 0 );
81
82  puts( "INIT - Backward priority queue test" );
83  Priority_test_driver( 32 );
84
85pause();
86
87  puts( "INIT - Binary Semaphore and Priority Inheritance Test" );
88
89  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
90  directive_failed( status, "rtems_semaphore_delete of SM2" );
91
92  puts( "INIT - rtems_semaphore_create - allocated binary semaphore" );
93  status = rtems_semaphore_create(
94    Semaphore_name[ 2 ],
95    0,
96    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
97    &Semaphore_id[ 2 ]
98  );
99  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
100
101  puts( "INIT - rtems_semaphore_release - allocated binary semaphore" );
102  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
103  directive_failed( status, "rtems_semaphore_release of SM2" );
104
105  puts( "INIT - rtems_semaphore_delete - allocated binary semaphore" );
106  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
107  directive_failed( status, "rtems_semaphore_delete of SM2" );
108
109  status = rtems_semaphore_create(
110    Semaphore_name[ 2 ],
111    1,
112    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
113    &Semaphore_id[ 2 ]
114  );
115  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
116
117  Priority_test_driver( 64 );
118
119pause();
120
121  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
122  directive_failed( status, "rtems_semaphore_delete of SM2" );
123
124  status = rtems_semaphore_create(
125    Semaphore_name[ 2 ],
126    0,
127    RTEMS_PRIORITY,
128    &Semaphore_id[ 2 ]
129  );
130  directive_failed( status, "rtems_semaphore_create of priority SM2" );
131
132  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
133  directive_failed( status, "rtems_semaphore_release of SM2" );
134
135  status = rtems_task_create(
136    Task_name[ 1 ],
137    4,
138    2048,
139    RTEMS_DEFAULT_MODES,
140    RTEMS_DEFAULT_ATTRIBUTES,
141    &Task_id[ 1 ]
142  );
143  directive_failed( status, "rtems_task_create of TA1" );
144
145  status = rtems_task_create(
146    Task_name[ 2 ],
147    4,
148    2048,
149    RTEMS_DEFAULT_MODES,
150    RTEMS_DEFAULT_ATTRIBUTES,
151    &Task_id[ 2 ]
152  );
153  directive_failed( status, "rtems_task_create of TA2" );
154
155  status = rtems_task_create(
156    Task_name[ 3 ],
157    4,
158    2048,
159    RTEMS_DEFAULT_MODES,
160    RTEMS_DEFAULT_ATTRIBUTES,
161    &Task_id[ 3 ]
162  );
163  directive_failed( status, "rtems_task_create of TA3" );
164
165  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
166  directive_failed( status, "rtems_task_start of TA1" );
167
168  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
169  directive_failed( status, "rtems_task_start of TA2" );
170
171  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
172  directive_failed( status, "rtems_task_start of TA3" );
173
174  status = rtems_task_delete( RTEMS_SELF );
175  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
176}
Note: See TracBrowser for help on using the repository browser.