source: rtems/c/src/ada-tests/sptests/sp02/sptest.adb @ f6bcc8f5

Last change on this file since f6bcc8f5 was f6bcc8f5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 13:25:16

2003-09-04 Joel Sherrill <joel@…>

  • samples/base_sp/base_sp.adb, samples/base_sp/config.h, samples/base_sp/sptest.adb, samples/base_sp/sptest.ads, samples/hello/config.h, samples/hello/hello.adb, samples/hello/sptest.adb, samples/hello/sptest.ads, samples/ticker/config.h, samples/ticker/sptest.adb, samples/ticker/sptest.ads, samples/ticker/ticker.adb, sptests/sp01/config.h, sptests/sp01/sp01.adb, sptests/sp01/sptest.adb, sptests/sp01/sptest.ads, sptests/sp02/config.h, sptests/sp02/sp02.adb, sptests/sp02/sptest.adb, sptests/sp02/sptest.ads, sptests/sp03/config.h, sptests/sp03/sp03.adb, sptests/sp03/sptest.adb, sptests/sp03/sptest.ads, sptests/sp04/config.h, sptests/sp04/sp04.adb, sptests/sp04/sptest.adb, sptests/sp04/sptest.ads, sptests/sp05/config.h, sptests/sp05/sp05.adb, sptests/sp05/sptest.adb, sptests/sp05/sptest.ads, sptests/sp06/config.h, sptests/sp06/sp06.adb, sptests/sp06/sptest.adb, sptests/sp06/sptest.ads, sptests/sp07/config.h, sptests/sp07/sp07.adb, sptests/sp07/sptest.adb, sptests/sp07/sptest.ads, sptests/sp08/config.h, sptests/sp08/sp08.adb, sptests/sp08/sptest.adb, sptests/sp08/sptest.ads, sptests/sp09/config.h, sptests/sp09/sp09.adb, sptests/sp09/sptest.adb, sptests/sp09/sptest.ads, sptests/sp11/config.h, sptests/sp11/sp11.adb, sptests/sp11/sptest.adb, sptests/sp11/sptest.ads, sptests/sp12/config.h, sptests/sp12/sp12.adb, sptests/sp12/sptest.adb, sptests/sp12/sptest.ads, sptests/sp13/config.h, sptests/sp13/sp13.adb, sptests/sp13/sptest.adb, sptests/sp13/sptest.ads, sptests/sp14/config.h, sptests/sp14/sp14.adb, sptests/sp14/sptest.adb, sptests/sp14/sptest.ads, sptests/sp15/config.h, sptests/sp15/sp15.adb, sptests/sp15/sptest.adb, sptests/sp15/sptest.ads, sptests/sp16/config.h, sptests/sp16/sp16.adb, sptests/sp16/sptest.adb, sptests/sp16/sptest.ads, sptests/sp17/config.h, sptests/sp17/sp17.adb, sptests/sp17/sptest.adb, sptests/sp17/sptest.ads, sptests/sp19/config.h, sptests/sp19/sp19.adb, sptests/sp19/sptest.adp, sptests/sp19/sptest.ads, sptests/sp20/config.h, sptests/sp20/sp20.adb, sptests/sp20/sptest.adb, sptests/sp20/sptest.ads, sptests/sp21/config.h, sptests/sp21/sp21.adb, sptests/sp21/sptest.adb, sptests/sp21/sptest.ads, sptests/sp22/config.h, sptests/sp22/sp22.adb, sptests/sp22/sptest.adb, sptests/sp22/sptest.ads, sptests/sp23/config.h, sptests/sp23/sp23.adb, sptests/sp23/sptest.adb, sptests/sp23/sptest.ads, sptests/sp24/config.h, sptests/sp24/sp24.adb, sptests/sp24/sptest.adb, sptests/sp24/sptest.ads, sptests/sp25/config.h, sptests/sp25/sp25.adb, sptests/sp25/sptest.adb, sptests/sp25/sptest.ads, sptests/spsize/spsize.adb, sptests/spsize/sptest.adb, sptests/spsize/sptest.ads, support/address_io.adb, support/address_io.ads, support/float_io.ads, support/fp.inc, support/init.c, support/integer.inc, support/rtems_calling_overhead.ads, support/status_io.ads, support/test_support.adb, support/test_support.ads, support/time_test_support.adb, support/time_test_support.ads, support/timer_driver.adb, support/timer_driver.ads, support/unsigned32_io.ads, tmtests/tm01/config.h, tmtests/tm01/tm01.adb, tmtests/tm01/tmtest.adb, tmtests/tm01/tmtest.ads, tmtests/tm02/config.h, tmtests/tm02/tm02.adb, tmtests/tm02/tmtest.adb, tmtests/tm02/tmtest.ads, tmtests/tm03/config.h, tmtests/tm03/tm03.adb, tmtests/tm03/tmtest.adb, tmtests/tm03/tmtest.ads, tmtests/tm04/config.h, tmtests/tm04/tm04.adb, tmtests/tm04/tmtest.adb, tmtests/tm04/tmtest.ads, tmtests/tm05/config.h, tmtests/tm05/tm05.adb, tmtests/tm05/tmtest.adb, tmtests/tm05/tmtest.ads, tmtests/tm06/config.h, tmtests/tm06/tm06.adb, tmtests/tm06/tmtest.adb, tmtests/tm06/tmtest.ads, tmtests/tm07/config.h, tmtests/tm07/tm07.adb, tmtests/tm07/tmtest.adb, tmtests/tm07/tmtest.ads, tmtests/tm08/config.h, tmtests/tm08/tm08.adb, tmtests/tm08/tmtest.adb, tmtests/tm08/tmtest.ads, tmtests/tm09/config.h, tmtests/tm09/tm09.adb, tmtests/tm09/tmtest.adb, tmtests/tm09/tmtest.ads, tmtests/tm10/config.h, tmtests/tm10/tm10.adb, tmtests/tm10/tmtest.adb, tmtests/tm10/tmtest.ads, tmtests/tm11/config.h, tmtests/tm11/tm11.adb, tmtests/tm11/tmtest.adb, tmtests/tm11/tmtest.ads, tmtests/tm12/config.h, tmtests/tm12/tm12.adb, tmtests/tm12/tmtest.adb, tmtests/tm12/tmtest.ads, tmtests/tm13/config.h, tmtests/tm13/tm13.adb, tmtests/tm13/tmtest.adb, tmtests/tm13/tmtest.ads, tmtests/tm14/config.h, tmtests/tm14/tm14.adb, tmtests/tm14/tmtest.adb, tmtests/tm14/tmtest.ads, tmtests/tm15/config.h, tmtests/tm15/tm15.adb, tmtests/tm15/tmtest.adb, tmtests/tm15/tmtest.ads, tmtests/tm16/config.h, tmtests/tm16/tm16.adb, tmtests/tm16/tmtest.adb, tmtests/tm16/tmtest.ads, tmtests/tm17/config.h, tmtests/tm17/tm17.adb, tmtests/tm17/tmtest.adb, tmtests/tm17/tmtest.ads, tmtests/tm18/config.h, tmtests/tm18/tm18.adb, tmtests/tm18/tmtest.adb, tmtests/tm18/tmtest.ads, tmtests/tm19/config.h, tmtests/tm19/tm19.adb, tmtests/tm19/tmtest.adb, tmtests/tm19/tmtest.ads, tmtests/tm20/config.h, tmtests/tm20/tm20.adb, tmtests/tm20/tmtest.adb, tmtests/tm20/tmtest.ads, tmtests/tm21/config.h, tmtests/tm21/tm21.adb, tmtests/tm21/tmtest.adb, tmtests/tm21/tmtest.ads, tmtests/tm22/config.h, tmtests/tm22/tm22.adb, tmtests/tm22/tmtest.adb, tmtests/tm22/tmtest.ads, tmtests/tm23/config.h, tmtests/tm23/tm23.adb, tmtests/tm23/tmtest.adb, tmtests/tm23/tmtest.ads, tmtests/tm24/config.h, tmtests/tm24/tm24.adb, tmtests/tm24/tmtest.adb, tmtests/tm24/tmtest.ads, tmtests/tm25/config.h, tmtests/tm25/tm25.adb, tmtests/tm25/tmtest.adb, tmtests/tm25/tmtest.ads, tmtests/tm28/config.h, tmtests/tm28/tm28.adb, tmtests/tm28/tmtest.adb, tmtests/tm28/tmtest.ads, tmtests/tm29/config.h, tmtests/tm29/tm29.adb, tmtests/tm29/tmtest.adb, tmtests/tm29/tmtest.ads, tmtests/tmck/config.h, tmtests/tmck/tmck.adb, tmtests/tmck/tmtest.adb, tmtests/tmck/tmtest.ads, tmtests/tmoverhd/config.h, tmtests/tmoverhd/dummy_rtems.adb, tmtests/tmoverhd/dummy_rtems.ads, tmtests/tmoverhd/tmoverhd.adb, tmtests/tmoverhd/tmtest.adb, tmtests/tmoverhd/tmtest.ads: Removed incorrect statement about copyright assignment.
  • Property mode set to 100644
File size: 8.5 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 2 of the RTEMS
7--  Single Processor Test Suite.
8--
9--  DEPENDENCIES:
10--
11-- 
12--
13--  COPYRIGHT (c) 1989-1997.
14--  On-Line Applications Research Corporation (OAR).
15--
16--  The license and distribution terms for this file may in
17--  the file LICENSE in this distribution or at
18--  http://www.OARcorp.com/rtems/license.html.
19--
20--  $Id$
21--
22
23with INTERFACES; use INTERFACES;
24with RTEMS;
25with TEST_SUPPORT;
26with TEXT_IO;
27with UNSIGNED32_IO;
28
29package body SPTEST is
30
31--PAGE
32--
33--  INIT
34--
35
36   procedure INIT (
37      ARGUMENT : in     RTEMS.TASK_ARGUMENT
38   ) is
39      STATUS : RTEMS.STATUS_CODES;
40   begin
41
42      TEXT_IO.NEW_LINE( 2 );
43      TEXT_IO.PUT_LINE( "*** TEST 2 ***" );
44
45      SPTEST.PREEMPT_TASK_NAME := RTEMS.BUILD_NAME(  'P', 'R', 'M', 'T' );
46
47      RTEMS.TASK_CREATE(
48         SPTEST.PREEMPT_TASK_NAME,
49         1,
50         2048,
51         RTEMS.DEFAULT_MODES,
52         RTEMS.DEFAULT_ATTRIBUTES,
53         SPTEST.PREEMPT_TASK_ID,
54         STATUS
55      );
56      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF PREEMPT" );
57
58      RTEMS.TASK_START(
59         SPTEST.PREEMPT_TASK_ID,
60         SPTEST.PREEMPT_TASK'ACCESS,
61         0,
62         STATUS
63      );
64      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF PREEMPT" );
65
66      TEXT_IO.PUT_LINE( "INIT - task_wake_after - yielding processor" );
67      RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
68      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
69
70      SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
71      SPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  'T', 'A', '2', ' ' );
72      SPTEST.TASK_NAME( 3 ) := RTEMS.BUILD_NAME(  'T', 'A', '3', ' ' );
73
74      RTEMS.TASK_CREATE(
75         SPTEST.TASK_NAME( 1 ),
76         3,
77         2048,
78         RTEMS.DEFAULT_MODES,
79         RTEMS.DEFAULT_ATTRIBUTES,
80         SPTEST.TASK_ID( 1 ),
81         STATUS
82      );
83      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
84
85      RTEMS.TASK_CREATE(
86         SPTEST.TASK_NAME( 2 ),
87         3,
88         2048,
89         RTEMS.DEFAULT_MODES,
90         RTEMS.DEFAULT_ATTRIBUTES,
91         SPTEST.TASK_ID( 2 ),
92         STATUS
93      );
94      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA2" );
95
96      RTEMS.TASK_CREATE(
97         SPTEST.TASK_NAME( 3 ),
98         3,
99         2048,
100         RTEMS.DEFAULT_MODES,
101         RTEMS.DEFAULT_ATTRIBUTES,
102         SPTEST.TASK_ID( 3 ),
103         STATUS
104      );
105      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA3" );
106
107      RTEMS.TASK_START(
108         SPTEST.TASK_ID( 1 ),
109         SPTEST.TASK_1'ACCESS,
110         0,
111         STATUS
112      );
113      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
114
115      RTEMS.TASK_START(
116         SPTEST.TASK_ID( 2 ),
117         SPTEST.TASK_2'ACCESS,
118         0,
119         STATUS
120      );
121      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA2" );
122
123      RTEMS.TASK_START(
124         SPTEST.TASK_ID( 3 ),
125         SPTEST.TASK_3'ACCESS,
126         0,
127         STATUS
128      );
129      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA3" );
130
131      TEXT_IO.PUT_LINE(
132         "INIT - suspending TA2 while middle task on a ready chain"
133      );
134 
135      RTEMS.TASK_SUSPEND( SPTEST.TASK_ID( 2 ), STATUS );
136      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND OF TA2" );
137
138      RTEMS.TASK_DELETE( SPTEST.TASK_ID( 1 ), STATUS );
139      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF TA1" );
140
141      RTEMS.TASK_DELETE( SPTEST.TASK_ID( 2 ), STATUS );
142      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF TA2" );
143
144      RTEMS.TASK_DELETE( SPTEST.TASK_ID( 3 ), STATUS );
145      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF TA3" );
146
147      RTEMS.TASK_CREATE(
148         SPTEST.TASK_NAME( 1 ),
149         1,
150         2048,
151         RTEMS.DEFAULT_MODES,
152         RTEMS.DEFAULT_ATTRIBUTES,
153         SPTEST.TASK_ID( 1 ),
154         STATUS
155      );
156      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
157
158      RTEMS.TASK_CREATE(
159         SPTEST.TASK_NAME( 2 ),
160         3,
161         2048,
162         RTEMS.DEFAULT_MODES,
163         RTEMS.DEFAULT_ATTRIBUTES,
164         SPTEST.TASK_ID( 2 ),
165         STATUS
166      );
167      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA2" );
168
169      RTEMS.TASK_CREATE(
170         SPTEST.TASK_NAME( 3 ),
171         3,
172         2048,
173         RTEMS.DEFAULT_MODES,
174         RTEMS.DEFAULT_ATTRIBUTES,
175         SPTEST.TASK_ID( 3 ),
176         STATUS
177      );
178      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA3" );
179
180      RTEMS.TASK_START(
181         SPTEST.TASK_ID( 1 ),
182         SPTEST.TASK_1'ACCESS,
183         0,
184         STATUS
185      );
186      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
187
188      RTEMS.TASK_START(
189         SPTEST.TASK_ID( 2 ),
190         SPTEST.TASK_2'ACCESS,
191         0,
192         STATUS
193      );
194      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA2" );
195
196      RTEMS.TASK_START(
197         SPTEST.TASK_ID( 3 ),
198         SPTEST.TASK_3'ACCESS,
199         0,
200         STATUS
201      );
202      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA3" );
203
204      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
205      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
206
207   end INIT;
208
209--PAGE
210--
211--  PREEMPT_TASK
212--
213
214   procedure PREEMPT_TASK (
215      ARGUMENT : in     RTEMS.TASK_ARGUMENT
216   ) is
217      STATUS            : RTEMS.STATUS_CODES;
218   begin
219
220      TEXT_IO.PUT_LINE( "PREEMPT - task_delete - deleting self" );
221      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
222      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF PREEMPT" );
223
224   end PREEMPT_TASK;
225
226--PAGE
227--
228--  TASK_1
229--
230
231   procedure TASK_1 (
232      ARGUMENT : in     RTEMS.TASK_ARGUMENT
233   ) is
234      TID2              : RTEMS.ID;
235      TID3              : RTEMS.ID;
236      STATUS            : RTEMS.STATUS_CODES;
237      PREVIOUS_PRIORITY : RTEMS.TASK_PRIORITY;
238   begin
239
240      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - sleep 1 second" );
241      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
242      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
243         
244      RTEMS.TASK_IDENT(
245         SPTEST.TASK_NAME( 2 ),
246         RTEMS.SEARCH_ALL_NODES,
247         TID2,
248         STATUS
249      );
250      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_IDENT OF TA2" );
251   
252      TEXT_IO.PUT( "TA1 - task_ident - tid of TA2 (" );
253      UNSIGNED32_IO.PUT( TID2, WIDTH => 8, BASE => 10#16# );
254      TEXT_IO.PUT_LINE( ")" );
255
256      RTEMS.TASK_IDENT(
257         SPTEST.TASK_NAME( 3 ),
258         RTEMS.SEARCH_ALL_NODES,
259         TID3,
260         STATUS
261      );
262      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_IDENT OF TA3" );
263   
264      TEXT_IO.PUT( "TA1 - task_ident - tid of TA3 (" );
265      UNSIGNED32_IO.PUT( TID3, WIDTH => 8, BASE => 10#16# );
266      TEXT_IO.PUT_LINE( ")" );
267
268      RTEMS.TASK_SET_PRIORITY( TID3, 2, PREVIOUS_PRIORITY, STATUS );
269      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SET_PRIORITY" );
270
271      TEXT_IO.PUT_LINE(
272         "TA1 - task_set_priority - set TA3's priority to 2"
273      );
274
275      TEXT_IO.PUT_LINE( "TA1 - task_suspend - suspend TA2" );
276      RTEMS.TASK_SUSPEND( TID2, STATUS );
277      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND OF TA2" );
278
279      TEXT_IO.PUT_LINE( "TA1 - task_delete - delete TA2" );
280      RTEMS.TASK_DELETE( TID2, STATUS );
281      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF TA2" );
282
283      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - sleep for 5 seconds" );
284      RTEMS.TASK_WAKE_AFTER( 5 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
285      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
286
287      TEXT_IO.PUT_LINE( "*** END OF TEST 2 ***" );
288      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
289   
290   end TASK_1;
291
292--PAGE
293--
294--  TASK_2
295--
296
297   procedure TASK_2 (
298      ARGUMENT : in     RTEMS.TASK_ARGUMENT
299   ) is
300      STATUS : RTEMS.STATUS_CODES;
301   begin
302
303      TEXT_IO.PUT_LINE( "TA2 - task_wake_after - sleep 1 minute" );
304      RTEMS.TASK_WAKE_AFTER( 60 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
305      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER IN TA2" );
306         
307   end TASK_2;
308
309--PAGE
310--
311--  TASK_3
312--
313
314   procedure TASK_3 (
315      ARGUMENT : in     RTEMS.TASK_ARGUMENT
316   ) is
317      STATUS : RTEMS.STATUS_CODES;
318   begin
319
320      TEXT_IO.PUT_LINE( "TA3 - task_wake_after - sleep 5 seconds" );
321      RTEMS.TASK_WAKE_AFTER( 5 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
322      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER IN TA3" );
323
324      TEXT_IO.PUT_LINE( "TA3 - task_delete - delete self" );
325      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
326      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF TA3" );
327         
328   end TASK_3;
329
330end SPTEST;
Note: See TracBrowser for help on using the repository browser.