2003-05-31 Bud Davis <bdavis9659@comcast.net>
[official-gcc.git] / gcc / ada / 5stasinf.ads
blob1002ee7ca218afd30960734d1163f06d243c0fa0
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 -- Copyright (C) 1992-2000 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This package contains the definitions and routines associated with the
35 -- implementation of the Task_Info pragma.
37 -- This is the Solaris (native) version of this module.
39 with System.OS_Interface;
40 with Unchecked_Deallocation;
41 package System.Task_Info is
42 pragma Elaborate_Body;
43 -- To ensure that a body is allowed
45 -----------------------------------------------------
46 -- Binding of Tasks to LWPs and LWPs to processors --
47 -----------------------------------------------------
49 -- The Solaris implementation of the GNU Low-Level Interface (GNULLI)
50 -- implements each Ada task as a Solaris thread. The Solaris thread
51 -- library distributes threads across one or more LWPs (Light Weight
52 -- Process) that are members of the same process. Solaris distributes
53 -- processes and LWPs across the available CPUs on a given machine. The
54 -- pragma Task_Info provides the mechanism to control the distribution
55 -- of tasks to LWPs, and LWPs to processors.
57 -- Each thread has a number of attributes that dictate it's scheduling.
58 -- These attributes are:
60 -- New_LWP: whether a new LWP is created for this thread.
62 -- Bound_To_LWP: whether the thread is bound to a specific LWP
63 -- for its entire lifetime.
65 -- CPU: the CPU number associated to the LWP
68 -- The Task_Info pragma:
70 -- pragma Task_Info (EXPRESSION);
72 -- allows the specification on a task by task basis of a value of type
73 -- System.Task_Info.Task_Info_Type to be passed to a task when it is
74 -- created. The specification of this type, and the effect on the task
75 -- that is created is target dependent.
77 -- The Task_Info pragma appears within a task definition (compare the
78 -- definition and implementation of pragma Priority). If no such pragma
79 -- appears, then the value Task_Info_Unspecified is passed. If a pragma
80 -- is present, then it supplies an alternative value. If the argument of
81 -- the pragma is a discriminant reference, then the value can be set on
82 -- a task by task basis by supplying the appropriate discriminant value.
84 -- Note that this means that the type used for Task_Info_Type must be
85 -- suitable for use as a discriminant (i.e. a scalar or access type).
87 -----------------------
88 -- Thread Attributes --
89 -----------------------
91 subtype CPU_Number is System.OS_Interface.processorid_t;
93 CPU_UNCHANGED : constant CPU_Number := System.OS_Interface.PBIND_QUERY;
94 -- Do not bind the LWP to a specific processor
96 ANY_CPU : constant CPU_Number := System.OS_Interface.PBIND_NONE;
97 -- Bind the LWP to any processor
99 Invalid_CPU_Number : exception;
101 type Thread_Attributes (New_LWP : Boolean) is record
102 Bound_To_LWP : Boolean := True;
103 case New_LWP is
104 when False =>
105 null;
106 when True =>
107 CPU : CPU_Number := CPU_UNCHANGED;
108 end case;
109 end record;
111 Default_Thread_Attributes : constant Thread_Attributes := (False, True);
113 function Unbound_Thread_Attributes
114 return Thread_Attributes;
116 function Bound_Thread_Attributes
117 return Thread_Attributes;
119 function Bound_Thread_Attributes (CPU : CPU_Number)
120 return Thread_Attributes;
122 type Task_Info_Type is access all Thread_Attributes;
124 function New_Unbound_Thread_Attributes
125 return Task_Info_Type;
127 function New_Bound_Thread_Attributes
128 return Task_Info_Type;
130 function New_Bound_Thread_Attributes (CPU : CPU_Number)
131 return Task_Info_Type;
133 type Task_Image_Type is access String;
134 -- Used to generate a meaningful identifier for tasks that are variables
135 -- and components of variables.
137 procedure Free_Task_Image is new
138 Unchecked_Deallocation (String, Task_Image_Type);
140 Unspecified_Task_Info : constant Task_Info_Type := null;
142 end System.Task_Info;