Merged with mainline at revision 128810.
[official-gcc.git] / gcc / ada / s-tasinf-solaris.ads
blobbebecd213df299b6edc33961467a5e3b250c4449
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-2007, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 and use of the Task_Info pragma. It is specialized
36 -- appropriately for targets that make use of this pragma.
38 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
39 -- Any changes to this interface may require corresponding compiler changes.
41 -- This unit may be used directly from an application program by providing
42 -- an appropriate WITH, and the interface can be expected to remain stable.
44 -- This is the Solaris (native) version of this module
46 with System.OS_Interface;
48 package System.Task_Info is
49 pragma Preelaborate;
50 pragma Elaborate_Body;
51 -- To ensure that a body is allowed
53 -----------------------------------------------------
54 -- Binding of Tasks to LWPs and LWPs to processors --
55 -----------------------------------------------------
57 -- The Solaris implementation of the GNU Low-Level Interface (GNULLI)
58 -- implements each Ada task as a Solaris thread. The Solaris thread
59 -- library distributes threads across one or more LWPs (Light Weight
60 -- Process) that are members of the same process. Solaris distributes
61 -- processes and LWPs across the available CPUs on a given machine. The
62 -- pragma Task_Info provides the mechanism to control the distribution
63 -- of tasks to LWPs, and LWPs to processors.
65 -- Each thread has a number of attributes that dictate it's scheduling.
66 -- These attributes are:
68 -- New_LWP: whether a new LWP is created for this thread.
70 -- Bound_To_LWP: whether the thread is bound to a specific LWP
71 -- for its entire lifetime.
73 -- CPU: the CPU number associated to the LWP
76 -- The Task_Info pragma:
78 -- pragma Task_Info (EXPRESSION);
80 -- allows the specification on a task by task basis of a value of type
81 -- System.Task_Info.Task_Info_Type to be passed to a task when it is
82 -- created. The specification of this type, and the effect on the task
83 -- that is created is target dependent.
85 -- The Task_Info pragma appears within a task definition (compare the
86 -- definition and implementation of pragma Priority). If no such pragma
87 -- appears, then the value Unspecified_Task_Info is passed. If a pragma
88 -- is present, then it supplies an alternative value. If the argument of
89 -- the pragma is a discriminant reference, then the value can be set on
90 -- a task by task basis by supplying the appropriate discriminant value.
92 -- Note that this means that the type used for Task_Info_Type must be
93 -- suitable for use as a discriminant (i.e. a scalar or access type).
95 -----------------------
96 -- Thread Attributes --
97 -----------------------
99 subtype CPU_Number is System.OS_Interface.processorid_t;
101 CPU_UNCHANGED : constant CPU_Number := System.OS_Interface.PBIND_QUERY;
102 -- Do not bind the LWP to a specific processor
104 ANY_CPU : constant CPU_Number := System.OS_Interface.PBIND_NONE;
105 -- Bind the LWP to any processor
107 Invalid_CPU_Number : exception;
109 type Thread_Attributes (New_LWP : Boolean) is record
110 Bound_To_LWP : Boolean := True;
111 case New_LWP is
112 when False =>
113 null;
114 when True =>
115 CPU : CPU_Number := CPU_UNCHANGED;
116 end case;
117 end record;
119 Default_Thread_Attributes : constant Thread_Attributes := (False, True);
121 function Unbound_Thread_Attributes
122 return Thread_Attributes;
124 function Bound_Thread_Attributes
125 return Thread_Attributes;
127 function Bound_Thread_Attributes (CPU : CPU_Number)
128 return Thread_Attributes;
130 type Task_Info_Type is access all Thread_Attributes;
132 function New_Unbound_Thread_Attributes
133 return Task_Info_Type;
135 function New_Bound_Thread_Attributes
136 return Task_Info_Type;
138 function New_Bound_Thread_Attributes (CPU : CPU_Number)
139 return Task_Info_Type;
141 Unspecified_Task_Info : constant Task_Info_Type := null;
143 end System.Task_Info;