------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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: 534 $ -- $Date: 2012-10-05 19:46:28 +0200 (Fri, 05 Oct 2012) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; with Framework_Config; use Framework_Config; with Resource_Set; use Resource_Set; with Tasks; use Tasks; with Task_Groups; use Task_Groups; with Parameters; use Parameters; with Parameters.extended; use Parameters.extended; use Parameters.User_Defined_Parameters_Table_Package; with Offsets; use Offsets; with Offsets.extended; use Offsets.extended; use Offsets.Offsets_Table_Package; with Ada.Numerics.Aux; use Ada.Numerics.Aux; with sets; package Task_Set is ---------------------------------------------------------- -- Definition of a set ---------------------------------------------------------- package Generic_Task_Set is new Sets ( Max_Element => Framework_Config.Max_Tasks, Element => Generic_Task_Ptr, Copy => Copy, Free => Free, Put => Put, xml_string => XML_String, xml_ref_string => XML_ref_String); use Generic_Task_Set; type Tasks_Set is new Generic_Task_Set.set with private; subtype Tasks_Range is Generic_Task_Set.element_range; subtype Tasks_Iterator is Generic_Task_Set.iterator; ---------------------------------------------------------- -- Exceptions defined in the set package ---------------------------------------------------------- -- Raised if periodic tasks are expected -- Task_Must_Be_Periodic : exception; -- Raised if tasks are not periodic and poisson process -- Task_Must_Be_Periodic_Or_Poisson_Process : exception; -- Raised if a task has a wrong type -- Task_Model_Error : exception; -- Raised when a given task is not in a task set -- Task_Not_Found : exception; -- Raised when parameters provided to Add_Task are wrong -- Invalid_Parameter : exception; -- Raised when a treatement required that the processor -- utilization is less than 1 for a given task set -- Processor_Utilization_Exceeded : exception; -- Tasks must have deadline equals to period -- Task_Must_Have_Period_Equal_To_Deadline : exception; -- All tasks must have different priority values -- Priority_Error : exception; -- Start times have to be null -- Start_Time_Error : exception; -- Offsets have to be null -- Offset_Error : exception; -- Tasks must have the same period value -- Task_Must_Have_The_Same_Period_Value : exception; -- Tasks must have deadline > 0 -- Deadline_Error : exception; ---------------------------------------------------------- -- I/O operations ---------------------------------------------------------- function Export_Xml (My_Tasks : in Tasks_Set; Graphic_Properties_Flag : Boolean := True) return Unbounded_String; function Export_Aadl_Implementations (My_Tasks : in Tasks_Set; My_Resources : in Resources_Set) return Unbounded_String; function Export_Aadl_Declarations (My_Tasks : in Tasks_Set; Address_Space_Name : in Unbounded_String; Number_Of_Ht : in Natural) return Unbounded_String; function Export_Aadl_User_Defined_Properties (My_Tasks : in Tasks_Set) return Unbounded_String; ---------------------------------------------------------- -- Procedure to proceed modification on a set ---------------------------------------------------------- procedure Check_Task_Critical_Section (My_Tasks : in Tasks_Set; Resource_Name : in Unbounded_String; Resource_Cpu_Name : in Unbounded_String; Task_Name : in Unbounded_String; Share_Begin : in Integer; Share_End : in Integer); procedure Check_Buffer_Roles (My_Tasks : in Tasks_Set; Buffer_Name : in Unbounded_String; Task_Name : in Unbounded_String; Time : in Integer; Size : in Integer); procedure Check_Task (My_Tasks : in Tasks_Set; Name : in Unbounded_String; Cpu_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; Task_Type : in Tasks_Type; Start_Time : in Integer; Capacity : in Integer; Period : in Integer; Deadline : in Integer; Jitter : in Integer; Blocking_Time : in Integer; Priority : in Integer; Criticality : in Integer; Policy : in Policies; Offset : in Offsets_Table := No_Offset; Stack_Memory_Size : in Integer := 0; Text_Memory_Size : in Integer := 0; Param : in User_Defined_Parameters_Table := No_User_Defined_Parameter; Parametric_Rule_Name : in Unbounded_String := empty_string; Seed_Value : in Integer := 0; Predictable : in Boolean := True; context_switch_overhead : in Integer := 0); procedure Add_Task (My_Tasks : in out Tasks_Set; Name : in Unbounded_String; Cpu_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; Task_Type : in Tasks_Type; Start_Time : in Integer; Capacity : in Integer; Period : in Integer; Deadline : in Integer; Jitter : in Integer; Blocking_Time : in Integer; Priority : in Integer; Criticality : in Integer; Policy : in Policies; Offset : in Offsets_Table := No_Offset; Stack_Memory_Size : in Integer := 0; Text_Memory_Size : in Integer := 0; Param : in User_Defined_Parameters_Table := No_User_Defined_Parameter; Parametric_Rule_Name : in Unbounded_String := empty_string; Seed_Value : in Integer := 0; Predictable : in Boolean := True; context_switch_overhead : in Integer := 0); procedure Add_Task (My_Tasks : in out Tasks_Set; A_Task : in out Generic_Task_Ptr; Name : in Unbounded_String; Cpu_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; Task_Type : in Tasks_Type; Start_Time : in Integer; Capacity : in Integer; Period : in Integer; Deadline : in Integer; Jitter : in Integer; Blocking_Time : in Integer; Priority : in Integer; Criticality : in Integer; Policy : in Policies; Offset : in Offsets_Table := No_Offset; Stack_Memory_Size : in Integer := 0; Text_Memory_Size : in Integer := 0; Param : in User_Defined_Parameters_Table := No_User_Defined_Parameter; Parametric_Rule_Name : in Unbounded_String := empty_string; Seed_Value : in Integer := 0; Predictable : in Boolean := True; context_switch_overhead : in Integer := 0); -- Retrieve task hosted by the address space/processor -- procedure Delete_Address_Space (My_Tasks : in out Tasks_Set; A_Addr : in Unbounded_String); procedure Delete_Processor (My_Tasks : in out Tasks_Set; A_Processor : in Unbounded_String); ------------------------------------------------------ -- Read information from a set ------------------------------------------------------ -- Get the number of tasks hosted by the -- processor "Processor_Name" -- function Get_Number_Of_Task_From_Processor (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Tasks_Range; -- Get the task pointer of the task named "Name" -- function Search_Task (My_Tasks : in Tasks_Set; Name : in Unbounded_String) return Generic_Task_Ptr; function Search_Task_by_id (My_Tasks : in Tasks_Set; id : in Unbounded_String) return Generic_Task_Ptr; -- Check if a given task is stored in the task set -- function Task_Is_Present (My_Tasks : in Tasks_Set; Name : in Unbounded_String) return Boolean; ---------------------------------------------------------- -- List of parameters the user can set of get directly -- throught the set ---------------------------------------------------------- type Task_Parameters is ( Cpu_Name, Address_Space_Name, Capacity, Start_Time, Priority, Period, Blocking_Time, Deadline, Jitter, Seed, Predictable); -- Set the value of a parameter of a given task -- procedure Set (My_Tasks : in out Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters; Param_Value : in Unbounded_String); procedure Set (My_Tasks : in out Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters; Param_Value : in Priority_Range); procedure Set (My_Tasks : in out Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters; Param_Value : in Natural); procedure Set (My_Tasks : in out Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters; Param_Value : in Boolean); -- Get the value of a parameter of a given task -- function Get (My_Tasks : in Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters) return Unbounded_String; function Get (My_Tasks : in Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters) return Priority_Range; function Get (My_Tasks : in Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters) return Natural; function Get (My_Tasks : in Tasks_Set; Task_Name : in Unbounded_String; Param_Name : in Task_Parameters) return Boolean; -------------------------------------------------------- -- Functions to proceed sort on a set -------------------------------------------------------- function Increasing_Si (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Utilization (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Name (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Deadline (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Decreasing_Deadline (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Period (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Decreasing_Period (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Priority (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Decreasing_Priority (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; ---------------------------------------------------- -- Control sub-programs ---------------------------------------------------- -- These functions test and return TRUE if all the -- tasks of a task set have a common property -- function Deadline_Inferior_To_Period (My_Tasks : in Tasks_Set) return Boolean; -- These function tests if all the -- tasks of a task set are harmonic -- -- If "Processor_Name" is a null string, the control -- is done on all the task of the set. In the other -- case, the control is done on tasks located on the -- processor "Processor_Name" -- function Is_Harmonic (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Boolean; -- These subprogram test if all the -- tasks of a task set have a common property -- -- If "Processor_Name" is a null string, the control -- is done on all the task of the set. In the other -- case, the control is done on tasks located on the -- processor "Processor_Name" -- procedure Have_Deadlines_Equal_Than_Periods_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Have_Same_Period_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Periodic_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Priority_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Start_Time_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Offset_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); procedure Deadline_Control (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String); ---------------------------------------------------- -- Compute some performance properties on -- a task set ---------------------------------------------------- function Scheduling_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Natural; function Scheduling_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double; function Scheduling_Period_With_Offset (My_Tasks : in Tasks_Set) return Natural; function Processor_Utilization_Over_Deadline (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double; function Processor_Utilization_Over_Period (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String) return Double; private type Tasks_Set is new Generic_Task_Set.set with null record; end Task_Set;