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 that the servicing of entry queues of a protected object
28 -- continues until there are no open entries with queued calls
29 -- and that this takes place as part of a single protected
33 -- This test enqueues a bunch of tasks on the entries of the
34 -- protected object Main_PO. At the same time another bunch of
35 -- of tasks are queued on the single entry of protected object
37 -- Once all the tasks have had time to block, the main procedure
38 -- opens all the entries for Main_PO by calling the
39 -- Start_Protected_Operation protected procedure. This should
40 -- process all the pending callers as part of a single protected
42 -- During this protected operation, the entries of Main_PO release
43 -- the tasks blocked on Holding_Pen by calling the protected
45 -- Once released from Holding_Pen, the task immediately calls
46 -- an entry in Main_PO.
47 -- These new calls should not gain access to Main_PO until
48 -- the initial protected operation on that object completes.
49 -- The order in which the entry calls on Main_PO are taken is
50 -- recorded in a global array and checked after all the tasks
55 -- 25 OCT 95 SAIC ACVC 2.1
56 -- 15 JAN 95 SAIC Fixed deadlock problem.
62 Verbose
: constant Boolean := False;
64 Half_Tasks
: constant := 15; -- how many tasks of each group
65 Max_Tasks
: constant := Half_Tasks
* 2; -- total number of tasks
67 Note_Order
: array (1..Max_Tasks
) of Integer := (1..Max_Tasks
=> 0);
68 Note_Cnt
: Integer := 0;
70 Report
.Test
("C953002",
71 "Check that the servicing of entry queues handles all" &
72 " open entries as part of a single protected operation");
74 task type Assault_PO
is
75 entry Take_ID
(Id
: Integer);
78 First_Wave
: array (1 .. Half_Tasks
) of Assault_PO
;
79 Second_Wave
: array (1 .. Half_Tasks
) of Assault_PO
;
82 entry E0
(Who
: Integer);
83 entry E1
(Who
: Integer);
84 entry E2
(Who
: Integer);
85 entry E3
(Who
: Integer);
87 procedure Start_Protected_Operation
;
89 Open
: Boolean := False;
92 protected Holding_Pen
is
93 -- Note that Release is called by tasks executing in
94 -- the protected object Main_PO.
95 entry Wait
(Who
: Integer);
99 Open
: Boolean := False;
103 protected body Main_PO
is
104 procedure Start_Protected_Operation
is
107 -- at this point all the First_Wave tasks are
108 -- waiting at the entries and all of them should
109 -- be processed as part of the protected operation.
110 end Start_Protected_Operation
;
112 entry All_Present
when E0
'Count + E1
'Count + E2
'Count + E3
'Count =
115 null; -- all tasks are waiting
118 entry E0
(Who
: Integer) when Open
is
121 -- note the order in which entry calls are handled.
122 Note_Cnt
:= Note_Cnt
+ 1;
123 Note_Order
(Note_Cnt
) := Who
;
126 entry E1
(Who
: Integer) when Open
is
129 Note_Cnt
:= Note_Cnt
+ 1;
130 Note_Order
(Note_Cnt
) := Who
;
133 entry E2
(Who
: Integer) when Open
is
136 Note_Cnt
:= Note_Cnt
+ 1;
137 Note_Order
(Note_Cnt
) := Who
;
140 entry E3
(Who
: Integer) when Open
is
143 Note_Cnt
:= Note_Cnt
+ 1;
144 Note_Order
(Note_Cnt
) := Who
;
149 protected body Holding_Pen
is
155 entry All_Present
when Wait
'Count = Max_Tasks
/ 2 is
157 null; -- all tasks waiting
160 entry Wait
(Who
: Integer) when Open
is
162 null; -- unblock the task
166 task body Assault_PO
is
169 accept Take_Id
(Id
: Integer) do
173 Holding_Pen
.Wait
(Me
);
176 when 0 => Main_PO
.E0
(Me
);
177 when 1 => Main_PO
.E1
(Me
);
178 when 2 => Main_PO
.E2
(Me
);
179 when 3 => Main_PO
.E3
(Me
);
180 when others => null; -- cant happen
183 Report
.Comment
("task" & Integer'Image (Me
) &
188 Report
.Failed
("exception in task");
191 begin -- test encapsulation
192 for I
in First_Wave
'Range loop
193 First_Wave
(I
).Take_ID
(100 + I
);
195 for I
in Second_Wave
'Range loop
196 Second_Wave
(I
).Take_ID
(200 + I
);
199 -- let all the tasks get blocked
201 Holding_Pen
.All_Present
;
203 -- let the games begin
205 Report
.Comment
("starting protected operation");
207 Main_PO
.Start_Protected_Operation
;
209 -- wait for all the tasks to complete
211 Report
.Comment
("waiting for tasks to complete");
215 -- make sure all tasks registered their order
216 if Note_Cnt
/= Max_Tasks
then
217 Report
.Failed
("task registration count wrong. " &
218 Integer'Image (Note_Cnt
));
221 -- check the order in which entries were handled.
222 -- all the 100 level items should be handled as part of the
223 -- first protected operation and thus should be completed
224 -- before any 200 level item.
227 for I
in 1..Max_Tasks
loop
228 Report
.Comment
("order" & Integer'Image (I
) & " is" &
229 Integer'Image (Note_Order
(I
)));
232 for I
in 2 .. Max_Tasks
loop
233 if Note_Order
(I
) < 200 and
234 Note_Order
(I
-1) >= 200 then
235 Report
.Failed
("protected operation failure" &
236 Integer'Image (Note_Order
(I
-1)) &
237 Integer'Image (Note_Order
(I
)));