Ejemplo n.º 1
0
def release_taskset(wait=True, delay=None, num_tasks=None):
    cmd = []
    if wait:
        cmd.append('-w')
    if delay != None:
        cmd.append('-d')
        cmd.append(delay)
    if num_tasks:
        cmd.append('-f')
        cmd.append(num_tasks)
    return spawn('release_ts', cmd, path=LIBLITMUS)
Ejemplo n.º 2
0
def release_taskset(wait=True, delay=None, num_tasks=None):
    cmd = []
    if wait:
        cmd.append('-w')
    if delay != None:
        cmd.append('-d')
        cmd.append(delay)
    if num_tasks:
        cmd.append('-f')
        cmd.append(num_tasks)
    return spawn('release_ts', cmd,
                 path=LIBLITMUS)
Ejemplo n.º 3
0
def run_task(task, *args, **kargs):
    (binary, args) = task_args(task, *args, **kargs)
    return spawn(binary, args, path=EXPERIMENTS_DIR)
Ejemplo n.º 4
0
def run_tasks(tasks, sched):
    procs = []

    if sched == 'HIME':
        task_id = 0
        for task in tasks.getElementsByTagName("task"):  # For each task
            task_id += 1
            task_path = ".task_input_hime_" + str(task_id)
            try:
                f = open(task_path, "w")
                if not task.getAttribute("slices"):
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    cpu = int(task.getAttribute("cpu"))

                    f.write("%d %f %d 0 %d 0" % (task_id, wcet, period, cpu))
                else:
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    first_cpu = int(task.getAttribute("cpu"))
                    slice_num = int(task.getAttribute("slices"))

                    f.write("%d %f %d 0 %d %d\n" %
                            (task_id, wcet, period, first_cpu, slice_num))
                    for slice in task.getElementsByTagName(
                            "slice"):  # For each slice
                        slice_cpu = int(slice.getAttribute("cpu"))
                        slice_budget = float(slice.getAttribute("budget"))
                        f.write("%d %d %f\n" %
                                (task_id, slice_cpu, slice_budget))

            except IOError as (msg):
                raise IOError("Could not create temporary file: %s", (msg))
            finally:
                f.close()
                procs += [
                    spawn(path.join(EXPERIMENTS_DIR, COMPUTE_TASK_HIME),
                          ["-w", "-T", RUNLENGTH, task_path])
                ]

    elif sched == 'EDF-WM':
        task_id = 0
        for task in tasks.getElementsByTagName("task"):  # For each task
            task_id += 1
            task_path = ".task_input_wm_" + str(task_id)
            try:
                f = open(task_path, "w")
                if not task.getAttribute("slices"):
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    cpu = int(task.getAttribute("cpu"))

                    f.write("%d %f %d 0 %d 0" % (task_id, wcet, period, cpu))
                else:
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    first_cpu = int(task.getAttribute("cpu"))
                    slice_num = int(task.getAttribute("slices"))

                    f.write("%d %f %d 0 %d %d\n" %
                            (task_id, wcet, period, first_cpu, slice_num))

                    for slice in task.getElementsByTagName(
                            "slice"):  # For each slice
                        slice_cpu = int(slice.getAttribute("cpu"))
                        slice_deadline = float(slice.getAttribute("deadline"))
                        slice_budget = float(slice.getAttribute("budget"))
                        slice_offset = float(slice.getAttribute("offset"))
                        f.write("%d %d %f %f %f\n" %
                                (task_id, slice_cpu, slice_deadline,
                                 slice_budget, slice_offset))

            except IOError as (msg):
                raise IOError("Could not create temporary file: %s", (msg))
            finally:
                f.close()
                procs += [
                    spawn(path.join(EXPERIMENTS_DIR, COMPUTE_TASK_EDFWM),
                          ["-w", "-T", RUNLENGTH, task_path])
                ]

    # wait for release
    release_taskset(num_tasks=len(procs)).wait()

    # wait for all tasks to terminate
    for p in procs:
        p.wait()
        assert p.returncode == 0
Ejemplo n.º 5
0
def start_background_tasks(num_cpus):
    return [
        spawn(BACKGROUND_TASK, [cpu], path=EXPERIMENTS_DIR)
        for cpu in xrange(num_cpus)
    ]
Ejemplo n.º 6
0
def ftcat(saveas, device=None, events=ALL_EVENTS):
    if device is None:
        device = DEVICE
    return spawn('ftcat', [device] + events,
                 stdout=saveas,
                 path=FT_TOOLS)
Ejemplo n.º 7
0
def run_tasks(tasks, sched):
    procs = []

    if sched == 'HIME':
        task_id = 0
        for task in tasks.getElementsByTagName("task"): # For each task
            task_id += 1
            task_path = ".task_input_hime_" + str(task_id)
            try:
                f = open(task_path, "w")
                if not task.getAttribute("slices"):
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    cpu = int(task.getAttribute("cpu"))

                    f.write("%d %f %d 0 %d 0" % (task_id, wcet, period, cpu))
                else:
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    first_cpu = int(task.getAttribute("cpu"))
                    slice_num = int(task.getAttribute("slices"))

                    f.write("%d %f %d 0 %d %d\n" % (task_id, wcet, period, first_cpu, slice_num))
                    for slice in task.getElementsByTagName("slice"): # For each slice
                        slice_cpu = int(slice.getAttribute("cpu"))
                        slice_budget = float(slice.getAttribute("budget"))
                        f.write("%d %d %f\n" % (task_id, slice_cpu, slice_budget))
                        
            except IOError as (msg):
                raise IOError("Could not create temporary file: %s", (msg))
            finally:
                f.close()
                procs += [spawn(path.join(EXPERIMENTS_DIR, COMPUTE_TASK_HIME), ["-w", "-T", RUNLENGTH, task_path])]

    elif sched == 'EDF-WM':
        task_id = 0
        for task in tasks.getElementsByTagName("task"): # For each task
            task_id += 1
            task_path = ".task_input_wm_" + str(task_id)
            try:
                f = open(task_path, "w")
                if not task.getAttribute("slices"):
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    cpu = int(task.getAttribute("cpu"))

                    f.write("%d %f %d 0 %d 0" % (task_id, wcet, period, cpu))
                else:
                    wcet = float(task.getAttribute("wcet"))
                    period = int(task.getAttribute("period"))
                    first_cpu = int(task.getAttribute("cpu"))
                    slice_num = int(task.getAttribute("slices"))

                    f.write("%d %f %d 0 %d %d\n" % (task_id, wcet, period, first_cpu, slice_num))

                    for slice in task.getElementsByTagName("slice"): # For each slice
                        slice_cpu = int(slice.getAttribute("cpu"))
                        slice_deadline = float(slice.getAttribute("deadline"))
                        slice_budget = float(slice.getAttribute("budget"))
                        slice_offset = float(slice.getAttribute("offset"))
                        f.write("%d %d %f %f %f\n" % (task_id, slice_cpu, slice_deadline, slice_budget, slice_offset))
                        
            except IOError as (msg):
                raise IOError("Could not create temporary file: %s", (msg))
            finally:
                f.close()
                procs += [spawn(path.join(EXPERIMENTS_DIR, COMPUTE_TASK_EDFWM), ["-w", "-T", RUNLENGTH, task_path])]

    # wait for release
    release_taskset(num_tasks=len(procs)).wait()

    # wait for all tasks to terminate
    for p in procs:
        p.wait()
        assert p.returncode == 0
Ejemplo n.º 8
0
def run_task(task, *args, **kargs):
    (binary, args) = task_args(task, *args, **kargs)
    return spawn(binary, args,
                 path=EXPERIMENTS_DIR)
Ejemplo n.º 9
0
def start_background_tasks(num_cpus):
    return [spawn(BACKGROUND_TASK, [cpu], path=EXPERIMENTS_DIR)
            for cpu in xrange(num_cpus)]