------------------------------------------------------------- ------------------- ------------------------------------------------------------------------------ -- 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 Text_IO; use Text_IO; 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 Task_Groups; use Task_Groups; with Tasks; use Tasks; use Tasks.Generic_Task_List_Package; with Task_Set; use Task_Set; with Task_Groups; use Task_Groups; with Task_Group_Set; use Task_Group_Set; with Systems; use Systems; with Task_Dependencies; use Task_Dependencies; package body Task_Group_Transformation is procedure Multiframe_to_Transaction (My_Multiframe : in Multiframe_Task_Group_Ptr; A_System : in out System) -- New Transaction System is -- New transaction variables A_Transaction : Transaction_Task_Group_Ptr; A_Task_Group : Generic_Task_Group_Ptr; A_Periodic_Task : Periodic_Task_Ptr; Offset_Sum : Integer; New_Offset : Offset_Type_Ptr; New_Offset_Table : Offsets_Table_Ptr; Start_Time : Integer; -- Old Multiframe variables A_Frame_Task : Frame_Task_Ptr; A_Task : Generic_Task_Ptr; Task_List_Iterator : Generic_Task_Iterator; begin A_Transaction := new Transaction_Task_Group; A_Transaction.name := My_Multiframe.name; -- TODO: other task_group attributes A_Task_Group := Generic_Task_Group_Ptr (A_Transaction); Add_Task_Group(A_System.task_groups, A_Task_Group); Offset_Sum := 0; if not is_empty (My_Multiframe.task_list) then -- Transaction.startTime = Multiframe.startTime = Multiframe.first_task.startTime A_Task := get_head(My_Multiframe.task_list); Start_Time := A_Task.Start_Time; reset_head_iterator (My_Multiframe.task_list, Task_List_Iterator); loop current_element (My_Multiframe.task_list, A_Task, Task_List_Iterator); A_Frame_Task := Frame_Task_Ptr (A_Task); New_Offset := new Offset_Type; New_Offset.offset_value := Offset_Sum; New_Offset.activation := 0; New_Offset_Table := new Offsets_Table; Offsets_Table_Package.Add (New_Offset_Table.all, New_Offset.all); Add_Task (A_System.Tasks, A_System.Task_Groups, A_Transaction.name, A_Frame_Task.name, A_Frame_Task.cpu_name, A_Frame_Task.address_space_name, Periodic_Type, -- Periodic_Type mandatory Start_Time, A_Frame_Task.capacity, 1, -- temporary period A_Frame_Task.deadline, 0, -- jitter A_Frame_Task.blocking_time, Integer (A_Frame_Task.priority), A_Frame_Task.criticality, A_Frame_Task.policy, New_Offset_Table.all, A_Frame_Task.stack_memory_size, A_Frame_Task.text_memory_size, A_Frame_Task.parameters, empty_string, 0, -- seed True, -- predictable A_Frame_Task.context_switch_overhead); Offset_Sum := Offset_Sum + A_Frame_Task.interarrival; if is_tail_element (My_Multiframe.task_list, Task_List_Iterator) then exit; end if; next_element (My_Multiframe.task_list, Task_List_Iterator); end loop; -- Set transaction period --A_Transaction.period := Offset_Sum; -- Loop to set task periods and precedence_dependencies in the --created transaction reset_head_iterator (A_Transaction.task_list, Task_List_Iterator); loop current_element (A_Transaction.task_list, A_Task, Task_List_Iterator); A_Periodic_Task := Periodic_Task_Ptr (A_Task); A_Periodic_Task.period := Offset_Sum; Update_All_Task_Dependencies(A_System.dependencies, A_Task); if is_tail_element (A_Transaction.task_list, Task_List_Iterator) then exit; end if; next_element (A_Transaction.task_list, Task_List_Iterator); end loop; end if; end Multiframe_to_Transaction; procedure Multiframe_To_Transaction_Sys (My_System : in out System; -- Multiframe System A_System : in out System) -- Transaction System is My_Iterator : Task_Groups_Iterator; A_Task_Group : Generic_Task_Group_Ptr; A_Multiframe : Multiframe_Task_Group_Ptr; begin Initialize (A_System); Duplicate (My_System, A_System); -- Clone all entities in My_System to A_System reset_iterator (My_System.Task_Groups, My_Iterator); loop current_element (My_System.Task_Groups, A_Task_Group, My_Iterator); A_Multiframe := Multiframe_Task_Group_Ptr (A_Task_Group); -- Delete A_Multiframe from A_System (clone) without deleting processors, etc... A_Task_Group := Search_Task_Group(A_System.task_groups, A_Multiframe.name); delete_task_group(A_System, A_Task_Group, false); -- Create Transaction (in A_System) from A_Multiframe (in My_System) Multiframe_to_Transaction (A_Multiframe, A_System); exit when is_last_element (My_System.Task_Groups, My_Iterator); next_element (My_System.Task_Groups, My_Iterator); end loop; end Multiframe_To_Transaction_Sys; procedure Multiframe_To_Transaction_Sys_Crossref (My_System : in out System; -- Multiframe System A_System : in out System) -- Transaction System is My_Iterator : Task_Groups_Iterator; A_Task_Group : Generic_Task_Group_Ptr; A_Multiframe : Multiframe_Task_Group_Ptr; A_Task_Dependencies_Set: Tasks_Dependencies_Ptr; begin Initialize (A_System); A_Task_Dependencies_Set := new Tasks_Dependencies; A_System.Core_units := My_System.Core_units; A_System.Processors := My_System.Processors; A_System.Resources := My_System.Resources; A_System.Messages := My_System.Messages; duplicate(My_System.Dependencies, A_Task_Dependencies_Set); -- Need to duplicate so My_System still has the correct dependency pointers A_System.Dependencies := A_Task_Dependencies_Set; A_System.Buffers := My_System.Buffers; A_System.Networks := My_System.Networks; A_System.Event_Analyzers := My_System.Event_Analyzers; A_System.Address_Spaces := My_System.Address_Spaces; -- A_System.deployments := My_System.deployments; -- Probably need to be recreated as this has generic_object pointers reset_iterator (My_System.Task_Groups, My_Iterator); loop current_element (My_System.Task_Groups, A_Task_Group, My_Iterator); A_Multiframe := Multiframe_Task_Group_Ptr (A_Task_Group); -- Create Transaction (in A_System) from A_Multiframe (in My_System) Multiframe_to_Transaction (A_Multiframe, A_System); exit when is_last_element (My_System.Task_Groups, My_Iterator); next_element (My_System.Task_Groups, My_Iterator); end loop; -- Entity pointer status after transformation: -- Shared: Processors, core_units, resources, messages, buffers, networks, event_analyzers -- Duplicates (updated): Task_dependencies -- New: Tasks -- If we only want updated duplicates and new pointers: Procedure Update_Core(processors_set, my_core) needs to be written end Multiframe_To_Transaction_Sys_Crossref; end Task_Group_Transformation;