with Xml_Tag; use Xml_Tag; with Parameters; use Parameters; with Parameters.extended; use Parameters.Framework_Parameters_Table_Package; with Tasks; use Tasks; with Task_Set; use Task_Set; with Offsets; use Offsets; with Offsets; use Offsets.Offsets_Table_Package; with Offsets.extended; use Offsets.extended; with Tables; with sets; with framework_config; use framework_config; with Ada.IO_Exceptions; use Ada.IO_Exceptions; with GNAT.Current_Exception; use GNAT.Current_Exception; with Text_IO; use Text_IO; 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 Systems; use Systems; with Framework; use Framework; 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 Call_Scheduling_Framework; use Call_Scheduling_Framework; with Multiprocessor_Services; use Multiprocessor_Services; with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface; with 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; with Time_Unit_Events; use Time_Unit_Events; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Ada.Directories; use Ada.Directories; with Scheduler; use Scheduler; with Ada.Directories; use Ada.Directories; with Ada.text_IO; use Ada.text_IO; with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings; use Ada.Strings; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with feasibility_test.feasibility_interval; use feasibility_test.feasibility_interval; procedure Call_Cheddar is task_exist : integer; start,finish : integer; sub_str : unbounded_string; -- A set of variables required to call the framework -- Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Param : Parameter_Ptr; A_Request : Framework_Request; dir : unbounded_string_list; Response_text : unbounded_string; str : unbounded_string; Nb_tasks : integer; Sum_Laxities : integer; Nb_preemptions : integer; response_time : integer; Deadline_i : integer; task_set_file_name,Data,line,sched_period : unbounded_string; dir1 : unbounded_string_list; Sys : system; F,F2 : Ada.Text_IO.File_Type; Min_lax : integer; laxity_i : integer; Data2 : unbounded_string; begin Call_Framework.initialize (False); Sched_period := To_Unbounded_String(Argument(1)); task_set_file_name := To_Unbounded_String(Argument(2)); initialize(Sys); Read_From_Xml_File (Sys, dir1, task_set_file_name); 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 := Integer'Value(To_String(Sched_period)); 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, Total_Order, Xml_Output); initialize (Request_List); initialize (Response_List); Initialize (A_Request); A_Request.statement := Scheduling_Simulation_Basics; add (Request_List, A_Request); Sequential_Framework_Request (Sys, Request_List, Response_List, Total_Order, Xml_Output); Sequential_Framework_Request (Sys, Request_List, Response_List); Response_text := Response_List.entries (0).text; -- Extracting the decision about the schedulability -- From the simulation str := Response_text; Append (Data2, "/////////////////////////////////////////////////////////////////////////////////////////////////" & ASCII.LF); Append (Data2, To_String(Response_text) & ASCII.LF); Append (Data2, "/////////////////////////////////////////////////////////////////////////////////////////////////" & ASCII.LF); task_exist := index (str, ""); while task_exist /= 0 loop str := Unbounded_Slice( str, index (str, "") + length(To_Unbounded_String("")), length(str)); task_exist := index (str, ""); end loop; sub_str := Unbounded_Slice(str, 1, 6); Append (Data2, To_String(sub_str) & ASCII.LF); if sub_str = To_Unbounded_String("- No d") then -- In this case, the task set is schedulable -- Then we compute the number of preemption -- and the sum of tasks laxities Append (Data, "schedulable_task_set" & ASCII.LF); start := index (Response_text, " ") + length(To_Unbounded_String(" ")); finish := index (Response_text, "") - 1; Nb_preemptions := integer'Value (to_string(Unbounded_Slice(Response_text,start,finish))); Append (Data, "Nb_preemption_of_the_candidate_sol = " & Nb_preemptions'Img & ASCII.LF); Nb_tasks := Integer (Get_Number_Of_Task_From_Processor (sys.Tasks, To_Unbounded_String("processor1"))); Sum_Laxities := 0; str := Response_text; for i in 1..Nb_tasks loop start := index (str, "=> ") + length(To_Unbounded_String("=> ")); finish := index (str, "/worst") - 1; response_time := integer'Value (to_string(Unbounded_Slice(str,start,finish))); Deadline_i := Get(My_Tasks => sys.Tasks, Task_Name => Suppress_Space (To_Unbounded_String ("Task" & i'Img)), Param_Name => Deadline); laxity_i := Deadline_i - response_time; if i = 1 then Min_lax := laxity_i; else if laxity_i < Min_lax then Min_lax := laxity_i; end if; end if; Sum_Laxities := Sum_Laxities + (Deadline_i - response_time); str := Unbounded_Slice(str, index (str, "") + length(To_Unbounded_String("")), length(str)); end loop; Append (Data, "Sum_laxities_of_the_candidate_sol = " & Sum_laxities'Img & ASCII.LF); Append (Data, "Min_laxities_of_the_candidate_sol = " & Min_lax'Img & ASCII.LF); else Append (Data, "Not_schedulable_task_set" & ASCII.LF); end if; Create(F,Ada.Text_IO.Out_File,"Output.txt"); Unbounded_IO.Put_Line(F, Data); Close(F); Create(F2,Ada.Text_IO.Out_File,"Output2.txt"); Unbounded_IO.Put_Line(F2, Data2); Close(F2); end Call_Cheddar;