--------------------------- ----------------------------------------------------- ------------------------------------------------------------------------------ -- 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 Tasks; use Tasks; with Time_Unit_Events; use Time_Unit_Events; use Time_Unit_Events.Time_Unit_Package; with double_util; use double_util; package body Buffers.Extended is procedure Buffer_Flow_Control (My_Buff : in Buffer_Ptr; My_Tasks : in Tasks_Set; Flow_Cons : in out Double; Flow_Prod : in out Double) is A_Task : Generic_Task_Ptr; begin --init Flow_Prod := 0.0; Flow_Cons := 0.0; -- compute data flow for I in 0 .. (My_Buff.roles.nb_entries - 1) loop -- compute producers data flow if (My_Buff.roles.entries (I).data.the_role = queuing_Producer) then A_Task := Search_Task (My_Tasks, My_Buff.roles.entries (I).item); case A_Task.task_type is when Periodic_Type => Flow_Prod := Flow_Prod + Double (My_Buff.roles.entries (I).data.size) / Double (Periodic_Task_Ptr (A_Task).period); when Poisson_Type => Flow_Prod := Flow_Prod + Double (My_Buff.roles.entries (I).data.size) / Double (Poisson_Task_Ptr (A_Task).period); when others => raise Flow_Constraint_Not_Respected; end case; end if; -- Compute consumers data flow -- if (My_Buff.roles.entries (I).data.the_role = queuing_Consumer) then A_Task := Search_Task (My_Tasks, My_Buff.roles.entries (I).item); case A_Task.task_type is when Periodic_Type => Flow_Cons := Flow_Cons + Double (My_Buff.roles.entries (I).data.size) / Double (Periodic_Task_Ptr (A_Task).period); when Poisson_Type => Flow_Cons := Flow_Cons + Double (My_Buff.roles.entries (I).data.size) / Double (Poisson_Task_Ptr (A_Task).period); when others => raise Flow_Constraint_Not_Respected; end case; end if; end loop; if (not equal (Flow_Prod, Flow_Cons)) and (Flow_Prod > Flow_Cons) then raise Flow_Constraint_Not_Respected; end if; end Buffer_Flow_Control; function Is_Cons_Prod_Harmonic (My_Buff : in Buffer_Ptr; My_Tasks : in Tasks_Set) return Boolean is A_Task1, A_Task2 : Generic_Task_Ptr; Result : Boolean := True; Tmp_Mod : Natural; begin for I in 0 .. (My_Buff.roles.nb_entries - 1) loop A_Task1 := Search_Task (My_Tasks, My_Buff.roles.entries (I).item); for J in I .. (My_Buff.roles.nb_entries - 1) loop A_Task2 := Search_Task (My_Tasks, My_Buff.roles.entries (J).item); if A_Task1.task_type = Periodic_Type then if (Periodic_Task_Ptr (A_Task1).period > Periodic_Task_Ptr (A_Task2).period) then Tmp_Mod := Periodic_Task_Ptr (A_Task1).period mod Periodic_Task_Ptr (A_Task2).period; else Tmp_Mod := Periodic_Task_Ptr (A_Task2).period mod Periodic_Task_Ptr (A_Task1).period; end if; else if A_Task1.task_type = Poisson_Type then if (Poisson_Task_Ptr (A_Task1).period > Poisson_Task_Ptr (A_Task2).period) then Tmp_Mod := Poisson_Task_Ptr (A_Task1).period mod Poisson_Task_Ptr (A_Task2).period; else Tmp_Mod := Poisson_Task_Ptr (A_Task2).period mod Poisson_Task_Ptr (A_Task1).period; end if; end if; end if; if (Tmp_Mod /= 0) then Result := False; end if; end loop; end loop; return Result; end Is_Cons_Prod_Harmonic; end Buffers.Extended;