* einfo.h, sinfo.h, treeprs.ads: Regenerate.
[platform/upstream/gcc.git] / gcc / ada / 5ftasinf.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 --                           (Compiler Interface)                           --
9 --                                                                          --
10 --                            $Revision: 1.4 $
11 --                                                                          --
12 --          Copyright (C) 1992-2000 Free Software Foundation, Inc.          --
13 --                                                                          --
14 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
15 -- terms of the  GNU General Public License as published  by the Free Soft- --
16 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
17 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
18 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
19 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
20 -- for  more details.  You should have  received  a copy of the GNU General --
21 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
22 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
23 -- MA 02111-1307, USA.                                                      --
24 --                                                                          --
25 -- As a special exception,  if other files  instantiate  generics from this --
26 -- unit, or you link  this unit with other files  to produce an executable, --
27 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
28 -- covered  by the  GNU  General  Public  License.  This exception does not --
29 -- however invalidate  any other reasons why  the executable file  might be --
30 -- covered by the  GNU Public License.                                      --
31 --                                                                          --
32 -- GNAT was originally developed  by the GNAT team at  New York University. --
33 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 --                                                                          --
35 ------------------------------------------------------------------------------
36
37 --  This package contains the definitions and routines associated with the
38 --  implementation of the Task_Info pragma. It is specialized appropriately
39 --  for targets that make use of this pragma.
40
41 --  Note: the compiler generates direct calls to this interface, via Rtsfind.
42 --  Any changes to this interface may require corresponding compiler changes.
43
44 with Interfaces.C;
45 with System.OS_Interface;
46 with Unchecked_Deallocation;
47
48 package System.Task_Info is
49 pragma Elaborate_Body;
50 --  To ensure that a body is allowed
51
52    package OSI renames System.OS_Interface;
53
54    -----------------------------------------
55    -- Implementation of Task_Info Feature --
56    -----------------------------------------
57
58    --  Pragma Task_Info allows an application to set the underlying
59    --  pthread scheduling attributes for a specific task.
60
61    ------------------
62    -- Declarations --
63    ------------------
64
65    type Thread_Scheduling_Scope is
66      (PTHREAD_SCOPE_PROCESS, PTHREAD_SCOPE_SYSTEM);
67
68    for Thread_Scheduling_Scope'Size use Interfaces.C.int'Size;
69
70    type Thread_Scheduling_Inheritance is
71       (PTHREAD_EXPLICIT_SCHED, PTHREAD_INHERIT_SCHED);
72
73    for Thread_Scheduling_Inheritance'Size use Interfaces.C.int'Size;
74
75    type Thread_Scheduling_Policy is
76       (SCHED_FIFO,   --  The first-in-first-out real-time policy
77        SCHED_RR,     --  The round-robin real-time scheduling policy
78        SCHED_TS);    --  The timeshare earnings based scheduling policy
79
80    for Thread_Scheduling_Policy'Size use Interfaces.C.int'Size;
81    for Thread_Scheduling_Policy use
82       (SCHED_FIFO => 1,
83        SCHED_RR   => 2,
84        SCHED_TS   => 3);
85
86    function SCHED_OTHER return Thread_Scheduling_Policy renames SCHED_TS;
87
88    No_Specified_Priority : constant := -1;
89
90    subtype Thread_Scheduling_Priority is Integer range
91      No_Specified_Priority .. 255;
92
93    function Min (Policy : Interfaces.C.int) return Interfaces.C.int
94      renames OSI.sched_get_priority_min;
95
96    function Max (Policy : Interfaces.C.int) return Interfaces.C.int
97      renames OSI.sched_get_priority_max;
98
99    subtype FIFO_Priority is Thread_Scheduling_Priority range
100       Thread_Scheduling_Priority (Min (OSI.SCHED_FIFO)) ..
101       Thread_Scheduling_Priority (Max (OSI.SCHED_FIFO));
102
103    subtype RR_Priority is Thread_Scheduling_Priority range
104       Thread_Scheduling_Priority (Min (OSI.SCHED_RR)) ..
105       Thread_Scheduling_Priority (Max (OSI.SCHED_RR));
106
107    subtype TS_Priority is Thread_Scheduling_Priority range
108       Thread_Scheduling_Priority (Min (OSI.SCHED_TS)) ..
109       Thread_Scheduling_Priority (Max (OSI.SCHED_TS));
110
111    subtype OTHER_Priority is Thread_Scheduling_Priority range
112       Thread_Scheduling_Priority (Min (OSI.SCHED_OTHER)) ..
113       Thread_Scheduling_Priority (Max (OSI.SCHED_OTHER));
114
115    subtype CPU_Number is Integer range -1 .. Integer'Last;
116    ANY_CPU : constant CPU_Number := CPU_Number'First;
117
118    type Thread_Attributes is record
119       Scope       : Thread_Scheduling_Scope       := PTHREAD_SCOPE_PROCESS;
120       Inheritance : Thread_Scheduling_Inheritance := PTHREAD_EXPLICIT_SCHED;
121       Policy      : Thread_Scheduling_Policy      := SCHED_RR;
122       Priority    : Thread_Scheduling_Priority    := No_Specified_Priority;
123       Runon_CPU   : CPU_Number                    := ANY_CPU;
124    end record;
125
126    Default_Thread_Attributes : constant Thread_Attributes :=
127      (PTHREAD_SCOPE_PROCESS, PTHREAD_EXPLICIT_SCHED, SCHED_RR,
128        No_Specified_Priority, ANY_CPU);
129
130    type Task_Info_Type is access all Thread_Attributes;
131
132    type Task_Image_Type is access String;
133    --  Used to generate a meaningful identifier for tasks that are variables
134    --  and components of variables.
135
136    procedure Free_Task_Image is new
137      Unchecked_Deallocation (String, Task_Image_Type);
138
139    Unspecified_Task_Info : constant Task_Info_Type := null;
140    --  Value passed to task in the absence of a Task_Info pragma
141
142 end System.Task_Info;