예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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)
예제 #6
0
    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 get_simulation_result() -> Tuple[TaskSet, List[Job], RawSimulationResult]:
    periodic_tasks = [
        create_implicit_deadline_periodic_task_h_rt(3, 3000, 7.0, 3),
        create_implicit_deadline_periodic_task_h_rt(2, 4000, 7.0, 2),
        create_implicit_deadline_periodic_task_h_rt(1, 4000, 14.0, 1),
        create_implicit_deadline_periodic_task_h_rt(0, 3000, 14.0, 0)
    ]

    jobs_list = [
        # Task 3
        Job(identifier=0, activation_time=0.0, task=periodic_tasks[0]),
        Job(identifier=1, activation_time=7.0, task=periodic_tasks[0]),

        # Task 2
        Job(identifier=2, activation_time=0.0, task=periodic_tasks[1]),
        Job(identifier=3, activation_time=7.0, task=periodic_tasks[1]),

        # Task 1
        Job(identifier=4, activation_time=0.0, task=periodic_tasks[2]),

        # Task 0
        Job(identifier=5, activation_time=0.0, task=periodic_tasks[3]),
    ]

    tasks = TaskSet(periodic_tasks=periodic_tasks,
                    aperiodic_tasks=[],
                    sporadic_tasks=[])

    simulation_result = execute_scheduler_simulation(
        tasks=TaskSet(periodic_tasks=periodic_tasks,
                      aperiodic_tasks=[],
                      sporadic_tasks=[]),
        jobs=jobs_list,
        processor_definition=generate_default_cpu(2, {1000}),
        environment_specification=default_environment_specification(),
        simulation_options=SimulationConfiguration(
            id_debug=True,
            thermal_simulation_type="DVFS",
            simulate_thermal_behaviour=True),
        scheduler=SGEDF(True))

    return tasks, jobs_list, simulation_result
예제 #8
0
    def test_simple_simulation_periodic_task_set_with_thermal(self):
        periodic_tasks = [
            self.__create_implicit_deadline_periodic_task_h_rt(
                3, 3000, 7.0, 3),
            self.__create_implicit_deadline_periodic_task_h_rt(
                2, 4000, 7.0, 2),
            self.__create_implicit_deadline_periodic_task_h_rt(
                1, 4000, 14.0, 1),
            self.__create_implicit_deadline_periodic_task_h_rt(
                0, 3000, 14.0, 0)
        ]

        jobs_list = [
            # Task 3
            Job(identifier=0, activation_time=0.0, task=periodic_tasks[0]),
            Job(identifier=1, activation_time=7.0, task=periodic_tasks[0]),

            # Task 2
            Job(identifier=2, activation_time=0.0, task=periodic_tasks[1]),
            Job(identifier=3, activation_time=7.0, task=periodic_tasks[1]),

            # Task 1
            Job(identifier=4, activation_time=0.0, task=periodic_tasks[2]),

            # Task 0
            Job(identifier=5, activation_time=0.0, task=periodic_tasks[3]),
        ]

        number_of_cores = 2
        available_frequencies = {1000}

        simulation_result = execute_scheduler_simulation(
            simulation_start_time=0.0,
            simulation_end_time=14.0,
            tasks=TaskSet(periodic_tasks=periodic_tasks,
                          aperiodic_tasks=[],
                          sporadic_tasks=[]),
            jobs=jobs_list,
            processor_definition=generate_default_cpu(number_of_cores,
                                                      available_frequencies),
            environment_specification=default_environment_specification(),
            simulation_options=SimulationConfiguration(
                id_debug=True,
                thermal_simulation_type="DVFS",
                simulate_thermal_behaviour=True),
            scheduler=self.__simple_priority_scheduler_definition())

        # Correct execution
        correct_job_sections_execution = {
            0: [
                JobSectionExecution(job_id=0,
                                    task_id=3,
                                    execution_start_time=0.0,
                                    execution_end_time=3.0,
                                    number_of_executed_cycles=3000),
                JobSectionExecution(job_id=2,
                                    task_id=2,
                                    execution_start_time=3.0,
                                    execution_end_time=4.0,
                                    number_of_executed_cycles=1000),
                JobSectionExecution(job_id=4,
                                    task_id=1,
                                    execution_start_time=4.0,
                                    execution_end_time=7.0,
                                    number_of_executed_cycles=3000),
                JobSectionExecution(job_id=1,
                                    task_id=3,
                                    execution_start_time=7.0,
                                    execution_end_time=10.0,
                                    number_of_executed_cycles=3000),
                JobSectionExecution(job_id=3,
                                    task_id=2,
                                    execution_start_time=10.0,
                                    execution_end_time=11.0,
                                    number_of_executed_cycles=1000)
            ],
            1: [
                JobSectionExecution(job_id=2,
                                    task_id=2,
                                    execution_start_time=0.0,
                                    execution_end_time=3.0,
                                    number_of_executed_cycles=3000),
                JobSectionExecution(job_id=4,
                                    task_id=1,
                                    execution_start_time=3.0,
                                    execution_end_time=4.0,
                                    number_of_executed_cycles=1000),
                JobSectionExecution(job_id=5,
                                    task_id=0,
                                    execution_start_time=4.0,
                                    execution_end_time=7.0,
                                    number_of_executed_cycles=3000),
                JobSectionExecution(job_id=3,
                                    task_id=2,
                                    execution_start_time=7.0,
                                    execution_end_time=10.0,
                                    number_of_executed_cycles=3000)
            ]
        }

        correct_cpu_frequencies = {
            0: [CPUUsedFrequency(1000, 0.0, 14.0)],
            1: [CPUUsedFrequency(1000, 0.0, 14.0)]
        }

        correct_scheduling_points = [0.0, 3.0, 4.0, 7.0, 10.0]

        assert simulation_result.have_been_scheduled

        assert (simulation_result.job_sections_execution ==
                correct_job_sections_execution)

        assert (simulation_result.cpus_frequencies == correct_cpu_frequencies)

        assert (
            simulation_result.scheduling_points == correct_scheduling_points)

        assert (simulation_result.hard_real_time_deadline_missed_stack_trace is
                None)
예제 #9
0
    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