annotate gcc/testsuite/ada/acats/tests/c9/c954a01.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 -- C954A01.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 if a task requeued without abort on a protected entry queue
kono
parents:
diff changeset
28 -- is aborted, the abort is deferred until the entry call completes,
kono
parents:
diff changeset
29 -- after which the task becomes completed.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- Declare a protected type which simulates a printer device driver
kono
parents:
diff changeset
33 -- (foundation code).
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Declare a task which simulates a printer server for multiple printers.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- For the protected type, declare an entry with a barrier that is set
kono
parents:
diff changeset
38 -- false by a protected procedure (which simulates starting a print job
kono
parents:
diff changeset
39 -- on the printer), and is set true by a second protected procedure (which
kono
parents:
diff changeset
40 -- simulates a handler called when the printer interrupts, indicating
kono
parents:
diff changeset
41 -- that printing is done).
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- For the task, declare an entry whose corresponding accept statement
kono
parents:
diff changeset
44 -- contains a call to first protected procedure of the protected type
kono
parents:
diff changeset
45 -- (which sets the barrier of the protected entry to false), followed by
kono
parents:
diff changeset
46 -- a requeue with abort to the protected entry. Declare a second entry
kono
parents:
diff changeset
47 -- which does nothing.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- Declare a "requesting" task which calls the printer server task entry
kono
parents:
diff changeset
50 -- (and thus executes the requeue). Attempt to abort the requesting
kono
parents:
diff changeset
51 -- task. Verify that it is not aborted. Call the second protected
kono
parents:
diff changeset
52 -- procedure of the protected type (the interrupt handler) and verify that
kono
parents:
diff changeset
53 -- the protected entry completes for the requesting task. Verify that
kono
parents:
diff changeset
54 -- the requesting task is then aborted.
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 -- TEST FILES:
kono
parents:
diff changeset
57 -- This test depends on the following foundation code:
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 -- F954A00.A
kono
parents:
diff changeset
60 --
kono
parents:
diff changeset
61 --
kono
parents:
diff changeset
62 -- CHANGE HISTORY:
kono
parents:
diff changeset
63 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
64 -- 10 Oct 96 SAIC Added pragma elaborate.
kono
parents:
diff changeset
65 --
kono
parents:
diff changeset
66 --!
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 package C954A01_0 is -- Printer server abstraction.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- Simulate a system with multiple printers. The entry Print requests
kono
parents:
diff changeset
71 -- that data be printed on the next available printer. The entry call
kono
parents:
diff changeset
72 -- is accepted when a printer is available, and completes when printing
kono
parents:
diff changeset
73 -- is done.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 task Printer_Server is
kono
parents:
diff changeset
77 entry Print (File_Name : String); -- Test the requeue statement.
kono
parents:
diff changeset
78 entry Verify_Results; -- Artifice for test purposes.
kono
parents:
diff changeset
79 end Printer_Server;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 end C954A01_0;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 --==================================================================--
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 with Report;
kono
parents:
diff changeset
88 with ImpDef;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 with F954A00; -- Printer device abstraction.
kono
parents:
diff changeset
91 use F954A00;
kono
parents:
diff changeset
92 pragma Elaborate(F954A00);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 package body C954A01_0 is -- Printer server abstraction.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 task body Printer_Server is
kono
parents:
diff changeset
97 Printers_Busy : Boolean := True;
kono
parents:
diff changeset
98 Index : Printer_ID := 1;
kono
parents:
diff changeset
99 Print_Accepted : Boolean := False;
kono
parents:
diff changeset
100 begin
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 loop
kono
parents:
diff changeset
103 -- Wait for a printer to become available:
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 while Printers_Busy loop
kono
parents:
diff changeset
106 Printers_Busy := False; -- Exit loop if
kono
parents:
diff changeset
107 -- entry accepted.
kono
parents:
diff changeset
108 select
kono
parents:
diff changeset
109 Printer(Index).Done_Printing; -- Accepted immed.
kono
parents:
diff changeset
110 -- when printer is
kono
parents:
diff changeset
111 -- available.
kono
parents:
diff changeset
112 else
kono
parents:
diff changeset
113 Index := 1 + (Index mod Number_Of_Printers);-- Entry not immed.
kono
parents:
diff changeset
114 Printers_Busy := True; -- accepted; keep
kono
parents:
diff changeset
115 end select; -- looping.
kono
parents:
diff changeset
116 end loop;
kono
parents:
diff changeset
117 -- Value of Index
kono
parents:
diff changeset
118 -- at loop exit
kono
parents:
diff changeset
119 -- identifies the
kono
parents:
diff changeset
120 -- avail. printer.
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- Wait for a print request or terminate:
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 select
kono
parents:
diff changeset
125 accept Print (File_Name : String) do
kono
parents:
diff changeset
126 Print_Accepted := True; -- Allow
kono
parents:
diff changeset
127 -- Verify_Results
kono
parents:
diff changeset
128 -- to be accepted.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 Printer(Index).Start_Printing (File_Name); -- Begin printing on
kono
parents:
diff changeset
131 -- the available
kono
parents:
diff changeset
132 -- -- -- printer.
kono
parents:
diff changeset
133 -- Requeue is tested here --
kono
parents:
diff changeset
134 -- --
kono
parents:
diff changeset
135 -- Requeue caller so
kono
parents:
diff changeset
136 requeue Printer(Index).Done_Printing; -- server task free
kono
parents:
diff changeset
137 -- to accept other
kono
parents:
diff changeset
138 end Print; -- requests.
kono
parents:
diff changeset
139 or
kono
parents:
diff changeset
140 -- Guard ensures that Verify_Results cannot be accepted
kono
parents:
diff changeset
141 -- until after Print has been accepted. This avoids a
kono
parents:
diff changeset
142 -- race condition in the main program.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 when Print_Accepted => accept Verify_Results; -- Artifice for
kono
parents:
diff changeset
145 -- testing purposes.
kono
parents:
diff changeset
146 or
kono
parents:
diff changeset
147 terminate;
kono
parents:
diff changeset
148 end select;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 -- Allow other tasks to get control
kono
parents:
diff changeset
151 delay ImpDef.Long_Minimum_Task_Switch;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 end loop;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 exception
kono
parents:
diff changeset
156 when others =>
kono
parents:
diff changeset
157 Report.Failed ("Exception raised in Printer_Server task");
kono
parents:
diff changeset
158 end Printer_Server;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 end C954A01_0;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 --==================================================================--
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 with Report;
kono
parents:
diff changeset
168 with ImpDef;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 with F954A00; -- Printer device abstraction.
kono
parents:
diff changeset
171 with C954A01_0; -- Printer server abstraction.
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 use C954A01_0;
kono
parents:
diff changeset
174 use F954A00;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 procedure C954A01 is
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 Long_Enough : constant Duration := ImpDef.Long_Switch_To_New_Task;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 --==============================================--
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 task Print_Request; -- Send a print request.
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 task body Print_Request is
kono
parents:
diff changeset
185 My_File : constant String := "MYFILE.DAT";
kono
parents:
diff changeset
186 begin
kono
parents:
diff changeset
187 Printer_Server.Print (My_File); -- Invoke requeue statement.
kono
parents:
diff changeset
188 Report.Failed ("Task continued execution following entry call");
kono
parents:
diff changeset
189 exception
kono
parents:
diff changeset
190 when others =>
kono
parents:
diff changeset
191 Report.Failed ("Exception raised in Print_Request task");
kono
parents:
diff changeset
192 end Print_Request;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 --==============================================--
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 begin -- Main program.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 Report.Test ("C954A01", "Requeue without abort - check that the abort " &
kono
parents:
diff changeset
199 "is deferred until after the rendezvous completes. (Task to PO)");
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 -- To pass this test, the following must be true:
kono
parents:
diff changeset
202 --
kono
parents:
diff changeset
203 -- (A) The abort of Print_Request is deferred until after the
kono
parents:
diff changeset
204 -- Done_Printing entry body completes.
kono
parents:
diff changeset
205 -- (B) Print_Request aborts after the Done_Printing entry call
kono
parents:
diff changeset
206 -- completes.
kono
parents:
diff changeset
207 --
kono
parents:
diff changeset
208 -- Call the entry Verify_Results. The entry call will not be accepted
kono
parents:
diff changeset
209 -- until after Print_Request has been requeued to Done_Printing.
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 Printer_Server.Verify_Results; -- Accepted after Print_Request is
kono
parents:
diff changeset
212 -- requeued to Done_Printing.
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 -- Simulate an application which needs access to the printer within
kono
parents:
diff changeset
215 -- a specified time, and which aborts the current printer job if time
kono
parents:
diff changeset
216 -- runs out.
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 select
kono
parents:
diff changeset
219 Printer(1).Done_Printing; -- Wait for printer to come free.
kono
parents:
diff changeset
220 or
kono
parents:
diff changeset
221 delay Long_Enough; -- Print job took too long.
kono
parents:
diff changeset
222 abort Print_Request; -- Abort print job.
kono
parents:
diff changeset
223 end select;
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 Printer_Server.Verify_Results; -- Abortion completion point: force
kono
parents:
diff changeset
226 -- abort to complete (if it's going
kono
parents:
diff changeset
227 -- to).
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 -- Verify that the Done_Printing entry body has not yet completed,
kono
parents:
diff changeset
230 -- and thus that Print_Request has not been aborted.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 if Printer(1).Is_Done then
kono
parents:
diff changeset
233 Report.Failed ("Target entry of requeue executed prematurely");
kono
parents:
diff changeset
234 elsif Print_Request'Terminated then
kono
parents:
diff changeset
235 Report.Failed ("Caller was aborted before entry was complete");
kono
parents:
diff changeset
236 else
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 Printer(1).Handle_Interrupt; -- Simulate a printer interrupt,
kono
parents:
diff changeset
239 -- signaling that printing is
kono
parents:
diff changeset
240 -- done.
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 -- The Done_Printing entry body will complete before the next protected
kono
parents:
diff changeset
243 -- action is called (Printer(1).Is_Done). Verify (A) and (B): that the
kono
parents:
diff changeset
244 -- Print_Request is aborted.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 Printer_Server.Verify_Results; -- Abortion completion point: force
kono
parents:
diff changeset
247 -- Print_Request abort to complete.
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 if not Printer(1).Is_Done then
kono
parents:
diff changeset
250 Report.Failed ("Target entry of requeue did not complete");
kono
parents:
diff changeset
251 end if;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 if not Print_Request'Terminated then
kono
parents:
diff changeset
254 Report.Failed ("Task not aborted following completion of entry call");
kono
parents:
diff changeset
255 abort Print_Request; -- Try to kill hung task.
kono
parents:
diff changeset
256 end if;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 end if;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 Report.Result;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 end C954A01;