Debian Codegraph @

gcc/ada/libgnarl/s-taspri__solaris.ads

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K _ P R I M I T I V E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2025, Free Software Foundation, Inc. --
10 -- --
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. --
17 -- --
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. --
21 -- --
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/>. --
26 -- --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This is a Solaris version of this package
33
34 -- This package provides low-level support for most tasking features
35
36 with Ada.Unchecked_Conversion;
37
38 with System.OS_Interface;
39 with System.OS_Locks;
40
41 package System.Task_Primitives is
42 pragma Preelaborate;
43
44 type Lock is limited private;
45 type Lock_Ptr is access all Lock;
46 -- Should be used for implementation of protected objects
47
48 function To_Lock_Ptr is
49 new Ada.Unchecked_Conversion (OS_Locks.RTS_Lock_Ptr, Lock_Ptr);
50 function To_RTS_Lock_Ptr is
51 new Ada.Unchecked_Conversion (Lock_Ptr, OS_Locks.RTS_Lock_Ptr);
52
53 type Suspension_Object is limited private;
54 -- Should be used for the implementation of Ada.Synchronous_Task_Control
55
56 type Task_Body_Access is access procedure;
57 -- Pointer to the task body's entry point (or possibly a wrapper
58 -- declared local to the GNARL).
59
60 type Private_Data is limited private;
61 -- Any information that the GNULLI needs maintained on a per-task basis.
62 -- A component of this type is guaranteed to be included in the
63 -- Ada_Task_Control_Block.
64
65 subtype Task_Address is System.Address;
66 Task_Address_Size : constant := Standard'Address_Size;
67 -- Type used for task addresses and its size
68
69 Alternate_Stack_Size : constant := 0;
70 -- No alternate signal stack is used on this platform
71
72 private
73
74 type Lock is new OS_Locks.RTS_Lock;
75
76 type Suspension_Object is record
77 State : Boolean;
78 pragma Atomic (State);
79 -- Boolean that indicates whether the object is open. This field is
80 -- marked Atomic to ensure that we can read its value without locking
81 -- the access to the Suspension_Object.
82
83 Waiting : Boolean;
84 -- Flag showing if there is a task already suspended on this object
85
86 L : aliased System.OS_Interface.mutex_t;
87 -- Protection for ensuring mutual exclusion on the Suspension_Object
88
89 CV : aliased System.OS_Interface.cond_t;
90 -- Condition variable used to queue threads until condition is signaled
91 end record;
92
93 -- Note that task support on gdb relies on the fact that the first two
94 -- fields of Private_Data are Thread and LWP.
95
96 type Private_Data is limited record
97 Thread : aliased System.OS_Interface.thread_t;
98 -- This component is written to once before concurrent access to it is
99 -- possible, and then remains constant. The place where it is written to
100 -- depends on how the enclosing ATCB comes into existence:
101 --
102 -- 1. For the environment task, the component is set in
103 -- System.Task_Primitive.Operations.Initialize.
104 -- 2. For foreign threads, it happens in
105 -- System.Task_Primitives.Operations.Register_Foreign_Thread.
106 -- 3. For others tasks, it's in
107 -- System.Task_Primitives.Operations.Create_Task.
108
109 LWP : System.OS_Interface.lwpid_t;
110 -- The LWP id of the thread. Set by self in Enter_Task
111
112 CV : aliased System.OS_Interface.cond_t;
113 -- Condition variable used to queue threads until condition is signaled
114
115 L : aliased System.OS_Locks.RTS_Lock;
116 -- Protection for all components is lock L
117
118 Active_Priority : System.Any_Priority := System.Any_Priority'First;
119 -- Simulated active priority, used iff Priority_Ceiling_Support is True
120
121 Locking : Lock_Ptr;
122 Locks : Lock_Ptr;
123 Wakeups : Natural := 0;
124 end record;
125
126 end System.Task_Primitives;