------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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.feasibility_interval is function Scheduling_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double is Period : Double := 1.0; Start_Time : Integer := 0; A_Task : Generic_Task_Ptr; My_Iterator : Tasks_Iterator; Res, Current : multi_int_ptr; begin -- Check if Tasks Are Periodic -- Periodic_Control (My_Tasks, Processor_Name); Res := new multi_int'(Multi (1)); reset_iterator (My_Tasks, My_Iterator); loop current_element (My_Tasks, A_Task, My_Iterator); if (A_Task.cpu_name = Processor_Name and A_Task.task_type = Periodic_Type) then Start_Time := Natural'Max (Start_Time, A_Task.start_time); Current := new multi_int'(Multi (Periodic_Task_Ptr (A_Task).period)); Res := lcm (Res, Current); end if; exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; if Start_Time /= 0 then Current := new multi_int'(Multi (2)); Res.all := Res.all * Current.all; Current.all := Multi (Start_Time); Res.all := Res.all + Current.all; end if; Period := Double (convert (Res.all)); return Period; end Scheduling_Period; function Scheduling_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Natural is Period : Natural := 1; Start_Time : Natural := 0; A_Task : Generic_Task_Ptr; My_Iterator : Tasks_Iterator; begin -- Check if tasks are periodic -- 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 and A_Task.task_type = Periodic_Type) then Start_Time := Natural'Max (Start_Time, A_Task.start_time); Period := natural_util.lcm (Period, Periodic_Task_Ptr (A_Task).period); end if; exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; if Start_Time /= 0 then Period := (Period * 2) + Start_Time; end if; return Period; end Scheduling_Period; function Scheduling_Period_With_Offset (My_Tasks : in Tasks_Set) return Natural is Period : Natural := 1; Start_Time : Natural := 0; Offset_Value : Natural := 0; Max_Offset : Natural := 0; A_Task : Generic_Task_Ptr; My_Iterator : Tasks_Iterator; begin -- Check if tasks are periodic -- --Periodic_Control (My_Tasks); reset_iterator (My_Tasks, My_Iterator); loop current_element (My_Tasks, A_Task, My_Iterator); Start_Time := A_Task.start_time; Offset_Value := 0; for I in 0 .. A_Task.offsets.nb_entries - 1 loop if (A_Task.offsets.entries(I).activation = 0) then Offset_Value := A_Task.offsets.entries(I).offset_value; exit; end if; end loop; Max_Offset := Natural'Max (Max_Offset, (Start_Time + Offset_Value)); Period := natural_util.lcm (Period, Periodic_Task_Ptr (A_Task).period); exit when is_last_element (My_Tasks, My_Iterator); next_element (My_Tasks, My_Iterator); end loop; Period := (Period * 2) + Max_Offset; return Period; end Scheduling_Period_With_Offset; end feasibility_test.feasibility_interval;