Esempio n. 1
0
def smff_test(filename, outfile, plot, verbose):

    options.init_pycpa()

    print "loading", filename
    loader = smff_loader.SMFFLoader()
    s = loader.parse(filename)


    if plot == True:
        # graph the smff system
        graph_file = string.replace(os.path.basename(filename), ".xml", "") + ".pdf"
        graph.graph_system(s, sched_param=True, exec_times=True, filename=graph_file)

    try:
        # analyze the system
        results = analysis.analyze_system(s)

        # print some analysis results

        print("Result:")
        for r in sorted(s.resources, key=str):
            print "results for resource %s" % r.name
            for t in sorted(r.tasks, key=str):
                print("%s - %d " % (str(t.name) , results[t].wcrt))

        if outfile is not None:
            # backannotate the xml
            loader.annotate_results()

            # write it
            loader.write(filename=outfile)

    except analysis.NotSchedulableException as (e):
        print str(e)
Esempio n. 2
0
    def xmlrpc_analyze_system(self, system_id):
        """ Analyze system and return a result id.

        :param system_id: ID of the system to analyze
        :type system_id: string
        :returns: ID of a results object
        :rtype: string
        """
        system = self._obj_from_id(system_id, model.System)

        results = None
        for r in system.resources:
            if r.scheduler is None:
                raise xmlrpc.Fault(
                    ILLEGAL_SYSTEM,
                    "component %s has no scheduler assigned" % r.name)

        logger.debug("analyzing...")
        try:
            results = analysis.analyze_system(system)
            rid = self._unique(results)
            self._objects[rid] = results
        except analysis.NotSchedulableException as e:
            raise xmlrpc.Fault(NOT_SCHEDULABLE,
                               "not schedulable: %s" % (str(e)))
        except Exception as e:
            # Print the exception plus traceback to server
            traceback.print_exc()
            raise xmlrpc.Fault(GENERAL_ERROR, str(e))
        logger.debug("{} = {}analyze_system({})".format(
            rid, self.debug_prefix, system_id))
        return rid
Esempio n. 3
0
def e2e_test(expected_wclat):
    options.init_pycpa()

    # generate an new system
    s = model.System()

    # add a resource to the system
    # register round robin scheduler
    r1 = s.bind_resource(model.Resource("R1",
                                        schedulers.RoundRobinScheduler()))

    # map two tasks to
    t11 = r1.bind_task(model.Task("T11", wcet=1, bcet=1))
    t12 = r1.bind_task(model.Task("T12", wcet=2, bcet=1))

    # register precedence constraint
    t11.link_dependent_task(t12)

    t11.in_event_model = model.PJdEventModel(P=4, J=3)

    # register a task chain as a stream
    s1 = s.bind_path(model.Path("S1", [t11, t12]))

    # perform a system analysis
    print("analyzing")
    task_results = analysis.analyze_system(s)

    # calculate the latency for the first 10 events
    for n in range(1, 11):
        best_case_latency, worst_case_latency = path_analysis.end_to_end_latency(
            s1, task_results, n)
        print("stream S1 e2e latency. best case: %d, worst case: %d" %
              (best_case_latency, worst_case_latency))
        assert (worst_case_latency == expected_wclat[n - 1])
Esempio n. 4
0
def spp_test():
    # init pycpa and trigger command line parsing
    options.init_pycpa()

    # generate an new system
    s = model.System()

    # add two resources (CPUs) to the system
    # and register the static priority preemptive scheduler
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))
    r2 = s.bind_resource(model.Resource("R2", schedulers.SPPScheduler()))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=10, bcet=5, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12", wcet=3, bcet=1, scheduling_parameter=2))

    # create and bind tasks to r2
    t21 = r2.bind_task(
        model.Task("T21", wcet=2, bcet=2, scheduling_parameter=1))
    t22 = r2.bind_task(
        model.Task("T22", wcet=9, bcet=4, scheduling_parameter=2))

    # specify precedence constraints: T11 -> T21; T12-> T22
    t11.link_dependent_task(t21)
    t12.link_dependent_task(t22)

    # register a periodic with jitter event model for T11 and T12
    t11.in_event_model = model.PJdEventModel(P=30, J=5)
    t12.in_event_model = model.PJdEventModel(P=15, J=6)

    # plot the system graph to visualize the architecture
    g = graph.graph_system(s, 'spp_graph.pdf', dotout='spp_graph.dot')

    # perform the analysis
    print("Performing analysis")
    task_results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print("%s: wcrt=%d" % (t.name, task_results[t].wcrt))
            print("    b_wcrt=%s" % (task_results[t].b_wcrt_str()))

    expected_wcrt = dict()
    expected_wcrt[t11] = 10
    expected_wcrt[t12] = 13
    expected_wcrt[t21] = 2
    expected_wcrt[t22] = 19

    for t in expected_wcrt.keys():
        assert (expected_wcrt[t] == task_results[t].wcrt)
Esempio n. 5
0
def gantt_test():
    # initialyze pycpa. (e.g. read command line switches and set up default options)
    options.init_pycpa()

    # generate an new system
    s = model.System()

    # instantiate a resource
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=5, bcet=5, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12", wcet=9, bcet=1, scheduling_parameter=2))

    # connect communicating tasks: T11 -> T12
    t11.link_dependent_task(t12)

    # register a PJd event model
    t11.in_event_model = model.PJdEventModel(P=30, J=60)

    # perform the analysis
    print("Performing analysis")
    results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print("%s: wcrt=%d" % (t.name, results[t].wcrt))

    simmodel = simulation.ResourceModel(r1)
    simmodel.runModel(task=t12,
                      scheduler=simulation.SimSPP(name="SPP", sim=simmodel))

    # plot
    hp_tasks = list()
    for t in sorted(r1.tasks, key=str):
        if t.scheduling_parameter <= t12.scheduling_parameter:
            hp_tasks.append(t)

    plot.plot_gantt(hp_tasks,
                    results,
                    height=2. / 3,
                    bar_linewidth=2,
                    min_dist_arrows=1,
                    arrow_head_width=1,
                    task=t12,
                    show=options.get_opt('show'),
                    file_name='gantt.pdf')
Esempio n. 6
0
def simple_test():
    # initialyze pycpa. (e.g. read command line switches and set up default options)
    options.init_pycpa()

    # generate an new system
    s = model.System()

    # instantiate a resource
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=5, bcet=5, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12", wcet=9, bcet=1, scheduling_parameter=2))

    # connect communicating tasks: T11 -> T12
    t11.link_dependent_task(t12)

    # register a PJd event model
    t11.in_event_model = model.PJdEventModel(P=30, J=60)

    # create a path
    p1 = model.Path("P1", [t11, t12])

    # add constraints to task t11
    s.constraints.add_backlog_constraint(t11, 5)

    # add constraints to task t12
    s.constraints.add_wcrt_constraint(t12, 90)

    try:
        # plot the system graph to visualize the architecture
        g = graph.graph_system(s, 'simple_graph.pdf')
    except Exception:
        # gracefully pass for machines without matplotlib
        pass

    # perform the analysis
    print("Performing analysis")
    results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print("%s: wcrt=%d" % (t.name, results[t].wcrt))

    bcl, wcl = path_analysis.end_to_end_latency(p1, results, 2)
    print "bcl: %d, wcl: %d" % (bcl, wcl)
Esempio n. 7
0
def constraints_example():

    options.init_pycpa()

    # generate an new system
    s = model.System()

    # add two resources (CPUs) to the system
    # and register the static priority preemptive scheduler
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))
    r2 = s.bind_resource(model.Resource("R2", schedulers.SPPScheduler()))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=10, bcet=5, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12", wcet=3, bcet=1, scheduling_parameter=2))

    # create and bind tasks to r2
    t21 = r2.bind_task(
        model.Task("T21", wcet=2, bcet=2, scheduling_parameter=1))
    t22 = r2.bind_task(
        model.Task("T22", wcet=9, bcet=4, scheduling_parameter=2))

    # specify precedence constraints: T11 -> T21; T12-> T22
    t11.link_dependent_task(t21)
    t12.link_dependent_task(t22)

    # register a periodic with jitter event model for T11 and T12
    t11.in_event_model = model.PJdEventModel(P=30, J=5)
    t12.in_event_model = model.PJdEventModel(P=15, J=6)

    p1 = model.Path("myPath", [t11, t21])
    s.bind_path(p1)

    # deliberately overconstrain the system
    s.constraints.add_path_constraint(p1, 5, n=2)
    s.constraints.add_wcrt_constraint(t11, 1)
    s.constraints.add_load_constraint(r1, 0.5)
    s.constraints.add_backlog_constraint(t11, 1)

    # perform the analysis
    print("Performing analysis")
    task_results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print("%s: wcrt=%d" % (t.name, task_results[t].wcrt))
Esempio n. 8
0
def test_spp():
    # generate an new system
    s = model.System()

    # add two resources (CPUs) to the system
    # and register the static priority preemptive scheduler
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))
    r2 = s.bind_resource(model.Resource("R2", schedulers.SPPScheduler()))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=10, bcet=5, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12", wcet=3, bcet=1, scheduling_parameter=2))

    # create and bind tasks to r2
    t21 = r2.bind_task(
        model.Task("T21", wcet=2, bcet=2, scheduling_parameter=1))
    t22 = r2.bind_task(
        model.Task("T22", wcet=9, bcet=4, scheduling_parameter=2))

    # specify precedence constraints: T11 -> T21; T12-> T22
    t11.link_dependent_task(t21)
    t12.link_dependent_task(t22)

    # register a periodic with jitter event model for T11 and T12
    t11.in_event_model = model.PJdEventModel(P=30, J=5)
    t12.in_event_model = model.PJdEventModel(P=15, J=6)

    # perform the analysis
    task_results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    busy_times_t11 = [0, 10]
    busy_times_t12 = [0, 13, 16]
    busy_times_t21 = [0, 2]
    busy_times_t22 = [0, 11, 20, 31, 40]

    assert task_results[t11].busy_times == busy_times_t11
    assert task_results[t12].busy_times == busy_times_t12
    assert task_results[t21].busy_times == busy_times_t21
    assert task_results[t22].busy_times == busy_times_t22

    assert task_results[t11].wcrt == 10
    assert task_results[t12].wcrt == 13
    assert task_results[t21].wcrt == 2
    assert task_results[t22].wcrt == 19
Esempio n. 9
0
def sampling_test(wclat_results):

    options.init_pycpa()

    # generate an new system
    s = model.System()

    # add two resources to the system
    # register two schedulers
    r1 = s.bind_resource(model.Resource("R1", schedulers.SPPScheduler()))

    # add a task
    t11 = r1.bind_task(model.Task(name="T11", wcet=3, bcet=1, scheduling_parameter=1))
    # register input event model
    t11.in_event_model = model.PJdEventModel(P=30, J=15)

    # add three more tasks, these will be triggered by other tasks
    t12 = r1.bind_task(model.Task(name="T12", wcet=3, bcet=2, scheduling_parameter=2))

    # add a sampling junction
    j1 = s.bind_junction(model.Junction(name="J1", strategy=junctions.SampledInput()))
    j1.strategy.set_trigger_event_model(model.PJdEventModel(P=50, J=0))

    # register a task chain as a stream: t11->j1->t12
    s1 = s.bind_path(model.Path("S1", [t11, j1, t12]))

    # graph the system
    graph.graph_system(s, "sampling_example.pdf")

    # analyze the system
    print("Performing analysis")
    results = analysis.analyze_system(s)

    # print the results
    print("Result:")
    for r in sorted(s.resources, key=str):
        print "load on resource %s: %0.2f" % (r.name, r.load())
        for t in sorted(r.tasks, key=str):
            print "  task %s - wcrt: %d" % (t.name, results[t].wcrt)

    # calculate the latency for the first 10 events
    for n in range(1, 11):
        best_case_latency, worst_case_latency = path_analysis.end_to_end_latency(s1, results, n)
        print("stream S1 e2e latency. best case: %d, worst case: %d" % (best_case_latency, worst_case_latency))
        assert(worst_case_latency == wclat_results[n-1])
Esempio n. 10
0
def _run_test(scheduler, priorities):
    # generate an new system
    s = model.System()

    # add two resources (CPUs) to the system
    # and register the static priority preemptive scheduler
    r1 = s.bind_resource(model.Resource("R1", scheduler))

    # create and bind tasks to r1
    t11 = r1.bind_task(
        model.Task("T11", wcet=10, bcet=1, scheduling_parameter=priorities[0]))
    t21 = r1.bind_task(
        model.Task("T21", wcet=2, bcet=2, scheduling_parameter=priorities[1]))
    t31 = r1.bind_task(
        model.Task("T31", wcet=4, bcet=2, scheduling_parameter=priorities[2]))

    # specify precedence constraints: T11 -> T21 -> T31
    t11.link_dependent_task(t21)
    t21.link_dependent_task(t31)

    # register a periodic with jitter event model for T11
    t11.in_event_model = model.PJdEventModel(P=20, J=5)

    # perform the analysis
    print("Performing analysis")
    task_results = analysis.analyze_system(s)

    failed = False
    for t in r1.tasks:
        for n in range(1, 11):
            if t.in_event_model.delta_min(n) != t.in_event_model.deltamin_func(
                    n):
                failed = True
                print("%s: cached EM of != uncached EM" % (t.name))
                print("delta_min(%d) = %d != %d" %
                      (n, t.in_event_model.delta_min(n),
                       t.in_event_model.deltamin_func(n)))
                print("for priorities = %s" % str(priorities))
                break

    return not failed
Esempio n. 11
0
def main():
    """ Loads the pickled system and analyzes it with the given command
    line parameter settings.
    """
    system = None

    # read the last argument without the help of argparse
    # since argparse is not initialized yet!
    if len(sys.argv) < 3:
        print("Please specify a filename!")
        print(
            "Format: analyze_pickled.py [optinal pycpa parameters] --file FILENAME "
        )
        exit(1)

    filename = sys.argv[-1]
    print("Loading: %s" % filename)

    try:
        with open(filename, 'rb') as f:
            s = pickle.load(f)
    except IOError as e:
        print e
        exit(1)

    print("DONE")
    print("... handing over to the pycpa kernel\n\n\n")

    # init pycpa and trigger command line parsing
    # this must be done late, as the modules dynamically loaded
    # by pickle can add additional argparse arguments
    options.init_pycpa()

    task_results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print("%s: wcrt=%d" % (t.name, task_results[t].wcrt))
            print("    b_wcrt=%s" % (task_results[t].b_wcrt_str()))
Esempio n. 12
0
def tdma_test():

    options.init_pycpa()

    s = model.System()
    r1 = s.bind_resource(model.Resource("R1", schedulers.TDMAScheduler()))
    r2 = s.bind_resource(model.Resource("R2", schedulers.TDMAScheduler()))

    # scheduling_parameter denotes the slotsize
    t11 = r1.bind_task(
        model.Task("T11", wcet=10, bcet=5, scheduling_parameter=2))
    t12 = r1.bind_task(
        model.Task("T12", wcet=3, bcet=1, scheduling_parameter=2))

    t21 = r2.bind_task(
        model.Task("T21", wcet=2, bcet=2, scheduling_parameter=2))
    t22 = r2.bind_task(
        model.Task("T22", wcet=3, bcet=3, scheduling_parameter=2))

    t11.link_dependent_task(t21)
    t12.link_dependent_task(t22)

    t11.in_event_model = model.PJdEventModel()
    t11.in_event_model.set_PJd(30, 5)

    t12.in_event_model = model.PJdEventModel()
    t12.in_event_model.set_PJd(15, 6)

    g = graph.graph_system(s, 'tdma_graph.pdf')

    print("Performing analysis")
    results = analysis.analyze_system(s)

    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print str(t), " - ", results[t].wcrt
            print "    ", results[t].b_wcrt_str()
Esempio n. 13
0
def rr_test():

    options.init_pycpa()

    s = model.System()
    r1 = s.bind_resource(model.Resource("R1",
                                        schedulers.RoundRobinScheduler()))
    r2 = s.bind_resource(model.Resource("R2",
                                        schedulers.RoundRobinScheduler()))

    # create and bind tasks
    # the scheduling_parameter denotes the slot size
    t11 = r1.bind_task(
        model.Task(name="T11", wcet=1, bcet=1, scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task(name="T12", wcet=1, bcet=1, scheduling_parameter=1))
    t21 = r2.bind_task(
        model.Task(name="T21", wcet=1, bcet=1, scheduling_parameter=1))
    t22 = r2.bind_task(
        model.Task(name="T22", wcet=1, bcet=1, scheduling_parameter=1))

    t11.link_dependent_task(t21)
    t22.link_dependent_task(t12)

    t11.in_event_model = model.CTEventModel(c=1, T=5)
    t22.in_event_model = model.CTEventModel(c=5, T=17)

    print("Performing analysis")
    results = analysis.analyze_system(s)

    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            print(t, " - ", results[t].wcrt)
            print("    b_wcrt=%s" % (results[t].b_wcrt_str()))

    graph.graph_system(s, show=options.get_opt('show'))
Esempio n. 14
0
| See LICENSE file for copyright and license details.

:Authors:
         - Philip Axer

Description
-----------

SymTA/S 1.4 Loader example
"""

from pycpa import analysis
from pycpa import symload
from pycpa import options

import os

## this is necessary because the file is also called from the regression test suite
path = os.path.dirname(os.path.realpath(__file__))

options.init_pycpa()
loader = symload.SymtaLoader14()
s = loader.parse(path + "/symta14_test.xml")
results = analysis.analyze_system(s)

print("Result:")
for r in sorted(s.resources, key=str):
    print "results for resource %s" % r.name
    for t in sorted(r.tasks, key=str):
        print str(t), "-", results[t].wcrt
Esempio n. 15
0
def generate_golden_model(test_id=0,
                          max_load=0.85,
                          max_tasks=50,
                          max_period=10000,
                          max_jitter=100000,
                          scheduler_string="schedulers.SPPScheduler()"):
    ntasks = int(random.random() * max_tasks)
    total_util = random.random() * max_load
    task_ids = [str(i + 1) for i in range(ntasks)]
    task_utilizations = util.uunifast(ntasks, total_util)
    task_jitters = [int(random.random() * max_jitter) for i in range(ntasks)]
    task_periods = [
        int(random.random() * max_period + 1) for i in range(ntasks)
    ]
    task_wcets = [int(u * p) for u, p in zip(task_utilizations, task_periods)]

    code_string = "# tasks: %d total_utilization %f\n" % (ntasks, total_util)
    code_string += "s = model.System()\n"

    code_string += """r1 = s.bind_resource(model.Resource("R1", %s))\n""" % (
        scheduler_string)
    code_string += """r2 = s.bind_resource(model.Resource("R2", %s))\n""" % (
        scheduler_string)
    for name, J, P, C in zip(task_ids, task_jitters, task_periods, task_wcets):
        #create a task on resource 1
        code_string += """task1_%s = model.Task(name="task1_%s", wcet=%d, scheduling_parameter=%d)\n""" % (
            name, name, C, int(name))
        code_string += """task1_%s.in_event_model = model.PJdEventModel(P=%d, J=%d)\n""" % (
            name, P, J)
        code_string += """task1_%s.deadline = %d\n""" % (
            name, P)  #set a deadline for EDF
        code_string += """r1.bind_task(task1_%s)\n""" % (name)
        #create a task on resource 2
        code_string += """task2_%s = model.Task(name="task2_%s", wcet=%d, scheduling_parameter=%d)\n""" % (
            name, name, C, int(name))
        code_string += """task2_%s.deadline = %d\n""" % (
            name, P)  #set a deadline for EDF
        code_string += """task1_%s.link_dependent_task(task2_%s)\n""" % (name,
                                                                         name)
        code_string += """r2.bind_task(task2_%s)\n""" % (name)

    exec_locals = dict()
    exec(code_string, globals(), exec_locals)
    system = exec_locals['s']

    task_names = list()
    for r in system.resources:
        for t in r.tasks:
            task_names.append(t.name)

    # override event model propagation
    for propagation in options.propagation_methods:
        max_iterations_code = "options.set_opt('max_iterations', float('inf'))\n"
        propagation_code = "options.set_opt('propagation', '%s')\n" % (
            propagation)
        exec(propagation_code, globals(), exec_locals)
        exec(max_iterations_code, globals(), exec_locals)
        print("### DEBUG: evaluating for %s / %s" %
              (propagation, scheduler_string))
        task_results = analysis.analyze_system(system)
        code_string += """# setting options\n"""
        code_string += max_iterations_code
        code_string += propagation_code
        code_string += """##########################################\n"""
        code_string += """task_results = analysis.analyze_system(s)\n"""
        code_string += """\n###########################################\n"""
        for obj_name in task_names:
            busy_times = str((task_results[exec_locals[obj_name]].busy_times))
            wcrt_code = "task_results[%s].wcrt" % obj_name
            bcrt_code = "task_results[%s].bcrt" % obj_name
            code_string += """#check busy times\n"""
            code_string += """assert task_results[%s].busy_times == %s\n""" % (
                obj_name, busy_times)

            code_string += """#check type wcrt\n"""
            code_string += """assert type(%s) == int\n""" % (wcrt_code)

            code_string += """#check type bcrt\n"""
            code_string += """assert type(%s) == int\n""" % (bcrt_code)

            code_string += """#check busy times\n"""
            code_string += """assert %s == %d\n""" % (
                wcrt_code, task_results[exec_locals[obj_name]].wcrt)

    code_string += """return s\n\n"""

    #indent
    code_string = "\n".join(
        ["    %s" % (line) for line in code_string.splitlines()])
    function_string = "def testcase_%d():\n%s" % (test_id, code_string)
    print(function_string)
Esempio n. 16
0
def time_bases_test(auto=True):
    # print the welcome message
    options.init_pycpa()
    # generate an new system
    s = model.System()

    # add two resources (CPUs) to the system
    # and register the static priority preemptive scheduler
    r1 = s.bind_resource(
        model.Resource("R1", schedulers.SPPScheduler(), frequency=333333333))
    r2 = s.bind_resource(
        model.Resource("R2", schedulers.SPPScheduler(), frequency=100000000))

    # get a common time-base
    common_time_base = util.ns

    if auto == True:
        common_time_base = util.calculate_base_time(
            [r.frequency for r in s.resources])

    print "Basetime is %d Hz" % common_time_base

    # create and bind tasks to r1. Here the timing is specified in absolute time (i.e. 10 ms)
    t11 = r1.bind_task(
        model.Task("T11",
                   wcet=util.time_to_time(10, util.ms, common_time_base,
                                          'ceil'),
                   bcet=util.time_to_time(5, util.ms, common_time_base,
                                          'floor'),
                   scheduling_parameter=1))
    t12 = r1.bind_task(
        model.Task("T12",
                   wcet=util.time_to_time(3, util.ms, common_time_base,
                                          'ceil'),
                   bcet=util.time_to_time(1, util.ms, common_time_base,
                                          'floor'),
                   scheduling_parameter=2))

    # create and bind tasks to r2. Here the timing is specified in cycle time (i.e. 10000 cycles)
    t21 = r2.bind_task(
        model.Task("T21",
                   wcet=util.cycles_to_time(200000, r2.frequency,
                                            common_time_base, 'ceil'),
                   bcet=util.cycles_to_time(200000, r2.frequency,
                                            common_time_base, 'floor'),
                   scheduling_parameter=1))
    t22 = r2.bind_task(
        model.Task("T22",
                   wcet=util.cycles_to_time(900000, r2.frequency,
                                            common_time_base, 'ceil'),
                   bcet=util.cycles_to_time(400000, r2.frequency,
                                            common_time_base, 'floor'),
                   scheduling_parameter=2))

    # specify precedence constraints: T11 -> T21; T12-> T22
    t11.link_dependent_task(t21)
    t12.link_dependent_task(t22)

    # register a periodic with jitter event model for T11 and T12
    t11.in_event_model = model.PJdEventModel(
        P=util.time_to_time(30, util.ms, common_time_base, 'floor'),
        J=util.time_to_time(5, util.ms, common_time_base, 'ceil'))
    t12.in_event_model = model.PJdEventModel(
        P=util.time_to_time(15, util.ms, common_time_base, 'floor'),
        J=util.time_to_time(6, util.ms, common_time_base, 'ceil'))

    # perform the analysis
    print("Performing analysis")
    task_results = analysis.analyze_system(s)

    # print the worst case response times (WCRTs)
    print("Result:")
    for r in sorted(s.resources, key=str):
        for t in sorted(r.tasks, key=str):
            wcrt_ms = util.time_to_time(task_results[t].wcrt, common_time_base,
                                        util.ms, 'ceil')
            print("%s: wcrt=%d ms" % (t.name, wcrt_ms))