------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2020, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev$ -- $Date$ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Text_IO; use Text_IO; with Processor_Set; use Processor_Set; use Processor_Set.Generic_Processor_Set; with processors; use processors; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; use unbounded_strings.strings_table_package; use unbounded_strings.unbounded_string_list_package; with Parameters; use Parameters; with Parameters.extended; use Parameters.extended; use Parameters.Framework_Parameters_Table_Package; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Systems; use Systems; with Call_Framework; use Call_Framework; with Call_Framework_Interface; use Call_Framework_Interface; use Call_Framework_Interface.Framework_Response_Package; use Call_Framework_Interface.Framework_Request_Package; with framework; use framework; with Call_Scheduling_Framework; use Call_Scheduling_Framework; with Multiprocessor_Services; use Multiprocessor_Services; with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface.Scheduling_Result_Per_Processor_Package; with GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with Version; use Version; with Ada.Exceptions; use Ada.Exceptions; procedure Response_Time is -- A set of variables required to call the framework -- Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; A_Param : Parameter_Ptr; Sys : System; Project_File_List : unbounded_string_list; Project_File_Dir_List : unbounded_string_list; -- Is the command should run in verbose mode ? -- Verbose : Boolean := False; -- The XML file to read (architecture model to analyze) -- Input_File : Boolean := False; Input_File_Name : Unbounded_String; -- The XML file to write scheduling table computed by Cheddar -- Scheduling_Output_File : Boolean := False; Scheduling_Output_File_Name : Unbounded_String; -- The XML file to write response time computed by the program -- Response_Time_Output_File : Boolean := False; Response_Time_Output_File_Name : Unbounded_String; a_file : File_Type; -- The duration on which we must compute the scheduling -- Feasibility_Interval_String : Unbounded_String; Feasibility_Interval : Natural :=0; Ok : Boolean :=False; -- If we want to compute the response time from simulation -- or with a feasibility test -- From_Simulation : Boolean :=False; From_Feasibility_Test : Boolean :=False; -- Iterator to analyse all processors of the model -- A_Processor : Generic_Processor_Ptr; My_Processor_Iterator : Processors_Iterator; -- Select extra interferences to compute when running -- WCRT feasibility test -- WCRT_With_memory_interferences : Memory_Interference_Computation_Approach_Type := No_Memory_Interference; WCRT_With_CRPD : CRPD_Computation_Approach_Type := No_CRPD; procedure Usage is begin Put_Line( "response_time is a program which computes response times of a task set, either from a scheduling or with a feasibility test. The analysis is run from an XML Cheddar project file and results are saved into a second XML file and display on the screen."); New_Line; Put_Line( "Check Cheddar home page for details : http://beru.univ-brest.fr/~singhoff/cheddar " ); New_Line; New_Line; Put_Line ("Usage : response_time [switch] [scheduling-feasibility-interval]"); Put_Line (" switch can be :"); Put_Line (" -u get this help"); Put_Line (" -v verbose mode "); Put_Line (" -s use scheduling simulation to compute response times. A feasibility interval is required with this method in order to specify on which time interval such scheduling simulation has to be computed."); Put_Line (" -f use a feasibility test to compute response times. There is no need to give a feasibility interval with this method."); Put_Line (" -m set memory interferences option for feasibility test ; possible values are No_Memory_Interference, DRAM_Single_Arbiter, Kalray_Multi_Arbiter."); Put_Line (" -c set cache interferences option for feasibility test ; possible values are No_CRPD, ECB_Only, ECB_Union_Multiset, UCB_Union_Multiset, Combined_Multiset."); Put_Line( " -o file-name, write the scheduling into the XML file file-name "); Put_Line( " if no -o argument is given, then the scheduling is not displayed/saved "); Put_Line( " -i file-name, read the system to analyze from the XML file file-name " ); Put_Line( " -r file-name, write response time results computed from the scheduling in the file file-name " ); New_Line; end Usage; -- Compute from scheduling simulation -- procedure Compute_From_Simulation is begin Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); A_Request.statement := Scheduling_Simulation_Time_Line; A_Param := new Parameter (Integer_Parameter); A_Param.parameter_name := To_Unbounded_String ("period"); A_Param.integer_value := feasibility_interval; Add (A_Request.param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("schedule_with_offsets"); A_Param.boolean_value := True; Add (A_Request.param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("schedule_with_precedencies"); A_Param.boolean_value := True; Add (A_Request.param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("schedule_with_resources"); A_Param.boolean_value := True; Add (A_Request.param, A_Param); A_Param := new Parameter (Integer_Parameter); A_Param.parameter_name := To_Unbounded_String ("seed_value"); A_Param.integer_value := 0; Add (A_Request.param, A_Param); Add (Request_List, A_Request); Sequential_Framework_Request (Sys, Request_List, Response_List); -- Display results -- Put_Line (To_String (Response_List.Entries (0).title)); for J in 0 .. Response_List.Nb_Entries - 1 loop Put_Line (To_String (Response_List.Entries (J).text)); end loop; -- Export Event table into the event_table.xml file -- if (Scheduling_Output_File) then Write_To_Xml_File (framework.Sched, Sys, Scheduling_Output_File_Name); end if; -- Now compute response time and display result on the standard output -- Initialize (A_Request); Initialize (A_Request.param); initialize (Response_List); initialize (Request_List); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("worst_case"); A_Param.boolean_value := True; add (A_Request.param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("best_case"); A_Param.boolean_value := True; add (A_Request.param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("average_case"); A_Param.boolean_value := True; add (A_Request.param, A_Param); -- Text file for the response time results -- if (Response_Time_Output_File) then Create (a_file, Mode => Out_File, Name => To_String (Response_Time_Output_File_Name)); end if; -- Output the results -- reset_iterator (Sys.Processors, My_Processor_Iterator); loop current_element (Sys.Processors, A_Processor, My_Processor_Iterator); A_Request.target := A_processor.Name; A_Request.statement := Scheduling_Simulation_Response_Time; add (Request_List, A_Request); Sequential_Framework_Request (Sys, Request_List, Response_List); for J in 0 .. Response_List.nb_entries - 1 loop if (Response_Time_Output_File) then put_line(a_file, to_String(Response_List.entries (j).title)); put_line(a_file, to_String(Response_List.entries (j).text)); else Put_Line(to_String(Response_List.entries (j).title)); Put_Line(to_String(Response_List.entries (j).text)); end if; end loop; exit when is_last_element (Sys.Processors, My_Processor_Iterator); next_element (Sys.Processors, My_Processor_Iterator); end loop; -- Text file for the analysis results -- if (Response_Time_Output_File) then Close (a_file); end if; end Compute_From_Simulation; -- Compute from feasibility test -- procedure Compute_From_Feasibility_Test is begin Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); -- Text file for the analysis results -- if (Response_Time_Output_File) then Create (a_file, Mode => Out_File, Name => To_String (Response_Time_Output_File_Name)); end if; -- Create the request -- if WCRT_With_memory_interferences = No_Memory_Interference then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_without_memory_interferences"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_memory_interferences = DRAM_Single_Arbiter then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_DRAM_single_arbiter"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_memory_interferences = Kalray_Multi_Arbiter then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_kalray_multi_arbiter"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_CRPD = No_CRPD then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_without_crpd"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_CRPD = ECB_Only then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_crpd_ECB_only"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_CRPD = ECB_Union_Multiset then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_crpd_ECB_union_multiset"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_CRPD = UCB_Union_Multiset then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_crpd_UCB_union_multiset"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; if WCRT_With_CRPD = Combined_Multiset then A_Param := new Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wcrt_with_crpd_combined_multiset"); A_Param.boolean_value := True; add (A_Request.param, A_Param); end if; -- Compute and Output the results -- reset_iterator (Sys.Processors, My_Processor_Iterator); loop current_element (Sys.Processors, A_Processor, My_Processor_Iterator); A_Request.target := A_processor.Name; A_Request.statement := Scheduling_Feasibility_periodic_task_worst_case_Response_Time; add (Request_List, A_Request); Sequential_Framework_Request (Sys, Request_List, Response_List); for J in 0 .. Response_List.nb_entries - 1 loop if (Response_Time_Output_File) then put_line(a_file, to_String(Response_List.entries (j).title)); put_line(a_file, to_String(Response_List.entries (j).text)); else Put_Line(to_String(Response_List.entries (j).title)); Put_Line(to_String(Response_List.entries (j).text)); end if; end loop; exit when is_last_element (Sys.Processors, My_Processor_Iterator); next_element (Sys.Processors, My_Processor_Iterator); end loop; -- Text file for the analysis results -- if (Response_Time_Output_File) then Close (a_file); end if; end Compute_From_Feasibility_Test; begin Copyright ("response_time"); -- Get arguments -- loop case GNAT.Command_Line.Getopt ("u v s m c f i: o: r:") is when ASCII.NUL => exit; when 'c' => To_CRPD_Computation_Approach_Type(To_Unbounded_String (GNAT.Command_Line.Parameter), WCRT_With_CRPD, Ok); if not Ok then Usage; Raise_Exception (Constraint_Error'Identity, "Unknown Cache interference option value"); end if; when 'm' => To_Memory_Interference_Computation_Approach_Type(To_Unbounded_String (GNAT.Command_Line.Parameter), WCRT_With_memory_interferences, Ok); if not Ok then Usage; Raise_Exception (Constraint_Error'Identity, "Unknown Cache interference option value"); end if; when 'i' => Input_File := True; Input_File_Name := To_Unbounded_String (GNAT.Command_Line.Parameter); when 'o' => Scheduling_Output_File := True; Scheduling_Output_File_Name := To_Unbounded_String (GNAT.Command_Line.Parameter); when 'r' => Response_Time_Output_File := True; Response_Time_Output_File_Name := To_Unbounded_String (GNAT.Command_Line.Parameter); when 's' => From_Simulation:= True; when 'f' => From_Feasibility_Test:= True; when 'v' => Verbose := True; when 'u' => Usage; OS_Exit (0); when others => Usage; OS_Exit (0); end case; end loop; loop declare S : constant String := GNAT.Command_Line.Get_Argument (Do_Expansion => True); begin exit when S'Length = 0; Feasibility_Interval_String := Feasibility_Interval_String & S; end; end loop; -- Check the feasibility interval on which we will compute the scheduling -- if (Feasibility_Interval_String /= empty_string) then to_natural (Feasibility_Interval_String, Feasibility_Interval, Ok); if not Ok then Usage; Raise_Exception (Constraint_Error'Identity, "The Feasibility Interval to compute the scheduling must be a numeric value"); end if; end if; -- Is an input file and an output file given ??? -- if (not Input_File) then Usage; OS_Exit (0); end if; -- Initialize the Cheddar framework -- Call_Framework.initialize (False); -- Read the XML project file -- initialize (Project_File_List); Systems.Read_From_Xml_File (Sys, Project_File_Dir_List, Input_File_Name); -- Compute the response time -- if (From_Simulation = From_Feasibility_Test) then Usage; Raise_Exception (Constraint_Error'Identity, "Response times must computed EITHER from simulation OR from feasibility test ; please select one approach"); end if; if (From_Feasibility_Test and Feasibility_Interval/=0) then Usage; Raise_Exception (Constraint_Error'Identity, "Response times computed from feasibility test do not require a value for the feasibility interval"); end if; if (From_simulation and Feasibility_Interval=0) then Usage; Raise_Exception (Constraint_Error'Identity, "Response times computed from simulation requires a value for the feasibility interval"); end if; if (From_Simulation) then Compute_From_Simulation; else Compute_From_Feasibility_Test; end if; end Response_Time;