annotate gcc/ada/libgnarl/s-tasuti.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . T A S K I N G . U T I L I T I E S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNARL is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNARL was developed by the GNARL team at Florida State University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides RTS Internal Declarations.
kono
parents:
diff changeset
33 -- These declarations are not part of the GNARLI
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
36 with System.Task_Primitives;
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 package System.Tasking.Utilities is
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 function ATCB_To_Address is new
kono
parents:
diff changeset
41 Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address);
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 ---------------------------------
kono
parents:
diff changeset
44 -- Task_Stage Related routines --
kono
parents:
diff changeset
45 ---------------------------------
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 function Make_Independent return Boolean;
kono
parents:
diff changeset
48 -- Move the current task to the outermost level (level 2) of the master
kono
parents:
diff changeset
49 -- hierarchy of the environment task. That is one level further out
kono
parents:
diff changeset
50 -- than normal tasks defined in library-level packages (level 3). The
kono
parents:
diff changeset
51 -- environment task will wait for level 3 tasks to terminate normally,
kono
parents:
diff changeset
52 -- then it will abort all the level 2 tasks. See Finalize_Global_Tasks
kono
parents:
diff changeset
53 -- procedure for more information.
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- This is a dangerous operation, and should never be used on nested tasks
kono
parents:
diff changeset
56 -- or tasks that depend on any objects that might be finalized earlier than
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 -- the termination of the environment task. It is primarily for internal
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58 -- use by the GNARL, to prevent such internal server tasks from preventing
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
59 -- a partition from terminating.
111
kono
parents:
diff changeset
60 --
kono
parents:
diff changeset
61 -- Also note that the run time assumes that the parent of an independent
kono
parents:
diff changeset
62 -- task is the environment task. If this is not the case, Make_Independent
kono
parents:
diff changeset
63 -- will change the task's parent. This assumption is particularly
kono
parents:
diff changeset
64 -- important for master level completion and for the computation of
kono
parents:
diff changeset
65 -- Independent_Task_Count.
kono
parents:
diff changeset
66 --
kono
parents:
diff changeset
67 -- NOTE WELL: Make_Independent should be called before the task reaches its
kono
parents:
diff changeset
68 -- "begin", like this:
kono
parents:
diff changeset
69 --
kono
parents:
diff changeset
70 -- task body Some_Independent_Task is
kono
parents:
diff changeset
71 -- ...
kono
parents:
diff changeset
72 -- Ignore : constant Boolean := Make_Independent;
kono
parents:
diff changeset
73 -- ...
kono
parents:
diff changeset
74 -- begin
kono
parents:
diff changeset
75 --
kono
parents:
diff changeset
76 -- The return value is meaningless; the only reason this is a function is
kono
parents:
diff changeset
77 -- to get around the Ada limitation that makes a procedure call
kono
parents:
diff changeset
78 -- syntactically illegal before the "begin".
kono
parents:
diff changeset
79 --
kono
parents:
diff changeset
80 -- Calling it before "begin" ensures that the call completes before the
kono
parents:
diff changeset
81 -- activating task can proceed. This is important for preventing race
kono
parents:
diff changeset
82 -- conditions. For example, if the environment task reaches
kono
parents:
diff changeset
83 -- Finalize_Global_Tasks before some task has finished Make_Independent,
kono
parents:
diff changeset
84 -- the program can hang.
kono
parents:
diff changeset
85 --
kono
parents:
diff changeset
86 -- Note also that if a package declares independent tasks, it should not
kono
parents:
diff changeset
87 -- initialize its package-body data after "begin" of the package, because
kono
parents:
diff changeset
88 -- that's where the tasks are activated. Initializing such data before the
kono
parents:
diff changeset
89 -- task activation helps prevent the tasks from accessing uninitialized
kono
parents:
diff changeset
90 -- data.
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 Independent_Task_Count : Natural := 0;
kono
parents:
diff changeset
93 -- Number of independent tasks. This counter is incremented each time
kono
parents:
diff changeset
94 -- Make_Independent is called. Note that if a server task terminates,
kono
parents:
diff changeset
95 -- this counter will not be decremented. Since Make_Independent locks
kono
parents:
diff changeset
96 -- the environment task (because every independent task depends on it),
kono
parents:
diff changeset
97 -- this counter is protected by the environment task's lock.
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 ---------------------------------
kono
parents:
diff changeset
100 -- Task Abort Related Routines --
kono
parents:
diff changeset
101 ---------------------------------
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Cancel_Queued_Entry_Calls (T : Task_Id);
kono
parents:
diff changeset
104 -- Cancel any entry calls queued on target task.
kono
parents:
diff changeset
105 -- Call this while holding T's lock (or RTS_Lock in Single_Lock mode).
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Exit_One_ATC_Level (Self_ID : Task_Id);
kono
parents:
diff changeset
108 pragma Inline (Exit_One_ATC_Level);
kono
parents:
diff changeset
109 -- Call only with abort deferred and holding lock of Self_ID.
kono
parents:
diff changeset
110 -- This is a bit of common code for all entry calls.
kono
parents:
diff changeset
111 -- The effect is to exit one level of ATC nesting.
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Abort_One_Task (Self_ID : Task_Id; T : Task_Id);
kono
parents:
diff changeset
114 -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but:
kono
parents:
diff changeset
115 -- (1) caller should be holding no locks
kono
parents:
diff changeset
116 -- (2) may be called for tasks that have not yet been activated
kono
parents:
diff changeset
117 -- (3) always aborts whole task
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 procedure Abort_Tasks (Tasks : Task_List);
kono
parents:
diff changeset
120 -- Abort_Tasks is called to initiate abort, however, the actual
kono
parents:
diff changeset
121 -- aborting is done by aborted task by means of Abort_Handler
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Make_Passive (Self_ID : Task_Id; Task_Completed : Boolean);
kono
parents:
diff changeset
124 -- Update counts to indicate current task is either terminated or
kono
parents:
diff changeset
125 -- accepting on a terminate alternative. Call holding no locks except
kono
parents:
diff changeset
126 -- Global_Task_Lock when calling from Terminate_Task, and RTS_Lock when
kono
parents:
diff changeset
127 -- Single_Lock is True.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 end System.Tasking.Utilities;