1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . T A S K _ I N F O --
10 -- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
35 -- This package contains the definitions and routines associated with the
36 -- implementation of the Task_Info pragma.
38 -- This is the Solaris (native) version of this module.
40 with System
.OS_Interface
;
41 with Unchecked_Deallocation
;
42 package System
.Task_Info
is
43 pragma Elaborate_Body
;
44 -- To ensure that a body is allowed
46 -----------------------------------------------------
47 -- Binding of Tasks to LWPs and LWPs to processors --
48 -----------------------------------------------------
50 -- The Solaris implementation of the GNU Low-Level Interface (GNULLI)
51 -- implements each Ada task as a Solaris thread. The Solaris thread
52 -- library distributes threads across one or more LWPs (Light Weight
53 -- Process) that are members of the same process. Solaris distributes
54 -- processes and LWPs across the available CPUs on a given machine. The
55 -- pragma Task_Info provides the mechanism to control the distribution
56 -- of tasks to LWPs, and LWPs to processors.
58 -- Each thread has a number of attributes that dictate it's scheduling.
59 -- These attributes are:
61 -- New_LWP: whether a new LWP is created for this thread.
63 -- Bound_To_LWP: whether the thread is bound to a specific LWP
64 -- for its entire lifetime.
66 -- CPU: the CPU number associated to the LWP
69 -- The Task_Info pragma:
71 -- pragma Task_Info (EXPRESSION);
73 -- allows the specification on a task by task basis of a value of type
74 -- System.Task_Info.Task_Info_Type to be passed to a task when it is
75 -- created. The specification of this type, and the effect on the task
76 -- that is created is target dependent.
78 -- The Task_Info pragma appears within a task definition (compare the
79 -- definition and implementation of pragma Priority). If no such pragma
80 -- appears, then the value Task_Info_Unspecified is passed. If a pragma
81 -- is present, then it supplies an alternative value. If the argument of
82 -- the pragma is a discriminant reference, then the value can be set on
83 -- a task by task basis by supplying the appropriate discriminant value.
85 -- Note that this means that the type used for Task_Info_Type must be
86 -- suitable for use as a discriminant (i.e. a scalar or access type).
88 -----------------------
89 -- Thread Attributes --
90 -----------------------
92 subtype CPU_Number
is System
.OS_Interface
.processorid_t
;
94 CPU_UNCHANGED
: constant CPU_Number
:= System
.OS_Interface
.PBIND_QUERY
;
95 -- Do not bind the LWP to a specific processor
97 ANY_CPU
: constant CPU_Number
:= System
.OS_Interface
.PBIND_NONE
;
98 -- Bind the LWP to any processor
100 Invalid_CPU_Number
: exception;
102 type Thread_Attributes
(New_LWP
: Boolean) is record
103 Bound_To_LWP
: Boolean := True;
108 CPU
: CPU_Number
:= CPU_UNCHANGED
;
112 Default_Thread_Attributes
: constant Thread_Attributes
:= (False, True);
114 function Unbound_Thread_Attributes
115 return Thread_Attributes
;
117 function Bound_Thread_Attributes
118 return Thread_Attributes
;
120 function Bound_Thread_Attributes
(CPU
: CPU_Number
)
121 return Thread_Attributes
;
123 type Task_Info_Type
is access all Thread_Attributes
;
125 function New_Unbound_Thread_Attributes
126 return Task_Info_Type
;
128 function New_Bound_Thread_Attributes
129 return Task_Info_Type
;
131 function New_Bound_Thread_Attributes
(CPU
: CPU_Number
)
132 return Task_Info_Type
;
134 type Task_Image_Type
is access String;
135 -- Used to generate a meaningful identifier for tasks that are variables
136 -- and components of variables.
138 procedure Free_Task_Image
is new
139 Unchecked_Deallocation
(String, Task_Image_Type
);
141 Unspecified_Task_Info
: constant Task_Info_Type
:= null;
143 end System
.Task_Info
;