| 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 |
|
|
-- (Compiler Interface) --
|
| 9 |
|
|
-- --
|
| 10 |
|
|
-- Copyright (C) 1998-2009, Free Software Foundation, Inc. --
|
| 11 |
|
|
-- --
|
| 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 3, 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. --
|
| 18 |
|
|
-- --
|
| 19 |
|
|
-- As a special exception under Section 7 of GPL version 3, you are granted --
|
| 20 |
|
|
-- additional permissions described in the GCC Runtime Library Exception, --
|
| 21 |
|
|
-- version 3.1, as published by the Free Software Foundation. --
|
| 22 |
|
|
-- --
|
| 23 |
|
|
-- You should have received a copy of the GNU General Public License and --
|
| 24 |
|
|
-- a copy of the GCC Runtime Library Exception along with this program; --
|
| 25 |
|
|
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
| 26 |
|
|
-- <http://www.gnu.org/licenses/>. --
|
| 27 |
|
|
-- --
|
| 28 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
| 29 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
| 30 |
|
|
-- --
|
| 31 |
|
|
------------------------------------------------------------------------------
|
| 32 |
|
|
|
| 33 |
|
|
-- This package contains the definitions and routines associated with the
|
| 34 |
|
|
-- implementation and use of the Task_Info pragma. It is specialized
|
| 35 |
|
|
-- appropriately for targets that make use of this pragma.
|
| 36 |
|
|
|
| 37 |
|
|
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
|
| 38 |
|
|
-- Any changes to this interface may require corresponding compiler changes.
|
| 39 |
|
|
|
| 40 |
|
|
-- This unit may be used directly from an application program by providing
|
| 41 |
|
|
-- an appropriate WITH, and the interface can be expected to remain stable.
|
| 42 |
|
|
|
| 43 |
|
|
-- This is a DEC Unix 4.0d version of this package
|
| 44 |
|
|
|
| 45 |
|
|
package System.Task_Info is
|
| 46 |
|
|
pragma Preelaborate;
|
| 47 |
|
|
pragma Elaborate_Body;
|
| 48 |
|
|
-- To ensure that a body is allowed
|
| 49 |
|
|
|
| 50 |
|
|
-----------------------------------------
|
| 51 |
|
|
-- Implementation of Task_Info Feature --
|
| 52 |
|
|
-----------------------------------------
|
| 53 |
|
|
|
| 54 |
|
|
-- The Task_Info pragma:
|
| 55 |
|
|
|
| 56 |
|
|
-- pragma Task_Info (EXPRESSION);
|
| 57 |
|
|
|
| 58 |
|
|
-- allows the specification on a task by task basis of a value of type
|
| 59 |
|
|
-- System.Task_Info.Task_Info_Type to be passed to a task when it is
|
| 60 |
|
|
-- created. The specification of this type, and the effect on the task
|
| 61 |
|
|
-- that is created is target dependent.
|
| 62 |
|
|
|
| 63 |
|
|
-- The Task_Info pragma appears within a task definition (compare the
|
| 64 |
|
|
-- definition and implementation of pragma Priority). If no such pragma
|
| 65 |
|
|
-- appears, then the value Unspecified_Task_Info is passed. If a pragma
|
| 66 |
|
|
-- is present, then it supplies an alternative value. If the argument of
|
| 67 |
|
|
-- the pragma is a discriminant reference, then the value can be set on
|
| 68 |
|
|
-- a task by task basis by supplying the appropriate discriminant value.
|
| 69 |
|
|
|
| 70 |
|
|
-- Note that this means that the type used for Task_Info_Type must be
|
| 71 |
|
|
-- suitable for use as a discriminant (i.e. a scalar or access type).
|
| 72 |
|
|
|
| 73 |
|
|
------------------
|
| 74 |
|
|
-- Declarations --
|
| 75 |
|
|
------------------
|
| 76 |
|
|
|
| 77 |
|
|
type Scope_Type is
|
| 78 |
|
|
(Process_Scope,
|
| 79 |
|
|
-- Contend only with threads in same process
|
| 80 |
|
|
|
| 81 |
|
|
System_Scope,
|
| 82 |
|
|
-- Contend with all threads on same CPU
|
| 83 |
|
|
|
| 84 |
|
|
Default_Scope);
|
| 85 |
|
|
|
| 86 |
|
|
type Thread_Attributes is record
|
| 87 |
|
|
Bind_To_Cpu_Number : Integer;
|
| 88 |
|
|
-- -1: Do nothing
|
| 89 |
|
|
-- 0: Unbind
|
| 90 |
|
|
-- 1-N: Bind all unbound threads to this CPU
|
| 91 |
|
|
|
| 92 |
|
|
Contention_Scope : Scope_Type;
|
| 93 |
|
|
end record;
|
| 94 |
|
|
|
| 95 |
|
|
type Task_Info_Type is access all Thread_Attributes;
|
| 96 |
|
|
-- Type used for passing information to task create call, using the
|
| 97 |
|
|
-- Task_Info pragma. This type may be specialized for individual
|
| 98 |
|
|
-- implementations, but it must be a type that can be used as a
|
| 99 |
|
|
-- discriminant (i.e. a scalar or access type).
|
| 100 |
|
|
|
| 101 |
|
|
Unspecified_Thread_Attribute : aliased Thread_Attributes :=
|
| 102 |
|
|
Thread_Attributes'(-1, Default_Scope);
|
| 103 |
|
|
|
| 104 |
|
|
Unspecified_Task_Info : constant Task_Info_Type :=
|
| 105 |
|
|
Unspecified_Thread_Attribute'Access;
|
| 106 |
|
|
-- Value passed to task in the absence of a Task_Info pragma
|
| 107 |
|
|
-- Don't call new here because the tasking run time has not been
|
| 108 |
|
|
-- elaborated yet, so calling Task_Lock is unsafe.
|
| 109 |
|
|
|
| 110 |
|
|
end System.Task_Info;
|