source: rtems/c/src/ada-tests/sptests/sp22/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: 7.9 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 22 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      TIME   : RTEMS.TIME_OF_DAY;
40      STATUS : RTEMS.STATUS_CODES;
41   begin
42
43      TEXT_IO.NEW_LINE( 2 );
44      TEXT_IO.PUT_LINE( "*** TEST 22 ***" );
45
46      TIME := ( 1988, 12, 31, 9, 0, 0, 0 );
47
48      RTEMS.CLOCK_SET( TIME, STATUS );
49      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
50
51      SPTEST.TASK_NAME( 1 )  := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
52      SPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'M', '1', ' ' );
53
54      RTEMS.TASK_CREATE(
55         SPTEST.TASK_NAME( 1 ),
56         1,
57         2048,
58         RTEMS.DEFAULT_MODES,
59         RTEMS.DEFAULT_ATTRIBUTES,
60         SPTEST.TASK_ID( 1 ),
61         STATUS
62      );
63      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
64
65      RTEMS.TASK_START(
66         SPTEST.TASK_ID( 1 ),
67         SPTEST.TASK_1'ACCESS,
68         0,
69         STATUS
70      );
71      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
72
73      TEXT_IO.PUT_LINE( "INIT - timer_create - creating timer 1" );
74      RTEMS.TIMER_CREATE(
75         SPTEST.TIMER_NAME( 1 ),
76         SPTEST.TIMER_ID( 1 ),
77         STATUS
78      );
79      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE OF TM1" );
80      TEXT_IO.PUT( "INIT - timer 1 has id (" );
81      UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
82      TEXT_IO.PUT_LINE( ")" );
83     
84      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
85      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
86
87   end INIT;
88
89--PAGE
90--
91--  DELAYED_RESUME
92--
93
94   procedure DELAYED_RESUME (
95      IGNORED_ID      : in     RTEMS.ID;
96      IGNORED_ADDRESS : in     RTEMS.ADDRESS
97   ) is
98      STATUS : RTEMS.STATUS_CODES;
99   begin
100
101      RTEMS.TASK_RESUME( SPTEST.TASK_ID( 1 ), STATUS );
102      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME OF SELF" );
103
104   end DELAYED_RESUME;
105
106--PAGE
107--
108--  PRINT_TIME
109--
110
111   procedure PRINT_TIME
112   is
113      TIME   : RTEMS.TIME_OF_DAY;
114      STATUS : RTEMS.STATUS_CODES;
115   begin
116
117      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
118      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
119
120      TEST_SUPPORT.PUT_NAME(
121         SPTEST.TASK_NAME( 1 ),
122         FALSE
123      );
124
125      TEST_SUPPORT.PRINT_TIME( "- clock_get - ", TIME, "" );
126      TEXT_IO.NEW_LINE;
127
128   end PRINT_TIME;
129   
130--PAGE
131--
132--  TASK_1
133--
134
135   procedure TASK_1 (
136      ARGUMENT : in     RTEMS.TASK_ARGUMENT
137   ) is
138      TMID   : RTEMS.ID;
139      TIME   : RTEMS.TIME_OF_DAY;
140      STATUS : RTEMS.STATUS_CODES;
141   begin
142
143-- GET ID
144
145      TEXT_IO.PUT_LINE( "TA1 - timer_ident - identing timer 1" );
146      RTEMS.TIMER_IDENT( SPTEST.TIMER_NAME( 1 ), TMID, STATUS );
147      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_IDENT OF TM1" );
148      TEXT_IO.PUT( "TA1 - timer 1 has id (" );
149      UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
150      TEXT_IO.PUT_LINE( ")" );
151   
152-- AFTER WHICH IS ALLOWED TO FIRE
153
154      SPTEST.PRINT_TIME;
155
156      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
157      RTEMS.TIMER_FIRE_AFTER(
158         TMID,
159         3 * TEST_SUPPORT.TICKS_PER_SECOND,
160         SPTEST.DELAYED_RESUME'ACCESS,
161         RTEMS.NULL_ADDRESS,
162         STATUS
163      );
164      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
165
166      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
167      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
168      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
169         
170      SPTEST.PRINT_TIME;
171
172-- AFTER WHICH IS RESET AND ALLOWED TO FIRE
173
174      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
175      RTEMS.TIMER_FIRE_AFTER(
176         TMID,
177         3 * TEST_SUPPORT.TICKS_PER_SECOND,
178         SPTEST.DELAYED_RESUME'ACCESS,
179         RTEMS.NULL_ADDRESS,
180         STATUS
181      );
182      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
183
184      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
185      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
186      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
187         
188      SPTEST.PRINT_TIME;
189
190      TEXT_IO.PUT_LINE( "TA1 - timer_reset - timer 1" );
191      RTEMS.TIMER_RESET( TMID, STATUS );
192      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_RESET" );
193         
194      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
195      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
196      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
197
198      SPTEST.PRINT_TIME;
199
200TEST_SUPPORT.PAUSE;
201
202--
203-- Reset the time since we do not know how long the user waited
204-- before pressing <cr> at the pause.  This insures that the
205-- actual output matches the screen.
206--
207
208      TIME := ( 1988, 12, 31, 9, 0, 7, 0 );
209
210      RTEMS.CLOCK_SET( TIME, STATUS );
211      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
212
213-- after which is canceled
214
215      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
216      RTEMS.TIMER_FIRE_AFTER(
217         TMID,
218         3 * TEST_SUPPORT.TICKS_PER_SECOND,
219         SPTEST.DELAYED_RESUME'ACCESS,
220         RTEMS.NULL_ADDRESS,
221         STATUS
222      );
223      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
224
225      TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
226      RTEMS.TIMER_CANCEL( TMID, STATUS );
227      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
228         
229-- when which is allowed to fire
230
231      SPTEST.PRINT_TIME;
232
233      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
234      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
235
236      TIME.SECOND := TIME.SECOND + 3;
237
238      TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
239      RTEMS.TIMER_FIRE_WHEN(
240         TMID,
241         TIME,
242         SPTEST.DELAYED_RESUME'ACCESS,
243         RTEMS.NULL_ADDRESS,
244         STATUS
245      );
246      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
247
248      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
249      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
250      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
251
252      SPTEST.PRINT_TIME;
253
254-- when which is canceled
255
256      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
257      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
258
259      TIME.SECOND := TIME.SECOND + 3;
260
261      TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
262      RTEMS.TIMER_FIRE_WHEN(
263         TMID,
264         TIME,
265         SPTEST.DELAYED_RESUME'ACCESS,
266         RTEMS.NULL_ADDRESS,
267         STATUS
268      );
269      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
270
271      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
272      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
273      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
274         
275      SPTEST.PRINT_TIME;
276
277      TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
278      RTEMS.TIMER_CANCEL( TMID, STATUS );
279      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
280         
281-- delete
282         
283      TEXT_IO.PUT_LINE(
284         "TA1 - task_wake_after - YIELD (only task at priority)"
285      );
286      RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
287      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER YIELD" );
288         
289      TEXT_IO.PUT_LINE( "TA1 - timer_delete - timer 1" );
290      RTEMS.TIMER_DELETE( TMID, STATUS );
291      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_DELETE" );
292         
293      TEXT_IO.PUT_LINE( "*** END OF TEST 22 ***" );
294      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
295   
296   end TASK_1;
297
298end SPTEST;
Note: See TracBrowser for help on using the repository browser.