source: rtems/c/src/ada-tests/mptests/mp08/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: 4.7 KB
Line 
1--
2--  MPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation for Test 8 of the RTEMS
7--  Multiprocessor Test Suite.
8--
9--  DEPENDENCIES:
10--
11-- 
12--
13--  COPYRIGHT (c) 1989-2011.
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 RTEMS.OBJECT;
26with RTEMS.SEMAPHORE;
27with RTEMS.TASKS;
28with TEST_SUPPORT;
29with TEXT_IO;
30with UNSIGNED32_IO;
31
32package body MPTEST is
33
34--
35--  INIT
36--
37
38   procedure INIT (
39      ARGUMENT : in     RTEMS.TASKS.ARGUMENT
40   ) is
41      STATUS : RTEMS.STATUS_CODES;
42   begin
43
44      TEXT_IO.NEW_LINE( 2 );
45      TEXT_IO.PUT( "*** TEST 8 -- NODE " );
46      UNSIGNED32_IO.PUT(
47         TEST_SUPPORT.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.SEMAPHORE_NAME( 1 ) := RTEMS.BUILD_NAME(  'S', 'E', 'M', ' ' );
56
57      if TEST_SUPPORT.NODE = 1 then
58
59         TEXT_IO.PUT_LINE( "Creating Semaphore(Global)" );
60
61         RTEMS.SEMAPHORE.CREATE(
62            MPTEST.SEMAPHORE_NAME( 1 ),
63            1,
64            RTEMS.GLOBAL,
65            MPTEST.SEMAPHORE_ID( 1 ),
66            STATUS
67         );
68         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_CREATE" );
69
70      end if;
71
72      TEXT_IO.PUT_LINE( "Creating Test_task (Global)" );
73      RTEMS.TASKS.CREATE( 
74         MPTEST.TASK_NAME( TEST_SUPPORT.NODE ), 
75         TEST_SUPPORT.NODE, 
76         2048, 
77         RTEMS.TIMESLICE,
78         RTEMS.GLOBAL,
79         MPTEST.TASK_ID( 1 ),
80         STATUS
81      );
82      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE" );
83
84      TEXT_IO.PUT_LINE( "Starting Test_task (Global)" );
85      RTEMS.TASKS.START(
86         MPTEST.TASK_ID( 1 ),
87         MPTEST.TEST_TASK'ACCESS,
88         0,
89         STATUS
90      );
91      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START" );
92
93      TEXT_IO.PUT_LINE( "Deleting initialization task" );
94      RTEMS.TASKS.DELETE( RTEMS.SELF, STATUS );
95      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
96
97   end INIT;
98
99--
100--  TEST_TASK
101--
102
103   procedure TEST_TASK (
104      ARGUMENT : in     RTEMS.TASKS.ARGUMENT
105   ) is
106      DOTS                     : RTEMS.UNSIGNED32;
107      COUNT                    : RTEMS.UNSIGNED32;
108      STATUS                   : RTEMS.STATUS_CODES;
109   begin
110
111      TEXT_IO.PUT_LINE( "Getting SMID of semaphore" );
112      loop
113
114         RTEMS.SEMAPHORE.IDENT( 
115            MPTEST.SEMAPHORE_NAME( 1 ),
116            RTEMS.SEARCH_ALL_NODES,
117            MPTEST.SEMAPHORE_ID( 1 ),
118            STATUS
119         );
120
121         exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
122
123      end loop;
124
125      if TEST_SUPPORT.NODE = 2 then
126
127         RTEMS.SEMAPHORE.DELETE(
128            MPTEST.SEMAPHORE_ID( 1 ),
129            STATUS
130         );
131         TEST_SUPPORT.FATAL_DIRECTIVE_STATUS( 
132            STATUS, 
133            RTEMS.ILLEGAL_ON_REMOTE_OBJECT,
134            "SEMAPHORE_DELETE" 
135         );
136
137         TEXT_IO.PUT_LINE(
138            "semaphore_delete correctly returned ILLEGAL_ON_REMOTE_OBJECT"
139         );
140
141      end if;
142
143      COUNT := 0;
144
145      loop
146
147         TEST_SUPPORT.PUT_DOT( "p" );
148
149         RTEMS.SEMAPHORE.OBTAIN(
150            MPTEST.SEMAPHORE_ID( 1 ),
151            RTEMS.DEFAULT_OPTIONS,
152            RTEMS.NO_TIMEOUT,
153            STATUS
154         );
155
156         if not RTEMS.IS_STATUS_SUCCESSFUL( STATUS ) then
157
158            TEST_SUPPORT.FATAL_DIRECTIVE_STATUS( 
159               STATUS, 
160               RTEMS.OBJECT_WAS_DELETED,
161               "SEMAPHORE_OBTAIN" 
162            );
163
164            TEXT_IO.NEW_LINE;
165
166            TEXT_IO.PUT_LINE( "Global semaphore deleted" );
167
168            TEXT_IO.PUT_LINE( "*** END OF TEST 8 ***" );
169
170            RTEMS.SHUTDOWN_EXECUTIVE( 0 );
171
172         end if;
173
174         COUNT := COUNT + 1;
175
176         if TEST_SUPPORT.NODE = 1 and then
177            COUNT >= 1000 then
178
179            RTEMS.TASKS.WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
180            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
181
182            TEXT_IO.NEW_LINE;
183
184            TEXT_IO.PUT_LINE( "Deleting global semaphore" );
185
186            RTEMS.SEMAPHORE.DELETE( MPTEST.SEMAPHORE_ID( 1 ), STATUS );
187            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_DELETE" );
188
189            TEXT_IO.PUT_LINE( "*** END OF TEST 8 ***" );
190
191            RTEMS.SHUTDOWN_EXECUTIVE( 0 );
192
193         end if;
194
195         TEST_SUPPORT.PUT_DOT( "v" );
196
197         RTEMS.SEMAPHORE.RELEASE( MPTEST.SEMAPHORE_ID( 1 ), STATUS );
198
199         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SEMAPHORE_RELEASE" );
200
201      end loop;
202
203   end TEST_TASK;
204
205end MPTEST;
Note: See TracBrowser for help on using the repository browser.