------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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 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 Translate; use Translate; 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; 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 Taski : Generic_Task_Ptr; My_Iterator : Tasks_Iterator; calcul : Double := 0.0; begin Periodic_Control (My_Tasks, Processor_Name); reset_iterator (My_Tasks, My_Iterator); loop current_element (My_Tasks, Taski, My_Iterator); if (Taski.task_type /= Aperiodic_Type) then calcul := calcul + (Double(Taski.capacity)/Double(Periodic_Task_Ptr(Taski).period)); end if; exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; return calcul; end Processor_Utilization_Over_Period; function compute_less (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return boolean is rightvalue, leftvalue : Double; --My_Tasks : Tasks_Set; --calcul : Double := 0.0; --tmp : Double :=0.1; -- My_Iterator : Tasks_Iterator; -- A_Task : Generic_Task_Ptr; begin leftvalue :=Processor_Utilization_Over_Period(My_Tasks,To_Unbounded_String("CPU_A")) ; rightvalue :=1.0; if leftvalue < rightvalue then return True; else return False; end if; end compute_less; end feasibility_test.processor_utilization;