annotate gcc/testsuite/ada/acats/tests/c9/c954001.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 -- C954001.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 a requeue statement within an entry_body with parameters
kono
parents:
diff changeset
28 -- may requeue the entry call to a protected entry with a subtype-
kono
parents:
diff changeset
29 -- conformant parameter profile. Check that, if the call is queued on the
kono
parents:
diff changeset
30 -- new entry's queue, the original caller remains blocked after the
kono
parents:
diff changeset
31 -- requeue, but the entry_body containing the requeue is completed.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- Declare a protected object which simulates a disk device. Declare an
kono
parents:
diff changeset
35 -- entry that requeues the caller to a second entry if the disk head is
kono
parents:
diff changeset
36 -- not in the proper location, but first sets the second entry's barrier
kono
parents:
diff changeset
37 -- to false. Declare a procedure which sets the second entry's barrier
kono
parents:
diff changeset
38 -- to true.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- Declare a task which calls the first entry such that the requeue is
kono
parents:
diff changeset
41 -- called. This task should be queued on the second entry and remain
kono
parents:
diff changeset
42 -- blocked, and the first entry should be complete. Call the procedure
kono
parents:
diff changeset
43 -- which releases the second entry's queue. The second entry should
kono
parents:
diff changeset
44 -- complete, after which the task should complete.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 -- CHANGE HISTORY:
kono
parents:
diff changeset
48 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 --!
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 package C954001_0 is -- Disk management abstraction.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- Simulate a read-only disk device with a head that may be moved to
kono
parents:
diff changeset
56 -- different tracks. If a read request is issued for the current
kono
parents:
diff changeset
57 -- track, the request can be satisfied immediately. Otherwise, the head
kono
parents:
diff changeset
58 -- must be moved to the correct track, during which time the calling task
kono
parents:
diff changeset
59 -- is blocked. When the head reaches the correct track, the disk generates
kono
parents:
diff changeset
60 -- an interrupt, after which the request can be satisfied, and the
kono
parents:
diff changeset
61 -- calling task can proceed.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Buffer_Size : constant := 100;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 type Disk_Buffer is new String (1 .. Buffer_Size);
kono
parents:
diff changeset
66 type Disk_Track is new Natural;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type Disk_Address is record
kono
parents:
diff changeset
69 Track : Disk_Track;
kono
parents:
diff changeset
70 -- Additional components.
kono
parents:
diff changeset
71 end record;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Initial_Track : constant Disk_Track := 0;
kono
parents:
diff changeset
74 New_Track : constant Disk_Track := 5;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 --==============================================--
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 protected Disk_Device is
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 entry Read (Where : Disk_Address; -- Read data from disk
kono
parents:
diff changeset
81 Data : out Disk_Buffer); -- track.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 procedure Disk_Interrupt; -- Handle interrupt
kono
parents:
diff changeset
84 -- from disk.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function TC_Track return Disk_Track; -- Return current track.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 function TC_Pending_Queued return Boolean; -- True when there is
kono
parents:
diff changeset
89 -- an entry in queue
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 private
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 entry Pending_Read (Where : Disk_Address; -- Wait for head to
kono
parents:
diff changeset
94 Data : out Disk_Buffer); -- move then read data.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 Current_Track : Disk_Track := Initial_Track; -- Current disk track.
kono
parents:
diff changeset
97 Operation_Pending : Boolean := False; -- Vis. entry barrier.
kono
parents:
diff changeset
98 Disk_Interrupted : Boolean := False; -- Priv. entry barrier.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 end Disk_Device;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 end C954001_0;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 --==================================================================--
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 package body C954001_0 is -- Disk management abstraction.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 protected body Disk_Device is
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 entry Read (Where : Disk_Address; Data : out Disk_Buffer)
kono
parents:
diff changeset
115 when not Operation_Pending is
kono
parents:
diff changeset
116 begin
kono
parents:
diff changeset
117 if (Where.Track = Current_Track) then -- If the head is over the
kono
parents:
diff changeset
118 -- Read data from disk... -- requested track, read
kono
parents:
diff changeset
119 null; -- the data.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 else -- Otherwise, defer read
kono
parents:
diff changeset
122 Operation_Pending := True; -- while head is moved to
kono
parents:
diff changeset
123 -- correct track (signaled
kono
parents:
diff changeset
124 -- -- -- by a disk interrupt).
kono
parents:
diff changeset
125 -- Requeue is tested here --
kono
parents:
diff changeset
126 -- --
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 requeue Pending_Read;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 end if;
kono
parents:
diff changeset
131 end Read;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 procedure Disk_Interrupt is -- Called when the disk
kono
parents:
diff changeset
135 begin -- interrupts, indicating
kono
parents:
diff changeset
136 Disk_Interrupted := True; -- that the head is over
kono
parents:
diff changeset
137 end Disk_Interrupt; -- the correct track.
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 function TC_Track return Disk_Track is -- Artifice required for
kono
parents:
diff changeset
141 begin -- testing purposes.
kono
parents:
diff changeset
142 return (Current_Track);
kono
parents:
diff changeset
143 end TC_Track;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 entry Pending_Read (Where : Disk_Address; Data : out Disk_Buffer)
kono
parents:
diff changeset
147 when Disk_Interrupted is
kono
parents:
diff changeset
148 begin
kono
parents:
diff changeset
149 Current_Track := Where.Track; -- Head is now over the
kono
parents:
diff changeset
150 -- Read data from disk... -- correct track; read
kono
parents:
diff changeset
151 Operation_Pending := False; -- the data.
kono
parents:
diff changeset
152 Disk_Interrupted := False;
kono
parents:
diff changeset
153 end Pending_Read;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 function TC_Pending_Queued return Boolean is
kono
parents:
diff changeset
156 begin
kono
parents:
diff changeset
157 -- Return true when there is something on the Pending_Read queue
kono
parents:
diff changeset
158 return (Pending_Read'Count /=0);
kono
parents:
diff changeset
159 end TC_Pending_Queued;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 end Disk_Device;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 end C954001_0;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 --==================================================================--
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 with Report;
kono
parents:
diff changeset
171 with ImpDef;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 with C954001_0; -- Disk management abstraction.
kono
parents:
diff changeset
174 use C954001_0;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 procedure C954001 is
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 task type Read_Task is -- an unusual (but legal) declaration
kono
parents:
diff changeset
180 end Read_Task;
kono
parents:
diff changeset
181 --
kono
parents:
diff changeset
182 --
kono
parents:
diff changeset
183 task body Read_Task is
kono
parents:
diff changeset
184 Location : constant Disk_Address := (Track => New_Track);
kono
parents:
diff changeset
185 Data : Disk_Buffer := (others => ' ');
kono
parents:
diff changeset
186 begin
kono
parents:
diff changeset
187 Disk_Device.Read (Location, Data); -- Invoke requeue statement.
kono
parents:
diff changeset
188 exception
kono
parents:
diff changeset
189 when others =>
kono
parents:
diff changeset
190 Report.Failed ("Exception raised in task");
kono
parents:
diff changeset
191 end Read_Task;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 --==============================================--
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 begin -- Main program.
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 Report.Test ("C954001", "Requeue from an entry within a P.O. " &
kono
parents:
diff changeset
198 "to a private entry within the same P.O.");
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 declare
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 IO_Request : Read_Task; -- Request a read from other
kono
parents:
diff changeset
204 -- than the current track.
kono
parents:
diff changeset
205 -- IO_Request will be requeued
kono
parents:
diff changeset
206 -- from Read to Pending_Read.
kono
parents:
diff changeset
207 begin
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 -- To pass this test, the following must be true:
kono
parents:
diff changeset
210 --
kono
parents:
diff changeset
211 -- (A) The Read entry call made by the task IO_Request must be
kono
parents:
diff changeset
212 -- completed by the requeue.
kono
parents:
diff changeset
213 -- (B) IO_Request must remain blocked following the requeue.
kono
parents:
diff changeset
214 -- (C) IO_Request must be queued on the Pending_Read entry queue.
kono
parents:
diff changeset
215 -- (D) IO_Request must continue execution after the Pending_Read
kono
parents:
diff changeset
216 -- entry completes.
kono
parents:
diff changeset
217 --
kono
parents:
diff changeset
218 -- First, verify (A): that the Read entry call is complete.
kono
parents:
diff changeset
219 --
kono
parents:
diff changeset
220 -- Call a protected operation (Disk_Device.TC_Track). Since no two
kono
parents:
diff changeset
221 -- protected actions may proceed concurrently unless both are protected
kono
parents:
diff changeset
222 -- function calls, a call to a protected operation at this point can
kono
parents:
diff changeset
223 -- proceed only if the Read entry call is already complete.
kono
parents:
diff changeset
224 --
kono
parents:
diff changeset
225 -- Note that if Read is NOT complete, the test will likely hang here.
kono
parents:
diff changeset
226 --
kono
parents:
diff changeset
227 -- Next, verify (B): that IO_Request remains blocked following the
kono
parents:
diff changeset
228 -- requeue. Also verify that Pending_Read (the entry to which
kono
parents:
diff changeset
229 -- IO_Request should have been queued) has not yet executed.
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 -- Wait until the task had made the call and the requeue has been
kono
parents:
diff changeset
232 -- effected.
kono
parents:
diff changeset
233 while not Disk_Device.TC_Pending_Queued loop
kono
parents:
diff changeset
234 delay ImpDef.Minimum_Task_Switch;
kono
parents:
diff changeset
235 end loop;
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 if Disk_Device.TC_Track /= Initial_Track then
kono
parents:
diff changeset
238 Report.Failed ("Target entry of requeue executed prematurely");
kono
parents:
diff changeset
239 elsif IO_Request'Terminated then
kono
parents:
diff changeset
240 Report.Failed ("Caller did not remain blocked after " &
kono
parents:
diff changeset
241 "the requeue or was never requeued");
kono
parents:
diff changeset
242 else
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 -- Verify (C): that IO_Request is queued on the
kono
parents:
diff changeset
245 -- Pending_Read entry queue.
kono
parents:
diff changeset
246 --
kono
parents:
diff changeset
247 -- Set the barrier for Pending_Read to true. Check that the
kono
parents:
diff changeset
248 -- current track is updated and that IO_Request terminates.
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 Disk_Device.Disk_Interrupt; -- Simulate a disk interrupt,
kono
parents:
diff changeset
251 -- signaling that the head is
kono
parents:
diff changeset
252 -- over the correct track.
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 -- The Pending_Read entry body will complete before the next
kono
parents:
diff changeset
255 -- protected action is called (Disk_Device.TC_Track).
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 if Disk_Device.TC_Track /= New_Track then
kono
parents:
diff changeset
258 Report.Failed ("Caller was not requeued on target entry");
kono
parents:
diff changeset
259 end if;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 -- Finally, verify (D): that Read_Task continues after Pending_Read
kono
parents:
diff changeset
262 -- completes.
kono
parents:
diff changeset
263 --
kono
parents:
diff changeset
264 -- Note that the test will hang here if Read_Task does not continue
kono
parents:
diff changeset
265 -- executing following the completion of the requeued entry call.
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 end if;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 end; -- We will not exit the declare block until the task completes
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 Report.Result;
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 end C954001;