home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / s-tasini.ads < prev    next >
Text File  |  1996-09-28  |  6KB  |  139 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --         S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N        --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.1 $                             --
  10. --                                                                          --
  11. --      Copyright (c) 1991,1992,1993,1994,1995 FSU, All Rights Reserved     --
  12. --                                                                          --
  13. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  14. -- terms  of  the  GNU  Library General Public License  as published by the --
  15. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  16. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  17. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  18. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. -- eral Library Public License  for more details.  You should have received --
  20. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  21. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  22. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package provides overall initialization of the tasking portion
  27. --  of the RTS.  This package must be elaborated before any tasking
  28. --  features are used.  It also contains initialization for
  29. --  Ada Task Control Block (ATCB) records.
  30.  
  31. package System.Tasking.Initialization is
  32.  
  33.    --  The following record holds the information used to initialize a task
  34.  
  35.    type ATCB_Init is record
  36.       Task_Entry_Point : Task_Procedure_Access;
  37.       Task_Arg         : System.Address;
  38.       Stack_Size       : Size_Type;
  39.       Activator        : Task_ID;
  40.       Parent           : Task_ID;
  41.       Master_of_Task   : Master_ID;
  42.       Elaborated       : Access_Boolean;
  43.       Entry_Num        : Task_Entry_Index;
  44.       Priority         : System.Priority;
  45.    end record;
  46.  
  47.    All_Tasks_List : Task_ID;
  48.    All_Tasks_L : System.Task_Primitives.Lock;
  49.    --  All_Tasks_L should not be locked by a task that holds any other
  50.    --  locks; in other words, All_Tasks_L should be the outermost lock.
  51.    --  Currently, only ATCB locks are locked at the same time as All_Tasks_L.
  52.  
  53.    procedure Remove_From_All_Tasks_List
  54.       (Source : Task_ID; Result : out Boolean);
  55.    --  Remove an entry from the All_Tasks_List.
  56.  
  57.    -----------------------------
  58.    -- ATCB related operations --
  59.    -----------------------------
  60.  
  61.    procedure Initialize_ATCB
  62.      (T    : Task_ID;
  63.       Init : ATCB_Init);
  64.    --  Initialize fields of a TCB and link into global TCB structures
  65.  
  66.    function New_ATCB
  67.      (Init : ATCB_Init)
  68.       return Task_ID;
  69.    --  New_ATCB creates a new ATCB using Ada allocators and initializes
  70.    --  it.
  71.  
  72.    function Unsafe_New_ATCB
  73.      (Init : ATCB_Init)
  74.       return Task_ID;
  75.    --  Like New_ATCB, but without the initialization.
  76.  
  77.    procedure Free_ATCB (T : in out Task_ID);
  78.    --  Release storage of a previously allocated ATCB
  79.  
  80.    ----------------------------------------------
  81.    -- RTS routine to be used for pragma assert --
  82.    ----------------------------------------------
  83.  
  84.    function Runtime_Assert_Shutdown (Msg : in String) return boolean;
  85.    --  This function is used to shut down the runtime when there is
  86.    --  an assertion error to be raise through "pragma Assert"
  87.    --  Usage should be either
  88.    --    pragma Assert (Runtime_Assert_Shutdown ("..."));
  89.    --    --  uncoditional shutdown
  90.    --  or
  91.    --    pragma Assert
  92.    --      (ASSERT_CONDITION or else Runtime_Assert_Shutdown ("..."));
  93.    --    --  conditional shutdown. Shut down the runtime only when the
  94.    --    --  ASSERT_CONDITION fails.
  95.  
  96.    --------------------------
  97.    -- Master ID operations --
  98.    --------------------------
  99.  
  100.    procedure Init_Master (M : out Master_ID);
  101.    pragma Inline (Init_Master);
  102.  
  103.    function Increment_Master (M : Master_ID) return Master_ID;
  104.    pragma Inline (Increment_Master);
  105.  
  106.    function Decrement_Master (M : Master_ID) return Master_ID;
  107.    pragma Inline (Decrement_Master);
  108.  
  109.    -------------------------------
  110.    -- Abortion related routines --
  111.    -------------------------------
  112.  
  113.    procedure Abort_Handler (Context : System.Task_Primitives.Pre_Call_State);
  114.    --  Handler to be installed at initialization; it is invoked by a task
  115.    --  when it is the target of an Abort_Task low-level operation.
  116.  
  117.    procedure Change_Base_Priority (T : Task_ID);
  118.    --  Change the base priority of T.
  119.    --  Has to be called with T.Lock write locked.
  120.  
  121.    procedure Defer_Abortion;
  122.    --  Defer the affects of low-level abortion in the calling task until a
  123.    --  matching Undefer_Abortion call is executed.  Defer_Abortion can be
  124.    --  nested; abortion will be deferred until the calling task has
  125.    --  called Undefer_Abortion for each outstanding call to
  126.    --  Defer_Abortion.  Note that abortion must be deferred before
  127.    --  calling any low-level (GNULLI) services.
  128. --    pragma Inline (Defer_Abortion); --  To allow breakpoints to be set. ???
  129.  
  130.    procedure Undefer_Abortion;
  131.    --  Undo the effects of one call to Defer_Abortion.  When the calling
  132.    --  task has called Undefer_Abortion for each outstanding call to
  133.    --  Defer_Abortion, any pending low-level abortion will take effect,
  134.    --  and subsequent low-level abortions will have an immediate
  135.    --  asynchronous effect.
  136. --    pragma Inline (Undefer_Abortion); --  To allow breakpoints to be set.
  137.  
  138. end System.Tasking.Initialization;
  139.