OSDN Git Service

* expr.c (expand_expr): Use unsave lang hook.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5stasinf.ads
1 ------------------------------------------------------------------------------
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 --                            $Revision: 1.3 $
10 --                                                                          --
11 --          Copyright (C) 1992-2000 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT 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.  GNAT 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 GNAT;  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 -- GNAT was originally developed  by the GNAT team at  New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 --                                                                          --
34 ------------------------------------------------------------------------------
35
36 --  This package contains the definitions and routines associated with the
37 --  implementation of the Task_Info pragma.
38
39 --  This is the Solaris (native) version of this module.
40
41 with System.OS_Interface;
42 with Unchecked_Deallocation;
43 package System.Task_Info is
44 pragma Elaborate_Body;
45 --  To ensure that a body is allowed
46
47    -----------------------------------------------------
48    -- Binding of Tasks to LWPs and LWPs to processors --
49    -----------------------------------------------------
50
51    --  The Solaris implementation of the GNU Low-Level Interface (GNULLI)
52    --  implements each Ada task as a Solaris thread.  The Solaris thread
53    --  library distributes threads across one or more LWPs (Light Weight
54    --  Process) that are members of the same process. Solaris distributes
55    --  processes and LWPs across the available CPUs on a given machine. The
56    --  pragma Task_Info provides the mechanism to control the distribution
57    --  of tasks to LWPs, and LWPs to processors.
58
59    --  Each thread has a number of attributes that dictate it's scheduling.
60    --  These attributes are:
61    --
62    --      New_LWP:       whether a new LWP is created for this thread.
63    --
64    --      Bound_To_LWP:  whether the thread is bound to a specific LWP
65    --                     for its entire lifetime.
66    --
67    --      CPU:           the CPU number associated to the LWP
68    --
69
70    --  The Task_Info pragma:
71
72    --    pragma Task_Info (EXPRESSION);
73
74    --  allows the specification on a task by task basis of a value of type
75    --  System.Task_Info.Task_Info_Type to be passed to a task when it is
76    --  created. The specification of this type, and the effect on the task
77    --  that is created is target dependent.
78
79    --  The Task_Info pragma appears within a task definition (compare the
80    --  definition and implementation of pragma Priority). If no such pragma
81    --  appears, then the value Task_Info_Unspecified is passed. If a pragma
82    --  is present, then it supplies an alternative value. If the argument of
83    --  the pragma is a discriminant reference, then the value can be set on
84    --  a task by task basis by supplying the appropriate discriminant value.
85
86    --  Note that this means that the type used for Task_Info_Type must be
87    --  suitable for use as a discriminant (i.e. a scalar or access type).
88
89    -----------------------
90    -- Thread Attributes --
91    -----------------------
92
93    subtype CPU_Number is System.OS_Interface.processorid_t;
94
95    CPU_UNCHANGED : constant CPU_Number := System.OS_Interface.PBIND_QUERY;
96    --  Do not bind the LWP to a specific processor
97
98    ANY_CPU       : constant CPU_Number := System.OS_Interface.PBIND_NONE;
99    --  Bind the LWP to any processor
100
101    Invalid_CPU_Number : exception;
102
103    type Thread_Attributes (New_LWP : Boolean) is record
104       Bound_To_LWP     : Boolean    := True;
105       case New_LWP is
106          when False =>
107             null;
108          when True =>
109             CPU        : CPU_Number := CPU_UNCHANGED;
110       end case;
111    end record;
112
113    Default_Thread_Attributes : constant Thread_Attributes := (False, True);
114
115    function Unbound_Thread_Attributes
116       return Thread_Attributes;
117
118    function Bound_Thread_Attributes
119       return Thread_Attributes;
120
121    function Bound_Thread_Attributes (CPU : CPU_Number)
122       return Thread_Attributes;
123
124    type Task_Info_Type is access all Thread_Attributes;
125
126    function New_Unbound_Thread_Attributes
127       return Task_Info_Type;
128
129    function New_Bound_Thread_Attributes
130       return Task_Info_Type;
131
132    function New_Bound_Thread_Attributes (CPU : CPU_Number)
133       return Task_Info_Type;
134
135    type Task_Image_Type is access String;
136    --  Used to generate a meaningful identifier for tasks that are variables
137    --  and components of variables.
138
139    procedure Free_Task_Image is new
140      Unchecked_Deallocation (String, Task_Image_Type);
141
142    Unspecified_Task_Info : constant Task_Info_Type := null;
143
144 end System.Task_Info;