1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.DEC --
9 -- Copyright (C) 2000-2007, 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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- This package is for OpenVMS/Alpha
36 with System.OS_Interface;
37 with System.Parameters;
39 with Ada.Unchecked_Conversion;
40 with System.Soft_Links;
42 package body System.Task_Primitives.Operations.DEC is
44 use System.OS_Interface;
45 use System.Parameters;
48 use type Interfaces.C.int;
50 package SSL renames System.Soft_Links;
52 -- The FAB_RAB_Type specifies where the context field (the calling
53 -- task) is stored. Other fields defined for FAB_RAB arent' need and
56 type FAB_RAB_Type is record
57 CTX : Unsigned_Longword;
60 for FAB_RAB_Type use record
61 CTX at 24 range 0 .. 31;
64 for FAB_RAB_Type'Size use 224;
66 type FAB_RAB_Access_Type is access all FAB_RAB_Type;
68 -----------------------
69 -- Local Subprograms --
70 -----------------------
72 pragma Warnings (Off);
73 -- Task_Id is 64 bits wide (but only 32 bits significant) on Integrity/VMS
75 function To_Unsigned_Longword is new
76 Ada.Unchecked_Conversion (Task_Id, Unsigned_Longword);
78 function To_Task_Id is new
79 Ada.Unchecked_Conversion (Unsigned_Longword, Task_Id);
83 function To_FAB_RAB is new
84 Ada.Unchecked_Conversion (Address, FAB_RAB_Access_Type);
86 ---------------------------
87 -- Interrupt_AST_Handler --
88 ---------------------------
90 procedure Interrupt_AST_Handler (ID : Address) is
91 Result : Interfaces.C.int;
92 AST_Self_ID : constant Task_Id := To_Task_Id (ID);
94 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
95 pragma Assert (Result = 0);
96 end Interrupt_AST_Handler;
100 ---------------------
102 procedure RMS_AST_Handler (ID : Address) is
103 AST_Self_ID : constant Task_Id := To_Task_Id (To_FAB_RAB (ID).CTX);
104 Result : Interfaces.C.int;
107 AST_Self_ID.Common.LL.AST_Pending := False;
108 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
109 pragma Assert (Result = 0);
116 function Self return Unsigned_Longword is
117 Self_ID : constant Task_Id := Self;
119 Self_ID.Common.LL.AST_Pending := True;
120 return To_Unsigned_Longword (Self);
123 -------------------------
124 -- Starlet_AST_Handler --
125 -------------------------
127 procedure Starlet_AST_Handler (ID : Address) is
128 Result : Interfaces.C.int;
129 AST_Self_ID : constant Task_Id := To_Task_Id (ID);
131 AST_Self_ID.Common.LL.AST_Pending := False;
132 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
133 pragma Assert (Result = 0);
134 end Starlet_AST_Handler;
140 procedure Task_Synch is
141 Synch_Self_ID : constant Task_Id := Self;
147 Write_Lock (Synch_Self_ID);
151 Synch_Self_ID.Common.State := AST_Server_Sleep;
153 while Synch_Self_ID.Common.LL.AST_Pending loop
154 Sleep (Synch_Self_ID, AST_Server_Sleep);
157 Synch_Self_ID.Common.State := Runnable;
162 Unlock (Synch_Self_ID);
165 SSL.Abort_Undefer.all;
168 end System.Task_Primitives.Operations.DEC;