------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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 6285, Université 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 Xml_Tag; use Xml_Tag; with double_util; use double_util; with Translate; use Translate; with unbounded_strings; use unbounded_strings; with Text_IO; use Text_IO; with Ada.Exceptions; use Ada.Exceptions; with GNAT.Current_Exception; use GNAT.Current_Exception; package body Scheduler.Fixed_Priority.aperiodic_server.polling is procedure Initialize (A_Scheduler : in out polling_aperiodic_server_Scheduler) is begin Reset (A_Scheduler); A_Scheduler.parameters.scheduler_type := hierarchical_polling_aperiodic_server_protocol; end Initialize; function Copy (A_Scheduler : in polling_aperiodic_server_Scheduler) return Generic_Scheduler_Ptr is Ptr : polling_aperiodic_server_Scheduler_Ptr; begin Ptr := new polling_aperiodic_server_Scheduler; Ptr.parameters := A_Scheduler.parameters; Ptr.Previously_Elected := A_Scheduler.Previously_Elected; Ptr.Used_Resource := A_Scheduler.Used_Resource; return Generic_Scheduler_Ptr (Ptr); end Copy; procedure Do_Election (My_Scheduler : in out polling_aperiodic_server_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; Core_Name : in Unbounded_String; Options : in Scheduling_Option; Event_To_Generate : in Time_Unit_Event_Type_Boolean_Table; Elected : in out Tasks_Range; No_Task : in out Boolean) is begin Do_Election (aperiodic_server_Scheduler (My_Scheduler), Si, Result, Msg, Current_Time, Processor_Name, Address_Space_Name, Core_Name, Options, Event_To_Generate, Elected, No_Task); -- Election : if Current_Time is within the server awake time limits -- we check if there are any aperiodic tasks to run -- if not the server falls back to sleep -- and only the periodic tasks are serviced until the next -- server's awakening time -- No_Task := True; if (Current_Time >= My_Scheduler.current_server_wake_time) and (Current_Time < My_Scheduler.current_server_wake_time + My_Scheduler.parameters.capacity) then if (My_Scheduler.aperiodic_Highest_Priority /= Natural'First) and (My_Scheduler.parameters.priority > Priority_Range(My_Scheduler.periodic_Highest_Priority)) then No_Task := False; Elected := My_Scheduler.aperiodic_Elected; else My_Scheduler.current_server_wake_time := My_Scheduler.current_server_wake_time + My_Scheduler.parameters.period; if My_Scheduler.periodic_Highest_Priority /= Natural'First then No_Task := False; Elected := My_Scheduler.periodic_Elected; end if; end if; else if My_Scheduler.periodic_Highest_Priority /= Natural'First then No_Task := False; Elected := My_Scheduler.periodic_Elected; end if; end if; -- If the server exhausted all its capacity -- it goes back to sleep -- if Current_Time = My_Scheduler.current_server_wake_time + My_Scheduler.parameters.capacity then My_Scheduler.current_server_wake_time := My_Scheduler.current_server_wake_time + My_Scheduler.parameters.period; end if; end Do_Election; end Scheduler.Fixed_Priority.aperiodic_server.polling;