1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S . --
10 -- Copyright (C) 2000-2005 Free Software Foundation, Inc. --
12 -- GNARL 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. GNARL 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 GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, 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 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
33 ------------------------------------------------------------------------------
35 -- This package is for OpenVMS/Alpha
37 with System
.OS_Interface
;
38 with System
.Parameters
;
40 with Unchecked_Conversion
;
41 with System
.Soft_Links
;
43 package body System
.Task_Primitives
.Operations
.DEC
is
45 use System
.OS_Interface
;
46 use System
.Parameters
;
49 use type Interfaces
.C
.int
;
51 package SSL
renames System
.Soft_Links
;
53 -- The FAB_RAB_Type specifies where the context field (the calling
54 -- task) is stored. Other fields defined for FAB_RAB arent' need and
57 type FAB_RAB_Type
is record
58 CTX
: Unsigned_Longword
;
61 for FAB_RAB_Type
use record
62 CTX
at 24 range 0 .. 31;
65 for FAB_RAB_Type
'Size use 224;
67 type FAB_RAB_Access_Type
is access all FAB_RAB_Type
;
69 -----------------------
70 -- Local Subprograms --
71 -----------------------
73 pragma Warnings
(Off
);
74 -- Task_Id is 64 bits wide (but only 32 bits significant) on Integrity/VMS
76 function To_Unsigned_Longword
is new
77 Unchecked_Conversion
(Task_Id
, Unsigned_Longword
);
79 function To_Task_Id
is new
80 Unchecked_Conversion
(Unsigned_Longword
, Task_Id
);
84 function To_FAB_RAB
is new
85 Unchecked_Conversion
(Address
, FAB_RAB_Access_Type
);
87 ---------------------------
88 -- Interrupt_AST_Handler --
89 ---------------------------
91 procedure Interrupt_AST_Handler
(ID
: Address
) is
92 Result
: Interfaces
.C
.int
;
93 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(ID
);
95 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
96 pragma Assert
(Result
= 0);
97 end Interrupt_AST_Handler
;
100 -- RMS_AST_Handler --
101 ---------------------
103 procedure RMS_AST_Handler
(ID
: Address
) is
104 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(To_FAB_RAB
(ID
).CTX
);
105 Result
: Interfaces
.C
.int
;
108 AST_Self_ID
.Common
.LL
.AST_Pending
:= False;
109 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
110 pragma Assert
(Result
= 0);
117 function Self
return Unsigned_Longword
is
118 Self_ID
: constant Task_Id
:= Self
;
120 Self_ID
.Common
.LL
.AST_Pending
:= True;
121 return To_Unsigned_Longword
(Self
);
124 -------------------------
125 -- Starlet_AST_Handler --
126 -------------------------
128 procedure Starlet_AST_Handler
(ID
: Address
) is
129 Result
: Interfaces
.C
.int
;
130 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(ID
);
132 AST_Self_ID
.Common
.LL
.AST_Pending
:= False;
133 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
134 pragma Assert
(Result
= 0);
135 end Starlet_AST_Handler
;
141 procedure Task_Synch
is
142 Synch_Self_ID
: constant Task_Id
:= Self
;
148 Write_Lock
(Synch_Self_ID
);
152 Synch_Self_ID
.Common
.State
:= AST_Server_Sleep
;
154 while Synch_Self_ID
.Common
.LL
.AST_Pending
loop
155 Sleep
(Synch_Self_ID
, AST_Server_Sleep
);
158 Synch_Self_ID
.Common
.State
:= Runnable
;
163 Unlock
(Synch_Self_ID
);
166 SSL
.Abort_Undefer
.all;
169 end System
.Task_Primitives
.Operations
.DEC
;