summaryrefslogtreecommitdiff
path: root/translate/grt/grt-processes.adb
diff options
context:
space:
mode:
Diffstat (limited to 'translate/grt/grt-processes.adb')
-rw-r--r--translate/grt/grt-processes.adb69
1 files changed, 51 insertions, 18 deletions
diff --git a/translate/grt/grt-processes.adb b/translate/grt/grt-processes.adb
index a4cf318..1bb0be8 100644
--- a/translate/grt/grt-processes.adb
+++ b/translate/grt/grt-processes.adb
@@ -15,6 +15,7 @@
-- along with GCC; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
+with GNAT.Table;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Storage_Elements; -- Work around GNAT bug.
@@ -32,11 +33,18 @@ with Grt.Disp_Signals;
with Grt.Stdio;
with Grt.Stats;
with Grt.Threads; use Grt.Threads;
-with Grt.Arch;
package body Grt.Processes is
Last_Time : constant Std_Time := Std_Time'Last;
+ -- Table of processes.
+ package Process_Table is new GNAT.Table
+ (Table_Component_Type => Process_Type,
+ Table_Index_Type => Process_Id,
+ Table_Low_Bound => 1,
+ Table_Initial => 16,
+ Table_Increment => 100);
+
-- List of non_sensitized processes.
package Non_Sensitized_Process_Table is new GNAT.Table
(Table_Component_Type => Process_Id,
@@ -116,9 +124,7 @@ package body Grt.Processes is
Postponed => Postponed,
State => State,
Timeout => Bad_Time,
- Stack => Stack,
- Stats_Time => 0,
- Stats_Run => 0);
+ Stack => Stack);
-- Used to create drivers.
Set_Current_Process (Process_Table.Last, null);
@@ -189,9 +195,7 @@ package body Grt.Processes is
Timeout => Bad_Time,
Subprg => To_Proc_Acc (Proc),
This => This,
- Stack => Null_Stack,
- Stats_Time => 0,
- Stats_Run => 0);
+ Stack => Null_Stack);
-- Used to create drivers.
Set_Current_Process (Process_Table.Last, null);
end Verilog_Process_Register;
@@ -503,12 +507,13 @@ package body Grt.Processes is
loop
-- Atomically get a process to be executed
Idx := Grt.Threads.Atomic_Inc (Mt_Index'Access);
- exit when Idx > Mt_Last;
+ if Idx > Mt_Last then
+ return;
+ end if;
Pid := Mt_Table (Idx);
declare
Proc : Process_Type renames Process_Table.Table (Pid);
- Ts_Start, Ts_End : Ghdl_U64;
begin
if Grt.Options.Trace_Processes then
Grt.Astdio.Put ("run process ");
@@ -522,7 +527,6 @@ package body Grt.Processes is
Internal_Error ("run non-resumed process");
end if;
Proc.Resumed := False;
- Ts_Start := Grt.Arch.Get_Time_Stamp;
Set_Current_Process
(Pid, To_Acc (Process_Table.Table (Pid)'Address));
if Proc.State = State_Sensitized then
@@ -530,9 +534,6 @@ package body Grt.Processes is
else
Stack_Switch (Proc.Stack, Get_Main_Stack);
end if;
- Ts_End := Grt.Arch.Get_Time_Stamp;
- Proc.Stats_Time := Proc.Stats_Time + (Ts_End - Ts_Start);
- Proc.Stats_Run := Proc.Stats_Run + 1;
if Grt.Options.Checks then
Ghdl_Signal_Internal_Checks;
Grt.Stack2.Check_Empty (Get_Stack2);
@@ -543,28 +544,60 @@ package body Grt.Processes is
function Run_Processes (Postponed : Boolean) return Integer
is
+ Table : Process_Id_Array_Acc;
Last : Natural;
begin
if Options.Flag_Stats then
Stats.Start_Processes;
end if;
- Mt_Index := 1;
if Postponed then
- Mt_Table := Postponed_Resume_Process_Table;
+ Table := Postponed_Resume_Process_Table;
Last := Last_Postponed_Resume_Process;
Last_Postponed_Resume_Process := 0;
else
- Mt_Table := Resume_Process_Table;
+ Table := Resume_Process_Table;
Last := Last_Resume_Process;
Last_Resume_Process := 0;
end if;
Nbr_Resumed_Processes := Nbr_Resumed_Processes + Last;
- Mt_Last := Last;
if Options.Nbr_Threads = 1 then
- Run_Processes_Threads;
+ for I in 1 .. Last loop
+ declare
+ Pid : constant Process_Id := Table (I);
+ Proc : Process_Type renames Process_Table.Table (Pid);
+ begin
+ if not Proc.Resumed then
+ Internal_Error ("run non-resumed process");
+ end if;
+ if Grt.Options.Trace_Processes then
+ Grt.Astdio.Put ("run process ");
+ Disp_Process_Name (Stdio.stdout, Pid);
+ Grt.Astdio.Put (" [");
+ Grt.Astdio.Put (Stdio.stdout, Proc.This);
+ Grt.Astdio.Put ("]");
+ Grt.Astdio.New_Line;
+ end if;
+
+ Proc.Resumed := False;
+ Set_Current_Process
+ (Pid, To_Acc (Process_Table.Table (Pid)'Address));
+ if Proc.State = State_Sensitized then
+ Proc.Subprg.all (Proc.This);
+ else
+ Stack_Switch (Proc.Stack, Get_Main_Stack);
+ end if;
+ if Grt.Options.Checks then
+ Ghdl_Signal_Internal_Checks;
+ Grt.Stack2.Check_Empty (Get_Stack2);
+ end if;
+ end;
+ end loop;
else
+ Mt_Last := Last;
+ Mt_Table := Table;
+ Mt_Index := 1;
Threads.Run_Parallel (Run_Processes_Threads'Access);
end if;