with audsley_opa_test; use audsley_opa_test; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; with Systems; use Systems; with GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.IO_Exceptions; with audsley_opa_crpd_test; use audsley_opa_crpd_test; with cache_analysis_test; use cache_analysis_test; with scheduling_simulation_test; use scheduling_simulation_test; with feasibility_interval_test; use feasibility_interval_test; with wcrt_crpd_test; use wcrt_crpd_test; with Framework_Config; use Framework_Config; with Efficiency_Test; use Efficiency_Test; with Scheduler; use Scheduler; with unbounded_strings; use unbounded_strings; with initialize_framework; use initialize_framework; with graphical_editor; use graphical_editor; with Task_Set; use Task_Set; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Priority_Assignment_Test_Printer; use Priority_Assignment_Test_Printer; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; with GNAT.String_Split; with Scheduler.Fixed_Priority.Hpf; use Scheduler.Fixed_Priority.Hpf; with Scheduling_Analysis; use Scheduling_Analysis; with Call_Framework_Interface; use Call_Framework_Interface; with feasibility_test.periodic_task_worst_case_response_time_fixed_priority; use feasibility_test.periodic_task_worst_case_response_time_fixed_priority; with Scheduling_Analysis; use Scheduling_Analysis.Double_Tasks_Parameters_Package; with Scheduler.Fixed_Priority; use Scheduler.Fixed_Priority; with Scheduler.Fixed_Priority.Rm; use Scheduler.Fixed_Priority.Rm; procedure call_test_cache is --Configuration for the task generator-------- number_of_task : Integer := 10; processor_utilization : Float := 0.75; cache_utilization : Float := 10.0; reuse_factor : Float := 0.3; cache_size : Integer := 256; ---------------------------------------------- sched_duration : Integer := 0; --Configuration for the scheduling simulator-- default_Period : Integer := 1000000; ---------------------------------------------- H : Integer := 0; Time_And_Date : TIME; filename : Unbounded_String := empty_string; prefix : Unbounded_String; sys : System; ---------------------------------------------- PU_String : Unbounded_String := empty_string; RF_String : Unbounded_String; SP_String : Unbounded_String; NT_String : Unbounded_String; result : Unbounded_String; F : Ada.Text_IO.File_Type; exp_dir : STRING := "framework_examples/cache_analysis_examples/xml/"; ---------------------------------------------- test_mode : Character := 'A'; crpd_comp_mode : Character := 'A'; crpd_comp_model : CRPD_Computation_Model := C_Pre_UCB; ---------------------------------------------- Subs : GNAT.String_Split.Slice_Set; Sub : Unbounded_String; Separator : STRING := ","; Str_Temp : Unbounded_String; R_Preemption : Natural := 0; R_Preemption_Avg : Natural := 0; R_Total_CRPD : Natural := 0; R_Total_CRPD_Avg : Natural := 0; R_Total_Schedulable : Natural := 0; R_PU : Natural := 0; R_counter : Natural := 0; ---------------------------------------------- my_scheduler : Rm_Scheduler; processor_name : String := "CPU_01"; msg : Unbounded_String; response_time : Response_Time_Table; CRPD_Computation_Approach : CRPD_Computation_Approach_Type := ECB_Only; fs_schedulable : Boolean := True; begin loop case GNAT.Command_Line.Getopt ("u: n: c: t: h: d: p: m: f:") is when ASCII.NUL => exit; when 'u' => Put_Line("Processor Utilization: " & GNAT.Command_Line.Parameter); PU_String := To_Unbounded_String (GNAT.Command_Line.Parameter); processor_utilization := (Float'Value(To_String(PU_String))/100.0); when 'n' => Put_Line("Number of tasks: " & GNAT.Command_Line.Parameter); NT_String := To_Unbounded_String (GNAT.Command_Line.Parameter); number_of_task := Integer'Value(GNAT.Command_Line.Parameter); when 'c' => Put_Line("Cache reuse factor: " & GNAT.Command_Line.Parameter); RF_String := To_Unbounded_String (GNAT.Command_Line.Parameter); reuse_factor := (Float'Value(To_String(RF_String))/100.0); when 'h' => Put_Line("Scheduling period: " & GNAT.Command_Line.Parameter); SP_String := To_Unbounded_String (GNAT.Command_Line.Parameter); default_Period := Integer'Value(To_String(SP_String)); when 't' => Put_Line("Test mode: " & GNAT.Command_Line.Parameter); test_mode := GNAT.Command_Line.Parameter(1); when 'p' => Put_Line("File Prefix: " & GNAT.Command_Line.Parameter); prefix := To_Unbounded_String (GNAT.Command_Line.Parameter); when 'd' => Put_Line("Debug Level: " & GNAT.Command_Line.Parameter); Cheddar_Debug := No_Debug; when 'm' => Put_Line("CRPD computation mode: " & GNAT.Command_Line.Parameter); crpd_comp_mode := GNAT.Command_Line.Parameter(1); if(crpd_comp_mode = 'C') then crpd_comp_model := C_UE; elsif(crpd_comp_mode = 'D') then crpd_comp_model := C_UE_lim; end if; when 'f' => Put_Line("File: " & GNAT.Command_Line.Parameter); filename := To_Unbounded_String(GNAT.Command_Line.Parameter); when others => OS_Exit(0); end case; end loop; if(test_mode = 'A') then Set_Directory(exp_dir); test_cache_aware_scheduling_simulator_with_case_study; elsif(test_mode = 'B') then begin Set_Directory(exp_dir & To_String(PU_String) & "/"); exception when Ada.IO_Exceptions.Name_Error => Set_Directory(exp_dir); Create_Directory(New_Directory => To_String(PU_String)); Set_Directory(exp_dir & To_String(PU_String) & "/"); end; Time_And_Date := Clock; filename := To_Unbounded_String(Image(Date => Time_And_Date)); test_feasibility_interval(file_name => filename, N => number_of_task, PU => processor_utilization, CU => cache_utilization, CS => cache_size, RF => reuse_factor); elsif(test_mode = 'C') then Test_WCRT_CRPD; elsif(test_mode = 'D') then Test_Multiset_Intersection; elsif(test_mode = 'G') then begin Set_Directory("framework_examples/cache_analysis_examples/fi/testcases/" & To_String(PU_String) & "/"); exception when Ada.IO_Exceptions.Name_Error => Create_Directory(New_Directory => "framework_examples/cache_analysis_examples/fi/testcases/" & To_String(PU_String)); Set_Directory("framework_examples/cache_analysis_examples/fi/testcases/" & To_String(PU_String) & "/"); end; Time_And_Date := Clock; filename := To_Unbounded_String(Image(Date => Time_And_Date)) & '-' & prefix; generate_test_cases(filename => filename, N => number_of_task, PU => processor_utilization, CU => cache_utilization, CS => cache_size, RF => reuse_factor, PU_String => To_String(PU_String)); elsif(test_mode ='S') then if(filename = empty_string) then Put_Line("- Please specify system file name with -f FILENAME"); GNAT.OS_Lib.OS_Exit (0); end if; if(PU_String = empty_string) then Put_Line("- Please specify processor utilization with -u UTILIZATION"); GNAT.OS_Lib.OS_Exit (0); end if; Set_Initialize; Initialize (sys); sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List, File_Name => filename); begin if(sched_duration = 0) then sched_duration := Compute_Hyperperiod(sys.Tasks); end if; exception when Constraint_Error => sched_duration := Integer'Last; end; Put_Line("- Simulation Period:" & sched_duration'Img); compute_scheduling_of_tasks_from_hardcoded_model(Period => sched_duration, Sys => sys, Output_File_Name => To_Unbounded_String(To_String(filename) & ".ev.xml"), Export_Data => False, CRPD_comp_model => crpd_comp_model); Put_Line("- Simulation complete !"); Set_Directory("framework_examples/cache_analysis_examples/fi/testcases/"); begin Open(F,Ada.Text_IO.Append_File,"Result_" & crpd_comp_model'Img & ".txt"); exception when Ada.IO_Exceptions.Name_Error => Create(F,Ada.Text_IO.Out_File,"Result_" & crpd_comp_model'Img & ".txt"); end; Append_String(result,To_String(PU_String),5); Append_String(result,"," & Ada.Directories.Simple_Name(Name => To_String(filename)),30); Append_String(result,"," & Ada.Strings.Fixed.Trim (sys.N_Preemption'Img, Left),10); Append_String(result,"," & Ada.Strings.Fixed.Trim (sys.N_CRPD_Total'Img, Left),10); if(sys.N_Schedulable) then Append_String(result,"," & "1",10); else Append_String(result,"," & "0",10); end if; Unbounded_IO.Put(F, result); Close(F); elsif(test_mode ='X') then Set_Directory("framework_examples/cache_analysis_examples/fi/testcases/"); for i in 0..2 loop if(i=0) then crpd_comp_model := C_UE; elsif(i=1) then crpd_comp_model := C_UE_lim; elsif(i=2) then crpd_comp_model := C_Pre_UCB; end if; result := empty_string; Open (F, Ada.Text_IO.In_File,"Result_" & crpd_comp_model'Img & ".txt"); R_PU := 50; R_Preemption := 0; R_Total_CRPD := 0; R_Total_Schedulable := 0; R_counter := 0; loop exit when End_Of_File (F); Str_Temp := To_Unbounded_String(To_String(Get_Line (F))); --Put_Line(To_String(Str_Temp)); GNAT.String_Split.Create (Subs, To_String(Str_Temp), Separator, Mode => GNAT.String_Split.Multiple); if((R_PU = Integer'Value(GNAT.String_Split.Slice (Subs, 1))) AND (R_counter < 1000)) then R_Preemption := R_Preemption + Integer'Value(GNAT.String_Split.Slice (Subs, 3)); R_Total_CRPD := R_Total_CRPD + Integer'Value(GNAT.String_Split.Slice (Subs, 4)); R_Total_Schedulable := R_Total_Schedulable + Integer'Value(GNAT.String_Split.Slice (Subs, 5)); R_counter := R_counter + 1; elsif(R_PU /= Integer'Value(GNAT.String_Split.Slice (Subs, 1))) then Append_String(result,R_PU'Img,5); Append_String(result,"," & R_Preemption'Img,10); Append_String(result,"," & R_Total_CRPD'Img,10); Append_String(result,"," & R_Total_Schedulable'Img,10); R_Total_CRPD_Avg := R_Total_CRPD/1000; R_Preemption_Avg := R_Preemption/1000; Append_String(result,"," & R_Preemption_Avg'Img,10); Append_String(result,"," & R_Total_CRPD_Avg'Img,10); Append(result,ASCII.LF); Put_Line(R_PU'Img & "," & R_Preemption'Img & "," & R_Total_CRPD'Img & "," & R_Total_Schedulable'Img); R_PU := Integer'Value(GNAT.String_Split.Slice (Subs, 1)); R_Preemption := 0; R_Total_CRPD := 0; R_Total_Schedulable := 0; R_counter := 0; end if; end loop; Append_String(result,R_PU'Img,5); Append_String(result,"," & R_Preemption'Img,10); Append_String(result,"," & R_Total_CRPD'Img,10); Append_String(result,"," & R_Total_Schedulable'Img,10); R_Total_CRPD_Avg := R_Total_CRPD/1000; R_Preemption_Avg := R_Preemption/1000; Append_String(result,"," & R_Preemption_Avg'Img,10); Append_String(result,"," & R_Total_CRPD_Avg'Img,10); Append(result,ASCII.LF); Put_Line(R_PU'Img & "," & R_Preemption'Img & "," & R_Total_CRPD'Img & "," & R_Total_Schedulable'Img); R_PU := Integer'Value(GNAT.String_Split.Slice (Subs, 1)); R_Preemption := 0; R_Total_CRPD := 0; R_Total_Schedulable := 0; Close (F); -------------------------------------------------------------------------- -- Write to a csv filemake -------------------------------------------------------------------------- begin Create(F,Ada.Text_IO.Append_File,"Analysis_" & crpd_comp_model'Img & ".csv"); exception when Ada.IO_Exceptions.Name_Error => Create(F,Ada.Text_IO.Out_File,"Analysis_" & crpd_comp_model'Img & ".csv"); end; Unbounded_IO.Put(F, result); Close(F); end loop; elsif(test_mode ='Z') then if(filename = empty_string) then Put_Line("- Please specify system file name with -f FILENAME"); GNAT.OS_Lib.OS_Exit (0); end if; Set_Initialize; Initialize (sys); sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List, File_Name => filename); Compute_Response_Time(My_Scheduler => my_scheduler, My_Tasks => sys.Tasks, Processor_Name => To_Unbounded_String(processor_name), Msg => msg, Response_Time => response_time, With_CRPD => True, CRPD_Computation_Approach => CRPD_Computation_Approach, Block_Reload_Time => 1, My_Cache_Access_Profiles => sys.Cache_Access_Profiles); for i in 0..Response_Time.nb_entries-1 loop Put_Line(To_String(Response_Time.entries(i).item.name) & "," & Response_Time.entries(i).item.deadline'Img & "," & Integer(Response_Time.entries(i).data)'Img); if (Integer(Response_Time.entries(i).data) > Response_Time.entries(i).item.deadline) then fs_schedulable := False; end if; end loop; Set_Directory("framework_examples/cache_analysis_examples/fi/testcases/"); begin Open(F,Ada.Text_IO.Append_File,"Result_" & CRPD_Computation_Approach'Img & ".txt"); exception when Ada.IO_Exceptions.Name_Error => Create(F,Ada.Text_IO.Out_File,"Result_" & CRPD_Computation_Approach'Img & ".txt"); end; Append_String(result,To_String(PU_String),5); Append_String(result,"," & Ada.Directories.Simple_Name(Name => To_String(filename)),30); if(fs_schedulable) then Append_String(result,"," & "1",10); else Append_String(result,"," & "0",10); end if; Unbounded_IO.Put(F, result); Close(F); end if; end call_test_cache;