with systems; use systems; with tasks; use tasks; with task_set; use task_set; use task_set.generic_task_set; with dependencies; use dependencies; with parameters; use parameters; with parameters.extended; use parameters.extended; use parameters.framework_parameters_table_package; with framework; use framework; with call_framework; use call_framework; with call_framework_interface; use call_framework_interface; use call_framework_interface.framework_response_package; use call_framework_interface.framework_request_package; with call_scheduling_framework; use call_scheduling_framework; with multiprocessor_services; use multiprocessor_services; with multiprocessor_services_interface; use multiprocessor_services_interface; use multiprocessor_services_interface.scheduling_result_per_processor_package; with time_unit_events; use time_unit_events; with ada.strings.unbounded; use ada.strings.unbounded; with core_units; use core_units; with scheduler_interface; use scheduler_interface; with processor_interface; use processor_interface; with processors; use processors; with processor_set; use processor_set; with task_dependencies; use task_dependencies; with scheduler_interface; use scheduler_interface; with GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with debug; use debug; with io_tools; use io_tools; with Text_IO; use Text_IO; with version; use version; with Ada.Exceptions; use Ada.Exceptions; with Ada.Numerics.Aux; use Ada.Numerics.Aux; with Ada.Containers.Ordered_Maps; package voltage_scaling is -- Config variable --True for static algorithm --False for dynamic algorithm only_static_algorithm : Boolean := false; --True for look ahead algorithm --False for cycle_conserving algorithm look_ahead_algorithm : Boolean := true; -- True to show the details of the algorithms in the terminal show_detail : Boolean := false; -- variable global -- EDF or RM scheduler_type : schedulers_type; -- Frequency table type tabfreq is array (0..3) of Double; freqs : tabfreq := (0.25,0.5,0.75,1.0); curr_freq : integer := 100; -- Last current time of a task execution curr_time_task_exec : natural :=0; fj : Double := 1.0; -- Hashmap type DVS_hashmap_type_element is record c_left : Double; a_task : Generic_Task_Ptr; element : Double; release_time : natural; end record; package DVS_map_package is new Ada.Containers.Ordered_Maps(Element_Type => DVS_hashmap_type_element, Key_Type => Unbounded_String); subtype DVS_map_subtype is DVS_map_package.Map; DVS_map: DVS_map_subtype; -- init procedure dvfs_init_voltage_scaling(a_processor : in generic_processor_ptr); -- static voltage scaling function select_frequency_static_voltage_scaling (my_tasks : DVS_map_subtype ) return Double ; function EDF_test_static_voltage_scaling (my_tasks : DVS_map_subtype; freq : Double) return boolean; function RM_test_static_voltage_scaling (my_tasks : DVS_map_subtype; freq : Double ;pi : natural) return boolean; -- Cycle conserving EDF function select_frequency_cycle_conserving_edf (a_task_Ui : DVS_map_subtype) return Double ; procedure cycle_conserving_task_release_edf (a_task : Generic_Task_Ptr; new_frequency : out Double); procedure cycle_conserving_task_completion_edf (a_task : Generic_Task_Ptr;new_frequency : out Double); -- Cycle conserving RM function select_frequency_cycle_conserving_rm (a_task_Ui : DVS_map_subtype ; current_time : natural; task_is_release : boolean ) return Double ; procedure cycle_conserving_task_release_rm (a_task : Generic_Task_Ptr ; current_time : natural; new_frequency : out Double); procedure cycle_conserving_task_completion_rm (a_task : Generic_Task_Ptr ; current_time : natural; new_frequency : out Double); procedure cycle_conserving_task_execution_rm (a_task : Generic_Task_Ptr ); procedure cycle_conserving_task_allocate_cycles(ki : Double); -- Look ahead function select_frequency_look_ahead (x : Double) return Double ; procedure look_ahead_task_release (a_task : Generic_Task_Ptr; current_time : in natural; new_frequency : out Double); procedure look_ahead_task_completion (a_task : Generic_Task_Ptr; current_time : in natural; new_frequency : out Double); procedure look_ahead_task_execution (a_task : Generic_Task_Ptr); procedure look_ahead_task_defer (a_task_Ui : DVS_map_subtype; current_time : in natural; new_frequency : out Double); -- Other function max_cycles_until_next_deadline(a_task_Ui : in DVS_map_subtype ;current_time : in natural) return natural; procedure new_frequency_double_to_integer(new_frequency_double : in Double; new_frequency : out integer) ; -- Procedure call by scheduler.adb procedure dvfs_upon_running_task (an_event : in time_unit_event_ptr; current_time : in natural; new_frequency : out integer); procedure dvfs_upon_task_release (an_event : in time_unit_event_ptr; current_time : in natural; new_frequency : out integer); procedure dvfs_upon_task_completion (an_event : in time_unit_event_ptr; current_time : in natural; new_frequency : out integer); end voltage_scaling;