Example #1
0
 def _buildTask(c, t, d, s, p1, p2):
     assert t == d
     task = Task(int(c), int(d))
     assert p1 >= p2
     if p1 == p2:
         dualPriorityInfo = DualPriorityTaskInfo(int(p1))
     else:
         dualPriorityInfo = DualPriorityTaskInfo(int(p1), int(s), int(p2))
     return task, dualPriorityInfo
Example #2
0
    def _buildWithPromo2(self, promo2):
        t1, t2, t3 = tuple(rmSortedTasks(self.taskset))

        promo1 = t1.minimalInterArrivalTime - t1.wcet
        schedulerInfo1 = DualPriorityTaskInfo(3, promo1, -3)
        schedulerInfo2 = DualPriorityTaskInfo(2, promo2, -2)
        schedulerInfo3 = DualPriorityTaskInfo(1)
        policy = DualPrioritySchedulingPolicy(
            (t1, schedulerInfo1), (t2, schedulerInfo2), (t3, schedulerInfo3))
        return policy
Example #3
0
def buildTask(c, t, d, s, p1, p2):
    assert t == d
    task = Task(int(c), int(d))
    if p1 < p2:
        raise AssertionError
    elif p1 == p2:
        dualPriorityInfo = DualPriorityTaskInfo(int(p1))
    else:
        dualPriorityInfo = DualPriorityTaskInfo(int(p1), int(s), int(p2))
    return task, dualPriorityInfo
Example #4
0
def test_simuDualPrio():
    t1 = Task(5, 10)
    t2 = Task(10, 20)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(11, 5, 1)),
                                          (t2, DualPriorityTaskInfo(12, 10, 2)))
    taskset = Taskset(t1, t2)
    setup = SimulationSetup(taskset,
                            time=40,
                            schedulingPolicy=policy)
    run = SimulationRun(setup)
    run.execute()
Example #5
0
def test_analysisBW1():
    t1 = Task(3, 6)
    t2 = Task(2, 8)
    t3 = Task(3, 12)

    taskset = Taskset(t1, t2, t3)
    policy = dichotomicPromotionSearch(taskset)

    expectedPolicy = DualPrioritySchedulingPolicy(
          (t1, DualPriorityTaskInfo(3, 3, -3)),
          (t2, DualPriorityTaskInfo(2, 4, -2)),
          (t3, DualPriorityTaskInfo(1)))
    assert expectedPolicy == policy
Example #6
0
def test_analysisBW3():
    t1 = Task(4, 16)
    t2 = Task(5, 20)
    t3 = Task(11, 28)
    t4 = Task(6, 56)

    taskset = Taskset(t1, t2, t3, t4)
    policy = dichotomicPromotionSearch(taskset)

    expectedPolicy = DualPrioritySchedulingPolicy(
          (t1, DualPriorityTaskInfo(4, 8, -4)),
          (t2, DualPriorityTaskInfo(3, 10, -3)),
          (t3, DualPriorityTaskInfo(2, 3, -2)),
          (t4, DualPriorityTaskInfo(1)))
    assert policy == expectedPolicy
Example #7
0
def test_firstT2Job1Standard():
    t1 = Task(2, 12, displayName='t1')
    t2 = Task(17, 33, displayName='t2')
    t3 = Task(13, 57, displayName='t3')
    taskset = Taskset(t1, t2, t3)

    policy = DualPrioritySchedulingPolicy(
          (t1, DualPriorityTaskInfo(3, 10, -3)),
          (t2, DualPriorityTaskInfo(2, 14, -2)),
          (t3, DualPriorityTaskInfo(1)))
    setup = SimulationSetup(taskset,
                            time=taskset.hyperperiod,
                            schedulingPolicy=policy,
                            deadlineMissFilter=True)
    result = SimulationRun(setup).result()
Example #8
0
def test_dualPriorityBW1_2():
    t1 = Task(3, 6)
    t2 = Task(2, 8)
    t3 = Task(3, 12)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(1)),
                                          (t2, DualPriorityTaskInfo(3)),
                                          (t3, DualPriorityTaskInfo(4, 10, 2)))
    taskset = Taskset(t1, t2, t3)
    hyperperiod = 24
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    run = SimulationRun(setup)
    result = run.result()
    assert not result.history.hasDeadlineMiss()
Example #9
0
 def genPolicy():
     shift = len(taskset)
     rmSortedTaskset = rmSortedTasks(taskset)
     for priority, task in enumerate(rmSortedTaskset):
         tInfo = DualPriorityTaskInfo(priority,
                                      task.minimalInterArrivalTime,
                                      priority - shift)
         yield task, tInfo
Example #10
0
def test_analysisBW4():
    t1 = Task(1, 4)
    t2 = Task(1, 6)
    t3 = Task(3, 12)
    t4 = Task(5, 30)
    t5 = Task(6, 36)

    taskset = Taskset(t1, t2, t3, t4, t5)
    policy = dichotomicPromotionSearch(taskset)

    expectedPolicy = DualPrioritySchedulingPolicy(
          (t1, DualPriorityTaskInfo(5, 2, -5)),
          (t2, DualPriorityTaskInfo(4, 3, -4)),
          (t3, DualPriorityTaskInfo(3, 6, -3)),
          (t4, DualPriorityTaskInfo(2, 15, -2)),
          (t5, DualPriorityTaskInfo(1)))
    assert policy == expectedPolicy
Example #11
0
def test_dualPriorityBW3_3():
    t1 = Task(4, 16)
    t2 = Task(5, 20)
    t3 = Task(11, 28)
    t4 = Task(6, 56)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(4)),
                                          (t2, DualPriorityTaskInfo(5, 19, 3)),
                                          (t3, DualPriorityTaskInfo(6, 19, 2)),
                                          (t4, DualPriorityTaskInfo(7, 50, 1)))
    taskset = Taskset(t1, t2, t3, t4)
    hyperperiod = 560
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    result = SimulationRun(setup).result()
    assert not result.history.hasDeadlineMiss()
Example #12
0
def test_dualPriorityBW2_4():
    t1 = Task(3, 12)
    t2 = Task(4, 16)
    t3 = Task(4, 20)
    t4 = Task(6, 20)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(4)),
                                          (t2, DualPriorityTaskInfo(5)),
                                          (t3, DualPriorityTaskInfo(6, 13, 3)),
                                          (t4, DualPriorityTaskInfo(7, 14, 2)))
    taskset = Taskset(t1, t2, t3, t4)
    hyperperiod = 240
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    result = SimulationRun(setup).result()
    assert not result.history.hasDeadlineMiss()
Example #13
0
def test_dualPriorityBW1_1():
    t1 = Task(3, 6)
    t2 = Task(2, 8)
    t3 = Task(3, 12)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(2)),
                                          (t2, DualPriorityTaskInfo(3)),
                                          (t3, DualPriorityTaskInfo(4)))

    taskset = Taskset(t1, t2, t3)
    hyperperiod = 24
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    run = SimulationRun(setup)
    result = run.result()
    expectedMisses = {DeadlineMiss(t3, 0)}
    assert result.history.deadlineMisses(hyperperiod) == expectedMisses
Example #14
0
def test_dualPriorityBW3_1():
    t1 = Task(4, 16)
    t2 = Task(5, 20)
    t3 = Task(11, 28)
    t4 = Task(6, 56)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(4)),
                                          (t2, DualPriorityTaskInfo(5)),
                                          (t3, DualPriorityTaskInfo(6)),
                                          (t4, DualPriorityTaskInfo(7)))
    taskset = Taskset(t1, t2, t3, t4)
    hyperperiod = 560
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    result = SimulationRun(setup).result()
    expectedMiss = DeadlineMiss(t3, 0)
    assert result.history.firstDeadlineMiss() == expectedMiss
Example #15
0
def test_dualPriorityBW4_3():
    t1 = Task(1, 4)
    t2 = Task(1, 6)
    t3 = Task(3, 12)
    t4 = Task(5, 30)
    t5 = Task(6, 36)

    policy = DualPrioritySchedulingPolicy((t1, DualPriorityTaskInfo(4)),
                                          (t2, DualPriorityTaskInfo(5)),
                                          (t3, DualPriorityTaskInfo(6)),
                                          (t4, DualPriorityTaskInfo(7, 29, 4)),
                                          (t5, DualPriorityTaskInfo(8, 23, 6)))
    taskset = Taskset(t1, t2, t3, t4, t5)
    hyperperiod = 180
    setup = SimulationSetup(taskset,
                            time=hyperperiod,
                            schedulingPolicy=policy)
    result = SimulationRun(setup).result()
    assert not result.history.hasDeadlineMiss()
Example #16
0
def fixRMRMPolicy(brokenPolicy, deadlineMiss):
    task = deadlineMiss.task
    lowPrio = brokenPolicy.lowPriority(task)
    highPrio = brokenPolicy.highPriority(task)
    promotion = brokenPolicy.promotion(task)
    if promotion == 0:
        raise ValidPromotionNotFound
    newInfo = DualPriorityTaskInfo(lowPrio, promotion - 1, highPrio)
    updatedPolicy = brokenPolicy.withUpdate((task, newInfo))
    return updatedPolicy
Example #17
0
def test_fileInput():
    Task.resetIdCounter()
    sif = DPInputFile('${HOME}/git/rt/tasksets/test.txt')
    setups = sif.lazyRead()
    setup1 = next(setups)
    t11 = Task(1, 5, uniqueId=0)
    t12 = Task(1, 3, uniqueId=1)
    taskset1 = Taskset(t11, t12)
    policy1 = DualPrioritySchedulingPolicy((t11, DualPriorityTaskInfo(2)),
                                           (t12, DualPriorityTaskInfo(1)))
    expected1 = SimulationSetup(taskset1,
                                taskset1.hyperperiod,
                                schedulingPolicy=policy1)
    assert setup1 == expected1

    setup2 = next(setups)
    t21 = Task(2, 12, uniqueId=2)
    t22 = Task(17, 33, uniqueId=3)
    t23 = Task(13, 57, uniqueId=4)
    taskset2 = Taskset(t21, t22, t23)
    policy2 = DualPrioritySchedulingPolicy(
        (t21, DualPriorityTaskInfo(3, 10, -3)),
        (t22, DualPriorityTaskInfo(2, 14, -2)), (t23, DualPriorityTaskInfo(1)))
    expected2 = SimulationSetup(taskset2,
                                taskset2.hyperperiod,
                                schedulingPolicy=policy2)
    assert setup2 == expected2

    setup3 = next(setups)
    t31 = Task(3, 12, uniqueId=5)
    t32 = Task(4, 16, uniqueId=6)
    t33 = Task(4, 20, uniqueId=7)
    t34 = Task(6, 20, uniqueId=8)
    taskset3 = Taskset(t31, t32, t33, t34)
    policy3 = DualPrioritySchedulingPolicy(
        (t31, DualPriorityTaskInfo(4, 12, -4)),
        (t32, DualPriorityTaskInfo(3, 9, -3)), (t33, DualPriorityTaskInfo(2)),
        (t34, DualPriorityTaskInfo(1)))
    expected3 = SimulationSetup(taskset3,
                                taskset3.hyperperiod,
                                schedulingPolicy=policy3)
    assert setup3 == expected3
Example #18
0
 def dpInfos():
     sortedTasks = sorted(taskset,
                          key=lambda x: (x.minimalInterArrivalTime, x.wcet))
     for i, task in enumerate(sortedTasks):
         yield task, DualPriorityTaskInfo(i + 1)
Example #19
0
 def taskPrios():
     for index, task in enumerate(sortedTasks):
         priority = index + 1
         yield task, DualPriorityTaskInfo(priority)