------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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 GNAT.Command_Line; use GNAT.Command_Line; with GNAT.Current_Exception; use GNAT.Current_Exception; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Framework_Config; use Framework_Config; with Systems; use Systems; with Task_Set; --use Task_Set; with Processors; use Processors; with Processor_Set; use Processor_Set; with processor_interface; use processor_interface; use Processor_Set.Generic_Processor_Set; with core_units; use core_units; use core_units.core_units_table_package; with Buffer_Set; --use Buffer_Set; with Resource_Set; --use Resource_Set; with Address_Space_Set; --use Address_Space_Set; with Text_IO; use Text_IO; with Ada.Directories; --use Ada.Directories; with unbounded_strings; use unbounded_strings; use unbounded_strings.unbounded_string_list_package; --with Debug; use Debug; with Parameters; use Parameters; use Parameters.Framework_Parameters_Table_Package; 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 Translate; use Translate; with natural_util; use natural_util; with Ellidiss_Tools; use Ellidiss_Tools; with GNAT.OS_Lib; use GNAT.OS_Lib; with Scheduler_Interface; use Scheduler_Interface; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; with arinc653_tools; use arinc653_tools; with xml_tag; use xml_tag; with xml_generic_parsers; use xml_generic_parsers; with framework; use framework; with multiprocessor_services; use multiprocessor_services; with Ada.IO_Exceptions; procedure Cheddarkernel is procedure Usage is begin Put_Line ("Usage : cheddar [switches]"); New_Line; Put_Line ("Switches :"); Put_Line (" -help : this help."); Put_Line (" -version : software version."); Put_Line (" -debug : activate debug mode."); Put_Line (" -file filename : XML project filename."); Put_Line (" -resultfile filename : specify the filename where the results will be written."); Put_Line (" -etoutput filename : event table XML output filename. (deprecated use -resultfile)"); Put_Line (" -xmloutput filename : xml result filename. (deprecated use -resultfile)"); Put_Line (" -outputtype : type of the output (xml, string or raw)."); Put_Line (" -schedperiod : maximum scheduling period use for simulation based tests and event table output if no or bigger hyper period is found."); Put_Line (" -cheddarsimuoutput : switch to the official cheddar simulation xml output."); Put_Line (" -request requesttype : request a service requesttype to cheddar kernel."); Put_Line (" * tft or theoreticaltests (bt and basictests are deprecated) : theoretical feasibility tests."); Put_Line (" * sft or simulationtests (st and schedulingtests are deprecated) : simulation feasibility tests."); Put_Line (" * cp or computepriority : compute priority for RM and DM schedulers."); Put_Line (" * cprm : compute priority for RM scheduler."); Put_Line (" * cpdm : compute priority for DM scheduler."); Put_Line (" * se or simulationevent (et and eventtable are deprecated) : get the XML containing the simulation event table."); --Put_Line (" * sft or selecttests : report of the available feasibility tests for the input file."); Put_Line (" * firstfit : place task/thread according to first fit algorithm."); Put_Line (" * bestfit : place task/thread according to best fit algorithm."); Put_Line (" * nextfit : place task/thread according to next fit algorithm."); Put_Line (" * smalltask : place task/thread according to small task algorithm."); Put_Line (" * generaltask : place task/thread according to small task algorithm."); Put_Line (" * baseperiod : compute the base period/hyper period."); Put_Line (" * all : all requests (except et)."); OS_Exit (0); end Usage; procedure Version is begin Put_Line (CheddarKernel_version); OS_Exit (0); end Version; procedure Compute_Scheduling (A_Sys : in out System; scheduling_period : in Natural) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; A_Param : Parameter_Ptr; begin --Put_Line ("Compute_Scheduling :" & scheduling_period'Img); Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); A_Request.statement := Scheduling_Simulation_Time_Line; -- add the call option for scheduling A_Param := new Parameters.Parameter (Integer_Parameter); A_Param.parameter_name := To_Unbounded_String ("period"); A_Param.integer_value := scheduling_period; Add (A_Request.param, A_Param); A_Param := new Parameters.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 Parameters.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 Parameters.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 Parameters.Parameter (Integer_Parameter); A_Param.parameter_name := To_Unbounded_String ("seed_value"); A_Param.integer_value := 0; Add (A_Request.param, A_Param); A_Param := new Parameters.Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("anomaly_detection"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param := new Parameters.Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("dvfs"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param := new Parameters.Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("wait_for_resource"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param.parameter_name := To_Unbounded_String ("preemption"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param.parameter_name := To_Unbounded_String ("wait_for_memory"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param.parameter_name := To_Unbounded_String ("context_switch_overhead"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param.parameter_name := To_Unbounded_String ("buffer_overflow"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); A_Param.parameter_name := To_Unbounded_String ("buffer_underflow"); A_Param.boolean_value := False; Add (A_Request.param, A_Param); -- add this request to the request list Add (Request_List, A_Request); Sequential_Framework_Request (A_Sys, Request_List, Response_List); end Compute_Scheduling; procedure Run_Basic_Feasibility_Tests ( A_Sys : in out System; A_Processor : in Generic_Processor_Ptr; Result : in out Unbounded_String; Output_Type : Output_Format) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; current_scheduler : Schedulers_Type; begin if (a_processor.processor_type = monocore_type) then current_scheduler := Mono_Core_Processor_Ptr (A_Processor).core.scheduling.scheduler_type; if (current_scheduler = Hierarchical_offline_Protocol) or (current_scheduler = Hierarchical_Cyclic_Protocol) then return; end if; else -- multicore for i in 0..Multi_Cores_Processor_ptr(a_processor).cores.nb_entries -1 loop current_scheduler := Multi_Cores_Processor_ptr(a_processor).cores.entries(i).scheduling.scheduler_type; if (current_scheduler = Hierarchical_offline_Protocol) or (current_scheduler = Hierarchical_Cyclic_Protocol) then return; end if; end loop; end if; Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); A_Request.target := A_Processor.name; A_Request.statement := Scheduling_Feasibility_Basics; Add (Request_List, A_Request); Sequential_Framework_Request ( A_Sys, Request_List, Response_List, Total_Order, Output_Type); for J in 0 .. Response_List.Nb_Entries - 1 loop if Output_Type = Xml_Output then Result := Result & Response_List.Entries (J).text & unbounded_lf; else Result := Result & Response_List.Entries (J).title & unbounded_lf; Result := Result & Response_List.Entries (J).text & unbounded_lf; end if; end loop; end Run_Basic_Feasibility_Tests; procedure Run_Basic_Simulation_Tests ( A_Sys : in out System; A_Processor : in Generic_Processor_Ptr; Max_Scheduling_Period : in Natural := 0; Result : in out Unbounded_String; Output_Type : Output_Format) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; A_Param : Parameter_Ptr; scheduling_period : Natural; validity : Unbounded_String; begin begin scheduling_period := Get_Scheduling_Period (A_Sys, A_Processor, Max_Scheduling_Period); validity := To_Unbounded_String ("true"); exception when Invalid_Scheduling_Period => scheduling_period := Max_Scheduling_Period; validity := To_Unbounded_String ("false"); end; Compute_Scheduling (A_Sys, scheduling_period); Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); A_Request.target := A_Processor.name; A_Request.statement := Scheduling_Simulation_Preemption_Number; Add (Request_List, A_Request); Initialize (A_Request); A_Request.target := A_Processor.name; A_Request.statement := Scheduling_Simulation_Context_Switch_Number; Add (Request_List, A_Request); Initialize (A_Request); A_Param := new Parameters.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 Parameters.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 Parameters.Parameter (Boolean_Parameter); A_Param.parameter_name := To_Unbounded_String ("average_case"); A_Param.boolean_value := True; Add (A_Request.param, A_Param); A_Request.target := A_Processor.name; A_Request.statement := Scheduling_Simulation_Response_Time; Add (Request_List, A_Request); Sequential_Framework_Request ( A_Sys, Request_List, Response_List, Total_Order, Output_Type); if Output_Type = Xml_Output then Result := Result & start_feasibility_Test & To_Unbounded_String (" name=""") & Lb_Task_Response_Time_From_Simulation (Current_Language) & To_Unbounded_String (""" reference=""") & A_Processor.name & To_Unbounded_String (""" basePeriod=""") & format (Natural (scheduling_period)) & To_Unbounded_String (""" validity=""") & To_String (validity) & To_Unbounded_String (""">") & unbounded_lf; end if; for J in 0 .. Response_List.Nb_Entries - 1 loop if Output_Type = Xml_Output then Result := Result & Response_List.Entries (J).text; else Result := Result & Response_List.Entries (J).title & unbounded_lf; Result := Result & Response_List.Entries (J).text & unbounded_lf; end if; end loop; if Output_Type = Xml_Output then Result := Result & To_String (unbounded_lf & end_feasibility_Test); end if; end Run_Basic_Simulation_Tests; procedure Compute_Priority ( A_Sys : in out System; scheduler : Unbounded_String; Result : in out Unbounded_String; Output_Type : Output_Format) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; rm_scheduler : Boolean := False; dm_scheduler : Boolean := False; begin Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); if scheduler = To_Unbounded_String ("both") then rm_scheduler := True; dm_scheduler := True; elsif scheduler = To_Unbounded_String ("rm") then rm_scheduler := True; elsif scheduler = To_Unbounded_String ("dm") then dm_scheduler := True; end if; if rm_scheduler = True then A_Request.statement := Scheduling_Set_Priorities_According_To_Rate_Monotonic; Add (Request_List, A_Request); end if; if dm_scheduler = True then A_Request.statement := Scheduling_Set_Priorities_According_To_Deadline_Monotonic; Add (Request_List, A_Request); end if; Sequential_Framework_Request ( A_Sys, Request_List, Response_List, Total_Order, Output_Type); for J in 0 .. Response_List.Nb_Entries - 1 loop if Output_Type = Xml_Output then Result := Result & Response_List.Entries (J).text; else Result := Result & Response_List.Entries (J).title & unbounded_lf; Result := Result & Response_List.Entries (J).text & unbounded_lf; end if; end loop; end Compute_Priority; --procedure Select_Feasibility_Tests --(A_Sys : in out System; --Xml_Filename : Unbounded_String; --Output_Type : Output_Format) --is --Response_List : Framework_Response_Table; --Request_List : Framework_Request_Table; --A_Request : Framework_Request; --Xml_Result_File : File_Type; --begin --Initialize (Response_List); --Initialize (Request_List); --Initialize (A_Request); --A_Request.statement := Select_Feasibility_Tests_Simple; --Add (Request_List, A_Request); ----A_Request.statement := Select_Feasibility_Tests_Compositional; ----Add (Request_List, A_Request); --if Xml_Filename = To_Unbounded_String ("") then --Sequential_Framework_Request --(A_Sys, --Request_List, --Response_List, --Total_Order, --String_Output); --for J in 0 .. Response_List.Nb_Entries - 1 loop --Put_Line (To_String (Response_List.Entries (J).title)); --Put_Line (To_String (Response_List.Entries (J).text)); --end loop; --else --Sequential_Framework_Request --(A_Sys, --Request_List, --Response_List, --Total_Order, --Output_Type); --Open --(Xml_Result_File, --Mode => Append_File, --Name => To_String (Xml_Filename)); --for J in 0 .. Response_List.Nb_Entries - 1 loop --Put_Line --(Xml_Result_File, --To_String (Response_List.Entries (J).text)); --end loop; --Close (Xml_Result_File); --end if; --end Select_Feasibility_Tests; procedure Compute_Task_Placement ( A_Sys : in out System; A_Type : in Partioning_Type := First_Fit; Result : in out Unbounded_String; Output_Type : Output_Format) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; begin Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); case A_Type is when General_Task => A_Request.statement := Scheduling_Feasibility_General_Task; when First_Fit => A_Request.statement := Scheduling_Feasibility_First_Fit; when Next_Fit => A_Request.statement := Scheduling_Feasibility_Next_Fit; when Best_Fit => A_Request.statement := Scheduling_Feasibility_Best_Fit; when Small_Task => A_Request.statement := Scheduling_Feasibility_Small_Task; end case; Add (Request_List, A_Request); Sequential_Framework_Request ( A_Sys, Request_List, Response_List, Total_Order, Output_Type); for J in 0 .. Response_List.Nb_Entries - 1 loop if Output_Type = Xml_Output then Result := Result & Response_List.Entries (J).text; else Result := Result & Response_List.Entries (J).title & unbounded_lf; Result := Result & Response_List.Entries (J).text & unbounded_lf; end if; end loop; end Compute_Task_Placement; procedure compute_base_period ( A_Sys : in out System; A_Processor : in Generic_Processor_Ptr; Max_Scheduling_Period : in Natural := 0; Result : in out Unbounded_String; Output_Type : Output_Format) is scheduling_period : Natural; validity : Unbounded_String; begin begin scheduling_period := Get_Scheduling_Period (A_Sys, A_Processor, Max_Scheduling_Period); validity := To_Unbounded_String ("true"); exception when Invalid_Scheduling_Period => scheduling_period := Max_Scheduling_Period; validity := To_Unbounded_String ("false"); end; if Output_Type = Xml_Output then Result := Result & start_computation & To_Unbounded_String (" name=""") & Lb_Xml_Base_Period (Current_Language) & To_Unbounded_String (""" reference=""") & A_Processor.name & To_Unbounded_String (""" schedulingPeriod=""") & format (Natural (scheduling_period)) & To_Unbounded_String (""" validity=""") & To_String (validity) & To_Unbounded_String ("""/>"); else Result := Result & To_Unbounded_String ("The scheduling period is equal to ") & format (Natural (scheduling_period)); end if; end compute_base_period; Project_File_Name : unbounded_string_ptr := new Unbounded_String; Aadl_Project_File_Name : unbounded_string_list; Cmd : Command_Line; Iter : Command_Line_Iterator; extension : Unbounded_String := To_Unbounded_String (""); Directory_Name : unbounded_string_ptr := new Unbounded_String; -- tests Sys : System; Project_File_List : unbounded_string_list; Project_File_Dir_List : unbounded_string_list; Basic_Feasibility_Tests_Request : Boolean := False; Scheduling_Tests_Request : Boolean := False; Compute_Priority_Request : unbounded_string := To_Unbounded_String (""); --Select_Feasibility_Tests_Request : Boolean := False; Task_Placement : Unbounded_String := To_Unbounded_String (""); Cheddar_Simu_Output : Boolean := False; Compute_base_period_Request : Boolean := False; Event_Table_Request : Boolean := False; --Compute_Scheduling_Request : boolean := True; Results_File_Name : unbounded_string_ptr := new Unbounded_String; Result_File : File_Type; Request_Results : Unbounded_String := To_Unbounded_String (""); Output_Type : Output_Format := Xml_Output; A_Processor : Generic_Processor_Ptr; My_Processor_Iterator : Processors_Iterator; --Into : File_Type; Ok : Boolean; Max_Scheduling_Period : Natural := 0; scheduling_period : Natural := 0; file_to_load : Boolean := False; set_result_tag : Boolean := True; cheddarkernel_exception : exception; begin -- initialization Project_File_Name.all := To_Unbounded_String (""); Results_File_Name.all := To_Unbounded_String (""); Directory_Name.all := To_Unbounded_String (""); Cheddar_Debug := No_Debug; --Very_Verbose initialize (Project_File_List); Setenv ("CHEDDAR_INSTALL_PATH", "."); -- Get arguments while Getopt("request: file: resultfile: outputtype: help version debug schedperiod: cheddarsimuoutput etoutput: xmloutput:") /= ASCII.NUL loop Add_Switch (Cmd, Full_Switch, GNAT.Command_Line.Parameter); end loop; Start (Cmd, Iter, Expanded => True); if Has_More (Iter) = False then Usage; end if; -- compute arguments while Has_More (Iter) loop --Put_Line("current switch : " & To_String (To_Unbounded_String(Current_Switch(Iter))) & To_String (To_Unbounded_String(Current_Parameter(Iter)))); if Current_Switch (Iter) = "debug" then Cheddar_Debug := Very_Verbose; elsif Current_Switch (Iter) = "resultfile" or Current_Switch (Iter) = "xmloutput" or Current_Switch (Iter) = "etoutput" then if Current_Parameter (Iter) = "" then raise cheddarkernel_exception with Current_Switch (Iter) & " switch is empty"; else Results_File_Name.all := To_Unbounded_String (Current_Parameter (Iter)); end if; elsif Current_Switch (Iter) = "outputtype" then if Current_Parameter (Iter) = "" then raise cheddarkernel_exception with Current_Switch (Iter) & " switch is empty"; else --Tmp_Output_Type.all := To_Unbounded_String (Current_Parameter (Iter)); if Current_Parameter (Iter) = "xml" then Output_Type := Xml_Output; elsif Current_Parameter (Iter) = "string" then Output_Type := String_Output; elsif Current_Parameter (Iter) = "raw" then Output_Type := Raw_Output; else raise cheddarkernel_exception with "outputtype switch must be equal to xml, string or raw"; end if; end if; --Xml_Result := True; elsif Current_Switch (Iter) = "help" then Usage; elsif Current_Switch (Iter) = "version" then Version; elsif Current_Switch (Iter) = "file" then if Current_Parameter (Iter) = "" then raise cheddarkernel_exception with Current_Switch (Iter) & " switch is empty"; else file_to_load := True; Project_File_Name.all := To_Unbounded_String (Current_Parameter (Iter)); --Put_Line ("filename : " & Current_Parameter (Iter)); add (Aadl_Project_File_Name, Project_File_Name); -- get the extension extension := To_Unbounded_String (Ada.Directories.Extension (To_String (Project_File_Name.all))); -- get the directory name Directory_Name.all := To_Unbounded_String (Ada.Directories.Containing_Directory (To_String (Project_File_Name.all))); Set_Arinc653_Partition_Table_Directory (Directory_Name.all); --add (Project_File_Dir_List, Directory_Name); end if; elsif Current_Switch (Iter) = "schedperiod" then if Current_Parameter (Iter) = "" then raise cheddarkernel_exception with Current_Switch (Iter) & " switch is empty"; else to_natural (To_Unbounded_String (Current_Parameter (Iter)), Max_Scheduling_Period, Ok); if Max_Scheduling_Period > Default_Scheduling_Period then raise cheddarkernel_exception with "The scheduling period is superior to the maximum authorized (" & To_String (To_Unbounded_String(Default_Scheduling_Period)) & ")"; end if; end if; elsif Current_Switch (Iter) = "cheddarsimuoutput" then Cheddar_Simu_Output := True; elsif Current_Switch (Iter) = "request" then if ((Current_Parameter (Iter) = "tft") or (Current_Parameter (Iter) = "theoreticaltests") or (Current_Parameter (Iter) = "basictests") or (Current_Parameter (Iter) = "bt")) then Basic_Feasibility_Tests_Request := True; elsif ((Current_Parameter (Iter) = "sft") or (Current_Parameter (Iter) = "simulationtests") or (Current_Parameter (Iter) = "schedulingtests") or (Current_Parameter (Iter) = "st")) then Scheduling_Tests_Request := True; elsif ((Current_Parameter (Iter) = "computepriority") or (Current_Parameter (Iter) = "cp")) then Compute_Priority_Request := To_Unbounded_String ("both"); elsif (Current_Parameter (Iter) = "cprm") then Compute_Priority_Request := To_Unbounded_String ("rm"); elsif (Current_Parameter (Iter) = "cpdm") then Compute_Priority_Request := To_Unbounded_String ("dm"); elsif ((Current_Parameter (Iter) = "se") or (Current_Parameter (Iter) = "simulationevent") or (Current_Parameter (Iter) = "eventtable") or (Current_Parameter (Iter) = "et")) then set_result_tag := False; Event_Table_Request := True; --elsif ((Current_Parameter (Iter) = "selecttests") or (Current_Parameter (Iter) = "sft")) then --Select_Feasibility_Tests_Request := True; elsif (Current_Parameter (Iter) = "firstfit") then Task_Placement := To_Unbounded_String ("firstfit"); elsif (Current_Parameter (Iter) = "bestfit") then Task_Placement := To_Unbounded_String ("bestfit"); elsif (Current_Parameter (Iter) = "nextfit") then Task_Placement := To_Unbounded_String ("nextfit"); elsif (Current_Parameter (Iter) = "smalltask") then Task_Placement := To_Unbounded_String ("smalltask"); elsif (Current_Parameter (Iter) = "generaltask") then Task_Placement := To_Unbounded_String ("generaltask"); elsif (Current_Parameter (Iter) = "baseperiod") then Compute_base_period_Request := True; elsif Current_Parameter (Iter) = "all" then Basic_Feasibility_Tests_Request := True; Scheduling_Tests_Request := True; Compute_Priority_Request := To_Unbounded_String ("both"); --Select_Feasibility_Tests_Request := True; else raise cheddarkernel_exception with Current_Switch (Iter) & " must be equal to theoreticaltests, tft, simulationtests, sft, computepriority, cp, cprm, cpdm, simulationevent, se, firstfit, bestfit, smalltask, generaltask, baseperiod or all"; end if; end if; Next (Iter); end loop; if file_to_load = True then -- Read project file initialize (Project_File_List); -- Put_Line("extension : " & To_String(extension)); if extension = "xml" then Call_Framework.initialize (False); Systems.Read_From_v2_Xml_File( Sys, Project_File_Dir_List, Project_File_Name.all, False); elsif extension = "xmlv3" then Call_Framework.initialize (False); Systems.Read_From_Xml_File( Sys, Project_File_Dir_List, Project_File_Name.all, False); else raise cheddarkernel_exception with Current_Switch (Iter) & " must be equal to xml or xmlv3"; end if; if Output_Type = Xml_Output then set_tag; if set_result_tag = True then Request_Results := To_unbounded_String(" ") & unbounded_lf; Request_Results := Request_Results & To_Unbounded_String ("") & unbounded_lf; end if; end if; -- Framework Request -- Compute basic feasibility tests if Basic_Feasibility_Tests_Request then reset_iterator (Sys.Processors, My_Processor_Iterator); loop current_element (Sys.Processors, A_Processor, My_Processor_Iterator); Run_Basic_Feasibility_Tests (Sys, A_Processor, Request_Results, Output_Type); exit when is_last_element (Sys.Processors, My_Processor_Iterator); next_element (Sys.Processors, My_Processor_Iterator); end loop; end if; -- Compute the scheduling if Scheduling_Tests_Request then -- Perform analysis on the computed scheduling for each processor reset_iterator (Sys.Processors, My_Processor_Iterator); loop current_element (Sys.Processors, A_Processor, My_Processor_Iterator); Run_Basic_Simulation_Tests (Sys, A_Processor, Max_Scheduling_Period, Request_Results, Output_Type); exit when is_last_element (Sys.Processors, My_Processor_Iterator); next_element (Sys.Processors, My_Processor_Iterator); end loop; end if; if (Compute_Priority_Request = To_Unbounded_String ("both")) or (Compute_Priority_Request = To_Unbounded_String ("rm")) or (Compute_Priority_Request = To_Unbounded_String ("dm")) then Compute_Priority (Sys, Compute_Priority_Request, Request_Results, Output_Type); end if; if Event_Table_Request then scheduling_period := Get_Max_Scheduling_Period(Sys, Max_Scheduling_Period); Compute_Scheduling (Sys, scheduling_period); if Cheddar_Simu_Output = False then Write_Xml_Event_Table (Sys, Request_Results, scheduling_period); --Get_Sheduling_XML_Event_Table ( --Sys, --Results_File_Name.all, --Max_Scheduling_Period); else get_xml_event_table (framework.sched, Sys, Request_Results); end if; end if; --if Select_Feasibility_Tests_Request then --Select_Feasibility_Tests (Sys, Xml_Results_File_Name.all, Output_Type); --end if; if Task_Placement = To_Unbounded_String ("firstfit") then Compute_Task_Placement (Sys, First_Fit, Request_Results, Output_Type); elsif Task_Placement = To_Unbounded_String ("bestfit") then Compute_Task_Placement (Sys, Best_Fit, Request_Results, Output_Type); elsif Task_Placement = To_Unbounded_String ("nextfit") then Compute_Task_Placement (Sys, Next_Fit, Request_Results, Output_Type); elsif Task_Placement = To_Unbounded_String ("smalltask") then Compute_Task_Placement (Sys, Small_Task, Request_Results, Output_Type); elsif Task_Placement = To_Unbounded_String ("generaltask") then Compute_Task_Placement (Sys, General_Task, Request_Results, Output_Type); end if; if Compute_base_period_Request then -- Perform analysis on the computed scheduling for each processor reset_iterator (Sys.Processors, My_Processor_Iterator); loop current_element (Sys.Processors, A_Processor, My_Processor_Iterator); compute_base_period (Sys, A_Processor, Max_Scheduling_Period, Request_Results, Output_Type); exit when is_last_element (Sys.Processors, My_Processor_Iterator); next_element (Sys.Processors, My_Processor_Iterator); end loop; end if; if set_result_tag = True and Output_Type = Xml_Output then Request_Results := Request_Results & unbounded_lf & To_Unbounded_String (""); end if; if Results_File_Name.all /= "" then Create ( Result_File, Mode => Out_File, Name => To_String (Results_File_Name.all)); Put (Result_File, Request_Results); Close (Result_File); else Put_Line (To_String (Request_Results)); end if; end if; exception -- invalid command line argument -- when GNAT.Command_Line.Invalid_Switch => begin Put_Line ("Invalid switch : " & Full_Switch); Usage; OS_Exit (-1); end; when GNAT.Command_Line.Invalid_Parameter => begin Put_Line("Missing parameter for switch : " & Full_Switch); Usage; OS_Exit (-1); end; when cheddarkernel_exception => begin Put_Line (Standard_Error, Exception_Message); Usage; OS_Exit (-1); end; --when max_sched_period_exceeded => --begin --Put_Line (Standard_Error, Exception_Message); --Usage; --OS_Exit (-1); --end; when xml_read_error => begin Put_Line("Can not read project XML file : " & Exception_Message); OS_Exit (-1); end; when Task_Set.Invalid_Parameter => begin Put_Line ("Invalid thread (task) argument : " & Exception_Message); OS_Exit (-1); end; when Address_Space_Set.Invalid_Parameter => begin Put_Line ("Invalid process (adress space) argument : " & Exception_Message); OS_Exit (-1); end; when Processor_Set.Invalid_Parameter => begin Put_Line ("Invalid processor argument : " & Exception_Message); OS_Exit (-1); end; when Buffer_Set.Invalid_Parameter => begin Put_Line ("Invalid event data port (buffer) argument : " & Exception_Message); OS_Exit (-1); end; when Resource_Set.Invalid_Parameter => begin Put_Line ("Invalid data (ressource) argument : " & Exception_Message); OS_Exit (-1); end; --when Xml_Read_Error => --Put_Line("Can not read project XML file : " & Exception_Message); when Ada.IO_Exceptions.Name_Error => begin Put_Line ("Can not open project files : name error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Status_Error => begin Put_Line ("Can not open project files : status error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Mode_Error => begin Put_Line ("Can not open project files : mode error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Use_Error => begin Put_Line ("Can not open project files : use error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Device_Error => begin Put_Line ("Can not open project files : device error"); OS_Exit (-1); end; when Ada.IO_Exceptions.End_Error => begin Put_Line ("Can not open project files : end error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Data_Error => begin Put_Line ("Can not open project files : data error"); OS_Exit (-1); end; when Ada.IO_Exceptions.Layout_Error => begin Put_Line ("Can not open project files : layout error"); OS_Exit (-1); end; when others => begin Put_Line ("This is an internal Cheddar bug ... sorry"); Put_Line ("Exception name : " & Exception_Name); Put_Line ("Exception message : " & Exception_Message); OS_Exit (-1); end; end Cheddarkernel;