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

4.104.115
Last change on this file since a986c075 was a986c075, checked in by Joel Sherrill <joel.sherrill@…>, on 12/14/08 at 18:36:00

2008-12-14 Joel Sherrill <joel.sherrill@…>

  • sp07/init.c, sp12/init.c, sp12/pridrv.c, sp12/pritask.c, sp12/system.h, sp16/system.h, sp25/system.h, sp26/task1.c, sp28/init.c, sp29/init.c, sp35/priinv.c, sp42/init.c: Run all tests successfully with maxixum number of priorities as 16 instead of 256. This was done by temporarily modifying the score priority.h maximum. This allowed testing of all API code to ensure that it worked properly with a reduced number of priorities. Most modifications were to switch from hard-coded maximum to using the API provided methods to determine maximum number of priority levels.
  • 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-2008.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.com/license/LICENSE.
20 *
21 *  $Id$
22 */
23
24#define CONFIGURE_INIT
25#include "system.h"
26
27rtems_task Init(
28  rtems_task_argument argument
29)
30{
31  rtems_status_code status;
32
33  puts( "\n\n*** TEST 12 ***" );
34
35  Task_name[ 1 ]          = rtems_build_name( 'T', 'A', '1', ' ' );
36  Task_name[ 2 ]          = rtems_build_name( 'T', 'A', '2', ' ' );
37  Task_name[ 3 ]          = rtems_build_name( 'T', 'A', '3', ' ' );
38  Task_name[ 4 ]          = rtems_build_name( 'T', 'A', '4', ' ' );
39  Task_name[ 5 ]          = rtems_build_name( 'T', 'A', '5', ' ' );
40
41  Priority_task_name[ 1 ] = rtems_build_name( 'P', 'R', 'I', '1' );
42  Priority_task_name[ 2 ] = rtems_build_name( 'P', 'R', 'I', '2' );
43  Priority_task_name[ 3 ] = rtems_build_name( 'P', 'R', 'I', '3' );
44  Priority_task_name[ 4 ] = rtems_build_name( 'P', 'R', 'I', '4' );
45  Priority_task_name[ 5 ] = rtems_build_name( 'P', 'R', 'I', '5' );
46
47  Semaphore_name[ 1 ]     = rtems_build_name( 'S', 'M', '1', ' ' );
48  Semaphore_name[ 2 ]     = rtems_build_name( 'S', 'M', '2', ' ' );
49  Semaphore_name[ 3 ]     = rtems_build_name( 'S', 'M', '3', ' ' );
50
51  status = rtems_semaphore_create(
52    Semaphore_name[ 1 ],
53    1,
54    RTEMS_DEFAULT_ATTRIBUTES,
55    RTEMS_NO_PRIORITY,
56    &Semaphore_id[ 1 ]
57  );
58  directive_failed( status, "rtems_semaphore_create of SM1" );
59
60  status = rtems_semaphore_create(
61    Semaphore_name[ 2 ],
62    0,
63    RTEMS_PRIORITY,
64    RTEMS_NO_PRIORITY,
65    &Semaphore_id[ 2 ]
66  );
67  directive_failed( status, "rtems_semaphore_create of SM2" );
68
69  status = rtems_semaphore_create(
70    Semaphore_name[ 3 ],
71    1,
72    RTEMS_DEFAULT_ATTRIBUTES,
73    RTEMS_NO_PRIORITY,
74    &Semaphore_id[ 3 ]
75  );
76  directive_failed( status, "rtems_semaphore_create of SM3" );
77
78  puts( "INIT - Forward priority queue test" );
79  Priority_test_driver( 0 );
80
81  puts( "INIT - Backward priority queue test" );
82  Priority_test_driver( (RTEMS_MAXIMUM_PRIORITY / 2) + 1 );
83
84rtems_test_pause();
85
86  puts( "INIT - Binary Semaphore and Priority Inheritance Test" );
87
88  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
89  directive_failed( status, "rtems_semaphore_delete of SM2 #1" );
90
91  puts( "INIT - rtems_semaphore_create - allocated binary semaphore" );
92  status = rtems_semaphore_create(
93    Semaphore_name[ 2 ],
94    0,
95    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
96    RTEMS_NO_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 #2" );
108
109  status = rtems_semaphore_create(
110    Semaphore_name[ 2 ],
111    1,
112    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
113    RTEMS_NO_PRIORITY,
114    &Semaphore_id[ 2 ]
115  );
116  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
117
118  Priority_test_driver( PRIORITY_INHERIT_BASE_PRIORITY );
119
120rtems_test_pause();
121
122  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
123  directive_failed( status, "rtems_semaphore_delete of SM2 #3" );
124
125  status = rtems_semaphore_create(
126    Semaphore_name[ 2 ],
127    0,
128    RTEMS_PRIORITY,
129    RTEMS_NO_PRIORITY,
130    &Semaphore_id[ 2 ]
131  );
132  directive_failed( status, "rtems_semaphore_create of priority SM2" );
133
134  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
135  directive_failed( status, "rtems_semaphore_release of SM2" );
136
137  status = rtems_task_create(
138    Task_name[ 1 ],
139    4,
140    RTEMS_MINIMUM_STACK_SIZE * 2,
141    RTEMS_DEFAULT_MODES,
142    RTEMS_DEFAULT_ATTRIBUTES,
143    &Task_id[ 1 ]
144  );
145  directive_failed( status, "rtems_task_create of TA1" );
146
147  status = rtems_task_create(
148    Task_name[ 2 ],
149    4,
150    RTEMS_MINIMUM_STACK_SIZE,
151    RTEMS_DEFAULT_MODES,
152    RTEMS_DEFAULT_ATTRIBUTES,
153    &Task_id[ 2 ]
154  );
155  directive_failed( status, "rtems_task_create of TA2" );
156
157  status = rtems_task_create(
158    Task_name[ 3 ],
159    4,
160    RTEMS_MINIMUM_STACK_SIZE,
161    RTEMS_DEFAULT_MODES,
162    RTEMS_DEFAULT_ATTRIBUTES,
163    &Task_id[ 3 ]
164  );
165  directive_failed( status, "rtems_task_create of TA3" );
166
167  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
168  directive_failed( status, "rtems_task_start of TA1" );
169
170  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
171  directive_failed( status, "rtems_task_start of TA2" );
172
173  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
174  directive_failed( status, "rtems_task_start of TA3" );
175
176  status = rtems_task_delete( RTEMS_SELF );
177  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
178}
Note: See TracBrowser for help on using the repository browser.