------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2010, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- the LISyC Team, University of Western Britanny. -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- 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: 523 $ -- $Date: 2012-09-26 15:09:39 +0200 (Wed, 26 Sep 2012) $ -- $Author: fotsing $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Xml_Tag; use Xml_Tag; with double_util; use double_util; with Translate; use Translate; with unbounded_strings; use unbounded_strings; package body Scheduler.Dynamic_Priority.Edf is procedure Initialize (A_Scheduler : in out Edf_Scheduler) is begin Reset (A_Scheduler); A_Scheduler.parameters.scheduler_type := Earliest_Deadline_First_Protocol; end Initialize; function Copy (A_Scheduler : in Edf_Scheduler) return Generic_Scheduler_Ptr is Ptr : Edf_Scheduler_Ptr; begin Ptr := new Edf_Scheduler; Ptr.parameters := A_Scheduler.parameters; Ptr.Previously_Elected := A_Scheduler.Previously_Elected; return Generic_Scheduler_Ptr (Ptr); end Copy; procedure Do_Election (My_Scheduler : in out Edf_Scheduler; Si : in out Scheduling_Information; Result : in out Scheduling_Sequence_Ptr; Msg : in out Unbounded_String; Current_Time : in Natural; Processor_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; My_Dependencies : in Tasks_Dependencies_Ptr; With_Offsets : in Boolean; With_Precedencies : in Boolean; With_Resources : in Boolean; Event_To_Generate : in Time_Unit_Event_Type_Boolean_Table; Elected : in out Tasks_Range; No_Task : in out Boolean) is Smallest_Deadline : Natural := Natural'Last; I : Tasks_Range := 0; begin loop if (Si.Tcbs (I).Tsk.cpu_name = Processor_Name) then if (Si.Tcbs (I).assigned_core_unit = empty_string or Si.Tcbs (I).assigned_core_unit = My_Scheduler.corresponding_core_unit) then if (Si.Tcbs (I).Wake_Up_Time <= Current_Time) and (Dynamic_Priority_Tcb_Ptr (Si.Tcbs (I)).Dynamic_Deadline < Smallest_Deadline) and (Si.Tcbs (I).Rest_Of_Capacity /= 0) then if (With_Offsets = False) or Check_Offset (Si.Tcbs (I), Current_Time) then if (With_Precedencies = False) or Check_Precedencies (Si, My_Dependencies, Current_Time, Si.Tcbs (I)) then Smallest_Deadline := Dynamic_Priority_Tcb_Ptr (Si.Tcbs (I)).Dynamic_Deadline; Elected := I; end if; end if; end if; end if; end if; I := I + 1; exit when Si.Tcbs (I) = null; end loop; if Smallest_Deadline = Natural'Last then No_Task := True; else No_Task := False; -- last time unit : compute dynamic deadline for periodic task -- if (Si.Tcbs (Elected).Rest_Of_Capacity = 1) and (Si.Tcbs (Elected).Tsk.task_type = Periodic_Type) then Dynamic_Priority_Tcb_Ptr (Si.Tcbs (Elected)).Dynamic_Deadline := Dynamic_Priority_Tcb_Ptr (Si.Tcbs (Elected)).Dynamic_Deadline + Periodic_Task_Ptr (Si.Tcbs (Elected).Tsk).period; end if; end if; end Do_Election; 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) 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 (My_Scheduler, My_Tasks, Processor_Name, Bound, Msg); Utildi := Processor_Utilization_Over_Deadline (My_Tasks, Processor_Name); Result := Result & Lb_Utilization_Bound1 (Current_Language); Result := Result & Lb_Edf (Current_Language); if Utildi <= Bound then 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 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; Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; 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 Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_Edf (Current_Language); 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 Result := Result & Lb_Pb_Strict_Constraints (Current_Language) & unbounded_lf; Pbconstraints := True; end if; -- Checks the result -- if Pbconstraints = False then if Verif then Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); Result := Result & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8].)" & unbounded_lf; else Result := Result & Lb_Sched_Explanation6 (Current_Language); Result := Result & Lb_Sched_Explanation62 (Current_Language) & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[8])." & unbounded_lf & Lb_Sched_Explanation7 (Current_Language) & Msg2 & unbounded_lf; end if; end if; end case; end Utilization_Factor_Feasibility_Test; end Scheduler.Dynamic_Priority.Edf;