1------------------------------------------------------------------------------ 2-- -- 3-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- 4-- -- 5-- S Y S T E M . T A S K I N G . U T I L I T I E S -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- 10-- -- 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 3, or (at your option) any later ver- -- 14-- sion. GNAT 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. -- 17-- -- 18-- As a special exception under Section 7 of GPL version 3, you are granted -- 19-- additional permissions described in the GCC Runtime Library Exception, -- 20-- version 3.1, as published by the Free Software Foundation. -- 21-- -- 22-- You should have received a copy of the GNU General Public License and -- 23-- a copy of the GCC Runtime Library Exception along with this program; -- 24-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 25-- <http://www.gnu.org/licenses/>. -- 26-- -- 27-- GNARL was developed by the GNARL team at Florida State University. -- 28-- Extensive contributions were provided by Ada Core Technologies, Inc. -- 29-- -- 30------------------------------------------------------------------------------ 31 32-- This package provides RTS Internal Declarations. 33-- These declarations are not part of the GNARLI 34 35with Ada.Unchecked_Conversion; 36with System.Task_Primitives; 37 38package System.Tasking.Utilities is 39 40 function ATCB_To_Address is new 41 Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address); 42 43 --------------------------------- 44 -- Task_Stage Related routines -- 45 --------------------------------- 46 47 procedure Make_Independent; 48 -- Move the current task to the outermost level (level 2) of the master 49 -- hierarchy of the environment task. That is one level further out 50 -- than normal tasks defined in library-level packages (level 3). The 51 -- environment task will wait for level 3 tasks to terminate normally, 52 -- then it will abort all the level 2 tasks. See Finalize_Global_Tasks 53 -- procedure for more information. 54 -- 55 -- This is a dangerous operation, and should never be used on nested tasks 56 -- or tasks that depend on any objects that might be finalized earlier than 57 -- the termination of the environment task. It is for internal use by the 58 -- GNARL, to prevent such internal server tasks from preventing a partition 59 -- from terminating. 60 -- 61 -- Also note that the run time assumes that the parent of an independent 62 -- task is the environment task. If this is not the case, Make_Independent 63 -- will change the task's parent. This assumption is particularly 64 -- important for master level completion and for the computation of 65 -- Independent_Task_Count. 66 67 Independent_Task_Count : Natural := 0; 68 -- Number of independent task. This counter is incremented each time 69 -- Make_Independent is called. Note that if a server task terminates, 70 -- this counter will not be decremented. Since Make_Independent locks 71 -- the environment task (because every independent task depends on it), 72 -- this counter is protected by the environment task's lock. 73 74 --------------------------------- 75 -- Task Abort Related Routines -- 76 --------------------------------- 77 78 procedure Cancel_Queued_Entry_Calls (T : Task_Id); 79 -- Cancel any entry calls queued on target task. 80 -- Call this while holding T's lock (or RTS_Lock in Single_Lock mode). 81 82 procedure Exit_One_ATC_Level (Self_ID : Task_Id); 83 pragma Inline (Exit_One_ATC_Level); 84 -- Call only with abort deferred and holding lock of Self_ID. 85 -- This is a bit of common code for all entry calls. 86 -- The effect is to exit one level of ATC nesting. 87 88 procedure Abort_One_Task (Self_ID : Task_Id; T : Task_Id); 89 -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but: 90 -- (1) caller should be holding no locks 91 -- (2) may be called for tasks that have not yet been activated 92 -- (3) always aborts whole task 93 94 procedure Abort_Tasks (Tasks : Task_List); 95 -- Abort_Tasks is called to initiate abort, however, the actual 96 -- aborting is done by aborted task by means of Abort_Handler 97 98 procedure Make_Passive (Self_ID : Task_Id; Task_Completed : Boolean); 99 -- Update counts to indicate current task is either terminated or 100 -- accepting on a terminate alternative. Call holding no locks except 101 -- Global_Task_Lock when calling from Terminate_Task, and RTS_Lock when 102 -- Single_Lock is True. 103 104end System.Tasking.Utilities; 105