------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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: 97 $ -- $Date: 2007-07-20 15:17:15 +0200 (Fri, 20 Jul 2007) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with io_tools; use io_tools; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; with Translate; use Translate; with scheduler_io; use scheduler_io; with Statements; use Statements; with Parameters; use Parameters; use Parameters.User_Defined_Parameters_Table_Package; with Parser; use Parser; with Sections; use Sections; with section_Set; use section_Set; use section_Set.package_Generic_section_Set; with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.Exceptions; use Ada.Exceptions; with Interpreter.extended; use Interpreter.extended; package body Scheduler.user_defined.interpreted.pipeline is function Export_Aadl_Properties (My_Scheduler : in pipeline_user_defined_Scheduler; Number_Of_Ht : in Natural) return Unbounded_String is Result : Unbounded_String := Export_Aadl_Properties (Generic_Scheduler (My_Scheduler), Number_Of_Ht); begin for I in 1 .. Number_Of_Ht loop Result := Result & ASCII.HT; end loop; Result := Result & To_Unbounded_String ("Cheddar_Properties::Source_Text => """ & To_String (Get_Behavior_File_Name (My_Scheduler)) & """;") & unbounded_lf; return Result; end Export_Aadl_Properties; procedure Initialize (A_Scheduler : in out pipeline_user_defined_Scheduler) is begin Reset (A_Scheduler); A_Scheduler.parameters.scheduler_type := pipeline_User_Defined_Protocol; end Initialize; function Copy (A_Scheduler : in pipeline_user_defined_Scheduler) return Generic_Scheduler_Ptr is Ptr : pipeline_user_defined_Scheduler_Ptr; begin Ptr := new pipeline_user_defined_Scheduler; Ptr.Previously_Elected := A_Scheduler.Previously_Elected; Ptr.parameters := A_Scheduler.parameters; Ptr.Root_Statement_Pointer := A_Scheduler.Root_Statement_Pointer; Ptr.Variables_Table := A_Scheduler.Variables_Table; return Generic_Scheduler_Ptr (Ptr); end Copy; procedure Put (My_Scheduler : in pipeline_user_defined_Scheduler) is begin Put (Generic_Scheduler (My_Scheduler)); Put (My_Scheduler.Root_Statement_Pointer); put (My_Scheduler.Variables_Table); end Put; procedure Do_Election (My_Scheduler : in out pipeline_user_defined_Scheduler; Si : in out Scheduling_Information; Result : in out Scheduling_Sequence_Ptr; Msg : in out Unbounded_String; Current_Time : in Natural; Processor_Name : in Unbounded_String; Address_Space_Name : in Unbounded_String; My_Dependencies : in Tasks_Dependencies_Ptr; With_Offsets : in Boolean; With_Precedencies : in Boolean; With_Resources : in Boolean; Event_To_Generate : in Time_Unit_Event_Type_Boolean_Table; Elected : in out Tasks_Range; No_Task : in out Boolean) is Current : Generic_Statement_Ptr; begin -- By default, no task are elected : it's a way -- to safer schedule a user_defined scheduler without -- a correctly designed code (election part of it) -- No_Task := True; -- We update simulation engine variables which has to update -- because of the task which was running at the previous unit of time -- Load_Read_Write_Interpreter_Variables (My_Scheduler, Si, Processor_Name); update_interpreter_variables_after_task_execution (My_Scheduler, Si, Current_Time, Processor_Name, empty_string, My_Dependencies, With_Offsets, With_Precedencies, With_Resources); -- Now, do "priority" section -- Current := My_Scheduler.Root_Statement_Pointer (Sections.Priority_Type); Dispatch (Current, Priority_Type, Processor_Name, My_Scheduler.Variables_Table, Msg); -- After priority section, we -- save some task run time information -- Save_Read_Write_Interpreter_Variables (My_Scheduler, Si, Processor_Name); -- Do "election" section -- Current := My_Scheduler.Root_Statement_Pointer (Election_Type); dispatch_return_statement (My_Scheduler, Current, Si, Current_Time, Processor_Name, empty_string, My_Dependencies, With_Offsets, With_Precedencies, With_Resources, Elected, No_Task); end Do_Election; -- Do "start" section statements -- procedure Specific_Scheduler_Initialization (My_Scheduler : in out pipeline_user_defined_Scheduler; Si : in out Scheduling_Information; Processor_Name : in Unbounded_String; address_space_name : in Unbounded_String; My_Tasks : in out Tasks_Set; my_schedulers : in Scheduler_table; My_Resources : in out Resources_Set; My_Buffers : in out Buffers_Set; My_Messages : in Messages_Set; Msg : in out Unbounded_String) is Current : Generic_Statement_Ptr; Var : Variables_Range; a_section : Computation_Section_Ptr; begin -- We should check the scheduler behavior syntax ... -- Open_Input (My_Scheduler.parameters.user_defined_scheduler_source); Parser.First_File (My_Scheduler.parameters.user_defined_scheduler_source_file_name); Create_Parametric_Variables (Parser.Variables_Table, My_Tasks); Parser.Yyparse; -- Store syntax tree and compiling information -- begin a_section := Computation_Section_Ptr (Search_section (Parser.Root_Statement_Pointer, Sections.Start_Type)); My_Scheduler.Root_Statement_Pointer (Sections.Start_Type) := a_section.first_statement; exception when others => My_Scheduler.Root_Statement_Pointer (Sections.Start_Type) := null; end; begin a_section := Computation_Section_Ptr (Search_section (Parser.Root_Statement_Pointer, Sections.Priority_Type)); My_Scheduler.Root_Statement_Pointer (Sections.Priority_Type) := a_section.first_statement; exception when others => My_Scheduler.Root_Statement_Pointer (Sections.Priority_Type) := null; end; begin a_section := Computation_Section_Ptr (Search_section (Parser.Root_Statement_Pointer, Sections.Election_Type)); My_Scheduler.Root_Statement_Pointer (Sections.Election_Type) := a_section.first_statement; exception when others => My_Scheduler.Root_Statement_Pointer (Sections.Election_Type) := null; end; My_Scheduler.Variables_Table := Parser.Variables_Table; My_Scheduler.Sets_Table := Parser.Sets_Table; Current := My_Scheduler.Root_Statement_Pointer (Start_Type); -- Initialize user_defined variables which are constant -- Initialize_Parametric_Variables (My_Scheduler.Variables_Table, My_Messages, My_Buffers, My_Resources, My_Tasks, Processor_Name); -- Initialize scheduler-user_defined.adb specific user_defined variables -- -- "nb_processors" -- Var := Find_Variable (My_Scheduler.Variables_Table, To_Unbounded_String ("nb_processors")); My_Scheduler.Variables_Table.entries (Var).Simulation.Integer_Value := Si.Number_Of_Processors; -- "nb_address_spaces" -- Var := Find_Variable (My_Scheduler.Variables_Table, To_Unbounded_String ("nb_address_spaces")); My_Scheduler.Variables_Table.entries (Var).Simulation.Integer_Value := Si.Number_Of_Address_Spaces; -- "simulation_length" -- Var := Find_Variable (My_Scheduler.Variables_Table, To_Unbounded_String ("simulation_length")); My_Scheduler.Variables_Table.entries (Var).Simulation.Integer_Value := Si.Simulation_Length; -- Load user_defined variable which can be changed by the programmer -- before executing sections -- Load_Read_Write_Interpreter_Variables (My_Scheduler, Si, Processor_Name); -- Now : run "start" statements -- Dispatch (Current, Start_Type, Processor_Name, My_Scheduler.Variables_Table, Msg); -- After start section, we -- save some task run time information -- Save_Read_Write_Interpreter_Variables (My_Scheduler, Si, Processor_Name); end Specific_Scheduler_Initialization; end Scheduler.user_defined.interpreted.pipeline;