POK
apex-semaphores.ads
1 -- ---------------------------------------------------------------------------
2 -- --
3 -- SEMAPHORE constant and type definitions and management services --
4 -- --
5 -- ---------------------------------------------------------------------------
6 with APEX.Processes;
7 package APEX.Semaphores is
8  Max_Number_Of_Semaphores : constant := System_Limit_Number_Of_Semaphores;
9  Max_Semaphore_Value : constant := 32_767;
10  subtype Semaphore_Name_Type is Name_Type;
11  type Semaphore_Id_Type is private;
12  Null_Semaphore_Id : constant Semaphore_Id_Type;
13  type Semaphore_Value_Type is new APEX_Integer range
14  0 .. Max_Semaphore_Value;
15  type Semaphore_Status_Type is record
16  Current_Value : Semaphore_Value_Type;
17  Maximum_Value : Semaphore_Value_Type;
18  Waiting_Processes : APEX.Processes.Waiting_Range_Type;
19  end record;
20  procedure Create_Semaphore
21  (Semaphore_Name : in Semaphore_Name_Type;
22  Current_Value : in Semaphore_Value_Type;
23  Maximum_Value : in Semaphore_Value_Type;
24  Queuing_Discipline : in Queuing_Discipline_Type;
25  Semaphore_Id : out Semaphore_Id_Type;
26  Return_Code : out Return_Code_Type);
27  procedure Wait_Semaphore
28  (Semaphore_Id : in Semaphore_Id_Type;
29  Time_Out : in System_Time_Type;
30  Return_Code : out Return_Code_Type);
31  procedure Signal_Semaphore
32  (Semaphore_Id : in Semaphore_Id_Type;
33  Return_Code : out Return_Code_Type);
34  procedure Get_Semaphore_Id
35  (Semaphore_Name : in Semaphore_Name_Type;
36  Semaphore_Id : out Semaphore_Id_Type;
37  Return_Code : out Return_Code_Type);
38  procedure Get_Semaphore_Status
39  (Semaphore_Id : in Semaphore_Id_Type;
40  Semaphore_Status : out Semaphore_Status_Type;
41  Return_Code : out Return_Code_Type);
42 private
43  type Semaphore_Id_Type is new APEX_Integer;
44  Null_Semaphore_Id : constant Semaphore_Id_Type := 0;
45  pragma Convention (C, Semaphore_Status_Type);
46 
47  -- POK BINDINGS
48  pragma Import (C, Create_Semaphore, "CREATE_SEMAPHORE");
49  pragma Import (C, Wait_Semaphore, "WAIT_SEMAPHORE");
50  pragma Import (C, Signal_Semaphore, "SIGNAL_SEMAPHORE");
51  pragma Import (C, Get_Semaphore_Id, "GET_SEMAPHORE_ID");
52  pragma Import (C, Get_Semaphore_Status, "GET_SEMAPHORE_STATUS");
53  -- END OF POK BINDINGS
54 end APEX.Semaphores;