1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K I N G . U T I L I T I E S --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- This package provides RTS Internal Declarations.
35 -- These declarations are not part of the GNARLI
37 with Unchecked_Conversion
;
39 package System
.Tasking
.Utilities
is
41 function ATCB_To_Address
is new
42 Unchecked_Conversion
(Task_Id
, System
.Address
);
44 ---------------------------------
45 -- Task_Stage Related routines --
46 ---------------------------------
48 procedure Make_Independent
;
49 -- Move the current task to the outermost level (level 2) of the master
50 -- hierarchy of the environment task. That is one level further out
51 -- than normal tasks defined in library-level packages (level 3). The
52 -- environment task will wait for level 3 tasks to terminate normally,
53 -- then it will abort all the level 2 tasks. See Finalize_Global_Tasks
54 -- procedure for more information.
56 -- This is a dangerous operation, and should only be used on nested tasks
57 -- or tasks that depend on any objects that might be finalized earlier than
58 -- the termination of the environment task. It is for internal use by the
59 -- GNARL, to prevent such internal server tasks from preventing a partition
62 -- Also note that the run time assumes that the parent of an independent
63 -- task is the environment task. If this is not the case, Make_Independent
64 -- will change the task's parent. This assumption is particularly
65 -- important for master level completion and for the computation of
66 -- Independent_Task_Count.
68 Independent_Task_Count
: Natural := 0;
69 -- Number of independent task. This counter is incremented each time
70 -- Make_Independent is called. Note that if a server task terminates,
71 -- this counter will not be decremented. Since Make_Independent locks
72 -- the environment task (because every independent task depends on it),
73 -- this counter is protected by the environment task's lock.
75 ---------------------------------
76 -- Task Abort Related Routines --
77 ---------------------------------
79 procedure Cancel_Queued_Entry_Calls
(T
: Task_Id
);
80 -- Cancel any entry calls queued on target task.
81 -- Call this while holding T's lock (or RTS_Lock in Single_Lock mode).
83 procedure Exit_One_ATC_Level
(Self_ID
: Task_Id
);
84 pragma Inline
(Exit_One_ATC_Level
);
85 -- Call only with abort deferred and holding lock of Self_ID.
86 -- This is a bit of common code for all entry calls.
87 -- The effect is to exit one level of ATC nesting.
89 procedure Abort_One_Task
(Self_ID
: Task_Id
; T
: Task_Id
);
90 -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but:
91 -- (1) caller should be holding no locks
92 -- (2) may be called for tasks that have not yet been activated
93 -- (3) always aborts whole task
95 procedure Abort_Tasks
(Tasks
: Task_List
);
96 -- Abort_Tasks is called to initiate abort, however, the actual
97 -- aborti is done by aborted task by means of Abort_Handler
99 procedure Make_Passive
(Self_ID
: Task_Id
; Task_Completed
: Boolean);
100 -- Update counts to indicate current task is either terminated or
101 -- accepting on a terminate alternative. Call holding no locks except
102 -- Global_Task_Lock when calling from Terminate_Task, and RTS_Lock when
103 -- Single_Lock is True.
105 end System
.Tasking
.Utilities
;