1-- C97201A.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 RENDEZVOUS REQUESTED BY A CONDITIONAL_ENTRY_CALL
26--     IS PERFORMED ONLY IF IMMEDIATELY POSSIBLE.
27
28-- CASE  A:  THE TASK TO BE CALLED IS NOT YET ACTIVE AS OF THE
29--     MOMENT OF CALL (CONDITIONAL_ENTRY_CALL),
30--     AND THIS FACT CAN BE DETERMINED STATICALLY.
31
32
33-- RM 4/20/82
34
35
36WITH REPORT; USE REPORT;
37PROCEDURE C97201A IS
38
39     ELSE_BRANCH_TAKEN    :  INTEGER  :=  3 ;
40
41BEGIN
42
43
44     TEST ("C97201A", "CHECK THAT NO RENDEZVOUS REQUESTED BY"      &
45                      " A CONDITIONAL_ENTRY_CALL CAN OCCUR  WHILE" &
46                      " THE CALLED TASK IS NOT YET ACTIVE"         );
47
48
49     -------------------------------------------------------------------
50
51
52     DECLARE
53
54
55          TASK  T  IS
56               ENTRY  DO_IT_NOW_ORELSE ( AUTHORIZED : IN BOOLEAN ) ;
57          END  T ;
58
59
60          TASK BODY  T  IS
61
62               PACKAGE       SECOND_ATTEMPT  IS    END  SECOND_ATTEMPT ;
63               PACKAGE BODY  SECOND_ATTEMPT  IS
64               BEGIN
65
66                    SELECT
67                         DO_IT_NOW_ORELSE (FALSE) ;--CALLING (OWN) ENTRY
68                    ELSE    -- (I.E. CALLER ADOPTS A NO-WAIT POLICY)
69                            --      THEREFORE THIS BRANCH MUST BE CHOSEN
70                         ELSE_BRANCH_TAKEN := 2 * ELSE_BRANCH_TAKEN ;
71                         COMMENT( "ELSE_BRANCH  TAKEN  (#2)" );
72                    END SELECT;
73
74               END  SECOND_ATTEMPT ;
75
76          BEGIN
77
78               ACCEPT DO_IT_NOW_ORELSE ( AUTHORIZED : IN BOOLEAN )  DO
79
80                    IF  AUTHORIZED  THEN
81                         COMMENT(  "AUTHORIZED ENTRY_CALL" );
82                    ELSE
83                         FAILED( "UNAUTHORIZED ENTRY_CALL" );
84                    END IF;
85
86               END DO_IT_NOW_ORELSE ;
87
88
89          END  T ;
90
91
92          PACKAGE       FIRST_ATTEMPT  IS      END  FIRST_ATTEMPT ;
93          PACKAGE BODY  FIRST_ATTEMPT  IS
94          BEGIN
95               SELECT
96                    T.DO_IT_NOW_ORELSE (FALSE) ;
97               ELSE        -- (I.E. CALLER ADOPTS A NO-WAIT POLICY)
98                            --      THEREFORE THIS BRANCH MUST BE CHOSEN
99                    ELSE_BRANCH_TAKEN := 1 + ELSE_BRANCH_TAKEN ;
100                    COMMENT( "ELSE_BRANCH  TAKEN  (#1)" );
101               END SELECT;
102
103          END  FIRST_ATTEMPT ;
104
105
106     BEGIN
107
108          T.DO_IT_NOW_ORELSE ( TRUE );   -- TO SATISFY THE SERVER'S
109                                          --     WAIT FOR SUCH A CALL
110
111     EXCEPTION
112
113          WHEN  TASKING_ERROR  =>
114               FAILED( "TASKING ERROR" );
115
116     END  ;
117
118
119     -------------------------------------------------------------------
120
121
122     -- BY NOW, THE TASK IS TERMINATED  (AND THE NONLOCALS UPDATED)
123
124
125     CASE  ELSE_BRANCH_TAKEN  IS
126
127          WHEN  3  =>
128               FAILED( "NO 'ELSE'; BOTH (?) RENDEZVOUS ATTEMPTED?" );
129
130          WHEN  4  =>
131               FAILED( "'ELSE' #1 ONLY; RENDEZVOUS (#2) ATTEMPTED?" );
132
133          WHEN  6  =>
134               FAILED( "'ELSE' #2 ONLY; RENDEZVOUS (#1) ATTEMPTED?" );
135
136          WHEN  7  =>
137               FAILED( "WRONG ORDER FOR 'ELSE':  #2,#1 " );
138
139          WHEN  8  =>
140               NULL ;
141
142          WHEN  OTHERS  =>
143               FAILED( "WRONG CASE_VALUE" );
144
145     END CASE;
146
147
148     RESULT;
149
150
151END  C97201A ;
152