------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2020, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR CNRS 6285, Universite de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- 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$ -- $Date$ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Numerics.Aux; use Ada.Numerics.Aux; with unbounded_strings; use unbounded_strings; with Framework_Config; use Framework_Config; with Tasks; use Tasks; with Task_Groups; use Task_Groups; with Parameters; use Parameters; with Parameters.extended; use Parameters.extended; with Parameters.extended; use Parameters.User_Defined_Parameters_Table_Package; with Offsets; use Offsets; with Offsets.extended; use Offsets.extended; with Offsets.extended; use Offsets.Offsets_Table_Package; with resource_set; use resource_set; with Cache_Access_Profile_Set; use Cache_Access_Profile_Set; with mils_security; use mils_security; 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 sporadic or periodic tasks are expected -- SR 11/2018 Task_Must_Be_Sporadic_Or_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 a given value 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; -- Offsets must be defined -- Offset_Must_Be_Defined : 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_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 Check_Task (My_Tasks : in Tasks_Set; Name : in Unbounded_String; Cpu_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; Core_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; every : in Integer := 0; energy_consumption : in Integer := 0; Cache_Access_Profile_Name : in Unbounded_String := empty_string; CFG_Name : in Unbounded_String := empty_string; mils_confidentiality_level : in MILS_Confidentiality_Level_Type := Top_Secret; mils_integrity_level : in MILS_Integrity_Level_Type := High; mils_component : in MILS_Component_Type := SLS; mils_task : in MILS_Task_Type := Application; mils_compliant : in Boolean := True; Text_Memory_Start_Address : in Integer := 0; CFG_Relocatable : in Boolean := False); ---------------------------------------------------------- -- Procedure to proceed modification on a set ---------------------------------------------------------- procedure Add_Task (My_Tasks : in out Tasks_Set; Name : in Unbounded_String; Cpu_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; Core_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; every : in Integer := 0; energy_consumption : in Integer := 0; Cache_Access_Profile_Name : in Unbounded_String := empty_string; CFG_Name : in Unbounded_String := empty_string; mils_confidentiality_level: in MILS_Confidentiality_Level_Type := Top_Secret; mils_integrity_level : in MILS_Integrity_Level_Type := High; mils_component : in MILS_Component_Type := SLS; mils_task : in MILS_Task_Type := Application; mils_compliant : in Boolean := True; Text_Memory_Start_Address : in Integer := 0; CFG_Relocatable : in Boolean := False); 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; Core_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; every : in Integer := 0; energy_consumption : in Integer := 0; Cache_Access_Profile_Name : in Unbounded_String := empty_string; CFG_Name : in Unbounded_String := empty_string; mils_confidentiality_level: in MILS_Confidentiality_Level_Type := Top_Secret; mils_integrity_level : in MILS_Integrity_Level_Type := High; mils_component : in MILS_Component_Type := SLS; mils_task : in MILS_Task_Type := Application; mils_compliant : in Boolean := True; Text_Memory_Start_Address : in Integer := 0; CFG_Relocatable : in Boolean := False); -- Search for tasks referencing an address space -- procedure Check_entity_referencing_Address_Space (My_Tasks : in Tasks_Set; A_Addr : in Unbounded_String); procedure Check_entity_referencing_processor (My_Tasks : in Tasks_Set; A_processor : in Unbounded_String); -- Delete all tasks located on the address space 'a_addr' -- procedure Delete_Address_Space (My_Tasks : in out Tasks_Set; A_Addr : in Unbounded_String); -- Delete all tasks located on the processor 'a_processor' -- 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, Criticality, mils_confidentiality_level, mils_integrity_level); -- 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_UCB (CAPs : Cache_Access_Profiles_Set; Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; 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; function Increasing_Offset (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Decreasing_Period_Deadline (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Period_Deadline (Op1 : in Generic_Task_Ptr; Op2 : in Generic_Task_Ptr) return Boolean; function Increasing_Text_Memory_Start_Address (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 Sporadic_Or_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); function Compute_Hyperperiod (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String := empty_string) return Integer; function Get_Max_Offset (My_Tasks : in Tasks_Set; Processor_Name : in Unbounded_String := empty_string) return Integer; private type Tasks_Set is new Generic_Task_Set.set with null record; end Task_Set;