1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.DEC --
9 -- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
11 -- GNARL 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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
30 ------------------------------------------------------------------------------
32 -- This package is for OpenVMS/Alpha
34 with System
.OS_Interface
;
35 with System
.Parameters
;
37 with Ada
.Unchecked_Conversion
;
38 with System
.Soft_Links
;
40 package body System
.Task_Primitives
.Operations
.DEC
is
42 use System
.OS_Interface
;
43 use System
.Parameters
;
46 use type Interfaces
.C
.int
;
48 package SSL
renames System
.Soft_Links
;
50 -- The FAB_RAB_Type specifies where the context field (the calling
51 -- task) is stored. Other fields defined for FAB_RAB arent' need and
54 type FAB_RAB_Type
is record
55 CTX
: Unsigned_Longword
;
58 for FAB_RAB_Type
use record
59 CTX
at 24 range 0 .. 31;
62 for FAB_RAB_Type
'Size use 224;
64 type FAB_RAB_Access_Type
is access all FAB_RAB_Type
;
66 -----------------------
67 -- Local Subprograms --
68 -----------------------
70 function To_Unsigned_Longword
is new
71 Ada
.Unchecked_Conversion
(Task_Id
, Unsigned_Longword
);
73 function To_Task_Id
is new
74 Ada
.Unchecked_Conversion
(Unsigned_Longword
, Task_Id
);
76 function To_FAB_RAB
is new
77 Ada
.Unchecked_Conversion
(Address
, FAB_RAB_Access_Type
);
79 ---------------------------
80 -- Interrupt_AST_Handler --
81 ---------------------------
83 procedure Interrupt_AST_Handler
(ID
: Address
) is
84 Result
: Interfaces
.C
.int
;
85 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(ID
);
87 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
88 pragma Assert
(Result
= 0);
89 end Interrupt_AST_Handler
;
95 procedure RMS_AST_Handler
(ID
: Address
) is
96 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(To_FAB_RAB
(ID
).CTX
);
97 Result
: Interfaces
.C
.int
;
100 AST_Self_ID
.Common
.LL
.AST_Pending
:= False;
101 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
102 pragma Assert
(Result
= 0);
109 function Self
return Unsigned_Longword
is
110 Self_ID
: constant Task_Id
:= Self
;
112 Self_ID
.Common
.LL
.AST_Pending
:= True;
113 return To_Unsigned_Longword
(Self
);
116 -------------------------
117 -- Starlet_AST_Handler --
118 -------------------------
120 procedure Starlet_AST_Handler
(ID
: Address
) is
121 Result
: Interfaces
.C
.int
;
122 AST_Self_ID
: constant Task_Id
:= To_Task_Id
(ID
);
124 AST_Self_ID
.Common
.LL
.AST_Pending
:= False;
125 Result
:= pthread_cond_signal_int_np
(AST_Self_ID
.Common
.LL
.CV
'Access);
126 pragma Assert
(Result
= 0);
127 end Starlet_AST_Handler
;
133 procedure Task_Synch
is
134 Synch_Self_ID
: constant Task_Id
:= Self
;
140 Write_Lock
(Synch_Self_ID
);
144 Synch_Self_ID
.Common
.State
:= AST_Server_Sleep
;
146 while Synch_Self_ID
.Common
.LL
.AST_Pending
loop
147 Sleep
(Synch_Self_ID
, AST_Server_Sleep
);
150 Synch_Self_ID
.Common
.State
:= Runnable
;
155 Unlock
(Synch_Self_ID
);
158 SSL
.Abort_Undefer
.all;
161 end System
.Task_Primitives
.Operations
.DEC
;