annotate gcc/testsuite/ada/acats/tests/c9/c953003.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C953003.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that the servicing of entry queues of a protected object
kono
parents:
diff changeset
28 -- continues until there are no open entries with queued (or
kono
parents:
diff changeset
29 -- requeued) calls and that internal requeues are handled
kono
parents:
diff changeset
30 -- as part of a single protected operation.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- A number of tasks are created and blocked on a protected object
kono
parents:
diff changeset
34 -- so that they can all be released at one time. When released,
kono
parents:
diff changeset
35 -- these tasks make an entry call to an entry in the Main_PO
kono
parents:
diff changeset
36 -- protected object. As part of the servicing of this entry
kono
parents:
diff changeset
37 -- call the call is passed through the remaining entries of the
kono
parents:
diff changeset
38 -- protected object by using internal requeues. The protected
kono
parents:
diff changeset
39 -- object checks that no other entry call is accepted until
kono
parents:
diff changeset
40 -- after all the internal requeuing has completed.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- CHANGE HISTORY:
kono
parents:
diff changeset
44 -- 12 JAN 96 SAIC Initial version for 2.1
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 --!
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 with Report;
kono
parents:
diff changeset
49 procedure C953003 is
kono
parents:
diff changeset
50 Verbose : constant Boolean := False;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 Order_Error : Boolean := False;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 Max_Tasks : constant := 10; -- total number of tasks
kono
parents:
diff changeset
55 Max_Entries : constant := 4; -- number of entries in Main_PO
kono
parents:
diff changeset
56 Note_Cnt : Integer := 0;
kono
parents:
diff changeset
57 Note_Order : array (1..Max_Tasks*Max_Entries) of Integer;
kono
parents:
diff changeset
58 begin
kono
parents:
diff changeset
59 Report.Test ("C953003",
kono
parents:
diff changeset
60 "Check that the servicing of entry queues handles all" &
kono
parents:
diff changeset
61 " open entries as part of a single protected operation," &
kono
parents:
diff changeset
62 " including those resulting from an internal requeue");
kono
parents:
diff changeset
63 declare
kono
parents:
diff changeset
64 task type Assault_PO is
kono
parents:
diff changeset
65 entry Take_ID (Id : Integer);
kono
parents:
diff changeset
66 end Assault_PO;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 Marines : array (1 .. Max_Tasks) of Assault_PO;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 protected Main_PO is
kono
parents:
diff changeset
71 entry E0 (Who : Integer);
kono
parents:
diff changeset
72 private
kono
parents:
diff changeset
73 entry E3 (Who : Integer);
kono
parents:
diff changeset
74 entry E2 (Who : Integer);
kono
parents:
diff changeset
75 entry E1 (Who : Integer);
kono
parents:
diff changeset
76 Expected_Next : Integer := 0;
kono
parents:
diff changeset
77 end Main_PO;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 protected body Main_PO is
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 entry E0 (Who : Integer) when True is
kono
parents:
diff changeset
83 begin
kono
parents:
diff changeset
84 Order_Error := Order_Error or Expected_Next /= 0;
kono
parents:
diff changeset
85 Expected_Next := 1;
kono
parents:
diff changeset
86 Note_Cnt := Note_Cnt + 1;
kono
parents:
diff changeset
87 Note_Order (Note_Cnt) := Who;
kono
parents:
diff changeset
88 requeue E1;
kono
parents:
diff changeset
89 end E0;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 entry E1 (Who : Integer) when True is
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93 Order_Error := Order_Error or Expected_Next /= 1;
kono
parents:
diff changeset
94 Expected_Next := 2;
kono
parents:
diff changeset
95 Note_Cnt := Note_Cnt + 1;
kono
parents:
diff changeset
96 Note_Order (Note_Cnt) := Who;
kono
parents:
diff changeset
97 requeue E2;
kono
parents:
diff changeset
98 end E1;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 entry E3 (Who : Integer) when True is
kono
parents:
diff changeset
101 begin
kono
parents:
diff changeset
102 Order_Error := Order_Error or Expected_Next /= 3;
kono
parents:
diff changeset
103 Expected_Next := 0;
kono
parents:
diff changeset
104 Note_Cnt := Note_Cnt + 1;
kono
parents:
diff changeset
105 Note_Order (Note_Cnt) := Who;
kono
parents:
diff changeset
106 -- all done - return now
kono
parents:
diff changeset
107 end E3;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 entry E2 (Who : Integer) when True is
kono
parents:
diff changeset
110 begin
kono
parents:
diff changeset
111 Order_Error := Order_Error or Expected_Next /= 2;
kono
parents:
diff changeset
112 Expected_Next := 3;
kono
parents:
diff changeset
113 Note_Cnt := Note_Cnt + 1;
kono
parents:
diff changeset
114 Note_Order (Note_Cnt) := Who;
kono
parents:
diff changeset
115 requeue E3;
kono
parents:
diff changeset
116 end E2;
kono
parents:
diff changeset
117 end Main_PO;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 protected Holding_Pen is
kono
parents:
diff changeset
120 entry Wait_For_All_Present;
kono
parents:
diff changeset
121 entry Wait;
kono
parents:
diff changeset
122 private
kono
parents:
diff changeset
123 Open : Boolean := False;
kono
parents:
diff changeset
124 end Holding_Pen;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 protected body Holding_Pen is
kono
parents:
diff changeset
127 entry Wait_For_All_Present when Wait'Count = Max_Tasks is
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129 Open := True;
kono
parents:
diff changeset
130 end Wait_For_All_Present;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 entry Wait when Open is
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134 null; -- just go
kono
parents:
diff changeset
135 end Wait;
kono
parents:
diff changeset
136 end Holding_Pen;
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 task body Assault_PO is
kono
parents:
diff changeset
140 Me : Integer;
kono
parents:
diff changeset
141 begin
kono
parents:
diff changeset
142 accept Take_Id (Id : Integer) do
kono
parents:
diff changeset
143 Me := Id;
kono
parents:
diff changeset
144 end Take_Id;
kono
parents:
diff changeset
145 Holding_Pen.Wait;
kono
parents:
diff changeset
146 Main_PO.E0 (Me);
kono
parents:
diff changeset
147 if Verbose then
kono
parents:
diff changeset
148 Report.Comment ("task" & Integer'Image (Me) &
kono
parents:
diff changeset
149 " done");
kono
parents:
diff changeset
150 end if;
kono
parents:
diff changeset
151 exception
kono
parents:
diff changeset
152 when others =>
kono
parents:
diff changeset
153 Report.Failed ("exception in task");
kono
parents:
diff changeset
154 end Assault_PO;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 begin -- test encapsulation
kono
parents:
diff changeset
157 for I in Marines'Range loop
kono
parents:
diff changeset
158 Marines (I).Take_ID (100 + I);
kono
parents:
diff changeset
159 end loop;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 -- let all the tasks get blocked so we can release them all
kono
parents:
diff changeset
162 -- at one time
kono
parents:
diff changeset
163 Holding_Pen.Wait_For_All_Present;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 -- wait for all the tasks to complete
kono
parents:
diff changeset
166 if Verbose then
kono
parents:
diff changeset
167 Report.Comment ("waiting for tasks to complete");
kono
parents:
diff changeset
168 end if;
kono
parents:
diff changeset
169 end;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 -- make sure all tasks registered their order
kono
parents:
diff changeset
172 if Note_Cnt /= Max_Tasks * Max_Entries then
kono
parents:
diff changeset
173 Report.Failed ("task registration count wrong. " &
kono
parents:
diff changeset
174 Integer'Image (Note_Cnt));
kono
parents:
diff changeset
175 end if;
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 if Order_Error then
kono
parents:
diff changeset
178 Report.Failed ("internal requeue not handled as part of operation");
kono
parents:
diff changeset
179 end if;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 if Verbose or Order_Error then
kono
parents:
diff changeset
182 for I in 1..Max_Tasks * Max_Entries loop
kono
parents:
diff changeset
183 Report.Comment ("order" & Integer'Image (I) & " is" &
kono
parents:
diff changeset
184 Integer'Image (Note_Order (I)));
kono
parents:
diff changeset
185 end loop;
kono
parents:
diff changeset
186 end if;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 Report.Result;
kono
parents:
diff changeset
189 end C953003;