-- C974001.A
|
-- C974001.A
|
--
|
--
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the abortable part of an asynchronous select statement
|
-- Check that the abortable part of an asynchronous select statement
|
-- is aborted if it does not complete before the triggering statement
|
-- is aborted if it does not complete before the triggering statement
|
-- completes, where the triggering statement is a delay_relative
|
-- completes, where the triggering statement is a delay_relative
|
-- statement and check that the sequence of statements of the triggering
|
-- statement and check that the sequence of statements of the triggering
|
-- alternative is executed after the abortable part is left.
|
-- alternative is executed after the abortable part is left.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- Declare a task with an accept statement containing an asynchronous
|
-- Declare a task with an accept statement containing an asynchronous
|
-- select with a delay_relative triggering statement. Parameterize
|
-- select with a delay_relative triggering statement. Parameterize
|
-- the accept statement with the time to be used in the delay. Simulate a
|
-- the accept statement with the time to be used in the delay. Simulate a
|
-- time-consuming calculation by declaring a procedure containing an
|
-- time-consuming calculation by declaring a procedure containing an
|
-- infinite loop. Call this procedure in the abortable part.
|
-- infinite loop. Call this procedure in the abortable part.
|
--
|
--
|
-- The delay will expire before the abortable part completes, at which
|
-- The delay will expire before the abortable part completes, at which
|
-- time the abortable part is aborted, and the sequence of statements
|
-- time the abortable part is aborted, and the sequence of statements
|
-- following the triggering statement is executed.
|
-- following the triggering statement is executed.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
--
|
--
|
--!
|
--!
|
|
|
with Report;
|
with Report;
|
with ImpDef;
|
with ImpDef;
|
|
|
procedure C974001 is
|
procedure C974001 is
|
|
|
|
|
--========================================================--
|
--========================================================--
|
|
|
-- Medium length delay
|
-- Medium length delay
|
Allotted_Time : constant Duration := ImpDef.Switch_To_New_Task;
|
Allotted_Time : constant Duration := ImpDef.Switch_To_New_Task;
|
|
|
Calculation_Canceled : exception;
|
Calculation_Canceled : exception;
|
|
|
|
|
Count : Integer := 1234;
|
Count : Integer := 1234;
|
|
|
procedure Lengthy_Calculation is
|
procedure Lengthy_Calculation is
|
begin
|
begin
|
-- Simulate a non-converging calculation.
|
-- Simulate a non-converging calculation.
|
loop -- Infinite loop.
|
loop -- Infinite loop.
|
Count := (Count + 1) mod 10;
|
Count := (Count + 1) mod 10;
|
delay ImpDef.Minimum_Task_Switch; -- allow other task
|
delay ImpDef.Minimum_Task_Switch; -- allow other task
|
end loop;
|
end loop;
|
end Lengthy_Calculation;
|
end Lengthy_Calculation;
|
|
|
|
|
--========================================================--
|
--========================================================--
|
|
|
|
|
task type Timed_Calculation is
|
task type Timed_Calculation is
|
entry Calculation (Time_Limit : in Duration);
|
entry Calculation (Time_Limit : in Duration);
|
end Timed_Calculation;
|
end Timed_Calculation;
|
|
|
|
|
task body Timed_Calculation is
|
task body Timed_Calculation is
|
--
|
--
|
begin
|
begin
|
loop
|
loop
|
select
|
select
|
accept Calculation (Time_Limit : in Duration) do
|
accept Calculation (Time_Limit : in Duration) do
|
|
|
-- --
|
-- --
|
-- Asynchronous select is tested here --
|
-- Asynchronous select is tested here --
|
-- --
|
-- --
|
|
|
select
|
select
|
delay Time_Limit; -- Time_Limit is not up yet, so
|
delay Time_Limit; -- Time_Limit is not up yet, so
|
-- Lengthy_Calculation starts.
|
-- Lengthy_Calculation starts.
|
|
|
raise Calculation_Canceled; -- This is executed after
|
raise Calculation_Canceled; -- This is executed after
|
-- Lengthy_Calculation aborted.
|
-- Lengthy_Calculation aborted.
|
then abort
|
then abort
|
Lengthy_Calculation; -- Delay expires before complete,
|
Lengthy_Calculation; -- Delay expires before complete,
|
-- so this call is aborted.
|
-- so this call is aborted.
|
|
|
-- Check that the whole of the abortable part is aborted,
|
-- Check that the whole of the abortable part is aborted,
|
-- not just the statement in the abortable part that was
|
-- not just the statement in the abortable part that was
|
-- executing at the time
|
-- executing at the time
|
Report.Failed ("Abortable part not aborted");
|
Report.Failed ("Abortable part not aborted");
|
|
|
end select;
|
end select;
|
|
|
Report.Failed ("Triggering alternative sequence of " &
|
Report.Failed ("Triggering alternative sequence of " &
|
"statements not executed");
|
"statements not executed");
|
|
|
exception -- New Ada 9x: handler within accept
|
exception -- New Ada 9x: handler within accept
|
when Calculation_Canceled =>
|
when Calculation_Canceled =>
|
if Count = 1234 then
|
if Count = 1234 then
|
Report.Failed ("Abortable part did not execute");
|
Report.Failed ("Abortable part did not execute");
|
end if;
|
end if;
|
end Calculation;
|
end Calculation;
|
or
|
or
|
terminate;
|
terminate;
|
end select;
|
end select;
|
end loop;
|
end loop;
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed ("Unexpected exception in Timed_Calculation task");
|
Report.Failed ("Unexpected exception in Timed_Calculation task");
|
end Timed_Calculation;
|
end Timed_Calculation;
|
|
|
|
|
--========================================================--
|
--========================================================--
|
|
|
|
|
begin -- Main program.
|
begin -- Main program.
|
|
|
Report.Test ("C974001", "Asynchronous Select: Trigger is delay_relative" &
|
Report.Test ("C974001", "Asynchronous Select: Trigger is delay_relative" &
|
" which completes before abortable part");
|
" which completes before abortable part");
|
|
|
declare
|
declare
|
Timed : Timed_Calculation; -- Task.
|
Timed : Timed_Calculation; -- Task.
|
begin
|
begin
|
Timed.Calculation (Time_Limit => Allotted_Time); -- Asynchronous select
|
Timed.Calculation (Time_Limit => Allotted_Time); -- Asynchronous select
|
-- inside accept block.
|
-- inside accept block.
|
exception
|
exception
|
when Calculation_Canceled =>
|
when Calculation_Canceled =>
|
null; -- expected behavior
|
null; -- expected behavior
|
end;
|
end;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end C974001;
|
end C974001;
|
|
|