3 -- Grant of Unlimited Rights
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
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.
27 -- Check when a dependent task and its master both
28 -- terminate as a result of a terminate alternative that
29 -- finalization is performed and that the finalization is
30 -- performed in the proper order.
33 -- A controlled type with finalization is used to determine
34 -- the order in which finalization occurs. The finalization
35 -- procedure records the identity of the object being
37 -- Two tasks, one nested inside the other, both contain
38 -- objects of the above finalization type. These tasks
39 -- cooperatively terminate so the termination and finalization
40 -- order can be noted.
44 -- 08 Jan 96 SAIC ACVC 2.1
45 -- 09 May 96 SAIC Addressed Reviewer comments.
50 with Ada
.Finalization
;
52 Verbose
: constant Boolean := False;
54 type Ids
is range 0..10;
55 Finalization_Order
: array (Ids
) of Ids
:= (Ids
=> 0);
56 Finalization_Cnt
: Ids
:= 0;
59 -- serializes concurrent access to Finalization_* above
60 procedure Done
(Id
: Ids
);
63 -- Objects of the following type are used to note the order in
64 -- which finalization occurs.
65 type Has_Finalization
is new Ada
.Finalization
.Limited_Controlled
with
69 procedure Finalize
(Object
: in out Has_Finalization
);
74 package body C930001_0
is
76 protected body Note
is
77 procedure Done
(Id
: Ids
) is
79 Finalization_Cnt
:= Finalization_Cnt
+ 1;
80 Finalization_Order
(Finalization_Cnt
) := Id
;
84 procedure Finalize
(Object
: in out Has_Finalization
) is
86 Note
.Done
(Object
.Id
);
88 Report
.Comment
("in Finalize for" & Ids
'Image (Object
.Id
));
96 with C930001_0
; use C930001_0
;
100 Report
.Test
("C930001", "Check that dependent tasks are terminated" &
101 " before the remaining finalization");
106 V1a
: C930001_0
.Has_Finalization
; -------> 4
111 V2
: C930001_0
.Has_Finalization
; -------> 2
114 C930001_0
.Note
.Done
(1); -------> 1
119 -- cooperative termination at this point of
124 -- 7.6.1(11) requires that V1b be finalized before V1a
125 V1b
: C930001_0
.Has_Finalization
; -------> 3
131 while not Level_1
'Terminated loop
132 delay ImpDef
.Switch_To_New_Task
;
134 C930001_0
.Note
.Done
(5); -------> 5
136 -- now check the order
137 for I
in Ids
range 1..5 loop
139 Report
.Comment
(Ids
'Image (I
) &
140 Ids
'Image (Finalization_Order
(I
)));
142 if Finalization_Order
(I
) /= I
then
143 Report
.Failed
("Finalization occurred out of order" &
147 Ids
'Image (Finalization_Order
(I
)));