Example #1
0
    def setUp(self):
        self.ts = tasks.TaskSystem([
            tasks.SporadicTask(10, 100),
            tasks.SporadicTask(10, 100),
            tasks.SporadicTask(10, 100),
            tasks.SporadicTask(10, 100),
        ])

        r.initialize_resource_model(self.ts)

        # dummy response-time guess
        for t in self.ts:
            t.response_time = 40

        # every task holds the resource for up to 1ms
        for t in self.ts:
            t.resmodel[0].add_request(1)

        # assign tasks to partitions
        self.ts[0].partition = 0
        self.ts[1].partition = 0
        self.ts[2].partition = 1
        self.ts[3].partition = 1

        self.p0 = tasks.TaskSystem((t for t in self.ts if t.partition == 0))
        self.p1 = tasks.TaskSystem((t for t in self.ts if t.partition == 1))

        # assign preemption levels
        lb.assign_fp_preemption_levels(self.ts)
Example #2
0
 def test_fp_preemption_levels(self):
     self.ts.sort_by_period()
     lb.assign_fp_preemption_levels(self.ts)
     self.assertEqual(self.ts[0].preemption_level, 0)
     self.assertEqual(self.ts[1].preemption_level, 1)
     self.assertEqual(self.ts[2].preemption_level, 2)
     self.assertEqual(self.ts[3].preemption_level, 3)
Example #3
0
def yang(app):
    t_list = []
    for ti in range(len(app.tasks)):
        response_time = app.tasks[ti].response_time()
        t_list.append(tasks.SporadicTask(response_time, response_time * 1000))
    ts = tasks.TaskSystem(t_list)
    fp.bound_response_times(1, ts)

    resources.initialize_resource_model(ts)
    for ti in range(len(app.tasks)):
        for cs in app.tasks[ti].cs:
            ts[ti].resmodel[cs.resource].add_request(cs.duration)
    for t in ts:
        t.partition = 0
    bounds.assign_fp_preemption_levels(ts)

    r_but = buttazzo(a)

    res = bounds.apply_pip_bounds(ts, 1)
    ret = {}
    for n in range(len(app.tasks) -
                   1):  # the blocking time of last task is always 0
        costH = 0
        for h in range(n):
            costH += ts[h].cost
        y_Bn = res.get_blocking_term(
            n) - costH  #cost of all the processes with higher priority

        if y_Bn > r_but[n][0]:
            feasible = False
        else:
            _, feasible, _ = schedule(app, app.tasks[n], r_but[n][1])
        ret[n] = (y_Bn, feasible)
    return ret
Example #4
0
    def setUp(self):
        self.ts = tasks.TaskSystem([
                tasks.SporadicTask(10,  100),
                tasks.SporadicTask(10,  100),
                tasks.SporadicTask(10,  100),
                tasks.SporadicTask(10,  100),
            ])

        r.initialize_resource_model(self.ts)

        # dummy response-time guess
        for t in self.ts:
            t.response_time = 40

        # every task holds the resource for up to 1ms
        for t in self.ts:
            t.resmodel[0].add_request(1)

        # assign tasks to partitions
        self.ts[0].partition = 0
        self.ts[1].partition = 0
        self.ts[2].partition = 1
        self.ts[3].partition = 1

        self.p0 = tasks.TaskSystem((t for t in self.ts if t.partition == 0))
        self.p1 = tasks.TaskSystem((t for t in self.ts if t.partition == 1))

        # assign preemption levels
        lb.assign_fp_preemption_levels(self.ts)
Example #5
0
 def setUp(self):
     self.ts = tasks.TaskSystem([
             tasks.SporadicTask(1,  4),
             tasks.SporadicTask(1,  5),
             tasks.SporadicTask(3,  9),
             tasks.SporadicTask(3, 18),
         ])
     self.ts_ = self.ts.copy()
     r.initialize_resource_model(self.ts)
     for i, t in enumerate(self.ts):
         t.partition = i % 2
         t.response_time = t.period
         t.resmodel[0].add_request(1)
         t.resmodel[1].add_request(1)
     lb.assign_fp_preemption_levels(self.ts)
Example #6
0
    def setUp(self):
        mscale = 100
        self.ts = tasks.TaskSystem([
                tasks.SporadicTask(17 * mscale,  100 * mscale),
                tasks.SporadicTask(67 * mscale,  340 * mscale),
                tasks.SporadicTask(27 * mscale,  150 * mscale),
            ])

        self.ts[0].partition = 0
        self.ts[1].partition = 1
        self.ts[2].partition = 0
        self.ts.assign_ids()

        r.initialize_resource_model(self.ts)
        lb.assign_fp_preemption_levels(self.ts)

        self.ts[0].resmodel[0].add_read_request(1 * mscale)
        self.ts[1].resmodel[0].add_read_request(1 * mscale)
        self.ts[2].resmodel[0].add_write_request(1 * mscale)
Example #7
0
    def setUp(self):
        mscale = 100
        self.ts = tasks.TaskSystem([
                tasks.SporadicTask( 17 * mscale,  100 * mscale),
                tasks.SporadicTask( 64 * mscale,  132 * mscale),
                tasks.SporadicTask( 67 * mscale,  340 * mscale),
                tasks.SporadicTask( 74 * mscale,  137 * mscale),
                tasks.SporadicTask( 31 * mscale,  249 * mscale),
                tasks.SporadicTask( 47 * mscale,  115 * mscale),
                tasks.SporadicTask( 27 * mscale,  150 * mscale),
                tasks.SporadicTask( 53 * mscale,  424 * mscale),
                tasks.SporadicTask(192 * mscale,  884 * mscale),
            ])

        self.ts[0].partition = 0
        self.ts[1].partition = 1
        self.ts[2].partition = 2
        self.ts[3].partition = 3
        self.ts[4].partition = 4

        self.ts[5].partition = 0
        self.ts[6].partition = 0

        self.ts[7].partition = 2
        self.ts[8].partition = 4
        self.ts.assign_ids()

        r.initialize_resource_model(self.ts)
        lb.assign_fp_preemption_levels(self.ts)

        self.ts[0].resmodel[0].add_read_request(1 * mscale)
        self.ts[1].resmodel[0].add_read_request(1 * mscale)
        self.ts[2].resmodel[0].add_read_request(1 * mscale)
        self.ts[3].resmodel[0].add_read_request(1 * mscale)
        self.ts[4].resmodel[0].add_read_request(1 * mscale)

        self.ts[6].resmodel[0].add_write_request(1 * mscale)
        self.ts[7].resmodel[0].add_write_request(1 * mscale)
        self.ts[8].resmodel[0].add_write_request(1 * mscale)
Example #8
0
def generate_taskset(num_cpus=4, util_per_cpu=0.5, tasks_per_cpu=3, req_prob=0.5,
                     min_req_len=50, max_req_len=250):
    ts = emstada.gen_taskset('uni-broad', 'logunif', num_cpus * tasks_per_cpu,
                             num_cpus * util_per_cpu)

    ts.sort_by_period()
    ts.assign_ids()
    r.initialize_resource_model(ts)
    lb.assign_fp_preemption_levels(ts)

    for t in ts:
        # randomly partition
#         t.partition = random.randint(0, num_cpus - 1)
        # randomly assign requests
        if random.random() < req_prob:
            t.resmodel[0].add_write_request(random.randint(min_req_len, max_req_len))

    bins = worst_fit_decreasing(ts, num_cpus, weight=lambda t: t.utilization())
    for cpu, tasks in enumerate(bins):
        for t in tasks:
            t.partition = cpu

    return ts
    def setUp(self):
        self.trivial_ts = tasks.TaskSystem([
                tasks.SporadicTask(25,  150),
                tasks.SporadicTask(30,  200),
                tasks.SporadicTask(60,  800),
                tasks.SporadicTask(30,  550),
                tasks.SporadicTask(200, 1000),
                tasks.SporadicTask(100, 825),
                tasks.SporadicTask(50, 1100),
            ])
        self.trivial_num_cpus = 2

        r.initialize_resource_model(self.trivial_ts)
        lb.assign_fp_preemption_levels(self.trivial_ts)

        for i, t in enumerate(self.trivial_ts):
            t.partition = 0
            t.response_time = 4*t.cost


        self.trivial_ts[0].resmodel[1].add_request(5)
        self.trivial_ts[0].resmodel[1].add_request(5)
        self.trivial_ts[0].resmodel[1].add_request(5)

        self.trivial_ts[1].resmodel[2].add_request(10)
        self.trivial_ts[1].resmodel[3].add_request(10)

        self.trivial_ts[2].resmodel[1].add_request(10)
        self.trivial_ts[2].resmodel[2].add_request(5)

        self.trivial_ts[3].resmodel[1].add_request(15)

        self.trivial_ts[4].resmodel[2].add_request(10)
        self.trivial_ts[4].resmodel[3].add_request(10)
        self.trivial_ts[4].resmodel[1].add_request(5)

        self.trivial_ts[5].resmodel[4].add_request(8)
Example #10
0
    def setUp(self):
        self.t1 = tasks.SporadicTask(10, 100)
        self.t2 = tasks.SporadicTask(25, 200)
        self.t3 = tasks.SporadicTask(33, 33)
        self.ts = tasks.TaskSystem([self.t1, self.t2, self.t3])

        self.ts.assign_ids()
        lb.assign_fp_preemption_levels(self.ts)

        for t in self.ts:
            t.response_time = t.period
            t.partition =  t.id % 2

        self.ts_no_req = self.ts.copy()

        r.initialize_resource_model(self.ts)
        r.initialize_resource_model(self.ts_no_req)

        self.t1.resmodel[0].add_request(1)
        self.t2.resmodel[0].add_request(2)
        self.t3.resmodel[0].add_request(3)

        # only one resource, assigned to the first processor
        self.resource_locality = { 0: 0 }
Example #11
0
 def test_cpp_bridge(self):
     lb.assign_fp_preemption_levels(self.ts)
     self.assertIsNotNone(lb.get_cpp_model(self.ts))
     self.assertIsNotNone(lb.get_cpp_model_rw(self.ts))
Example #12
0
    def setUp(self):
        xml = StringIO.StringIO(TASKSET)
        self.ts = ser.load(xml)

        lb.assign_fp_preemption_levels(self.ts)