]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.ada/task_watch/foo.adb
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / task_watch / foo.adb
CommitLineData
4a94e368 1-- Copyright 2009-2022 Free Software Foundation, Inc.
8a18382f
TT
2--
3-- This program is free software; you can redistribute it and/or modify
4-- it under the terms of the GNU General Public License as published by
5-- the Free Software Foundation; either version 3 of the License, or
6-- (at your option) any later version.
7--
8-- This program is distributed in the hope that it will be useful,
9-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-- GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License
14-- along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16procedure Foo is
17
18 Value : Integer := 0;
19
20 task type Caller is
21 entry Initialize;
22 entry Call_Break_Me;
23 entry Finalize;
24 end Caller;
25 type Caller_Ptr is access Caller;
26
27 procedure Break_Me is
28 begin
29 Value := Value + 1;
30 end Break_Me;
31
32 task body Caller is
33 begin
34 accept Initialize do
35 null;
36 end Initialize;
37 accept Call_Break_Me do
38 Break_Me;
39 end Call_Break_Me;
40 accept Finalize do
41 null;
42 end Finalize;
43 end Caller;
44
45 Task_List : array (1 .. 3) of Caller_Ptr;
46
47begin
48
49 -- Start all our tasks, and call the "Initialize" entry to make
50 -- sure all of them have now been started. We call that entry
51 -- immediately after having created the task in order to make sure
52 -- that we wait for that task to be created before we try to create
53 -- another one. That way, we know that the order in our Task_List
54 -- corresponds to the order in the GNAT runtime.
55 for J in Task_List'Range loop
56 Task_List (J) := new Caller;
57 Task_List (J).Initialize;
58 end loop;
59
60 -- Next, call their Call_Break_Me entry of each task, using the same
61 -- order as the order used to create them.
62 for J in Task_List'Range loop -- STOP_HERE
63 Task_List (J).Call_Break_Me;
64 end loop;
65
66 -- And finally, let all the tasks die...
67 for J in Task_List'Range loop
68 Task_List (J).Finalize;
69 end loop;
70
71 null; -- STOP_HERE_2
72
73end Foo;