source: rtems/c/src/ada-tests/sptests/sp06/sptest.adb @ 110e1f1

4.104.115
Last change on this file since 110e1f1 was 110e1f1, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 14, 2009 at 9:17:59 PM

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

  • samples/base_sp/sptest.adb, samples/hello/sptest.adb, samples/nsecs/sptest.adb, samples/ticker/sptest.adb, sptests/sp01/sptest.adb, sptests/sp02/sptest.adb, sptests/sp03/sptest.adb, sptests/sp04/sptest.adb, sptests/sp05/sptest.adb, sptests/sp06/sptest.adb, sptests/sp07/sptest.adb, sptests/sp08/sptest.adb, sptests/sp09/sptest.adb, sptests/sp11/sptest.adb, sptests/sp12/sptest.adb, sptests/sp13/sptest.adb, sptests/sp14/sptest.adb, sptests/sp15/sptest.adb, sptests/sp16/sptest.adb, sptests/sp17/sptest.adb, sptests/sp19/sptest.adp, sptests/sp20/sptest.adb, sptests/sp22/sptest.adb, sptests/sp23/sptest.adb, sptests/sp24/sptest.adb, sptests/sp25/sptest.adb, sptests/spname01/spname01.adb, sptests/spname01/sptest.adb, sptests/spname01/sptest.ads, support/address_io.adb, support/init.c, support/test_support.adb, support/test_support.ads, support/time_test_support.adb, support/timer_driver.adb, tmtests/tm01/tmtest.adb, tmtests/tm01/tmtest.ads, tmtests/tm02/tmtest.adb, tmtests/tm02/tmtest.ads, tmtests/tm03/tmtest.adb, tmtests/tm03/tmtest.ads, tmtests/tm04/tmtest.adb, tmtests/tm04/tmtest.ads, tmtests/tm05/tmtest.adb, tmtests/tm05/tmtest.ads, tmtests/tm06/tmtest.adb, tmtests/tm06/tmtest.ads, tmtests/tm07/tmtest.adb, tmtests/tm07/tmtest.ads, tmtests/tm08/tmtest.adb, tmtests/tm08/tmtest.ads, tmtests/tm09/tmtest.adb, tmtests/tm09/tmtest.ads, tmtests/tm10/tmtest.adb, tmtests/tm10/tmtest.ads, tmtests/tm11/tmtest.adb, tmtests/tm11/tmtest.ads, tmtests/tm12/tmtest.adb, tmtests/tm12/tmtest.ads, tmtests/tm13/tmtest.adb, tmtests/tm13/tmtest.ads, tmtests/tm14/tmtest.adb, tmtests/tm14/tmtest.ads, tmtests/tm15/tmtest.adb, tmtests/tm15/tmtest.ads, tmtests/tm16/tmtest.adb, tmtests/tm16/tmtest.ads, tmtests/tm17/tmtest.adb, tmtests/tm17/tmtest.ads, tmtests/tm18/tmtest.adb, tmtests/tm18/tmtest.ads, tmtests/tm19/tmtest.adb, tmtests/tm19/tmtest.ads, tmtests/tm20/tmtest.adb, tmtests/tm20/tmtest.ads, tmtests/tm21/tmtest.adb, tmtests/tm21/tmtest.ads, tmtests/tm22/tmtest.adb, tmtests/tm22/tmtest.ads, tmtests/tm23/tmtest.adb, tmtests/tm23/tmtest.ads, tmtests/tm24/tmtest.adb, tmtests/tm24/tmtest.ads, tmtests/tm25/tmtest.adb, tmtests/tm25/tmtest.ads, tmtests/tm28/tmtest.adb, tmtests/tm28/tmtest.ads, tmtests/tm29/tmtest.adb, tmtests/tm29/tmtest.ads, tmtests/tmck/tmtest.adb, tmtests/tmck/tmtest.ads, tmtests/tmoverhd/dummy_rtems.adb, tmtests/tmoverhd/tmtest.adb, tmtests/tmoverhd/tmtest.ads: Remove many warnings.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 6 of the RTEMS
7--  Single Processor Test Suite.
8--
9--  DEPENDENCIES:
10--
11-- 
12--
13--  COPYRIGHT (c) 1989-2009.
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.rtems.com/license/LICENSE.
19--
20--  $Id$
21--
22
23with INTERFACES; use INTERFACES;
24with TEST_SUPPORT;
25with TEXT_IO;
26
27package body SPTEST is
28
29--PAGE
30--
31--  INIT
32--
33
34   procedure INIT (
35      ARGUMENT : in     RTEMS.TASK_ARGUMENT
36   ) is
37      pragma Unreferenced(ARGUMENT);
38      STATUS            : RTEMS.STATUS_CODES;
39      PREVIOUS_PRIORITY : RTEMS.TASK_PRIORITY;
40   begin
41
42      TEXT_IO.NEW_LINE( 2 );
43      TEXT_IO.PUT_LINE( "*** TEST 6 ***" );
44
45      SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
46      SPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  'T', 'A', '2', ' ' );
47      SPTEST.TASK_NAME( 3 ) := RTEMS.BUILD_NAME(  'T', 'A', '3', ' ' );
48
49      SPTEST.ARGUMENT := 0;
50      SPTEST.RESTART_ARGUMENT := 1;
51
52      RTEMS.TASK_CREATE( 
53         SPTEST.TASK_NAME( 1 ), 
54         1, 
55         2048, 
56         RTEMS.DEFAULT_MODES,
57         RTEMS.DEFAULT_ATTRIBUTES,
58         SPTEST.TASK_ID( 1 ),
59         STATUS
60      );
61      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
62
63      RTEMS.TASK_CREATE( 
64         SPTEST.TASK_NAME( 2 ), 
65         1, 
66         2048, 
67         RTEMS.DEFAULT_MODES,
68         RTEMS.DEFAULT_ATTRIBUTES,
69         SPTEST.TASK_ID( 2 ),
70         STATUS
71      );
72      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA2" );
73
74      RTEMS.TASK_CREATE( 
75         SPTEST.TASK_NAME( 3 ), 
76         10, 
77         2048, 
78         RTEMS.DEFAULT_MODES,
79         RTEMS.DEFAULT_ATTRIBUTES,
80         SPTEST.TASK_ID( 3 ),
81         STATUS
82      );
83      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA3" );
84
85      RTEMS.TASK_START(
86         SPTEST.TASK_ID( 1 ),
87         SPTEST.TASK_1'ACCESS,
88         0,
89         STATUS
90      );
91      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
92
93      RTEMS.TASK_START(
94         SPTEST.TASK_ID( 2 ),
95         SPTEST.TASK_2'ACCESS,
96         SPTEST.ARGUMENT,
97         STATUS
98      );
99      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA2" );
100
101      RTEMS.TASK_START(
102         SPTEST.TASK_ID( 3 ),
103         SPTEST.TASK_3'ACCESS,
104         SPTEST.ARGUMENT,
105         STATUS
106      );
107      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA3" );
108
109      RTEMS.TASK_SET_PRIORITY(
110         SPTEST.TASK_ID( 3 ),
111         5,
112         PREVIOUS_PRIORITY,
113         STATUS
114      );
115      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SET_PRIORITY OF TA3" );
116
117      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
118      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
119
120   end INIT;
121
122--PAGE
123--
124--  TASK_1
125--
126
127   procedure TASK_1 (
128      ARGUMENT : in     RTEMS.TASK_ARGUMENT
129   ) is
130      PASS   : RTEMS.UNSIGNED32;
131      STATUS : RTEMS.STATUS_CODES;
132   begin
133
134      TEXT_IO.PUT_LINE( "TA1 - is beginning to run" );
135
136      PASS := ARGUMENT + 1;
137
138      if PASS = 5 then
139         TEXT_IO.PUT_LINE( "*** END OF TEST 6 ***" );
140         RTEMS.SHUTDOWN_EXECUTIVE( 0 );
141      end if;
142
143      if PASS = 1 then
144         TEXT_IO.PUT_LINE( "TA1 - restarting TA3" );
145         RTEMS.TASK_RESTART( 
146            SPTEST.TASK_ID( 3 ), 
147            SPTEST.RESTART_ARGUMENT, 
148            STATUS
149         );
150         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESTART OF TA3" );
151
152         RTEMS.TASK_WAKE_AFTER( 2 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
153         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
154
155      end if;
156
157      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
158      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
159
160      TEXT_IO.PUT_LINE( "TA1 - task_restart - restarting TA2" );
161      RTEMS.TASK_RESTART( 
162         SPTEST.TASK_ID( 2 ), 
163         SPTEST.RESTART_ARGUMENT, 
164         STATUS
165      );
166      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESTART OF TA2" );
167
168      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
169      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
170
171      TEXT_IO.PUT_LINE( "TA1 - task_restart - restarting self" );
172      RTEMS.TASK_RESTART( SPTEST.TASK_ID( 1 ), PASS, STATUS );
173      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESTART OF SELF" );
174
175   end TASK_1;
176
177--PAGE
178--
179--  TASK_2
180--
181
182   procedure TASK_2 (
183      ARGUMENT : in     RTEMS.TASK_ARGUMENT
184   ) is
185      STATUS : RTEMS.STATUS_CODES;
186   begin
187
188      TEXT_IO.PUT_LINE( "TA2 - is beginning to run" );
189
190      if ARGUMENT = SPTEST.ARGUMENT then
191         RTEMS.TASK_WAKE_AFTER( 2 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
192         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
193      end if;
194
195      loop
196
197         TEXT_IO.PUT_LINE( "TA2 - task_wake_after - sleep 1/2 second" );
198         RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND / 2, STATUS );
199         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
200
201      end loop;
202
203   end TASK_2;
204
205--PAGE
206--
207--  TASK_3
208--
209
210   procedure TASK_3 (
211      ARGUMENT : in     RTEMS.TASK_ARGUMENT
212   ) is
213      pragma Unreferenced(ARGUMENT);
214      STATUS : RTEMS.STATUS_CODES;
215   begin
216
217      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
218      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
219
220   end TASK_3;
221
222end SPTEST;
Note: See TracBrowser for help on using the repository browser.