------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2023, 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 README.md -- -- 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.priority_exchange is procedure initialize (a_scheduler : in out priority_exchange_aperiodic_server_scheduler) is begin reset (a_scheduler); a_scheduler.parameters.scheduler_type := hierarchical_priority_exchange_aperiodic_server_protocol; end initialize; function copy (a_scheduler : in priority_exchange_aperiodic_server_scheduler) return generic_scheduler_ptr is ptr : priority_exchange_aperiodic_server_scheduler_ptr; begin ptr := new priority_exchange_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 priority_exchange_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.priority_exchange;