1-- C94001G.ADA
2
3--                             Grant of Unlimited Rights
4--
5--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7--     unlimited rights in the software and documentation contained herein.
8--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9--     this public release, the Government intends to confer upon all
10--     recipients unlimited rights  equal to those held by the Government.
11--     These rights include rights to use, duplicate, release or disclose the
12--     released technical data and computer software in whole or in part, in
13--     any manner and for any purpose whatsoever, and to have or permit others
14--     to do so.
15--
16--                                    DISCLAIMER
17--
18--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23--     PARTICULAR PURPOSE OF SAID MATERIAL.
24--*
25-- CHECK THAT A COMPLETED TASK WITH DEPENDENT TASKS TERMINATES WHEN
26-- A L L  DEPENDENT TASKS HAVE TERMINATED.
27
28-- WEI  3/ 4/82
29-- JBG 4/2/84
30-- JWC 6/28/85   RENAMED FROM C940AIA-B.ADA
31
32with Impdef;
33WITH REPORT;
34 USE REPORT;
35PROCEDURE C94001G IS
36
37     PACKAGE SPY IS      -- PROVIDE PROTECTED ACCESS TO SPYNUMB
38          SUBTYPE ARG IS NATURAL RANGE 0..9;
39          FUNCTION SPYNUMB RETURN NATURAL;                      -- READ
40          FUNCTION FINIT_POS (DIGT : IN ARG) RETURN NATURAL;    -- WRITE
41          PROCEDURE PSPY_NUMB (DIGT : IN ARG);                  -- WRITE
42     END SPY;
43
44     USE SPY;
45
46     PACKAGE BODY SPY IS
47
48          TASK GUARD IS
49               ENTRY READ  (NUMB : OUT NATURAL);
50               ENTRY WRITE (NUMB : IN NATURAL);
51          END GUARD;
52
53          TASK BODY GUARD IS
54               SPYNUMB : NATURAL := 0;
55          BEGIN
56               LOOP
57                    SELECT
58                         ACCEPT READ (NUMB : OUT NATURAL) DO
59                              NUMB := SPYNUMB;
60                         END READ;
61                    OR   ACCEPT WRITE (NUMB : IN NATURAL) DO
62                              SPYNUMB := 10*SPYNUMB+NUMB;
63                         END WRITE;
64                    OR   TERMINATE;
65                    END SELECT;
66               END LOOP;
67          END GUARD;
68
69          FUNCTION SPYNUMB RETURN NATURAL IS
70               TEMP : NATURAL;
71          BEGIN
72               GUARD.READ (TEMP);
73               RETURN TEMP;
74          END SPYNUMB;
75
76          FUNCTION FINIT_POS (DIGT: IN ARG) RETURN NATURAL IS
77          BEGIN
78               GUARD.WRITE (DIGT);
79               RETURN DIGT;
80          END FINIT_POS;
81
82          PROCEDURE PSPY_NUMB (DIGT : IN ARG) IS
83          BEGIN
84               GUARD.WRITE (DIGT);
85          END PSPY_NUMB;
86     END SPY;
87
88BEGIN
89     TEST ("C94001G", "TERMINATION WHEN ALL DEPENDENT TASKS " &
90                      "HAVE TERMINATED");
91
92BLOCK:
93     DECLARE
94
95          TASK TYPE TT1;
96
97          TASK BODY TT1 IS
98          BEGIN
99               DELAY 1.0 * Impdef.One_Second;
100               PSPY_NUMB (1);
101          END TT1;
102
103          TASK T1 IS
104          END T1;
105
106          TASK BODY T1 IS
107               OBJ_TT1_1, OBJ_TT1_2, OBJ_TT1_3 : TT1;
108          BEGIN
109               NULL;
110          END T1;
111
112     BEGIN
113          NULL;
114     END BLOCK;               -- WAIT HERE FOR TERMINATION.
115
116     IF SPYNUMB /= 111 THEN
117          FAILED ("TASK T1 TERMINATED BEFORE " &
118                  "ALL DEPENDENT TASKS HAVE TERMINATED");
119          COMMENT ("ACTUAL ORDER WAS:" & INTEGER'IMAGE(SPYNUMB));
120     END IF;
121
122     RESULT;
123
124END C94001G;
125