| 1 | 706 | jeremybenn | ------------------------------------------------------------------------------
 | 
      
         | 2 |  |  | --                                                                          --
 | 
      
         | 3 |  |  | --                         GNAT COMPILER COMPONENTS                         --
 | 
      
         | 4 |  |  | --                                                                          --
 | 
      
         | 5 |  |  | --                     S Y S T E M . T A S K _ I N F O                      --
 | 
      
         | 6 |  |  | --                                                                          --
 | 
      
         | 7 |  |  | --                                 S p e c                                  --
 | 
      
         | 8 |  |  | --                                                                          --
 | 
      
         | 9 |  |  | --          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
 | 
      
         | 10 |  |  | --                                                                          --
 | 
      
         | 11 |  |  | -- GNAT 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 |  |  | -- GNAT was originally developed  by the GNAT team at  New York University. --
 | 
      
         | 28 |  |  | -- Extensive contributions were provided by Ada Core Technologies Inc.      --
 | 
      
         | 29 |  |  | --                                                                          --
 | 
      
         | 30 |  |  | ------------------------------------------------------------------------------
 | 
      
         | 31 |  |  |  
 | 
      
         | 32 |  |  | --  This package contains the definitions and routines associated with the
 | 
      
         | 33 |  |  | --  implementation and use of the Task_Info pragma. It is specialized
 | 
      
         | 34 |  |  | --  appropriately for targets that make use of this pragma.
 | 
      
         | 35 |  |  |  
 | 
      
         | 36 |  |  | --  Note: the compiler generates direct calls to this interface, via Rtsfind.
 | 
      
         | 37 |  |  | --  Any changes to this interface may require corresponding compiler changes.
 | 
      
         | 38 |  |  |  
 | 
      
         | 39 |  |  | --  This unit may be used directly from an application program by providing
 | 
      
         | 40 |  |  | --  an appropriate WITH, and the interface can be expected to remain stable.
 | 
      
         | 41 |  |  |  
 | 
      
         | 42 |  |  | --  This is the Solaris (native) version of this module
 | 
      
         | 43 |  |  |  
 | 
      
         | 44 |  |  | with System.OS_Interface;
 | 
      
         | 45 |  |  |  
 | 
      
         | 46 |  |  | package System.Task_Info is
 | 
      
         | 47 |  |  |    pragma Preelaborate;
 | 
      
         | 48 |  |  |    pragma Elaborate_Body;
 | 
      
         | 49 |  |  |    --  To ensure that a body is allowed
 | 
      
         | 50 |  |  |  
 | 
      
         | 51 |  |  |    -----------------------------------------------------
 | 
      
         | 52 |  |  |    -- Binding of Tasks to LWPs and LWPs to processors --
 | 
      
         | 53 |  |  |    -----------------------------------------------------
 | 
      
         | 54 |  |  |  
 | 
      
         | 55 |  |  |    --  The Solaris implementation of the GNU Low-Level Interface (GNULLI)
 | 
      
         | 56 |  |  |    --  implements each Ada task as a Solaris thread.  The Solaris thread
 | 
      
         | 57 |  |  |    --  library distributes threads across one or more LWPs (Light Weight
 | 
      
         | 58 |  |  |    --  Process) that are members of the same process. Solaris distributes
 | 
      
         | 59 |  |  |    --  processes and LWPs across the available CPUs on a given machine. The
 | 
      
         | 60 |  |  |    --  pragma Task_Info provides the mechanism to control the distribution
 | 
      
         | 61 |  |  |    --  of tasks to LWPs, and LWPs to processors.
 | 
      
         | 62 |  |  |  
 | 
      
         | 63 |  |  |    --  Each thread has a number of attributes that dictate it's scheduling.
 | 
      
         | 64 |  |  |    --  These attributes are:
 | 
      
         | 65 |  |  |    --
 | 
      
         | 66 |  |  |    --      New_LWP:       whether a new LWP is created for this thread.
 | 
      
         | 67 |  |  |    --
 | 
      
         | 68 |  |  |    --      Bound_To_LWP:  whether the thread is bound to a specific LWP
 | 
      
         | 69 |  |  |    --                     for its entire lifetime.
 | 
      
         | 70 |  |  |    --
 | 
      
         | 71 |  |  |    --      CPU:           the CPU number associated to the LWP
 | 
      
         | 72 |  |  |    --
 | 
      
         | 73 |  |  |  
 | 
      
         | 74 |  |  |    --  The Task_Info pragma:
 | 
      
         | 75 |  |  |  
 | 
      
         | 76 |  |  |    --    pragma Task_Info (EXPRESSION);
 | 
      
         | 77 |  |  |  
 | 
      
         | 78 |  |  |    --  allows the specification on a task by task basis of a value of type
 | 
      
         | 79 |  |  |    --  System.Task_Info.Task_Info_Type to be passed to a task when it is
 | 
      
         | 80 |  |  |    --  created. The specification of this type, and the effect on the task
 | 
      
         | 81 |  |  |    --  that is created is target dependent.
 | 
      
         | 82 |  |  |  
 | 
      
         | 83 |  |  |    --  The Task_Info pragma appears within a task definition (compare the
 | 
      
         | 84 |  |  |    --  definition and implementation of pragma Priority). If no such pragma
 | 
      
         | 85 |  |  |    --  appears, then the value Unspecified_Task_Info is passed. If a pragma
 | 
      
         | 86 |  |  |    --  is present, then it supplies an alternative value. If the argument of
 | 
      
         | 87 |  |  |    --  the pragma is a discriminant reference, then the value can be set on
 | 
      
         | 88 |  |  |    --  a task by task basis by supplying the appropriate discriminant value.
 | 
      
         | 89 |  |  |  
 | 
      
         | 90 |  |  |    --  Note that this means that the type used for Task_Info_Type must be
 | 
      
         | 91 |  |  |    --  suitable for use as a discriminant (i.e. a scalar or access type).
 | 
      
         | 92 |  |  |  
 | 
      
         | 93 |  |  |    -----------------------
 | 
      
         | 94 |  |  |    -- Thread Attributes --
 | 
      
         | 95 |  |  |    -----------------------
 | 
      
         | 96 |  |  |  
 | 
      
         | 97 |  |  |    subtype CPU_Number is System.OS_Interface.processorid_t;
 | 
      
         | 98 |  |  |  
 | 
      
         | 99 |  |  |    CPU_UNCHANGED : constant CPU_Number := System.OS_Interface.PBIND_QUERY;
 | 
      
         | 100 |  |  |    --  Do not bind the LWP to a specific processor
 | 
      
         | 101 |  |  |  
 | 
      
         | 102 |  |  |    ANY_CPU       : constant CPU_Number := System.OS_Interface.PBIND_NONE;
 | 
      
         | 103 |  |  |    --  Bind the LWP to any processor
 | 
      
         | 104 |  |  |  
 | 
      
         | 105 |  |  |    Invalid_CPU_Number : exception;
 | 
      
         | 106 |  |  |  
 | 
      
         | 107 |  |  |    type Thread_Attributes (New_LWP : Boolean) is record
 | 
      
         | 108 |  |  |       Bound_To_LWP     : Boolean    := True;
 | 
      
         | 109 |  |  |       case New_LWP is
 | 
      
         | 110 |  |  |          when False =>
 | 
      
         | 111 |  |  |             null;
 | 
      
         | 112 |  |  |          when True =>
 | 
      
         | 113 |  |  |             CPU        : CPU_Number := CPU_UNCHANGED;
 | 
      
         | 114 |  |  |       end case;
 | 
      
         | 115 |  |  |    end record;
 | 
      
         | 116 |  |  |  
 | 
      
         | 117 |  |  |    Default_Thread_Attributes : constant Thread_Attributes := (False, True);
 | 
      
         | 118 |  |  |  
 | 
      
         | 119 |  |  |    function Unbound_Thread_Attributes
 | 
      
         | 120 |  |  |       return Thread_Attributes;
 | 
      
         | 121 |  |  |  
 | 
      
         | 122 |  |  |    function Bound_Thread_Attributes
 | 
      
         | 123 |  |  |       return Thread_Attributes;
 | 
      
         | 124 |  |  |  
 | 
      
         | 125 |  |  |    function Bound_Thread_Attributes (CPU : CPU_Number)
 | 
      
         | 126 |  |  |       return Thread_Attributes;
 | 
      
         | 127 |  |  |  
 | 
      
         | 128 |  |  |    type Task_Info_Type is access all Thread_Attributes;
 | 
      
         | 129 |  |  |  
 | 
      
         | 130 |  |  |    function New_Unbound_Thread_Attributes
 | 
      
         | 131 |  |  |       return Task_Info_Type;
 | 
      
         | 132 |  |  |  
 | 
      
         | 133 |  |  |    function New_Bound_Thread_Attributes
 | 
      
         | 134 |  |  |       return Task_Info_Type;
 | 
      
         | 135 |  |  |  
 | 
      
         | 136 |  |  |    function New_Bound_Thread_Attributes (CPU : CPU_Number)
 | 
      
         | 137 |  |  |       return Task_Info_Type;
 | 
      
         | 138 |  |  |  
 | 
      
         | 139 |  |  |    Unspecified_Task_Info : constant Task_Info_Type := null;
 | 
      
         | 140 |  |  |  
 | 
      
         | 141 |  |  | end System.Task_Info;
 |