source: rtems/c/src/ada-tests/mptests/mp03/mptest.adb @ 3c4d8cd1

4.115
Last change on this file since 3c4d8cd1 was 3c4d8cd1, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 16, 2011 at 3:53:16 PM

2011-02-16 Joel Sherrill <joel.sherrill@…>

  • ada-tests/mptests/mp01/mp01.adb, ada-tests/mptests/mp01/mptest.adb, ada-tests/mptests/mp01/mptest.ads, ada-tests/mptests/mp01/node1/mp01_node1.adb, ada-tests/mptests/mp01/node2/mp01_node2.adb, ada-tests/mptests/mp02/mptest.adb, ada-tests/mptests/mp02/mptest.ads, ada-tests/mptests/mp02/node1/mp02_node1.adb, ada-tests/mptests/mp02/node2/mp02_node2.adb, ada-tests/mptests/mp03/mptest.adb, ada-tests/mptests/mp03/mptest.ads, ada-tests/mptests/mp03/node1/mp03_node1.adb, ada-tests/mptests/mp03/node2/mp03_node2.adb, ada-tests/mptests/mp04/mptest.adb, ada-tests/mptests/mp04/mptest.ads, ada-tests/mptests/mp04/node1/mp04_node1.adb, ada-tests/mptests/mp04/node2/mp04_node2.adb, ada-tests/mptests/mp05/mptest.adb, ada-tests/mptests/mp05/mptest.ads, ada-tests/mptests/mp05/node1/mp05_node1.adb, ada-tests/mptests/mp05/node2/mp05_node2.adb, ada-tests/mptests/mp06/mptest.adb, ada-tests/mptests/mp06/mptest.ads, ada-tests/mptests/mp06/node1/mp06_node1.adb, ada-tests/mptests/mp06/node2/mp06_node2.adb, ada-tests/mptests/mp07/mptest.adb, ada-tests/mptests/mp07/mptest.ads, ada-tests/mptests/mp07/node1/mp07_node1.adb, ada-tests/mptests/mp07/node2/mp07_node2.adb, ada-tests/mptests/mp08/mptest.adb, ada-tests/mptests/mp08/mptest.ads, ada-tests/mptests/mp08/node1/mp08_node1.adb, ada-tests/mptests/mp08/node2/mp08_node2.adb, ada-tests/mptests/mp09/mptest.adb, ada-tests/mptests/mp09/mptest.ads, ada-tests/mptests/mp09/node1/mp09_node1.adb, ada-tests/mptests/mp09/node2/mp09_node2.adb, ada-tests/mptests/mp10/mptest.adb, ada-tests/mptests/mp10/mptest.ads, ada-tests/mptests/mp10/node1/mp10_node1.adb, ada-tests/mptests/mp10/node2/mp10_node2.adb, ada-tests/mptests/mp11/mptest.adb, ada-tests/mptests/mp11/mptest.ads, ada-tests/mptests/mp11/node1/mp11_node1.adb, ada-tests/mptests/mp11/node2/mp11_node2.adb, ada-tests/mptests/mp12/mptest.adb, ada-tests/mptests/mp12/mptest.ads, ada-tests/mptests/mp12/node1/mp12_node1.adb, ada-tests/mptests/mp12/node2/mp12_node2.adb, ada-tests/mptests/mp13/mptest.adb, ada-tests/mptests/mp13/mptest.ads, ada-tests/mptests/mp13/node1/mp13_node1.adb, ada-tests/mptests/mp13/node2/mp13_node2.adb, ada-tests/mptests/mp14/mptest.adb, ada-tests/mptests/mp14/mptest.ads, ada-tests/mptests/mp14/node1/mp14_node1.adb, ada-tests/mptests/mp14/node2/mp14_node2.adb, ada-tests/samples/base_mp/mptest.adb, ada-tests/samples/base_mp/mptest.ads, ada-tests/samples/base_sp/base_sp.adb, ada-tests/samples/base_sp/sptest.adb, ada-tests/samples/base_sp/sptest.ads, ada-tests/samples/hello/hello.adb, ada-tests/samples/hello/sptest.adb, ada-tests/samples/hello/sptest.ads, ada-tests/samples/nsecs/nsecs.adb, ada-tests/samples/nsecs/sptest.adb, ada-tests/samples/nsecs/sptest.ads, ada-tests/samples/ticker/sptest.adb, ada-tests/samples/ticker/sptest.ads, ada-tests/samples/ticker/ticker.adb, ada-tests/sptests/sp01/sp01.adb, ada-tests/sptests/sp01/sptest.adb, ada-tests/sptests/sp01/sptest.ads, ada-tests/sptests/sp02/sp02.adb, ada-tests/sptests/sp02/sptest.adb, ada-tests/sptests/sp02/sptest.ads, ada-tests/sptests/sp03/sp03.adb, ada-tests/sptests/sp03/sptest.adb, ada-tests/sptests/sp03/sptest.ads, ada-tests/sptests/sp04/sp04.adb, ada-tests/sptests/sp04/sptest.adb, ada-tests/sptests/sp04/sptest.ads, ada-tests/sptests/sp05/sp05.adb, ada-tests/sptests/sp05/sptest.adb, ada-tests/sptests/sp05/sptest.ads, ada-tests/sptests/sp06/sp06.adb, ada-tests/sptests/sp06/sptest.adb, ada-tests/sptests/sp06/sptest.ads, ada-tests/sptests/sp07/sp07.adb, ada-tests/sptests/sp07/sptest.adb, ada-tests/sptests/sp07/sptest.ads, ada-tests/sptests/sp08/sp08.adb, ada-tests/sptests/sp08/sptest.adb, ada-tests/sptests/sp08/sptest.ads, ada-tests/sptests/sp09/sp09.adb, ada-tests/sptests/sp09/sptest.adb, ada-tests/sptests/sp09/sptest.ads, ada-tests/sptests/sp11/sp11.adb, ada-tests/sptests/sp11/sptest.adb, ada-tests/sptests/sp11/sptest.ads, ada-tests/sptests/sp12/sp12.adb, ada-tests/sptests/sp12/sptest.adb, ada-tests/sptests/sp12/sptest.ads, ada-tests/sptests/sp13/sp13.adb, ada-tests/sptests/sp13/sptest.adb, ada-tests/sptests/sp13/sptest.ads, ada-tests/sptests/sp14/sp14.adb, ada-tests/sptests/sp14/sptest.adb, ada-tests/sptests/sp14/sptest.ads, ada-tests/sptests/sp15/sp15.adb, ada-tests/sptests/sp15/sptest.adb, ada-tests/sptests/sp15/sptest.ads, ada-tests/sptests/sp16/sp16.adb, ada-tests/sptests/sp16/sptest.adb, ada-tests/sptests/sp16/sptest.ads, ada-tests/sptests/sp17/sp17.adb, ada-tests/sptests/sp17/sptest.adb, ada-tests/sptests/sp17/sptest.ads, ada-tests/sptests/sp19/sp19.adb, ada-tests/sptests/sp19/sptest.adp, ada-tests/sptests/sp19/sptest.ads, ada-tests/sptests/sp20/sp20.adb, ada-tests/sptests/sp20/sptest.adb, ada-tests/sptests/sp20/sptest.ads, ada-tests/sptests/sp22/sp22.adb, ada-tests/sptests/sp22/sptest.adb, ada-tests/sptests/sp22/sptest.ads, ada-tests/sptests/sp23/sp23.adb, ada-tests/sptests/sp23/sptest.adb, ada-tests/sptests/sp23/sptest.ads, ada-tests/sptests/sp24/sp24.adb, ada-tests/sptests/sp24/sptest.adb, ada-tests/sptests/sp24/sptest.ads, ada-tests/sptests/sp25/sp25.adb, ada-tests/sptests/sp25/sptest.adb, ada-tests/sptests/sp25/sptest.ads, ada-tests/support/test_support.adb, ada-tests/tmtests/tm01/tm01.adb, ada-tests/tmtests/tm01/tmtest.adb, ada-tests/tmtests/tm01/tmtest.ads, ada-tests/tmtests/tm02/tm02.adb, ada-tests/tmtests/tm02/tmtest.adb, ada-tests/tmtests/tm02/tmtest.ads, ada-tests/tmtests/tm03/tm03.adb, ada-tests/tmtests/tm03/tmtest.adb, ada-tests/tmtests/tm03/tmtest.ads, ada-tests/tmtests/tm04/tm04.adb, ada-tests/tmtests/tm04/tmtest.adb, ada-tests/tmtests/tm04/tmtest.ads, ada-tests/tmtests/tm05/tm05.adb, ada-tests/tmtests/tm05/tmtest.adb, ada-tests/tmtests/tm05/tmtest.ads, ada-tests/tmtests/tm06/tm06.adb, ada-tests/tmtests/tm06/tmtest.adb, ada-tests/tmtests/tm06/tmtest.ads, ada-tests/tmtests/tm07/tm07.adb, ada-tests/tmtests/tm07/tmtest.adb, ada-tests/tmtests/tm07/tmtest.ads, ada-tests/tmtests/tm08/tm08.adb, ada-tests/tmtests/tm08/tmtest.adb, ada-tests/tmtests/tm08/tmtest.ads, ada-tests/tmtests/tm09/tm09.adb, ada-tests/tmtests/tm09/tmtest.adb, ada-tests/tmtests/tm09/tmtest.ads, ada-tests/tmtests/tm10/tm10.adb, ada-tests/tmtests/tm10/tmtest.adb, ada-tests/tmtests/tm10/tmtest.ads, ada-tests/tmtests/tm11/tm11.adb, ada-tests/tmtests/tm11/tmtest.adb, ada-tests/tmtests/tm11/tmtest.ads, ada-tests/tmtests/tm12/tm12.adb, ada-tests/tmtests/tm12/tmtest.adb, ada-tests/tmtests/tm12/tmtest.ads, ada-tests/tmtests/tm13/tm13.adb, ada-tests/tmtests/tm13/tmtest.adb, ada-tests/tmtests/tm13/tmtest.ads, ada-tests/tmtests/tm14/tm14.adb, ada-tests/tmtests/tm14/tmtest.adb, ada-tests/tmtests/tm14/tmtest.ads, ada-tests/tmtests/tm15/tm15.adb, ada-tests/tmtests/tm15/tmtest.adb, ada-tests/tmtests/tm15/tmtest.ads, ada-tests/tmtests/tm16/tm16.adb, ada-tests/tmtests/tm16/tmtest.adb, ada-tests/tmtests/tm16/tmtest.ads, ada-tests/tmtests/tm17/tm17.adb, ada-tests/tmtests/tm17/tmtest.adb, ada-tests/tmtests/tm17/tmtest.ads, ada-tests/tmtests/tm18/tm18.adb, ada-tests/tmtests/tm18/tmtest.adb, ada-tests/tmtests/tm18/tmtest.ads, ada-tests/tmtests/tm19/tm19.adb, ada-tests/tmtests/tm19/tmtest.adb, ada-tests/tmtests/tm19/tmtest.ads, ada-tests/tmtests/tm20/tm20.adb, ada-tests/tmtests/tm20/tmtest.adb, ada-tests/tmtests/tm20/tmtest.ads, ada-tests/tmtests/tm21/tm21.adb, ada-tests/tmtests/tm21/tmtest.adb, ada-tests/tmtests/tm21/tmtest.ads, ada-tests/tmtests/tm22/tm22.adb, ada-tests/tmtests/tm22/tmtest.adb, ada-tests/tmtests/tm22/tmtest.ads, ada-tests/tmtests/tm23/tm23.adb, ada-tests/tmtests/tm23/tmtest.adb, ada-tests/tmtests/tm23/tmtest.ads, ada-tests/tmtests/tm24/tm24.adb, ada-tests/tmtests/tm24/tmtest.adb, ada-tests/tmtests/tm24/tmtest.ads, ada-tests/tmtests/tm25/tm25.adb, ada-tests/tmtests/tm25/tmtest.adb, ada-tests/tmtests/tm25/tmtest.ads, ada-tests/tmtests/tm28/tm28.adb, ada-tests/tmtests/tm28/tmtest.adb, ada-tests/tmtests/tm28/tmtest.ads, ada-tests/tmtests/tm29/tm29.adb, ada-tests/tmtests/tm29/tmtest.adb, ada-tests/tmtests/tm29/tmtest.ads, ada-tests/tmtests/tmck/tmck.adb, ada-tests/tmtests/tmck/tmtest.adb, ada-tests/tmtests/tmck/tmtest.ads, ada-tests/tmtests/tmoverhd/dummy_rtems.adb, ada-tests/tmtests/tmoverhd/dummy_rtems.ads, ada-tests/tmtests/tmoverhd/tmoverhd.adb, ada-tests/tmtests/tmoverhd/tmtest.adb, ada-tests/tmtests/tmoverhd/tmtest.ads: Account for RTEMS binding child package rework. Eliminate all warnings.
  • Property mode set to 100644
File size: 6.6 KB
Line 
1--
2--  This package is the implementation for Test 3 of the RTEMS
3--  Multiprocessor Test Suite.
4--
5--  DEPENDENCIES:
6--
7-- 
8--
9--  COPYRIGHT (c) 1989-2011.
10--  On-Line Applications Research Corporation (OAR).
11--
12--  The license and distribution terms for this file may in
13--  the file LICENSE in this distribution or at
14--  http://www.rtems.com/license/LICENSE.
15--
16--  $Id$
17--
18
19with INTERFACES; use INTERFACES;
20with RTEMS;
21with RTEMS.EVENT;
22with RTEMS.TASKS;
23with RTEMS.TIMER;
24with TEST_SUPPORT;
25with TEXT_IO;
26with UNSIGNED32_IO;
27
28package body MPTEST is
29
30--
31--  INIT
32--
33
34   procedure INIT (
35      ARGUMENT : in     RTEMS.TASKS.ARGUMENT
36   ) is
37      STATUS : RTEMS.STATUS_CODES;
38   begin
39
40      TEXT_IO.NEW_LINE( 2 );
41      TEXT_IO.PUT( "*** TEST 3 -- NODE " );
42      UNSIGNED32_IO.PUT(
43         TEST_SUPPORT.NODE,
44         WIDTH => 1
45      );
46      TEXT_IO.PUT_LINE( " ***" );
47     
48      MPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  '1', '1', '1', ' ' );
49      MPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  '2', '2', '2', ' ' );
50
51      TEXT_IO.PUT_LINE( "Creating Test_task (Global)" );
52      RTEMS.TASKS.CREATE( 
53         MPTEST.TASK_NAME( TEST_SUPPORT.NODE ), 
54         1, 
55         2048, 
56         RTEMS.NO_PREEMPT,
57         RTEMS.GLOBAL,
58         MPTEST.TASK_ID( 1 ),
59         STATUS
60      );
61      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE" );
62
63      TEXT_IO.PUT_LINE( "Starting Test_task (Global)" );
64      RTEMS.TASKS.START(
65         MPTEST.TASK_ID( 1 ),
66         MPTEST.TEST_TASK'ACCESS,
67         0,
68         STATUS
69      );
70      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START" );
71
72      MPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'M', '1', ' ' );
73
74      RTEMS.TIMER.CREATE( 
75         MPTEST.TIMER_NAME( 1 ), 
76         MPTEST.TIMER_ID( 1 ),
77         STATUS
78      );
79      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE" );
80
81      TEXT_IO.PUT_LINE( "Deleting initialization task" );
82      RTEMS.TASKS.DELETE( RTEMS.SELF, STATUS );
83      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
84
85   end INIT;
86
87--
88--  DELAYED_SEND_EVENT
89--
90
91   procedure DELAYED_SEND_EVENT (
92      IGNORED_ID      : in     RTEMS.ID;
93      IGNORED_ADDRESS : in     RTEMS.ADDRESS
94   ) is
95      STATUS  : RTEMS.STATUS_CODES;
96   begin
97
98      RTEMS.EVENT.SEND( MPTEST.TASK_ID( 1 ), RTEMS.EVENT_16, STATUS );
99      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "EVENT_SEND" );
100
101   end DELAYED_SEND_EVENT;
102
103--
104--  TEST_TASK
105--
106
107   procedure TEST_TASK (
108      ARGUMENT : in     RTEMS.TASKS.ARGUMENT
109   ) is
110      TID         : RTEMS.ID;
111      STATUS      : RTEMS.STATUS_CODES;
112   begin
113
114      RTEMS.TASKS.IDENT( RTEMS.SELF, RTEMS.SEARCH_ALL_NODES, TID, STATUS );
115      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_IDENT OF SELF" );
116   
117      TEXT_IO.PUT_LINE( "Getting TID of remote task" );
118      if TEST_SUPPORT.NODE = 1 then
119         MPTEST.REMOTE_NODE := 2;
120      else
121         MPTEST.REMOTE_NODE := 1;
122      end if;
123
124      TEXT_IO.PUT( "Remote task's name is : " );
125      TEST_SUPPORT.PUT_NAME( MPTEST.TASK_NAME( MPTEST.REMOTE_NODE ), TRUE );
126
127      loop
128
129         RTEMS.TASKS.IDENT( 
130            MPTEST.TASK_NAME( MPTEST.REMOTE_NODE ),
131            RTEMS.SEARCH_ALL_NODES,
132            MPTEST.REMOTE_TID,
133            STATUS
134         );
135
136         exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
137
138      end loop;
139
140      RTEMS.TIMER.FIRE_AFTER( 
141         MPTEST.TIMER_ID( 1 ), 
142         10 * TEST_SUPPORT.TICKS_PER_SECOND, 
143         MPTEST.DELAYED_SEND_EVENT'ACCESS,
144         RTEMS.NULL_ADDRESS,
145         STATUS
146      );
147      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
148
149      MPTEST.TEST_TASK_SUPPORT( 1 );
150
151      RTEMS.TIMER.FIRE_AFTER( 
152         MPTEST.TIMER_ID( 1 ), 
153         11 * TEST_SUPPORT.TICKS_PER_SECOND, 
154         MPTEST.DELAYED_SEND_EVENT'ACCESS,
155         RTEMS.NULL_ADDRESS,
156         STATUS
157      );
158      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
159
160      if TEST_SUPPORT.NODE = 2 then
161         
162         RTEMS.TASKS.WAKE_AFTER( 
163            2 * TEST_SUPPORT.TICKS_PER_SECOND,
164            STATUS
165         );
166        TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
167
168      end if;
169
170      MPTEST.TEST_TASK_SUPPORT( 2 );
171
172      TEXT_IO.PUT_LINE( "*** END OF TEST 3 ***" );
173
174      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
175
176   end TEST_TASK;
177
178--
179--  TEST_TASK_SUPPORT
180--
181
182
183   procedure TEST_TASK_SUPPORT (
184      NODE : in    RTEMS.UNSIGNED32
185   ) is
186      EVENTS : RTEMS.EVENT_SET;
187      STATUS : RTEMS.STATUS_CODES;
188   begin
189
190      if TEST_SUPPORT.NODE = NODE then
191
192         loop
193
194            RTEMS.EVENT.RECEIVE( 
195               RTEMS.EVENT_16,
196               RTEMS.NO_WAIT,
197               RTEMS.NO_TIMEOUT,
198               EVENTS,
199               STATUS
200            );
201
202            exit when RTEMS.ARE_STATUSES_EQUAL( RTEMS.SUCCESSFUL, STATUS );
203
204            TEST_SUPPORT.FATAL_DIRECTIVE_STATUS( 
205               STATUS,
206               RTEMS.UNSATISFIED,
207               "EVENT_RECEIVE"
208            );
209
210            RTEMS.TASKS.WAKE_AFTER( 
211               2 * TEST_SUPPORT.TICKS_PER_SECOND, 
212               STATUS
213            );
214            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
215
216            TEST_SUPPORT.PUT_NAME( MPTEST.TASK_NAME( NODE ), FALSE );
217            TEXT_IO.PUT_LINE( " - Suspending remote task" );
218            RTEMS.TASKS.SUSPEND( MPTEST.REMOTE_TID, STATUS );
219            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
220
221            RTEMS.TASKS.WAKE_AFTER( 
222               2 * TEST_SUPPORT.TICKS_PER_SECOND, 
223               STATUS
224            );
225            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
226
227            TEST_SUPPORT.PUT_NAME( MPTEST.TASK_NAME( NODE ), FALSE );
228            TEXT_IO.PUT_LINE( " - Resuming remote task" );
229
230            RTEMS.TASKS.RESUME( MPTEST.REMOTE_TID, STATUS );
231            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME" );
232
233         end loop;
234
235      else
236
237         loop
238
239            RTEMS.EVENT.RECEIVE( 
240               RTEMS.EVENT_16,
241               RTEMS.NO_WAIT,
242               RTEMS.NO_TIMEOUT,
243               EVENTS,
244               STATUS
245            );
246
247            exit when RTEMS.ARE_STATUSES_EQUAL( RTEMS.SUCCESSFUL, STATUS );
248
249            TEST_SUPPORT.FATAL_DIRECTIVE_STATUS( 
250               STATUS,
251               RTEMS.UNSATISFIED,
252               "EVENT_RECEIVE"
253            );
254
255            TEST_SUPPORT.PUT_NAME( MPTEST.TASK_NAME( REMOTE_NODE ), FALSE );
256            TEXT_IO.PUT_LINE( " - have I been suspended???" ); 
257            RTEMS.TASKS.WAKE_AFTER( 
258               TEST_SUPPORT.TICKS_PER_SECOND / 2,
259               STATUS
260            );
261            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
262
263         end loop;
264
265      end if;
266
267   end TEST_TASK_SUPPORT;
268
269end MPTEST;
Note: See TracBrowser for help on using the repository browser.