Beispiel #1
0
    def generate(self):
        if self.comboGenerator.currentIndex() == 0:
            n = self.get_nb_tasks()
            u = StaffordRandFixedSum(n, self.get_utilization(), 1)
        elif self.comboGenerator.currentIndex() == 1:
            n = self.get_nb_tasks()
            u = UUniFastDiscard(n, self.get_utilization(), 1)
        else:
            u = gen_kato_utilizations(1, self.get_min_utilization(),
                                      self.get_max_utilization(),
                                      self.get_utilization())
            n = len(u[0])

        p_types = self.get_periods()
        if p_types[0] == "unif":
            p = gen_periods_uniform(n, 1, p_types[1], p_types[2], p_types[3])
        elif p_types[0] == "lunif":
            p = gen_periods_loguniform(n, 1, p_types[1], p_types[2],
                                       p_types[3])
        else:
            p = gen_periods_discrete(n, 1, p_types[1])
        if u and p:
            self.taskset = gen_tasksets(u, p)[0]
            self.accept()
        elif not u:
            QMessageBox.warning(
                self, "Generation failed",
                "Please check the utilization and the number of tasks.")
        else:
            QMessageBox.warning(self, "Generation failed",
                                "Pleache check the periods.")
Beispiel #2
0
    def generate(self):
        if self.comboGenerator.currentIndex() == 0:
            n = self.get_nb_tasks()
            u = StaffordRandFixedSum(n, self.get_utilization(), 1)
        elif self.comboGenerator.currentIndex() == 1:
            n = self.get_nb_tasks()
            u = UUniFastDiscard(n, self.get_utilization(), 1)
        else:
            u = gen_kato_utilizations(1, self.get_min_utilization(),
                                      self.get_max_utilization(),
                                      self.get_utilization())
            n = len(u[0])

        p_types = self.get_periods()
        if p_types[0] == "unif":
            p = gen_periods_uniform(n, 1, p_types[1], p_types[2], p_types[3])
        elif p_types[0] == "lunif":
            p = gen_periods_loguniform(n, 1, p_types[1], p_types[2],
                                       p_types[3])
        else:
            p = gen_periods_discrete(n, 1, p_types[1])
        if u and p:
            self.taskset = gen_tasksets(u, p)[0]
            self.accept()
        elif not u:
            QMessageBox.warning(
                self, "Generation failed",
                "Please check the utilization and the number of tasks.")
        else:
            QMessageBox.warning(
                self, "Generation failed",
                "Pleache check the periods.")
Beispiel #3
0
def create(num_sets, num_tasks, utilization):
    ut = task_generator.gen_randfixedsum(num_sets, num_tasks, utilization)
    ut2 = ut
    pd = task_generator.gen_periods_uniform(num_tasks, num_sets, 2, 100)
    tset = task_generator.gen_tasksets(ut2, pd)

    # print(tset)
    # tset_wcet = []
    # for set in tset:
    #     tset_wcet.append([])
    #     for task in set:
    #         tset_wcet[len(tset_wcet) - 1].append((
    #             task[0], # Acet
    #             task[1], # Period
    #             get_acet_from_wcet(task[0], task[0]/10) # Wcet
    #         ))
    #     print(tset_wcet[len(tset_wcet) - 1])

    return tset
Beispiel #4
0
def gensavetasksets(schedulers, n, nsets, u, min_p, max_p, outdir):

    # Manual configuration:
    configuration = Configuration()
    configuration.duration = 1000 * configuration.cycles_per_ms

    u = task_generator.StaffordRandFixedSum(n, u, nsets)
    periods = task_generator.gen_periods_uniform_ex(n, nsets, min_p, max_p,
                                                    10000000, True)
    # Add processors.
    for i in range(1, 5):
        configuration.add_processor(name="CPU " + str(i), identifier=i)

    if not os.path.exists(outdir):
        os.mkdir(outdir)

    for i, exp_set in enumerate(task_generator.gen_tasksets(u, periods)):
        for scheduler_name in schedulers:
            configuration.scheduler_info.clas = scheduler_name
            #            print("{}:".format(scheduler_name))
            while configuration.task_info_list:
                del configuration.task_info_list[0]
            id_ = 1
            for (c, p) in exp_set:
                configuration.add_task(name="T{}".format(id_),
                                       identifier=id_,
                                       period=p,
                                       activation_date=0,
                                       wcet=c,
                                       deadline=p,
                                       abort_on_miss=True)
                id_ += 1

            configuration.duration = configuration.get_hyperperiod(
            ) * configuration.cycles_per_ms

            # Vérification de la config.
            configuration.check_all()

            # save one taskset
            configuration.save(outdir + "/exp_{}.xml".format(i + 1))
Beispiel #5
0
def main(argv):
    global procCount
    if len(argv) == 8:
        # Configuration load from a file.
        nrOfRuns = int(argv[1])
        nrOfProc = int(argv[2])
        minNrOfPeriodicTasks = int(argv[3])
        maxNrOfPeriodicTasks = int(argv[4])
        minNrOfSporadicTasks = int(argv[5])
        maxNrOfSporadicTasks = int(argv[6])
        tasksFileName = argv[7]
    else:
        raise Exception("Configuration is not correct.")

    schedulingAlgos = [
        'simso.schedulers.EDCL',
        'simso.schedulers.EDF',
        # 'simso.schedulers.EDF_US',
        'simso.schedulers.EDHS',
        # 'simso.schedulers.EDZL',
        'simso.schedulers.G_FL',
        # 'simso.schedulers.G_FL_ZL',
        'simso.schedulers.LB_P_EDF',
        # 'simso.schedulers.LLF',
        # 'simso.schedulers.MLLF',
        # 'simso.schedulers.PD2',
        # 'simso.schedulers.P_EDF2',
        # 'simso.schedulers.P_EDF',
        # 'simso.schedulers.P_EDF_WF',
        # 'simso.schedulers.PriD',
        'simso.schedulers.P_RM',
        'simso.schedulers.RM',
        'simso.schedulers.RUN',
        # 'simso.schedulers.Static_EDF',
    ]

    with open(tasksFileName, 'w+') as csvfile:
        fieldnames = ['Index', 'Successful', 'Algo', 'NrOfProc', 'Utilization', 'NrOfPeriodic', 'NrOfSporadic', 'AvgPeriod_Periodic',
                      'AvgActivation_Sporadic', 'TaskName', 'TaskType', 'RespTime', 'Avg_CPU']
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
        writer.writeheader()

        for runCounter in range(1, nrOfRuns + 1):
            nrOfPeriodic = random.randint(minNrOfPeriodicTasks, maxNrOfPeriodicTasks)
            nrOfSporadic = random.randint(minNrOfSporadicTasks, maxNrOfSporadicTasks)
            utilization = round(random.uniform(nrOfProc/2, nrOfProc), 1)

            u = StaffordRandFixedSum(nrOfPeriodic + nrOfSporadic, utilization, 1)
            p_types = get_periods()
            p = gen_periods_loguniform(nrOfPeriodic + nrOfSporadic, 1, p_types[1], p_types[2], p_types[3])

            if u and p:
                taskset = gen_tasksets(u, p)[0]

                print (
                    "Generating configuration with id " + str(runCounter) + " NrOfPeriodic: " + str(nrOfPeriodic) + ", NrOfSporadic: " + str(nrOfSporadic) + ", Utilization: " + str(utilization))

                configuration = Configuration()
                configuration.duration = 100 * configuration.cycles_per_ms

                for procCount in range(1, nrOfProc+1):
                    configuration.add_processor(name = "CPU_" + procCount.__str__(), identifier=procCount)

                i = 0
                sumOfPeriods_Periodic = 0
                sumOfActivations_Sporadic = 0
                for ci, pi in taskset:
                    i += 1
                    if i <= nrOfPeriodic:
                        configuration.add_task(
                            "Task " + str(i), i, period=pi, wcet=ci, deadline=pi)
                        sumOfPeriods_Periodic += pi
                    else:
                        list_activation_dates = gen_arrivals(pi, 0, configuration.duration_ms)
                        configuration.add_task(
                            "Task " + str(i), i, period=pi, wcet=ci, deadline=pi,
                            task_type="Sporadic", list_activation_dates=list_activation_dates)

                        if (len(list_activation_dates) == 0):
                            sumOfActivations_Sporadic += 0
                        else:
                            sumOfActivations_Sporadic += sum(list_activation_dates) / len(list_activation_dates)

                for scheduler in schedulingAlgos:
                    configuration.scheduler_info.clas = scheduler
                    # Init a model from the configuration.
                    model = Model(configuration)
                    # Execute the simulation.

                    successFul = False
                    try:
                        model.run_model()
                        successFul = True
                    except:
                        print('Algorithm ' + scheduler + " failed!")
                        successFul = False

                    print("Finished for algo: " + scheduler)

                    if(successFul):
                        # Print response times
                        for measurement in model._measurements:
                            taskName = measurement._taskName
                            taskType = measurement._taskType
                            respTime = measurement._respTime

                            averageCPULoad = model.getAverageLoad()

                            writer.writerow({fieldnames[0]: runCounter,
                                            fieldnames[1]: successFul,
                                            fieldnames[2]: scheduler,
                                            fieldnames[3]: procCount,
                                            fieldnames[4]: utilization,
                                            fieldnames[5]: nrOfPeriodic,
                                            fieldnames[6]: nrOfSporadic,
                                            fieldnames[7]: sumOfPeriods_Periodic / nrOfPeriodic,
                                            fieldnames[8]: sumOfActivations_Sporadic / nrOfSporadic,
                                            fieldnames[9]: taskName,
                                            fieldnames[10]: taskType,
                                            fieldnames[11]: respTime,
                                            fieldnames[12]: averageCPULoad}
                                            )

            else:
                print(
                "Incorrect configuration: NrOfPeriodic: " + str(nrOfPeriodic) + ", NrOfSporadic: " + str(nrOfSporadic) + ", Utilization: " + str(utilization))

        csvfile.close()
Beispiel #6
0
def main(argv):
    schedulers = [
        "schedulers/RM.py", "schedulers/EDF.py", "schedulers/PriD.py",
        "schedulers/EDF_US.py", "schedulers/EDZL.py", "schedulers/LLF.py",
        "schedulers/MLLF.py", "schedulers/P_EDF.py", "schedulers/LB_P_EDF.py",
        "schedulers/EDHS.py", "schedulers/EKG.py", "schedulers/LRE_TL.py",
        "schedulers/DP_WRAP.py", "schedulers/BF.py", "schedulers/LLREF.py",
        "schedulers/PD2.py", "schedulers/ER_PD2.py", "schedulers/RUN.py"
    ]

    schedulers = [
        "schedulers/EDF.py", "schedulers/EDZL.py", "schedulers/MLLF.py",
        "schedulers/P_EDF.py", "schedulers/EDHS.py", "schedulers/EKG.py",
        "schedulers/LRE_TL.py", "schedulers/LLREF.py", "schedulers/ER_PD2.py",
        "schedulers/RUN.py"
    ]

    schedulers = ["schedulers/EDF.py", "schedulers/EDF2.py"]

    schedulers = [
        "schedulers/WC_U_EDF.py", "schedulers/U_EDF.py", "schedulers/RUN.py",
        "schedulers/WC_RUN.py"
    ]
    schedulers = [
        "schedulers/RUN.py", "schedulers/WC_RUN.py",
        "/home/max/Documents/These/RTCSA/experiments/schedulers/WC_RUN.py"
    ]
    schedulers = [
        "schedulers/WC_U_EDF.py", "schedulers/U_EDF.py",
        "/home/max/Documents/These/RTCSA/experiments/schedulers/WC_U_EDF.py"
    ]
    schedulers = ["schedulers/PD2.py", "schedulers/ER_PD2.py"]

    output = input("Output directory: ")
    os.mkdir(output)

    wcet_file = open(output + "/wcet.csv", "w")
    csv_wcet = csv.writer(wcet_file)
    ResultExp.print_header(csv_wcet)

    acet_file = open(output + "/acet.csv", "w")
    csv_acet = csv.writer(acet_file)
    ResultExp.print_header(csv_acet)

    if argv:
        for i, f in enumerate(argv):
            configuration = Configuration(f)
            for scheduler_name in schedulers:
                print(scheduler_name)
                configuration.scheduler_info.set_name(scheduler_name,
                                                      configuration.cur_dir)

                configuration.check_all()
                execute(configuration, "wcet", csv_wcet, wcet_file, i)
                execute(configuration, "acet", csv_acet, acet_file, i)
    else:
        # Manual configuration:
        configuration = Configuration()
        configuration.duration = 1000 * configuration.cycles_per_ms

        # Generate tasks:
        nsets = int(input("Number of experiments: "))
        n = int(input("Number of tasks: "))
        nb_proc = int(input("Number of processors: "))
        u = float(input("Load: "))

        u = task_generator.StaffordRandFixedSum(n, u, nsets)
        periods = task_generator.gen_periods_loguniform(n,
                                                        nsets,
                                                        2,
                                                        100,
                                                        round_to_int=True)
        # Add processors:
        for i in range(1, nb_proc + 1):
            configuration.add_processor(name="CPU {}".format(i), identifier=i)

        for i, exp_set in enumerate(task_generator.gen_tasksets(u, periods)):
            for scheduler_name in schedulers:
                print(scheduler_name)
                configuration.scheduler_info.set_name(scheduler_name,
                                                      configuration.cur_dir)
                while configuration.task_info_list:
                    del configuration.task_info_list[0]
                id_ = 1
                for (c, p) in exp_set:
                    configuration.add_task(name="T{}".format(id_),
                                           identifier=id_,
                                           period=p,
                                           activation_date=0,
                                           wcet=c,
                                           acet=c * .75,
                                           et_stddev=c * .1,
                                           deadline=p,
                                           abort_on_miss=True)
                    id_ += 1

                # Check the configuration:
                configuration.check_all()

                # Save the current exp:
                configuration.save(output + "/exp_{}.xml".format(i))

                # Execute the simulation:
                execute(configuration, "wcet", csv_wcet, wcet_file, i)
                execute(configuration, "acet", csv_acet, acet_file, i)
Beispiel #7
0
def main(argv):
    print("usage: ./exp [filename1] [filename2] ...")
 
#    outdir = input("Output directory: ")
    outdir = "results"
    if not os.path.exists(outdir):
        os.mkdir(outdir)

    result_file = open(outdir + "/result.csv", "w")
    csv_result = csv.writer(result_file)
    ResultExp.print_header(csv_result)

    schedulers = [
        "simso.schedulers.RM"]
#        "simso.schedulers.EDF",
#        "simso.schedulers.RM_mono"]

    if not argv:
        for i in range (1, 11):
            argv.append("tasksets/exp_{}.xml".format(str(i)))            
    if argv:
        for i, f in enumerate(argv):
            configuration = Configuration(f)
            for scheduler_name in schedulers:
                configuration.scheduler_info.clas = scheduler_name
#                configuration.check_all()
                execute(configuration, "ofrp", csv_result, result_file, i+1)
    else:
        # Manual configuration:
        configuration = Configuration()
        configuration.duration = 1000 * configuration.cycles_per_ms

        # Generate tasks:
        nsets = int(input("Number of experiments: "))
        n = int(input("Number of tasks: "))
        nb_proc = int(input("Number of processors: "))
        u = float(input("Load: "))

        u = task_generator.StaffordRandFixedSum(n, u, nsets)
        periods = task_generator.gen_periods_loguniform(n, nsets, 2, 100,
                                                        round_to_int=True)
        # Add processors:
        for i in range(1, nb_proc + 1):
            configuration.add_processor(name="CPU {}".format(i), identifier=i)

        for i, exp_set in enumerate(task_generator.gen_tasksets(u, periods)):
            for scheduler_name in schedulers:
                print(scheduler_name)
                configuration.scheduler_info.clas = scheduler_name
                while configuration.task_info_list:
                    del configuration.task_info_list[0]
                id_ = 1
                for (c, p) in exp_set:
                    configuration.add_task(
                        name="T{}".format(id_), identifier=id_,
                        period=p, activation_date=0, wcet=c,
                        acet=c * .75, et_stddev=c * .1,
                        deadline=p, abort_on_miss=True)
                    id_ += 1
                
                configuration.duration = configuration.get_hyperperiod * configuration.cycles_per_ms

                # Check the configuration:
                configuration.check_all()

                # Save the current exp:
                configuration.save(outdir + "/exp_{}.xml".format(i+1))

                # Execute the simulation:
                execute(configuration, "ofrp", csv_result, result_file, i+1)
Beispiel #8
0
def main(argv):
    schedulers = [
        "schedulers/RM.py", "schedulers/EDF.py", "schedulers/PriD.py",
        "schedulers/EDF_US.py", "schedulers/EDZL.py", "schedulers/LLF.py",
        "schedulers/MLLF.py",
        "schedulers/P_EDF.py", "schedulers/LB_P_EDF.py", "schedulers/EDHS.py",
        "schedulers/EKG.py", "schedulers/LRE_TL.py", "schedulers/DP_WRAP.py",
        "schedulers/BF.py", "schedulers/LLREF.py", "schedulers/PD2.py",
        "schedulers/ER_PD2.py", "schedulers/RUN.py"]

    schedulers = [
        "schedulers/EDF.py", "schedulers/EDZL.py", "schedulers/MLLF.py",
        "schedulers/P_EDF.py", "schedulers/EDHS.py", "schedulers/EKG.py",
        "schedulers/LRE_TL.py", "schedulers/LLREF.py", "schedulers/ER_PD2.py",
        "schedulers/RUN.py"]

    schedulers = ["schedulers/EDF.py", "schedulers/EDF2.py"]

    schedulers = ["schedulers/WC_U_EDF.py", "schedulers/U_EDF.py",
                  "schedulers/RUN.py", "schedulers/WC_RUN.py"]
    schedulers = ["schedulers/RUN.py", "schedulers/WC_RUN.py",
                  "/home/max/Documents/These/RTCSA/experiments/schedulers/WC_RUN.py"]
    schedulers = ["schedulers/WC_U_EDF.py", "schedulers/U_EDF.py",
                  "/home/max/Documents/These/RTCSA/experiments/schedulers/WC_U_EDF.py"]
    schedulers = ["schedulers/PD2.py", "schedulers/ER_PD2.py"]

    output = input("Output directory: ")
    os.mkdir(output)

    wcet_file = open(output + "/wcet.csv", "w")
    csv_wcet = csv.writer(wcet_file)
    ResultExp.print_header(csv_wcet)

    acet_file = open(output + "/acet.csv", "w")
    csv_acet = csv.writer(acet_file)
    ResultExp.print_header(csv_acet)

    if argv:
        for i, f in enumerate(argv):
            configuration = Configuration(f)
            for scheduler_name in schedulers:
                print(scheduler_name)
                configuration.scheduler_info.set_name(scheduler_name,
                                                      configuration.cur_dir)

                configuration.check_all()
                execute(configuration, "wcet", csv_wcet, wcet_file, i)
                execute(configuration, "acet", csv_acet, acet_file, i)
    else:
        # Manual configuration:
        configuration = Configuration()
        configuration.duration = 1000 * configuration.cycles_per_ms

        # Generate tasks:
        nsets = int(input("Number of experiments: "))
        n = int(input("Number of tasks: "))
        nb_proc = int(input("Number of processors: "))
        u = float(input("Load: "))

        u = task_generator.StaffordRandFixedSum(n, u, nsets)
        periods = task_generator.gen_periods_loguniform(n, nsets, 2, 100,
                                                        round_to_int=True)
        # Add processors:
        for i in range(1, nb_proc + 1):
            configuration.add_processor(name="CPU {}".format(i), identifier=i)

        for i, exp_set in enumerate(task_generator.gen_tasksets(u, periods)):
            for scheduler_name in schedulers:
                print(scheduler_name)
                configuration.scheduler_info.set_name(scheduler_name,
                                                      configuration.cur_dir)
                while configuration.task_info_list:
                    del configuration.task_info_list[0]
                id_ = 1
                for (c, p) in exp_set:
                    configuration.add_task(
                        name="T{}".format(id_), identifier=id_,
                        period=p, activation_date=0, wcet=c,
                        acet=c * .75, et_stddev=c * .1,
                        deadline=p, abort_on_miss=True)
                    id_ += 1

                # Check the configuration:
                configuration.check_all()

                # Save the current exp:
                configuration.save(output + "/exp_{}.xml".format(i))

                # Execute the simulation:
                execute(configuration, "wcet", csv_wcet, wcet_file, i)
                execute(configuration, "acet", csv_acet, acet_file, i)