def run_exp_without_base_util_gen(): if PARAMS.GENERATE_NEW_TC: # generate taskset and write to file as pickle object print "Generating Taskset and Saving to Pickle file..." all_taskset = tgen.generate_all_tasksets() hf.write_object_to_file(all_taskset, PARAMS.TASKET_FILENAME) else: print "Loading Taskset from Pickle file..." all_taskset = hf.load_object_from_file(PARAMS.TASKET_FILENAME) eh.run_sched_exp(all_taskset)
# __author__ = "Monowar Hasan" # __email__ = "*****@*****.**" import helper_functions as hf import taskset_generator as tgen import experiment_handler as eh from config import * if __name__ == "__main__": if PARAMS.GENERATE_NEW_TC: # generate taskset and write to file as pickle object print "Generating Taskset and Saving to Pickle file..." # all_taskset = tgen.generate_all_tasksets() all_taskset = tgen.generate_all_tasksets_base_util() hf.write_object_to_file(all_taskset, PARAMS.TASKET_FILENAME) else: print "Loading Taskset from Pickle file..." all_taskset = hf.load_object_from_file(PARAMS.TASKET_FILENAME) # all_taskset = None # eh.dummy_run_period_selection_exp() # eh.do_run_sched_exp_all_global(tcconfig=None) eh.run_sched_exp_all_global_fftmax(all_taskset) print "Script finished"
out_xi_list.append((util, xi)) out_eta_list.append((util, eta_max)) return out_xi_list, out_eta_list if __name__ == '__main__': n_core = 2 # decide load from file or generate new taskset if PARAMS.GENERATE_NEW_TC_ESEARCH: # generate taskset and write to file as pickle object print "Generating Taskset and Saving to Pickle file..." tc, util_list = TGEN.generate_exsearch_tasksets(n_core) HF.write_object_to_file(tc, PARAMS.ESEARCH_TASKET_FILENAME) HF.write_object_to_file(util_list, PARAMS.ESEARCH_UTIL_FILENAME) else: print "Loading Taskset from Pickle file..." tc = HF.load_object_from_file(PARAMS.ESEARCH_TASKET_FILENAME) util_list = HF.write_object_to_file(PARAMS.ESEARCH_UTIL_FILENAME) xi_esearch, eta_esearch = run_experimet(tc, util_list, PARAMS.EXPERIMENT_NAME_ESEARCH) xi_prop, eta_prop = run_experimet(tc, util_list, PARAMS.EXPERIMENT_NAME_PROP) # print "Ex" # print xi_esearch # # print "prop"
def run_sched_exp_all_global_fftmax(all_taskset): """ This is the script that run schedulability experiments for All_global and Best-fit_Tmax approach """ se_sched_allglobal_dict = defaultdict(lambda: defaultdict(dict)) se_sched_fftmax_dict = defaultdict(lambda: defaultdict(dict)) rt_sched_dict = defaultdict(lambda: defaultdict(dict)) for core in PARAMS.CORE_LIST: total_grp = PARAMS.N_BASE_UTIL_GRP for uindx in range(total_grp): se_sched_allglobal_count = 0 se_sched_fftmax_count = 0 rt_sched_count = 0 for ntc in range(0, PARAMS.N_TASKSET_EACH_CONF): print "Analyzing Core:", core, "Utilization Group:", uindx, "NTC Task index", ntc tcconfig = all_taskset[core][uindx][ntc] prt = prepare_rt_taskset(tcconfig) if prt: if PARAMS.SHOW_DEBUG_MSG: print "=== RT TASKSET SCHEDULABLE ===" print "Total RT util", tcconfig.rt_util, "Total SE util", tcconfig.se_util, "Total util", tcconfig.total_util print "RT Core Assignement:", tcconfig.rt_core_assignment for rt_tsk in tcconfig.rt_taskset: print "RT Task id", rt_tsk.tid, "Period", rt_tsk.period, "WCET", rt_tsk.wcet, "WCRT:", rt_tsk.wcrt rt_sched_count += 1 # run experiments is_se_sched_allglobal, is_se_sched_fftmax = do_run_sched_exp_all_global_fftmax( tcconfig) if is_se_sched_allglobal: if PARAMS.SHOW_DEBUG_MSG: print "\n ALL_GLOBAL: Taskset is schedulable" se_sched_allglobal_count += 1 # increase sched count if is_se_sched_fftmax: if PARAMS.SHOW_DEBUG_MSG: print "\n ALL_GLOBAL: Taskset is schedulable" se_sched_fftmax_count += 1 # increase sched count else: print "RT tasks are not schedulable. Continue.." # save sched counts se_sched_allglobal_dict[core][uindx] = se_sched_allglobal_count se_sched_fftmax_dict[core][uindx] = se_sched_fftmax_count rt_sched_dict[core][uindx] = rt_sched_count # save the dictionary as class object output = oc.ExportSchedOutputAllGlobalTmax( core_list=PARAMS.CORE_LIST, ntc_each_conf=PARAMS.N_TASKSET_EACH_CONF, rt_sched_dict=rt_sched_dict, se_sched_allglobal_dict=se_sched_allglobal_dict, se_sched_fftmax_dict=se_sched_fftmax_dict) # saving results to pickle file print "--> Schedulability Experiment :: Saving result to file..." hf.write_object_to_file(output, PARAMS.EXP_RES_FILENAME_SCHED_ALLGLOBAL_FFTMAX)
def run_sched_exp_with_base_util_tc(all_taskset): """ This is the script that run period selection methods and obtain schedulability and Euclidian distance """ ecdist_prop_dict = defaultdict(lambda: defaultdict(dict)) ecdist_ff_dict = defaultdict(lambda: defaultdict(dict)) se_sched_prop_dict = defaultdict(lambda: defaultdict(dict)) se_sched_ff_dict = defaultdict(lambda: defaultdict(dict)) rt_sched_dict = defaultdict(lambda: defaultdict(dict)) for core in PARAMS.CORE_LIST: total_grp = PARAMS.N_BASE_UTIL_GRP for uindx in range(total_grp): se_sched_prop_count = 0 se_sched_ff_count = 0 rt_sched_count = 0 ecdist_list_prop = [] ecdist_list_ff = [] for ntc in range(0, PARAMS.N_TASKSET_EACH_CONF): print "Analyzing Core:", core, "Utilization Group:", uindx, "NTC Task index", ntc tcconfig = all_taskset[core][uindx][ntc] prt = prepare_rt_taskset(tcconfig) if prt: if PARAMS.SHOW_DEBUG_MSG: print "=== RT TASKSET SCHEDULABLE ===" print "Total RT util", tcconfig.rt_util, "Total SE util", tcconfig.se_util, "Total util", tcconfig.total_util print "RT Core Assignement:", tcconfig.rt_core_assignment for rt_tsk in tcconfig.rt_taskset: print "RT Task id", rt_tsk.tid, "Period", rt_tsk.period, "WCET", rt_tsk.wcet, "WCRT:", rt_tsk.wcrt rt_sched_count += 1 tcconfig_proposed = copy.deepcopy(tcconfig) tcconfig_ff = copy.deepcopy(tcconfig) # proposed scheme is_se_sched_prop = schf.get_se_periods_proposed( tcconfig=tcconfig_proposed) if is_se_sched_prop: if PARAMS.SHOW_DEBUG_MSG: print "\n PROP: Taskset is schedulable. Printing periods and WCRT.." for se_tsk in tcconfig_proposed.se_taskset: print "Se task:", se_tsk.tid, "wcet:", se_tsk.wcet, "wcrt:", se_tsk.wcrt, "period:", se_tsk.period, "Tmax:", se_tsk.period_max tvec_prop = [ se_tsk.period for se_tsk in tcconfig_proposed.se_taskset ] tmaxvec_prop = [ se_tsk.period_max for se_tsk in tcconfig_proposed.se_taskset ] ecdist_prop = hf.get_normalized_euc_dist( tvec_prop, tmaxvec_prop) se_sched_prop_count += 1 # increase sched count ecdist_list_prop.append(ecdist_prop) # save distance # now test with best-fit scheme is_se_sched_ff = schf.get_se_periods_bestfit( tcconfig=tcconfig_ff) if is_se_sched_ff: if PARAMS.SHOW_DEBUG_MSG: print "\n FF: Taskset is schedulable. Printing periods and WCRT.." for se_tsk in tcconfig_ff.se_taskset: print "Se task:", se_tsk.tid, "wcet:", se_tsk.wcet, "wcrt:", se_tsk.wcrt, "period:", se_tsk.period, "Tmax:", se_tsk.period_max tvec_ff = [ se_tsk.period for se_tsk in tcconfig_ff.se_taskset ] tmaxvec_ff = [ se_tsk.period_max for se_tsk in tcconfig_ff.se_taskset ] ecdist_ff = hf.get_normalized_euc_dist( tvec_ff, tmaxvec_ff) se_sched_ff_count += 1 # increase sched count ecdist_list_ff.append(ecdist_ff) # save distance else: print "RT tasks are not schedulable. Continue.." # save sched counts se_sched_prop_dict[core][uindx] = se_sched_prop_count se_sched_ff_dict[core][uindx] = se_sched_ff_count rt_sched_dict[core][uindx] = rt_sched_count # save distance for all util ecdist_prop_dict[core][uindx] = ecdist_list_prop ecdist_ff_dict[core][uindx] = ecdist_list_ff # save the dictionary as class object output = oc.ExportSchedOutput(core_list=PARAMS.CORE_LIST, ntc_each_conf=PARAMS.N_TASKSET_EACH_CONF, rt_sched_dict=rt_sched_dict, se_sched_prop_dict=se_sched_prop_dict, se_sched_ff_dict=se_sched_ff_dict, ecdist_prop_dict=ecdist_prop_dict, ecdist_ff_dict=ecdist_ff_dict) # saving results to pickle file print "--> Schedulability Experiment :: Saving result to file..." hf.write_object_to_file(output, PARAMS.EXP_RES_FILENAME_SCHED)
PARAMS.EXPERIMENT_NAME_PROP) dt_both_ref, dt_any_ref = SIM.simulate_schedule( core, tc_conf_prop, rt_alloc_ref, x, sim_duration, attack_time, se_task_attack_detector_list, PARAMS.EXPERIMENT_NAME_REF) # detection_time_prop[core_index].append(SIM.simulate_schedule(core, tc_conf_prop, rt_alloc, x, sim_duration, attack_time, se_task_attack_detector_list, PARAMS.EXPERIMENT_NAME_PROP)) # detection_time_ref[core_index].append(SIM.simulate_schedule(core, tc_conf_prop, rt_alloc, x, sim_duration, attack_time, se_task_attack_detector_list, # PARAMS.EXPERIMENT_NAME_REF)) detection_time_both_prop[core_index].append(dt_both_prop) detection_time_any_prop[core_index].append(dt_any_prop) detection_time_both_ref[core_index].append(dt_both_ref) detection_time_any_ref[core_index].append(dt_any_ref) sim_exp_result = ER.CSSimResult(detection_time_both_prop, detection_time_any_prop, detection_time_both_ref, detection_time_any_ref) print "Experiment Done! Writing Results..." HF.write_object_to_file(sim_exp_result, PARAMS.EXP_CS_FILENAME) # print "prop" # print detection_time_both_prop # print detection_time_any_prop # # print "ref" # print detection_time_both_ref # print detection_time_any_ref print "Script Finished!!"
rt_sched_list_per_core.append(rt_sched_per_util_list) output = ER.ExportOutput(etasum_list_per_core, etasum_std_list_per_core, xi_list_per_core, xi_std_list_per_core, rt_sched_list_per_core, se_sched_list_per_core) return output if __name__ == "__main__": # decide load from file or generate new taskset if PARAMS.GENERATE_NEW_TC: # generate taskset and write to file as pickle object print "Generating Taskset and Saving to Pickle file..." tc = TGEN.generate_all_tasksets() HF.write_object_to_file(tc, PARAMS.TASKET_FILENAME) else: print "Loading Taskset from Pickle file..." tc = HF.load_object_from_file(PARAMS.TASKET_FILENAME) # output_prop = run_experiment(tc, PARAMS.EXPERIMENT_NAME_PROP) # # # saving results to pickle file # print PARAMS.EXPERIMENT_NAME_PROP, "--> Saving result to file..." # HF.write_object_to_file(output_prop, PARAMS.EXP_RES_FILENAME_PROP) output_bf = run_experiment(tc, PARAMS.EXPERIMENT_NAME_BF) # saving results to pickle file print PARAMS.EXPERIMENT_NAME_REF, "--> Saving result to file..." HF.write_object_to_file(output_bf, PARAMS.EXP_RES_FILENAME_BF)
rt_sched_list_per_core.append(rt_sched_per_util_list) output = ER.ExportOutput(etasum_list_per_core, etasum_std_list_per_core, xi_list_per_core, xi_std_list_per_core, rt_sched_list_per_core, se_sched_list_per_core) return output if __name__ == "__main__": # decide load from file or generate new taskset if PARAMS.GENERATE_NEW_TC: # generate taskset and write to file as pickle object print "Generating Taskset and Saving to Pickle file..." tc = TGEN.generate_all_tasksets() HF.write_object_to_file(tc, PARAMS.TASKET_FILENAME) else: print "Loading Taskset from Pickle file..." tc = HF.load_object_from_file(PARAMS.TASKET_FILENAME) output_prop = run_experiment(tc, PARAMS.EXPERIMENT_NAME_PROP) # saving results to pickle file print PARAMS.EXPERIMENT_NAME_PROP, "--> Saving result to file..." HF.write_object_to_file(output_prop, PARAMS.EXP_RES_FILENAME_PROP) output_ref = run_experiment(tc, PARAMS.EXPERIMENT_NAME_REF) # saving results to pickle file print PARAMS.EXPERIMENT_NAME_REF, "--> Saving result to file..." HF.write_object_to_file(output_ref, PARAMS.EXP_RES_FILENAME_REF)