------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, 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: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Resources; use Resources; use Resources.Resource_accesses; with Time_Unit_Events; use Time_Unit_Events; use Time_Unit_Events.Time_Unit_Package; with natural_util; use natural_util; with double_util; use double_util; with integer_util; use integer_util; with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; with Objects; use Objects; with Objects.extended; use Objects.extended; with Multi_precision_integers; use Multi_precision_integers; with Multi_precision_integers_IO; use Multi_precision_integers_IO; with multi_int_util; use multi_int_util; with initialize_framework; use initialize_framework; with Text_IO; use Text_IO; with Translate; use Translate; with unbounded_strings; use unbounded_strings; with Scheduler; use Scheduler; with Scheduling_Analysis; use Scheduling_Analysis; use Scheduling_Analysis.Double_Tasks_Parameters_Package; with priority_assignment.rm; use priority_assignment.rm; with priority_assignment.dm; use priority_assignment.dm; with systems; use systems; with Xml_Tag; use Xml_Tag; with Translate; use Translate; with Ada.Numerics.Aux; use Ada.Numerics.Aux; package body feasibility_test.processor_utilization is function Processor_Utilization_Over_Deadline (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double is Utilization : Double := 0.0; My_Iterator : Tasks_Iterator; A_Task : Generic_Task_Ptr; begin -- Check if tasks are periodic -- Periodic_Control (My_Tasks, Processor_Name); -- Check if deadline a greater than 0 -- Deadline_Control (My_Tasks, Processor_Name); reset_iterator (My_Tasks, My_Iterator); loop current_element (My_Tasks, A_Task, My_Iterator); if (A_Task.cpu_name = Processor_Name) then Utilization := Utilization + (Double (A_Task.capacity) / Double (A_Task.deadline)); end if; exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; return Utilization; end Processor_Utilization_Over_Deadline; function Processor_Utilization_Over_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double is Utilization : Double := 0.0; My_Iterator : Tasks_Iterator; A_Task : Generic_Task_Ptr; begin -- Check if tasks are periodics -- Periodic_Control (My_Tasks, Processor_Name); reset_iterator (My_Tasks, My_Iterator); loop current_element (My_Tasks, A_Task, My_Iterator); if (A_Task.cpu_name = Processor_Name) then if A_Task.task_type /= Aperiodic_Type then Utilization := Utilization + (Double (A_Task.capacity) / Double (Periodic_Task_Ptr (A_Task).period)); end if; end if; exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; return Utilization; end Processor_Utilization_Over_Period; procedure Bound_On_Processor_Utilization (My_Scheduler : in Generic_Scheduler_ptr; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Double; Msg : in out Unbounded_String) is begin case my_scheduler.parameters.scheduler_type is when Earliest_Deadline_First_Protocol | Least_Laxity_First_Protocol | D_Over_Protocol | Maximum_Urgency_First_Based_On_Laxity_Protocol | Maximum_Urgency_First_Based_On_Deadline_Protocol => bound_on_processor_utilization(dynamic_priority_scheduler(my_scheduler.all), my_tasks, processor_name, result, msg); when Rate_Monotonic_Protocol | Deadline_Monotonic_Protocol | Posix_1003_Highest_Priority_First_Protocol => bound_on_processor_utilization(fixed_priority_scheduler(my_scheduler.all), my_tasks, processor_name, result, msg); when others => raise Invalid_Scheduler; end case; end Bound_On_Processor_Utilization; procedure Bound_On_Processor_Utilization (My_Scheduler : in Dynamic_Priority_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Double; Msg : in out Unbounded_String) is begin Result := 1.0; Msg := To_Unbounded_String (" (") & Lb_See (Current_Language) & To_Unbounded_String ("[1], page 8, ") & Lb_Theorem (Current_Language) & To_Unbounded_String ("2). ") & unbounded_lf; end Bound_On_Processor_Utilization; procedure Bound_On_Processor_Utilization (My_Scheduler : in Fixed_Priority_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Double; Msg : in out Unbounded_String) is Nb : constant Double := Double (Get_Number_Of_Task_From_Processor (My_Tasks, Processor_Name)); begin if not Is_Harmonic (My_Tasks, Processor_Name) then Msg := To_Unbounded_String (" (") & Lb_See (Current_Language) & To_Unbounded_String ("[1], page 16, ") & Lb_Theorem (Current_Language) & To_Unbounded_String ("8). ") & unbounded_lf; Result := Nb * (Pow (2.0, (1.0 / Nb)) - 1.0); else Msg := To_Unbounded_String (" (") & Lb_See (Current_Language) & To_Unbounded_String ("[19], page 13).") & unbounded_lf; Result := 1.0; end if; end Bound_On_Processor_Utilization; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in generic_Scheduler_ptr; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is begin case my_scheduler.parameters.scheduler_type is when Rate_Monotonic_Protocol => Utilization_Factor_Feasibility_Test(rm_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when Deadline_Monotonic_Protocol => Utilization_Factor_Feasibility_Test(dm_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when Maximum_Urgency_First_Based_On_Laxity_Protocol | Maximum_Urgency_First_Based_On_Deadline_Protocol => Utilization_Factor_Feasibility_Test(muf_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when Least_Laxity_First_Protocol => Utilization_Factor_Feasibility_Test(llf_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when Earliest_Deadline_First_Protocol => Utilization_Factor_Feasibility_Test(edf_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when d_over_protocol => Utilization_Factor_Feasibility_Test(d_over_scheduler(my_scheduler.all), my_tasks, processor_name, result, Output); when others => if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); Result := Result & Lb_Compute_Scheduling_Error_19 (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Compute_Scheduling_Error_19 (Current_Language) & unbounded_lf; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in D_Over_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Tmp : Tasks_Set; Bound : Double := 0.0; Utildi : Double := 0.0; Msg : Unbounded_String := empty_string; Verif : Boolean := True; A_Task : Generic_Task_Ptr; My_Task_Iterator : Tasks_Iterator; A_Task2 : Generic_Task_Ptr; My_Task_Iterator2 : Tasks_Iterator; Calcul : Double := 0.0; L_Debut : Natural; L_Dernier : Natural; Ech_Sur_Req : Boolean := True; Pbconstraints : Boolean := False; Msg2 : Unbounded_String := empty_string; Msg3 : Unbounded_String := empty_string; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); case Get_Preemptive (My_Scheduler) is when preemptive => Bound_On_Processor_Utilization (dynamic_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_D_Over (Current_Language); end if; if Utildi <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation2 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; else Result := Result & To_Unbounded_String (""" biblio=""") & Msg & To_Unbounded_String (""""); end if; when not_preemptive => Current_Processor_Name := Processor_Name; select_and_copy (My_Tasks, Tmp, Select_Cpu'Access); Msg2 := empty_string; --Check if the system is in stricts constraints --The test works only on stricts constraints ! -- reset_iterator (Tmp, My_Task_Iterator); loop current_element (Tmp, A_Task, My_Task_Iterator); if (A_Task.cpu_name = Processor_Name) then if (Periodic_Task_Ptr (A_Task).period /= A_Task.deadline) then Ech_Sur_Req := False; end if; end if; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); end loop; sort (Tmp, Increasing_Deadline'Access); reset_iterator (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); L_Debut := Periodic_Task_Ptr (A_Task).period + 1; Verif := True; -- Main loop of all tasks -- if Ech_Sur_Req then if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_D_Over (Current_Language); end if; loop Msg3 := empty_string; if (A_Task.cpu_name = Processor_Name) then L_Dernier := Periodic_Task_Ptr (A_Task).period - 1; for L_Courant in L_Debut .. L_Dernier loop reset_iterator (Tmp, My_Task_Iterator2); -- Second loop until the current task -- Calcul := 0.0; loop current_element (Tmp, A_Task2, My_Task_Iterator2); exit when A_Task.name = A_Task2.name; Calcul := Calcul + Double ((Integer ((L_Courant - 1) / Periodic_Task_Ptr ( A_Task2).period)) * A_Task2.capacity); next_element (Tmp, My_Task_Iterator2); end loop; -- Checking -- Calcul := Calcul + Double (A_Task.capacity); if Calcul > Double (L_Courant) then Verif := False; Msg3 := A_Task.name & " "; end if; end loop; end if; Msg2 := Msg2 & Msg3; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); end loop; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); Result := Result & Lb_Pb_Strict_Constraints (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Pb_Strict_Constraints (Current_Language) & unbounded_lf; end if; Pbconstraints := True; end if; -- Checks the result -- if Pbconstraints = False then if Verif then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8].)" & unbounded_lf; end if; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation6 (Current_Language); Result := Result & Lb_Sched_Explanation62 (Current_Language) & Lb_Sched_Explanation7 (Current_Language) & Msg2; if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8])."; end if; end if; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in Edf_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Tmp : Tasks_Set; Bound : Double := 0.0; Utildi : Double := 0.0; Msg : Unbounded_String := empty_string; Verif : Boolean := True; A_Task : Generic_Task_Ptr; My_Task_Iterator : Tasks_Iterator; A_Task2 : Generic_Task_Ptr; My_Task_Iterator2 : Tasks_Iterator; Calcul : Double := 0.0; L_Debut : Natural; L_Dernier : Natural; Ech_Sur_Req : Boolean := True; Pbconstraints : Boolean := False; Msg2 : Unbounded_String := empty_string; Msg3 : Unbounded_String := empty_string; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); case Get_Preemptive (My_Scheduler) is when preemptive => Bound_On_Processor_Utilization (dynamic_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_Edf (Current_Language); end if; if Utildi <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation2 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; else Result := Result & To_Unbounded_String (""" biblio=""") & Msg & To_Unbounded_String (""""); end if; when not_preemptive => Current_Processor_Name := Processor_Name; select_and_copy (My_Tasks, Tmp, Select_Cpu'Access); Periodic_Control (Tmp, Processor_Name); Msg2 := empty_string; --Check if the system is in stricts constraints --The test works only on stricts constraints ! -- reset_iterator (Tmp, My_Task_Iterator); loop current_element (Tmp, A_Task, My_Task_Iterator); if (A_Task.cpu_name = Processor_Name) then if (Periodic_Task_Ptr (A_Task).period /= A_Task.deadline) then Ech_Sur_Req := False; end if; end if; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); end loop; sort (Tmp, Increasing_Deadline'Access); reset_iterator (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); L_Debut := Periodic_Task_Ptr (A_Task).period + 1; Verif := True; -- Main loop of all tasks -- if Ech_Sur_Req then if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_Edf (Current_Language); end if; loop Msg3 := empty_string; if (A_Task.cpu_name = Processor_Name) then L_Dernier := Periodic_Task_Ptr (A_Task).period - 1; for L_Courant in L_Debut .. L_Dernier loop reset_iterator (Tmp, My_Task_Iterator2); -- Second loop until the current task -- Calcul := 0.0; loop current_element (Tmp, A_Task2, My_Task_Iterator2); exit when A_Task.name = A_Task2.name; Calcul := Calcul + Double ((Integer ((L_Courant - 1) / Periodic_Task_Ptr ( A_Task2).period)) * A_Task2.capacity); next_element (Tmp, My_Task_Iterator2); end loop; -- Checking -- Calcul := Calcul + Double (A_Task.capacity); if Calcul > Double (L_Courant) then Verif := False; Msg3 := A_Task.name & " "; end if; end loop; end if; Msg2 := Msg2 & Msg3; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); end loop; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); Result := Result & Lb_Pb_Strict_Constraints (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Pb_Strict_Constraints (Current_Language) & unbounded_lf; end if; Pbconstraints := True; end if; -- Checks the result -- if Pbconstraints = False then if Verif then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8].)" & unbounded_lf; end if; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation6 (Current_Language); Result := Result & Lb_Sched_Explanation62 (Current_Language) & Lb_Sched_Explanation7 (Current_Language) & Msg2; if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8])."; end if; end if; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in Llf_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Bound : Double := 0.0; Utildi : Double := 0.0; Msg : Unbounded_String := empty_string; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); -- if Output = Xml2_Output then -- Result := Result & To_Unbounded_String (" --scheduler=""llf"""); -- end if; case Get_Preemptive (My_Scheduler) is when preemptive => Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); Bound_On_Processor_Utilization (dynamic_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_Llf (Current_Language); end if; if Utildi <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation2 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & To_Unbounded_String (" (") & Lb_See (Current_Language) & To_Unbounded_String ("[7]).") & End_Ref & unbounded_lf; else Result := Result & To_Unbounded_String (""" biblio=""[7]"""); end if; when not_preemptive => if Output = Xml2_Output then -- Result := Result & -- To_Unbounded_String(" preemptive=""false"" --result=""false"" explanation="""); Result := Result & To_Unbounded_String (" result=""false"" explanation="""); Result := Result & Lb_Pb_Sched_Unknown (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Pb_Sched_Unknown (Current_Language) & unbounded_lf; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in Muf_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Tmp : Tasks_Set; Bound : Double := 0.0; Utildi : Double := 0.0; Msg : Unbounded_String := empty_string; Verif : Boolean := True; A_Task : Generic_Task_Ptr; My_Task_Iterator : Tasks_Iterator; A_Task2 : Generic_Task_Ptr; My_Task_Iterator2 : Tasks_Iterator; Calcul : Double := 0.0; L_Debut : Natural; L_Dernier : Natural; Ech_Sur_Req : Boolean := True; Pbconstraints : Boolean := False; Msg2 : Unbounded_String := empty_string; Msg3 : Unbounded_String := empty_string; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); case Get_Preemptive (My_Scheduler) is when preemptive => Bound_On_Processor_Utilization (dynamic_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_Muf (Current_Language); end if; if Utildi <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation2 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; else Result := Result & To_Unbounded_String (""" biblio=""") & Msg & To_Unbounded_String (""""); end if; when not_preemptive => Current_Processor_Name := Processor_Name; select_and_copy (My_Tasks, Tmp, Select_Cpu'Access); Msg2 := empty_string; --Check if the system is in stricts constraints --The test works only on stricts constraints ! -- reset_iterator (Tmp, My_Task_Iterator); loop current_element (Tmp, A_Task, My_Task_Iterator); if (A_Task.cpu_name = Processor_Name) then if (Periodic_Task_Ptr (A_Task).period /= A_Task.deadline) then Ech_Sur_Req := False; end if; end if; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); end loop; sort (Tmp, Increasing_Deadline'Access); reset_iterator (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); L_Debut := Periodic_Task_Ptr (A_Task).period + 1; Verif := True; -- Main loop of all tasks -- if Ech_Sur_Req then if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_Muf (Current_Language); end if; loop Msg3 := empty_string; if (A_Task.cpu_name = Processor_Name) then L_Dernier := Periodic_Task_Ptr (A_Task).period - 1; for L_Courant in L_Debut .. L_Dernier loop reset_iterator (Tmp, My_Task_Iterator2); -- Second loop until the current task -- Calcul := 0.0; loop current_element (Tmp, A_Task2, My_Task_Iterator2); exit when A_Task.name = A_Task2.name; Calcul := Calcul + Double ((Integer ((L_Courant - 1) / Periodic_Task_Ptr ( A_Task2).period)) * A_Task2.capacity); next_element (Tmp, My_Task_Iterator2); end loop; -- Checking -- Calcul := Calcul + Double (A_Task.capacity); if Calcul > Double (L_Courant) then Verif := False; Msg3 := A_Task.name & " "; end if; end loop; end if; Msg2 := Msg2 & Msg3; exit when is_last_element (Tmp, My_Task_Iterator); next_element (Tmp, My_Task_Iterator); current_element (Tmp, A_Task, My_Task_Iterator); end loop; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); Result := Result & Lb_Pb_Strict_Constraints (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Pb_Strict_Constraints (Current_Language) & unbounded_lf; end if; Pbconstraints := True; end if; -- Checks the result -- if Pbconstraints = False then if Verif then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8].)" & unbounded_lf; end if; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation6 (Current_Language); Result := Result & Lb_Sched_Explanation62 (Current_Language) & Lb_Sched_Explanation7 (Current_Language) & Msg2; if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[8]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8])."; end if; end if; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in Dm_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Bound : Double := 0.0; Utildi : Double := 0.0; Msg : Unbounded_String := empty_string; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); -- if Output = Xml2_Output then -- Result := Result & To_Unbounded_String (" scheduler=""dm"""); -- end if; Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); Bound_On_Processor_Utilization (fixed_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); case Get_Preemptive (My_Scheduler) is when preemptive => if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_Dm (Current_Language); end if; if Utildi <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation2 (Current_Language); Result := Result & Start_Fact_Bound & format (Utildi) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & To_Unbounded_String (" (") & Lb_See (Current_Language) & To_Unbounded_String ("[7]).") & End_Ref & unbounded_lf; else -- JLE : why the msg variable which contains a different biblio --reference is not used??? Result := Result & To_Unbounded_String (""" biblio=""[7]"""); end if; when not_preemptive => if Output = Xml2_Output then -- Result := Result & -- To_Unbounded_String( -- " preemptive=""false"" result=""false"" explanation="""); Result := Result & To_Unbounded_String( " result=""false"" explanation="""); Result := Result & Lb_Pb_Sched_Unknown (Current_Language); Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String (""""); else Result := Result & Lb_Pb_Sched_Unknown (Current_Language) & unbounded_lf; end if; end case; end Utilization_Factor_Feasibility_Test; procedure Utilization_Factor_Feasibility_Test (My_Scheduler : in Rm_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String; Result : in out Unbounded_String; Output : in Output_Format := String_Output) is Tmp : Tasks_Set; Bound : Double := 0.0; Util : Double := 0.0; Msg, Msg2 : Unbounded_String := empty_string; Verification : Boolean := True; A_Task : Generic_Task_Ptr; My_Task_Iterator : Tasks_Iterator; A_Task2 : Generic_Task_Ptr; My_Task_Iterator2 : Tasks_Iterator; Compute : Double := 0.0; Max_Bi : Double := 0.0; I_Bound : Double := 0.0; Task_Number : Natural := 0; begin Start_Time_Control (My_Tasks, Processor_Name); Offset_Control (My_Tasks, Processor_Name); -- if Output = Xml2_Output then -- Result := Result & To_Unbounded_String (" scheduler=""rm"""); -- end if; Util := Processor_Utilization_Over_Period (My_Tasks, Processor_Name); Bound_On_Processor_Utilization (fixed_priority_scheduler(My_Scheduler), My_Tasks, Processor_Name, Bound, Msg); case Get_Preemptive (My_Scheduler) is when preemptive => if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound1 (Current_Language) & Lb_Rm (Current_Language); -- else -- Result := Result & -- To_Unbounded_String (" preemptive=""true"""); end if; if Util <= Bound then if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""true"" explanation="""); end if; Result := Result & Lb_Sched_Explanation1 (Current_Language); Result := Result & Start_Fact_Bound & format (Util) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation12 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; else if Output = Xml2_Output then Result := Result & To_Unbounded_String (" result=""false"" explanation="""); end if; Result := Result & Lb_Sched_Explanation3 (Current_Language); Result := Result & Start_Fact_Bound & format (Util) & End_Fact_Bound; Result := Result & Lb_Sched_Explanation22 (Current_Language); Result := Result & Start_Fact_Bound & format (Bound) & End_Fact_Bound; end if; if Output /= Xml2_Output then Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; else Result := Result & To_Unbounded_String (""" biblio=""") & Msg & To_Unbounded_String (""""); end if; when not_preemptive => if Output /= Xml2_Output then Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_Rm (Current_Language); -- else -- Result := Result & -- To_Unbounded_String (" preemptive=""false"""); end if; Current_Processor_Name := Processor_Name; select_and_copy (My_Tasks, Tmp, Select_Cpu'Access); sort (Tmp, Increasing_Period'Access); Msg2 := empty_string; -- Main loop of all tasks -- Verification := True; reset_iterator (Tmp, My_Task_Iterator); loop current_element (Tmp, A_Task, My_Task_Iterator); if (A_Task.cpu_name = Processor_Name) then Compute := 0.0; -- Loop until the current task -- reset_iterator (Tmp, My_Task_Iterator2); Task_Number := 0; loop current_element (Tmp, A_Task2, My_Task_Iterator2); if (A_Task2.cpu_name = Processor_Name) then Task_Number := Task_Number + 1; Compute := Compute + Double (A_Task2.capacity) / Double ( Periodic_Task_Ptr (A_Task2).period); end if; exit when A_Task.name = A_Task2.name; next_element (Tmp, My_Task_Iterator2); end loop; -- Looking for the max Bi -- Max_Bi := 0.0; loop exit when is_last_element (Tmp, My_Task_Iterator2); next_element (Tmp, My_Task_Iterator2); current_element (Tmp, A_Task2, My_Task_Iterator2); if (A_Task2.cpu_name = Processor_Name) then if Double (A_Task2.capacity) > Max_Bi then Max_Bi := Double (A_Task2.capacity); end if; end if; end loop; Compute := Compute + Max_Bi / Double (Periodic_Task_Ptr (A_Task).period); I_Bound := (Double (Task_Number)) * (Pow (2.0, (1.0 / (Double (Task_Number)))) - 1.0); if Compute > I_Bound then Verification := False; Msg2 := Msg2 & A_Task.name & " "; end if; end if; exit when is_last_element (Tmp, My_Task_Iterator); next_element (My_Tasks, My_Task_Iterator); end loop; -- Checks the result -- if Verification then if Output = Xml2_Output then Result := Result & " result=""true"" explanation="""; end if; Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); if Output = Xml2_Output then Result := Result & " (" & format (I_Bound) & ")"; Result := Result & """ biblio=""" & "[3]" & """"; else Result := Result & Lb_See (Current_Language) & "[3]." & unbounded_lf; end if; else if Output = Xml2_Output then Result := Result & " result=""false"" explanation="""; end if; Result := Result & Lb_Sched_Explanation8 (Current_Language); if Output = Xml2_Output then Result := Result & Lb_Sched_Explanation81 (Current_Language) & To_Unbounded_String (" (") & Lb_Sched_Explanation82 (Current_Language) & Msg2 & To_Unbounded_String (")."); else Result := Result & Lb_Sched_Explanation81 (Current_Language) & Lb_Sched_Explanation82 (Current_Language) & Msg2; end if; if Output = Xml2_Output then Result := Result & To_Unbounded_String (""" biblio=""") & To_Unbounded_String ("[3]") & To_Unbounded_String (""""); else Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[3])."; end if; end if; end case; free (Tmp); end Utilization_Factor_Feasibility_Test; end feasibility_test.processor_utilization;