------------------------------------------------- ------------------------------- ------------------------------------------------------------------------------ -- 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.Fixed_Priority.Rm is procedure Initialize (A_Scheduler : in out Rm_Scheduler) is begin Reset (A_Scheduler); A_Scheduler.parameters.scheduler_type := Rate_Monotonic_Protocol; end Initialize; function Copy (A_Scheduler : in Rm_Scheduler) return Generic_Scheduler_Ptr is Ptr : Rm_Scheduler_Ptr; begin Ptr := new Rm_Scheduler; Ptr.parameters := A_Scheduler.parameters; Ptr.Previously_Elected := A_Scheduler.Previously_Elected; Ptr.Used_Resource := A_Scheduler.Used_Resource; return Generic_Scheduler_Ptr (Ptr); end Copy; procedure Check_Before_Scheduling (My_Scheduler : in Rm_Scheduler; My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) is begin Periodic_Control (My_Tasks, Processor_Name); Have_Deadlines_Equal_Than_Periods_Control (My_Tasks, Processor_Name); end Check_Before_Scheduling; procedure Compute_Response_Time (My_Scheduler : in Rm_Scheduler; My_Tasks : in out Tasks_Set; Processor_Name : in Unbounded_String; Msg : in out Unbounded_String; Response_Time : out Response_Time_Table) is begin -- check if tasks are periodic -- Periodic_Control (My_Tasks, Processor_Name); -- check start time -- Start_Time_Control (My_Tasks, Processor_Name); -- check offset -- Offset_Control (My_Tasks, Processor_Name); -- check if deadlines are equal than period -- Have_Deadlines_Equal_Than_Periods_Control (My_Tasks, Processor_Name); -- Check processor utilization first -- if (Processor_Utilization_Over_Period (My_Tasks, Processor_Name) > 1.0) then raise Processor_Utilization_Exceeded; end if; -- Compute response time -- Scheduler.Fixed_Priority.Compute_Response_Time (Fixed_Priority_Scheduler (My_Scheduler), My_Tasks, Processor_Name, Msg, Response_Time); end Compute_Response_Time; 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) 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); Util := Processor_Utilization_Over_Period (My_Tasks, Processor_Name); Bound_On_Processor_Utilization (My_Scheduler, My_Tasks, Processor_Name, Bound, Msg); case Get_Preemptive (My_Scheduler) is when preemptive => Result := Result & Lb_Utilization_Bound1 (Current_Language) & Lb_Rm (Current_Language); if Util <= Bound then 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 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; Result := Result & Start_Ref & Msg & End_Ref & unbounded_lf; when not_preemptive => Result := Result & Lb_Utilization_Bound11 (Current_Language) & Lb_Rm (Current_Language); 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 Result := Result & Lb_Sched_Explanation5 (Current_Language); Result := Result & Lb_Sched_Explanation52 (Current_Language); Result := Result & Lb_See (Current_Language) & "[3]." & unbounded_lf; else Result := Result & Lb_Sched_Explanation8 (Current_Language); Result := Result & Lb_Sched_Explanation81 (Current_Language) & To_Unbounded_String (" (") & Lb_See (Current_Language) & "[3])." & unbounded_lf & Lb_Sched_Explanation82 (Current_Language) & Msg2 & unbounded_lf; end if; end case; free (Tmp); end Utilization_Factor_Feasibility_Test; end Scheduler.Fixed_Priority.Rm;