def test_simple_simulation_bad_behaviour_scheduler(self): periodic_tasks = [ self.__create_implicit_deadline_periodic_task_h_rt( 1, 4000, 7.0, 1), self.__create_implicit_deadline_periodic_task_h_rt( 0, 4000, 7.0, 0), self.__create_implicit_deadline_periodic_task_h_rt( 3, 4000, 14.0, 3), self.__create_implicit_deadline_periodic_task_h_rt( 2, 4000, 14.0, 2) ] number_of_cores = 2 available_frequencies = {1000} try: execute_scheduler_simulation_simple( tasks=TaskSet(periodic_tasks=periodic_tasks, aperiodic_tasks=[], sporadic_tasks=[]), aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu( number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=self.__bad_behaviour_scheduler_definition()) assert False except Exception: assert True
def test_simple_simulation_not_accepted_task_set(self): periodic_tasks = [ self.__create_implicit_deadline_periodic_task_h_rt( 1, 4000, 7.0, 1), self.__create_implicit_deadline_periodic_task_h_rt( 0, 4000, 7.0, 0), self.__create_implicit_deadline_periodic_task_h_rt( 3, 4000, 14.0, 3), self.__create_implicit_deadline_periodic_task_h_rt( 2, 4000, 14.0, None) ] number_of_cores = 2 available_frequencies = {1000} simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=TaskSet(periodic_tasks=periodic_tasks, aperiodic_tasks=[], sporadic_tasks=[]), aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=self.__simple_priority_scheduler_definition()) # Correct execution assert not simulation_result.have_been_scheduled
def test_simple_simulation_periodic_task_set(self): periodic_tasks = [ create_implicit_deadline_periodic_task_h_rt(0, 10000, 20.0), create_implicit_deadline_periodic_task_h_rt(1, 5000, 10.0), create_implicit_deadline_periodic_task_h_rt(2, 7000, 10.0), create_implicit_deadline_periodic_task_h_rt(3, 7000, 10.0), create_implicit_deadline_periodic_task_h_rt(4, 7000, 10.0), create_implicit_deadline_periodic_task_h_rt(5, 14000, 20.0), create_implicit_deadline_periodic_task_h_rt(6, 3000, 5.0) ] number_of_cores = 5 available_frequencies = {1000} simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=TaskSet(periodic_tasks=periodic_tasks, aperiodic_tasks=[], sporadic_tasks=[]), aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=SALECS(activate_debug=True)) # Correct execution assert simulation_result.have_been_scheduled assert simulation_result.hard_real_time_deadline_missed_stack_trace is None
def test_partitioned_task_set(self): task_set = TaskSet(periodic_tasks=[ create_implicit_deadline_periodic_task_h_rt(j, i[0], i[1]) for j, i in enumerate(periodic_implicit_deadline_tasks) ], sporadic_tasks=[], aperiodic_tasks=[]) number_of_cores = 4 available_frequencies = {1000} simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=task_set, aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=SCALECS(activate_debug=True, store_clusters_obtained=True)) # Correct execution assert simulation_result.have_been_scheduled assert simulation_result.hard_real_time_deadline_missed_stack_trace is None
def test_readme_example(self): # Simulation configuration base_frequency = 1000 available_frequencies = {base_frequency} number_of_cores = 4 number_of_tasks = 9 # Task generation tasks_deadlines = UniformIntegerDeadlineGenerator.generate( number_of_tasks=number_of_tasks, min_deadline=2, max_deadline=12, major_cycle=24) x = PTGUUniFastDiscard.generate(utilization=number_of_cores, tasks_deadlines=tasks_deadlines, processor_frequency=base_frequency) # Definition of the task set task_set = TaskSet(periodic_tasks=[ PeriodicTask( identifier=i, worst_case_execution_time=j.worst_case_execution_time, relative_deadline=j.deadline, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=j.deadline) for i, j in enumerate(x) ], aperiodic_tasks=[], sporadic_tasks=[]) # Execute simulation simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=task_set, aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=SALECS(activate_debug=True)) # Display execution fig = generate_task_execution_plot(task_set=task_set, schedule_result=simulation_result, title="Task execution", outline_boxes=True)
def test_simple_simulation_periodic_task_set(self): periodic_tasks = [ self.create_implicit_deadline_periodic_task_s_rt(0, 1000, 20.0), self.create_implicit_deadline_periodic_task_s_rt(1, 500, 10.0), self.create_implicit_deadline_periodic_task_s_rt(2, 700, 10.0), self.create_implicit_deadline_periodic_task_s_rt(3, 700, 10.0), self.create_implicit_deadline_periodic_task_s_rt(4, 700, 10.0), self.create_implicit_deadline_periodic_task_s_rt(5, 1400, 20.0) ] task_set = TaskSet(periodic_tasks=periodic_tasks, aperiodic_tasks=[], sporadic_tasks=[]) number_of_cores = 5 available_frequencies = {100} simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=task_set, aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies, 0), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=SOLDTFS(240, simulate_thermal=False)) # Correct execution assert simulation_result.have_been_scheduled # Check the percentage of execution accomplished (by implementation the OLDTFS control won't # accomplish full execution of the tasks) cycles_per_task_in_major_cycle: Dict[int, int] = { i.identifier: i.worst_case_execution_time * round(20 / i.relative_deadline) for i in periodic_tasks } executed_cycles_by_task: Dict[int, int] = { i: 0 for i in cycles_per_task_in_major_cycle.keys() } for i in simulation_result.job_sections_execution.values(): for j in i: executed_cycles_by_task[j.task_id] = executed_cycles_by_task[ j.task_id] + j.number_of_executed_cycles # In this task set it only accomplish a 70% of execution in all tasks (It should be reviewed) all((executed_cycles_by_task[i] / cycles_per_task_in_major_cycle[i]) > 0.7 for i in cycles_per_task_in_major_cycle.keys())
def test_complex_simulation_periodic_task_set(self): task_set = TaskSet( periodic_tasks=[ PeriodicTask( identifier=0, worst_case_execution_time=63, relative_deadline=3.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=3.0), PeriodicTask( identifier=1, worst_case_execution_time=1976, relative_deadline=4.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=4.0), PeriodicTask( identifier=2, worst_case_execution_time=3408, relative_deadline=12.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=12.0), PeriodicTask( identifier=3, worst_case_execution_time=74, relative_deadline=2.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=2.0), PeriodicTask( identifier=4, worst_case_execution_time=3285, relative_deadline=15.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=15.0), PeriodicTask( identifier=5, worst_case_execution_time=2715, relative_deadline=5.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=5.0), PeriodicTask( identifier=6, worst_case_execution_time=408, relative_deadline=6.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=6.0), PeriodicTask( identifier=7, worst_case_execution_time=1336, relative_deadline=4.0, best_case_execution_time=None, execution_time_distribution=None, memory_footprint=None, priority=None, preemptive_execution=PreemptiveExecution.FULLY_PREEMPTIVE, deadline_criteria=Criticality.HARD, energy_consumption=None, phase=None, period=4.0)], aperiodic_tasks=[], sporadic_tasks=[]) number_of_cores = 2 available_frequencies = {1000} simulation_result, periodic_jobs, major_cycle = execute_scheduler_simulation_simple( tasks=task_set, aperiodic_tasks_jobs=[], sporadic_tasks_jobs=[], processor_definition=generate_default_cpu(number_of_cores, available_frequencies), environment_specification=default_environment_specification(), simulation_options=SimulationConfiguration(id_debug=True), scheduler=SRUN(activate_debug=True, store_clusters_obtained=True) ) # Correct execution assert simulation_result.have_been_scheduled if simulation_result.hard_real_time_deadline_missed_stack_trace is not None: print(simulation_result.hard_real_time_deadline_missed_stack_trace.time) assert simulation_result.hard_real_time_deadline_missed_stack_trace is None