OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c9/] [c974001.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- C974001.A
2
--
3
--
4
--                             Grant of Unlimited Rights
5
--
6
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
7
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
8
--     unlimited rights in the software and documentation contained herein.
9
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
10
--     this public release, the Government intends to confer upon all
11
--     recipients unlimited rights  equal to those held by the Government.
12
--     These rights include rights to use, duplicate, release or disclose the
13
--     released technical data and computer software in whole or in part, in
14
--     any manner and for any purpose whatsoever, and to have or permit others
15
--     to do so.
16
--
17
--                                    DISCLAIMER
18
--
19
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
20
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
21
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
22
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
23
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
24
--     PARTICULAR PURPOSE OF SAID MATERIAL.
25
--*
26
--
27
-- OBJECTIVE:
28
--      Check that the abortable part of an asynchronous select statement
29
--      is aborted if it does not complete before the triggering statement
30
--      completes, where the triggering statement is a delay_relative
31
--      statement and check that the sequence of statements of the triggering
32
--      alternative is executed after the abortable part is left.
33
--
34
-- TEST DESCRIPTION:
35
--      Declare a task with an accept statement containing an asynchronous
36
--      select with a delay_relative triggering statement. Parameterize
37
--      the accept statement with the time to be used in the delay. Simulate a
38
--      time-consuming calculation by declaring a procedure containing an
39
--      infinite loop. Call this procedure in the abortable part.
40
--
41
--      The delay will expire before the abortable part completes, at which
42
--      time the abortable part is aborted, and the sequence of statements
43
--      following the triggering statement is executed.
44
--
45
--
46
-- CHANGE HISTORY:
47
--      06 Dec 94   SAIC    ACVC 2.0
48
--
49
--!
50
 
51
with Report;
52
with ImpDef;
53
 
54
procedure C974001 is
55
 
56
 
57
          --========================================================--
58
 
59
   -- Medium length delay
60
   Allotted_Time : constant Duration :=  ImpDef.Switch_To_New_Task;
61
 
62
   Calculation_Canceled : exception;
63
 
64
 
65
   Count : Integer := 1234;
66
 
67
   procedure Lengthy_Calculation is
68
   begin
69
      -- Simulate a non-converging calculation.
70
      loop                                           -- Infinite loop.
71
         Count := (Count + 1) mod 10;
72
         delay ImpDef.Minimum_Task_Switch;           -- allow other task
73
      end loop;
74
   end Lengthy_Calculation;
75
 
76
 
77
          --========================================================--
78
 
79
 
80
   task type Timed_Calculation is
81
      entry Calculation (Time_Limit : in Duration);
82
   end Timed_Calculation;
83
 
84
 
85
   task body Timed_Calculation is
86
   --
87
   begin
88
      loop
89
         select
90
            accept Calculation (Time_Limit : in Duration) do
91
 
92
               --                                    --
93
               -- Asynchronous select is tested here --
94
               --                                    --
95
 
96
               select
97
                  delay Time_Limit;           -- Time_Limit is not up yet, so
98
                                              -- Lengthy_Calculation starts.
99
 
100
                  raise Calculation_Canceled; -- This is executed after
101
                                              -- Lengthy_Calculation aborted.
102
               then abort
103
                  Lengthy_Calculation;        -- Delay expires before complete,
104
                                              -- so this call is aborted.
105
 
106
                  -- Check that the whole of the abortable part is aborted,
107
                  -- not just the statement in the abortable part that was
108
                  -- executing at the time
109
                  Report.Failed ("Abortable part not aborted");
110
 
111
               end select;
112
 
113
               Report.Failed ("Triggering alternative sequence of " &
114
                              "statements not executed");
115
 
116
            exception    -- New Ada 9x: handler within accept
117
               when Calculation_Canceled =>
118
                  if Count = 1234 then
119
                     Report.Failed ("Abortable part did not execute");
120
                  end if;
121
            end Calculation;
122
         or
123
            terminate;
124
         end select;
125
      end loop;
126
   exception
127
      when others =>
128
         Report.Failed ("Unexpected exception in Timed_Calculation task");
129
   end Timed_Calculation;
130
 
131
 
132
          --========================================================--
133
 
134
 
135
begin  -- Main program.
136
 
137
   Report.Test ("C974001", "Asynchronous Select: Trigger is delay_relative" &
138
                           " which completes before abortable part");
139
 
140
   declare
141
      Timed : Timed_Calculation;  -- Task.
142
   begin
143
      Timed.Calculation (Time_Limit => Allotted_Time); -- Asynchronous select
144
                                                       -- inside accept block.
145
   exception
146
      when Calculation_Canceled =>
147
         null; -- expected behavior
148
   end;
149
 
150
   Report.Result;
151
 
152
end C974001;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.