diff options
Diffstat (limited to 'gcc/ada/s-tarest.adb')
-rw-r--r-- | gcc/ada/s-tarest.adb | 119 |
1 files changed, 112 insertions, 7 deletions
diff --git a/gcc/ada/s-tarest.adb b/gcc/ada/s-tarest.adb index bba83ab..ec94313 100644 --- a/gcc/ada/s-tarest.adb +++ b/gcc/ada/s-tarest.adb @@ -111,6 +111,24 @@ package body System.Tasking.Restricted.Stages is -- Terminate the calling task. -- This should only be called by the Task_Wrapper procedure. + procedure Create_Restricted_Task + (Priority : Integer; + Stack_Address : System.Address; + Size : System.Parameters.Size_Type; + Task_Info : System.Task_Info.Task_Info_Type; + CPU : Integer; + State : Task_Procedure_Access; + Discriminants : System.Address; + Elaborated : Access_Boolean; + Task_Image : String; + Created_Task : Task_Id); + -- Code shared between Create_Restricted_Task_Concurrent and + -- Create_Restricted_Task_Sequential. See comment of the former in the + -- specification of this package. + + procedure Activate_Tasks (Chain : Task_Id); + -- Activate the list of tasks started by Chain + procedure Init_RTS; -- This procedure performs the initialization of the GNARL. -- It consists of initializing the environment task, global locks, and @@ -301,6 +319,40 @@ package body System.Tasking.Restricted.Stages is -- Restricted GNARLI -- ----------------------- + ----------------------------------- + -- Activate_All_Tasks_Sequential -- + ----------------------------------- + + procedure Activate_All_Tasks_Sequential is + begin + pragma Assert (Partition_Elaboration_Policy = 'S'); + + Activate_Tasks (Tasks_Activation_Chain); + Tasks_Activation_Chain := Null_Task; + end Activate_All_Tasks_Sequential; + + ------------------------------- + -- Activate_Restricted_Tasks -- + ------------------------------- + + procedure Activate_Restricted_Tasks + (Chain_Access : Activation_Chain_Access) is + begin + if Partition_Elaboration_Policy = 'S' then + + -- In sequential elaboration policy, the chain must be empty. This + -- procedure can be called if the unit has been compiled without + -- partition elaboration policy, but the partition has a sequential + -- elaboration policy. + + pragma Assert (Chain_Access.T_ID = Null_Task); + null; + else + Activate_Tasks (Chain_Access.T_ID); + Chain_Access.T_ID := Null_Task; + end if; + end Activate_Restricted_Tasks; + -------------------- -- Activate_Tasks -- -------------------- @@ -311,7 +363,7 @@ package body System.Tasking.Restricted.Stages is -- created before the activated task. That satisfies our -- in-order-of-creation ATCB locking policy. - procedure Activate_Tasks is + procedure Activate_Tasks (Chain : Task_Id) is Self_ID : constant Task_Id := STPO.Self; C : Task_Id; Activate_Prio : System.Any_Priority; @@ -333,7 +385,7 @@ package body System.Tasking.Restricted.Stages is -- Activate all the tasks in the chain. Creation of the thread of -- control was deferred until activation. So create it now. - C := Tasks_Activation_Chain; + C := Chain; while C /= null loop if C.Common.State /= Terminated then pragma Assert (C.Common.State = Unactivated); @@ -381,10 +433,6 @@ package body System.Tasking.Restricted.Stages is if Single_Lock then Unlock_RTS; end if; - - -- Remove the tasks from the chain - - Tasks_Activation_Chain := null; end Activate_Tasks; ------------------------------------ @@ -557,9 +605,66 @@ package body System.Tasking.Restricted.Stages is -- may be used by the operation of Ada code within the task. SSL.Create_TSD (Created_Task.Common.Compiler_Data); + end Create_Restricted_Task; + + procedure Create_Restricted_Task + (Priority : Integer; + Stack_Address : System.Address; + Size : System.Parameters.Size_Type; + Task_Info : System.Task_Info.Task_Info_Type; + CPU : Integer; + State : Task_Procedure_Access; + Discriminants : System.Address; + Elaborated : Access_Boolean; + Chain : in out Activation_Chain; + Task_Image : String; + Created_Task : Task_Id) is + begin + Create_Restricted_Task (Priority, Stack_Address, Size, Task_Info, + CPU, State, Discriminants, Elaborated, + Task_Image, Created_Task); + + -- Append this task to the activation chain + + if Partition_Elaboration_Policy = 'S' then + + -- In fact the elaboration policy is sequential, add this task to + -- the global activation chain to defer its activation. + + Created_Task.Common.Activation_Link := Tasks_Activation_Chain; + Tasks_Activation_Chain := Created_Task; + + else + Created_Task.Common.Activation_Link := Chain.T_ID; + Chain.T_ID := Created_Task; + end if; + end Create_Restricted_Task; + + --------------------------------------- + -- Create_Restricted_Task_Sequential -- + --------------------------------------- + + procedure Create_Restricted_Task_Sequential + (Priority : Integer; + Stack_Address : System.Address; + Size : System.Parameters.Size_Type; + Task_Info : System.Task_Info.Task_Info_Type; + CPU : Integer; + State : Task_Procedure_Access; + Discriminants : System.Address; + Elaborated : Access_Boolean; + Task_Image : String; + Created_Task : Task_Id) is + begin + Create_Restricted_Task (Priority, Stack_Address, Size, Task_Info, + CPU, State, Discriminants, Elaborated, + Task_Image, Created_Task); + + -- Append this task to the activation chain + Created_Task.Common.Activation_Link := Tasks_Activation_Chain; Tasks_Activation_Chain := Created_Task; - end Create_Restricted_Task; + end Create_Restricted_Task_Sequential; --------------------------- -- Finalize_Global_Tasks -- |