OSDN Git Service

* c-common.h (enum rid): Remove RID_BOUNDED, RID_UNBOUNDED.
[pf3gnuchains/gcc-fork.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 --          Copyright (C) 1992-2000 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 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.                                                      --
22 --                                                                          --
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.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 --  This package contains the definitions and routines associated with the
36 --  implementation of the Task_Info pragma. It is specialized appropriately
37 --  for targets that make use of this pragma.
38
39 --  Note: the compiler generates direct calls to this interface, via Rtsfind.
40 --  Any changes to this interface may require corresponding compiler changes.
41
42 with Interfaces.C;
43 with System.OS_Interface;
44 with Unchecked_Deallocation;
45
46 package System.Task_Info is
47 pragma Elaborate_Body;
48 --  To ensure that a body is allowed
49
50    package OSI renames System.OS_Interface;
51
52    -----------------------------------------
53    -- Implementation of Task_Info Feature --
54    -----------------------------------------
55
56    --  Pragma Task_Info allows an application to set the underlying
57    --  pthread scheduling attributes for a specific task.
58
59    ------------------
60    -- Declarations --
61    ------------------
62
63    type Thread_Scheduling_Scope is
64      (PTHREAD_SCOPE_PROCESS, PTHREAD_SCOPE_SYSTEM);
65
66    for Thread_Scheduling_Scope'Size use Interfaces.C.int'Size;
67
68    type Thread_Scheduling_Inheritance is
69       (PTHREAD_EXPLICIT_SCHED, PTHREAD_INHERIT_SCHED);
70
71    for Thread_Scheduling_Inheritance'Size use Interfaces.C.int'Size;
72
73    type Thread_Scheduling_Policy is
74       (SCHED_FIFO,   --  The first-in-first-out real-time policy
75        SCHED_RR,     --  The round-robin real-time scheduling policy
76        SCHED_TS);    --  The timeshare earnings based scheduling policy
77
78    for Thread_Scheduling_Policy'Size use Interfaces.C.int'Size;
79    for Thread_Scheduling_Policy use
80       (SCHED_FIFO => 1,
81        SCHED_RR   => 2,
82        SCHED_TS   => 3);
83
84    function SCHED_OTHER return Thread_Scheduling_Policy renames SCHED_TS;
85
86    No_Specified_Priority : constant := -1;
87
88    subtype Thread_Scheduling_Priority is Integer range
89      No_Specified_Priority .. 255;
90
91    function Min (Policy : Interfaces.C.int) return Interfaces.C.int
92      renames OSI.sched_get_priority_min;
93
94    function Max (Policy : Interfaces.C.int) return Interfaces.C.int
95      renames OSI.sched_get_priority_max;
96
97    subtype FIFO_Priority is Thread_Scheduling_Priority range
98       Thread_Scheduling_Priority (Min (OSI.SCHED_FIFO)) ..
99       Thread_Scheduling_Priority (Max (OSI.SCHED_FIFO));
100
101    subtype RR_Priority is Thread_Scheduling_Priority range
102       Thread_Scheduling_Priority (Min (OSI.SCHED_RR)) ..
103       Thread_Scheduling_Priority (Max (OSI.SCHED_RR));
104
105    subtype TS_Priority is Thread_Scheduling_Priority range
106       Thread_Scheduling_Priority (Min (OSI.SCHED_TS)) ..
107       Thread_Scheduling_Priority (Max (OSI.SCHED_TS));
108
109    subtype OTHER_Priority is Thread_Scheduling_Priority range
110       Thread_Scheduling_Priority (Min (OSI.SCHED_OTHER)) ..
111       Thread_Scheduling_Priority (Max (OSI.SCHED_OTHER));
112
113    subtype CPU_Number is Integer range -1 .. Integer'Last;
114    ANY_CPU : constant CPU_Number := CPU_Number'First;
115
116    type Thread_Attributes is record
117       Scope       : Thread_Scheduling_Scope       := PTHREAD_SCOPE_PROCESS;
118       Inheritance : Thread_Scheduling_Inheritance := PTHREAD_EXPLICIT_SCHED;
119       Policy      : Thread_Scheduling_Policy      := SCHED_RR;
120       Priority    : Thread_Scheduling_Priority    := No_Specified_Priority;
121       Runon_CPU   : CPU_Number                    := ANY_CPU;
122    end record;
123
124    Default_Thread_Attributes : constant Thread_Attributes :=
125      (PTHREAD_SCOPE_PROCESS, PTHREAD_EXPLICIT_SCHED, SCHED_RR,
126        No_Specified_Priority, ANY_CPU);
127
128    type Task_Info_Type is access all Thread_Attributes;
129
130    type Task_Image_Type is access String;
131    --  Used to generate a meaningful identifier for tasks that are variables
132    --  and components of variables.
133
134    procedure Free_Task_Image is new
135      Unchecked_Deallocation (String, Task_Image_Type);
136
137    Unspecified_Task_Info : constant Task_Info_Type := null;
138    --  Value passed to task in the absence of a Task_Info pragma
139
140 end System.Task_Info;