------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2023, 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 README.md -- -- 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/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;