示例#1
0
def test_fileOutputNoPromo():
    taskset = Taskset(Task(1, 40), Task(4, 42), Task(1, 46), Task(10, 46),
                      Task(28, 60), Task(11, 64))

    def dpInfos():
        sortedTasks = sorted(taskset,
                             key=lambda x: (x.minimalInterArrivalTime, x.wcet))
        for i, task in enumerate(sortedTasks):
            yield task, DualPriorityTaskInfo(i + 1)

    policy = DualPrioritySchedulingPolicy(*dpInfos())
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy)
    testPath = 'test_fileOutputNoPromo.txt'
    sof = DPOutputFile(testPath)
    cleanFile(testPath)
    sof.write(setup)

    expectedFileContent = ('1 40 40 40 1 1\n'
                           '4 42 42 42 2 2\n'
                           '1 46 46 46 3 3\n'
                           '10 46 46 46 4 4\n'
                           '28 60 60 60 5 5\n'
                           '11 64 64 64 6 6\n'
                           '\n')
    with open(testPath) as file:
        fileContent = file.read()
        assert fileContent == expectedFileContent
    cleanFile(testPath)
示例#2
0
def genSetups(file):
    while file:
        pairs = list(genTasks(file))
        if not pairs:
            break
        tasks, dInfos = zip(*pairs)
        taskset = Taskset(*tasks)
        policy = DualPrioritySchedulingPolicy(*pairs)
        yield taskset, policy
示例#3
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
示例#4
0
def baseRMPolicy(taskset):
    sortedTasks = rmSortedTasks(taskset)

    def taskPrios():
        for index, task in enumerate(sortedTasks):
            priority = index + 1
            yield task, DualPriorityTaskInfo(priority)

    policy = DualPrioritySchedulingPolicy(*taskPrios())
    return policy
示例#5
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
示例#6
0
 def _genSetups(self, file):
     while file:
         pairs = list(self._genTasks(file))
         if not pairs:
             break
         tasks, dInfos = zip(*pairs)
         taskset = Taskset(*tasks)
         policy = DualPrioritySchedulingPolicy(*pairs)
         setup = SimulationSetup(taskset,
                                 taskset.hyperperiod,
                                 schedulingPolicy=policy)
         yield setup
示例#7
0
def baseRMRMPolicy(taskset):
    def genPolicy():
        shift = len(taskset)
        rmSortedTaskset = rmSortedTasks(taskset)
        for priority, task in enumerate(rmSortedTaskset):
            tInfo = DualPriorityTaskInfo(priority,
                                         task.minimalInterArrivalTime,
                                         priority - shift)
            yield task, tInfo

    policy = DualPrioritySchedulingPolicy(*genPolicy())
    return policy
示例#8
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()
示例#9
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
示例#10
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
示例#11
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()
示例#12
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()
示例#13
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()
示例#14
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()
示例#15
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
示例#16
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
示例#17
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
示例#18
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()