home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / s-tataat.ads < prev    next >
Text File  |  2000-07-19  |  6KB  |  122 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --         S Y S T E M . T A S K I N G . T A S K _ A T T R I B U T E S      --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.8 $
  10. --                                                                          --
  11. --             Copyright (C) 1995-1998 Florida State University             --
  12. --                                                                          --
  13. -- GNARL is free software; you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNARL; see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNARL was developed by the GNARL team at Florida State University. It is --
  32. -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  33. -- State University (http://www.gnat.com).                                  --
  34. --                                                                          --
  35. ------------------------------------------------------------------------------
  36.  
  37. --  This package provides support for the body of Ada.Task_Attributes.
  38.  
  39. with Ada.Finalization;
  40. --  used for Limited_Controlled
  41.  
  42. with System.Storage_Elements;
  43. --  used for Integer_Address
  44.  
  45. package System.Tasking.Task_Attributes is
  46.  
  47.    type Attribute is new Integer;
  48.    --  A stand-in for the generic formal type of Ada.Task_Attributes
  49.    --  in the following declarations.
  50.  
  51.    type Node;
  52.    type Access_Node is access all Node;
  53.    type Dummy_Wrapper;
  54.    type Access_Dummy_Wrapper is access all Dummy_Wrapper;
  55.  
  56.    type Deallocator is access procedure (P : in out Access_Node);
  57.    --  Called to deallocate an Wrapper. P is a pointer to a Node within.
  58.  
  59.    type Instance;
  60.  
  61.    type Access_Instance is access all Instance;
  62.  
  63.    type Instance is new Ada.Finalization.Limited_Controlled with record
  64.       Deallocate    : Deallocator;
  65.       Initial_Value : aliased System.Storage_Elements.Integer_Address;
  66.  
  67.       Index : Direct_Index;
  68.       --  The index of the TCB location used by this instantiation,
  69.       --  if it is stored in the TCB, otherwise zero.
  70.  
  71.       Next : Access_Instance;
  72.       --  Next instance in All_Attributes list.
  73.    end record;
  74.  
  75.    procedure Finalize (X : in out Instance);
  76.  
  77.    type Node is record
  78.       Wrapper  : Access_Dummy_Wrapper;
  79.       Instance : Access_Instance;
  80.       Next     : Access_Node;
  81.    end record;
  82.  
  83.    --  The following type is a stand-in for the actual
  84.    --  wrapper type, which is different for each instantiation
  85.    --  of Ada.Task_Attributes.
  86.  
  87.    type Dummy_Wrapper is record
  88.       Noed : aliased Node;
  89.  
  90.       Value : aliased Attribute;
  91.       --  The generic formal type, may be controlled
  92.    end record;
  93.  
  94.    In_Use : Direct_Index_Vector := 0;
  95.    --  is True for direct indices that are already used.
  96.  
  97.    All_Attributes : Access_Instance;
  98.    --  A linked list of all indirectly access attributes,
  99.    --  which includes all those that require finalization.
  100.  
  101.    All_Attrs_L : aliased System.Task_Primitives.RTS_Lock;
  102.    --  Protects In_Use, Next_Indirect_Index, and All_Attributes.
  103.    --  Deadlock prevention order of locking:
  104.    --    1) All_Attrs_L
  105.    --    2) All_Tasks_L
  106.    --    3) any TCB.L
  107.  
  108.    procedure Initialize_Attributes (T : Task_ID);
  109.    --  Initialize all attributes created via Ada.Task_Attributes for T.
  110.    --  This must be called by the creator of the task, inside Create_Task,
  111.    --  via soft-link Initialize_Attributes_Link. On entry, abortion must
  112.    --  be deferred and the caller must hold no locks
  113.  
  114.    procedure Finalize_Attributes (T : Task_ID);
  115.    --  Finalize all attributes created via Ada.Task_Attributes for T.
  116.    --  This is to be called by the task after it is marked as terminated
  117.    --  (and before it actually dies), inside Leave_Task, via soft-link
  118.    --  Finalize_Attributes_Link. On entry, abortion must be deferred and
  119.    --  T.L must be write-locked.
  120.  
  121. end System.Tasking.Task_Attributes;
  122.