source: rtems/c/src/ada-tests/mptests/mp13/mptest.adb @ bb483c7

4.104.114.84.95
Last change on this file since bb483c7 was 35e4691, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:50:41 PM

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

  • mptests/mp01/config.h, mptests/mp01/mp01.adb, mptests/mp01/mptest.adb, mptests/mp01/mptest.ads, mptests/mp02/mptest.adb, mptests/mp02/mptest.ads, mptests/mp03/mptest.adb, mptests/mp03/mptest.ads, mptests/mp04/mptest.adb, mptests/mp04/mptest.ads, mptests/mp05/mptest.adb, mptests/mp05/mptest.ads, mptests/mp06/mptest.adb, mptests/mp06/mptest.ads, mptests/mp07/mptest.adb, mptests/mp07/mptest.ads, mptests/mp08/mptest.adb, mptests/mp08/mptest.ads, mptests/mp09/mptest.adb, mptests/mp09/mptest.ads, mptests/mp10/mptest.adb, mptests/mp10/mptest.ads, mptests/mp11/mptest.adb, mptests/mp11/mptest.ads, mptests/mp12/mptest.adb, mptests/mp12/mptest.ads, mptests/mp13/mptest.adb, mptests/mp13/mptest.ads, mptests/mp14/mptest.adb, mptests/mp14/mptest.ads, samples/base_mp/config.h, samples/base_mp/mptest.adb, samples/base_mp/mptest.ads, 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.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/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: URL for license changed.
  • Property mode set to 100644
File size: 8.7 KB
Line 
1--
2--  MPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation for Test 13 of the RTEMS
7--  Multiprocessor 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.rtems.com/license/LICENSE.
19--
20--  $Id$
21--
22
23with INTERFACES; use INTERFACES;
24with RTEMS;
25with TEST_SUPPORT;
26with TEXT_IO;
27with UNSIGNED32_IO;
28
29package body MPTEST is
30
31   package body PER_NODE_CONFIGURATION is separate;
32
33--PAGE
34--
35--  INIT
36--
37
38   procedure INIT (
39      ARGUMENT : in     RTEMS.TASK_ARGUMENT
40   ) is
41      STATUS : RTEMS.STATUS_CODES;
42   begin
43
44      TEXT_IO.NEW_LINE( 2 );
45      TEXT_IO.PUT( "*** TEST 13 -- NODE " );
46      UNSIGNED32_IO.PUT(
47         MPTEST.MULTIPROCESSING_CONFIGURATION.NODE,
48         WIDTH => 1
49      );
50      TEXT_IO.PUT_LINE( " ***" );
51
52      MPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  '1', '1', '1', ' ' );
53      MPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  '2', '2', '2', ' ' );
54
55      MPTEST.QUEUE_NAME( 1 ) := RTEMS.BUILD_NAME(  'M', 'S', 'G', ' ' );
56
57      MPTEST.SEMAPHORE_NAME( 1 ) := RTEMS.BUILD_NAME(  'S', 'E', 'M', ' ' );
58
59      if MPTEST.MULTIPROCESSING_CONFIGURATION.NODE = 1 then
60
61         TEXT_IO.PUT_LINE( "Creating Message Queue (Global)" );
62         RTEMS.MESSAGE_QUEUE_CREATE(
63            MPTEST.QUEUE_NAME( 1 ),
64            3,
65            RTEMS.GLOBAL + RTEMS.LIMIT,
66            MPTEST.QUEUE_ID( 1 ),
67            STATUS
68         );
69         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "MESSAGE_QUEUE_CREATE" );
70
71         TEXT_IO.PUT_LINE( "Creating Semaphore (Global)" );
72         RTEMS.SEMAPHORE_CREATE(
73            MPTEST.SEMAPHORE_NAME( 1 ),
74            1,
75            RTEMS.GLOBAL + RTEMS.PRIORITY,
76            MPTEST.SEMAPHORE_ID( 1 ),
77            STATUS
78         );
79         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_CREATE" );
80
81         RTEMS.SEMAPHORE_OBTAIN(
82            MPTEST.SEMAPHORE_ID( 1 ),
83            RTEMS.DEFAULT_OPTIONS,
84            RTEMS.NO_TIMEOUT,
85            STATUS
86         );
87         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_OBTAIN" );
88
89      end if;
90
91      TEXT_IO.PUT_LINE( "Creating Test_task 1 (local)" );
92         RTEMS.TASK_CREATE(
93         MPTEST.TASK_NAME( 1 ),
94         1,
95         2048,
96         RTEMS.TIMESLICE,
97         RTEMS.DEFAULT_ATTRIBUTES,
98         MPTEST.TASK_ID( 1 ),
99         STATUS
100      );
101      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE" );
102
103      TEXT_IO.PUT_LINE( "Starting Test_task 1 (local)" );
104      RTEMS.TASK_START(
105         MPTEST.TASK_ID( 1 ),
106         MPTEST.TEST_TASK_1'ACCESS,
107         0,
108         STATUS
109      );
110      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START" );
111
112      TEXT_IO.PUT_LINE( "Creating Test_task 2 (local)" );
113      RTEMS.TASK_CREATE(
114         MPTEST.TASK_NAME( 2 ),
115         1,
116         2048,
117         RTEMS.TIMESLICE,
118         RTEMS.DEFAULT_ATTRIBUTES,
119         MPTEST.TASK_ID( 2 ),
120         STATUS
121      );
122      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE" );
123
124      TEXT_IO.PUT_LINE( "Starting Test_task 2 (local)" );
125      RTEMS.TASK_START(
126         MPTEST.TASK_ID( 2 ),
127         MPTEST.TEST_TASK_2'ACCESS,
128         0,
129         STATUS
130      );
131      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START" );
132
133      if MPTEST.MULTIPROCESSING_CONFIGURATION.NODE = 1 then
134
135         RTEMS.TASK_WAKE_AFTER( 5 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
136         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
137
138         TEXT_IO.PUT_LINE( "*** END OF TEST 13 ***" );
139
140         RTEMS.SHUTDOWN_EXECUTIVE( 0 );
141
142      end if;
143
144      TEXT_IO.PUT_LINE( "Deleting initialization task" );
145      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
146      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
147
148   end INIT;
149
150--PAGE
151--
152--  TEST_TASK_1
153--
154
155   procedure TEST_TASK_1 (
156      ARGUMENT : in     RTEMS.TASK_ARGUMENT
157   ) is
158      COUNT               : RTEMS.UNSIGNED32;
159      RECEIVE_BUFFER_AREA : RTEMS.BUFFER;
160      RECEIVE_BUFFER      : RTEMS.BUFFER_POINTER;
161      STATUS              : RTEMS.STATUS_CODES;
162   begin
163
164      RECEIVE_BUFFER :=
165         RTEMS.TO_BUFFER_POINTER( RECEIVE_BUFFER_AREA'ADDRESS );
166
167      TEXT_IO.PUT_LINE( "Getting QID of message queue" );
168
169      loop
170
171         RTEMS.MESSAGE_QUEUE_IDENT(
172            MPTEST.QUEUE_NAME( 1 ),
173            RTEMS.SEARCH_ALL_NODES,
174            MPTEST.QUEUE_ID( 1 ),
175            STATUS
176         );
177
178         exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
179
180      end loop;
181
182      if MPTEST.MULTIPROCESSING_CONFIGURATION.NODE = 1 then
183
184         TEXT_IO.PUT_LINE( "Receiving message ..." );
185         RTEMS.MESSAGE_QUEUE_RECEIVE(
186            MPTEST.QUEUE_ID( 1 ),
187            RECEIVE_BUFFER,
188            RTEMS.DEFAULT_OPTIONS,
189            RTEMS.NO_TIMEOUT,
190            STATUS
191         );
192         TEXT_IO.PUT_LINE( "How did I get back from here???" );
193         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "MESSAGE_QUEUE_RECEIVE" );
194
195      end if;
196
197      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
198      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
199
200      TEXT_IO.PUT_LINE( "Receiving message ..." );
201      RTEMS.MESSAGE_QUEUE_RECEIVE(
202         MPTEST.QUEUE_ID( 1 ),
203         RECEIVE_BUFFER,
204         RTEMS.DEFAULT_OPTIONS,
205         2 * TEST_SUPPORT.TICKS_PER_SECOND,
206         STATUS
207      );
208      TEST_SUPPORT.FATAL_DIRECTIVE_STATUS(
209         STATUS,
210         RTEMS.TIMEOUT,
211         "MESSAGE_QUEUE_RECEIVE"
212      );
213      TEST_SUPPORT.FATAL_DIRECTIVE_STATUS(
214         STATUS,
215         RTEMS.TIMEOUT,
216         "MESSAGE_QUEUE_OBTAIN"
217      );
218
219      TEXT_IO.PUT_LINE(
220         "message_queue_receive correctly returned TIMEOUT"
221      );
222
223      TEXT_IO.PUT_LINE( "Deleting self" );
224      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
225      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
226
227   end TEST_TASK_1;
228
229--PAGE
230--
231--  TEST_TASK_2
232--
233
234   procedure TEST_TASK_2 (
235      ARGUMENT : in     RTEMS.TASK_ARGUMENT
236   ) is
237      STATUS : RTEMS.STATUS_CODES;
238   begin
239
240      TEXT_IO.PUT_LINE( "Getting SMID of semaphore" );
241
242      loop
243
244         RTEMS.SEMAPHORE_IDENT(
245            MPTEST.SEMAPHORE_NAME( 1 ),
246            RTEMS.SEARCH_ALL_NODES,
247            MPTEST.SEMAPHORE_ID( 1 ),
248            STATUS
249         );
250
251         exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
252
253      end loop;
254
255      if MPTEST.MULTIPROCESSING_CONFIGURATION.NODE = 1 then
256
257         RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
258         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
259
260         TEXT_IO.PUT_LINE( "Releasing semaphore ..." );
261         RTEMS.SEMAPHORE_RELEASE( MPTEST.SEMAPHORE_ID( 1 ), STATUS );
262         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_RELEASE" );
263
264         RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND / 2, STATUS );
265         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
266
267         TEXT_IO.PUT_LINE( "Getting semaphore ..." );
268         RTEMS.SEMAPHORE_OBTAIN(
269            MPTEST.SEMAPHORE_ID( 1 ),
270            RTEMS.DEFAULT_OPTIONS,
271            RTEMS.NO_TIMEOUT,
272            STATUS
273         );
274         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_OBTAIN" );
275
276         TEXT_IO.PUT_LINE( "Getting semaphore ..." );
277         RTEMS.SEMAPHORE_OBTAIN(
278            MPTEST.SEMAPHORE_ID( 1 ),
279            RTEMS.DEFAULT_OPTIONS,
280            RTEMS.NO_TIMEOUT,
281            STATUS
282         );
283         TEXT_IO.PUT_LINE( "How did I get back from here???" );
284         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_OBTAIN" );
285
286      end if;
287
288      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND / 2, STATUS );
289      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
290
291      TEXT_IO.PUT_LINE( "Getting semaphore ..." );
292      RTEMS.SEMAPHORE_OBTAIN(
293         MPTEST.SEMAPHORE_ID( 1 ),
294         RTEMS.DEFAULT_OPTIONS,
295         RTEMS.NO_TIMEOUT,
296         STATUS
297      );
298      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_OBTAIN" );
299
300      TEXT_IO.PUT_LINE( "Releasing semaphore ..." );
301      RTEMS.SEMAPHORE_RELEASE( MPTEST.SEMAPHORE_ID( 1 ), STATUS );
302      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_RELEASE" );
303
304      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
305      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
306
307      TEXT_IO.PUT_LINE( "Getting semaphore ..." );
308      RTEMS.SEMAPHORE_OBTAIN(
309         MPTEST.SEMAPHORE_ID( 1 ),
310         RTEMS.DEFAULT_OPTIONS,
311         2 * TEST_SUPPORT.TICKS_PER_SECOND,
312         STATUS
313      );
314      TEST_SUPPORT.FATAL_DIRECTIVE_STATUS(
315         STATUS,
316         RTEMS.TIMEOUT,
317         "SEMAPHORE_OBTAIN"
318      );
319      TEXT_IO.PUT_LINE( "semaphore_obtain correctly returned TIMEOUT" );
320
321      TEXT_IO.PUT_LINE( "*** END OF TEST 13 ***" );
322
323      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
324
325   end TEST_TASK_2;
326
327end MPTEST;
Note: See TracBrowser for help on using the repository browser.