예제 #1
0
def test_simulationWithAggregators():
    aggregators = (AggregatorTag.PreemptionTime, AggregatorTag.ExecutionTime,
                   AggregatorTag.PreemptionCount)

    for setup in genSetups(50, aggregators):
        run = SimulationRun(setup)
        run.execute()
예제 #2
0
def test_executionTimeStats():
    longTask = Task(20, 50, FixedArrivalDistribution(50), displayName='long')
    shortTask = Task(1, 5, FixedArrivalDistribution(5), displayName='short')

    taskset = Taskset(longTask, shortTask)
    setup = SimulationSetup(taskset, time=29)
    run = SimulationRun(setup)
    result = run.result()
    stats = SimulationStatistics(result)
    execTime = stats.totalExecutionTime()
    assert execTime == 26
예제 #3
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()
예제 #4
0
def test_executionTimeAggregator():
    longTask = Task(20, 50, FixedArrivalDistribution(50), displayName='long')
    shortTask = Task(1, 5, FixedArrivalDistribution(5), displayName='short')

    taskset = Taskset(longTask, shortTask)
    setup = SimulationSetup(taskset,
                            time=29,
                            aggregatorTags=[AggregatorTag.ExecutionTime])
    run = SimulationRun(setup)
    result = run.result()
    aggregateExecTime = result.aggregateStat(AggregatorTag.ExecutionTime)
    assert aggregateExecTime == 26
예제 #5
0
def test_counterExample1():
    t1 = Task(23, 40)
    t2 = Task(23, 58)
    t3 = Task(1, 60)
    taskset = Taskset(t1, t2, t3)

    dPolicy = dichotomicPromotionSearch(taskset)
    dSetup = SimulationSetup(taskset,
                             taskset.hyperperiod,
                             schedulingPolicy=dPolicy,
                             trackHistory=True,
                             trackPreemptions=False)
    dHistory = SimulationRun(dSetup).result().history
    assert not dHistory.hasDeadlineMiss()
예제 #6
0
def test_dajamPromo1():
    t1 = Task(3, 6)
    t2 = Task(2, 8)
    t3 = Task(3, 12)
    taskset = Taskset(t1, t2, t3)

    policy = dajamPromotions(taskset)

    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=False,
                            trackPreemptions=False)
    history = SimulationRun(setup).result().history
    assert not history.hasDeadlineMiss()
예제 #7
0
def test_bwPolicy1():
    t1 = Task(3, 6)
    t2 = Task(2, 8)
    t3 = Task(3, 12)
    taskset = Taskset(t1, t2, t3)

    bwPolicy = burnsWellingsPolicy(taskset)

    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=bwPolicy,
                            trackHistory=True,
                            trackPreemptions=False)
    history = SimulationRun(setup).result().history
    assert not history.hasDeadlineMiss()
예제 #8
0
def test_simulationResult():
    t1 = Task(1, 2, FixedArrivalDistribution(3), LogPreemptionCost(1, 0.1),
              displayName='t1')
    t2 = Task(4, 5, PoissonArrivalDistribution(6, 2), FixedPreemptionCost(3),
              displayName='t2')
    taskset = Taskset(t1, t2)
    setup = SimulationSetup(taskset, time=200)
    run = SimulationRun(setup)
    result = run.result()

    with TemporaryDirectory() as testdir:
        dataEnv = FileEnv(testdir)
        key = 'test'
        dataEnv.save(result, key)
        copy = dataEnv.load(key)
    assert(copy == result)
예제 #9
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()
예제 #10
0
def test_freePreemptionsTotals():
    longTask = Task(20, 50, FixedArrivalDistribution(50), displayName='long')
    shortTask = Task(1, 5, FixedArrivalDistribution(5), displayName='short')

    taskset = Taskset(longTask, shortTask)
    setup = SimulationSetup(taskset, time=50, trackPreemptions=True)
    run = SimulationRun(setup)
    result = run.result()
    stats = SimulationStatistics(result)
    nbPreemptions = stats.nbOfPreemptions
    expectedNbPreemptions = 4
    preemptionCost = stats.totalPreemptionTime
    expectedPreemptionCost = 0

    assert nbPreemptions == expectedNbPreemptions
    assert preemptionCost == expectedPreemptionCost
예제 #11
0
    def _buildOptimised(self):
        _, t2, _ = tuple(rmSortedTasks(self.taskset))
        rmPolicy = baseRMPolicy(self.taskset)
        hyperperiod = self.taskset.hyperperiod
        aggregators = (AggregatorTag.LongestResponseTime, )
        setup = SimulationSetup(self.taskset,
                                time=hyperperiod,
                                schedulingPolicy=rmPolicy,
                                aggregatorTags=aggregators)
        result = SimulationRun(setup).result()
        longestResponseTimes = result.aggregateStat(
            AggregatorTag.LongestResponseTime)
        t2RT = longestResponseTimes[t2]
        period2 = t2.minimalInterArrivalTime

        policy = self._buildWithPromo2(period2 - t2RT)
        return policy
예제 #12
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
예제 #13
0
def findFirstDeadlineMiss(taskset, policy):
    setup = SimulationSetup(taskset,
                            time=taskset.hyperperiod,
                            schedulingPolicy=policy,
                            deadlineMissFilter=True,
                            trackHistory=False,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    return history.firstDeadlineMiss()
예제 #14
0
def execFunction(setup):
    taskset, policy = setup
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=False,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    return history, policy, taskset
예제 #15
0
def getHistory(taskset, policy, *stopTask):
    dmFilter = DeadlineMissFilter(False, *stopTask)

    setup = SimulationSetup(taskset,
                            time=taskset.hyperperiod,
                            deadlineMissFilter=dmFilter,
                            trackHistory=False,
                            trackPreemptions=False,
                            schedulingPolicy=policy)
    result = SimulationRun(setup).result()
    return result.history
예제 #16
0
def test_preemptionNbAggregator():
    longTask = Task(20,
                    50,
                    FixedArrivalDistribution(50),
                    FixedPreemptionCost(2),
                    displayName='long')
    shortTask = Task(1,
                     5,
                     FixedArrivalDistribution(5),
                     FixedPreemptionCost(2),
                     displayName='short')

    taskset = Taskset(longTask, shortTask)
    setup = SimulationSetup(taskset,
                            time=29,
                            aggregatorTags=[AggregatorTag.PreemptionCount])
    run = SimulationRun(setup)
    result = run.result()
    aggregateNbPreempt = result.aggregateStat(AggregatorTag.PreemptionCount)
    assert aggregateNbPreempt == 5
예제 #17
0
def assertGDF(taskset, success=True):
    policy = greedyDeadlineFixPolicy(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            deadlineMissFilter=True)
    result = SimulationRun(setup).result()
    history = result.history
    if success:
        assert not history.hasDeadlineMiss()
    else:
        assert history.hasDeadlineMiss()
예제 #18
0
def execFunction(taskset, lpvPrep):
    policy = rmLaxityPromotions(taskset, lpvPrep=lpvPrep)
    if len(policy.promotedTasks()) > 0:
        setup = SimulationSetup(taskset,
                                taskset.hyperperiod,
                                schedulingPolicy=policy,
                                trackHistory=False,
                                trackPreemptions=False)
        result = SimulationRun(setup).result()
        history = result.history
    else:
        history = True
    return history, policy, taskset
예제 #19
0
def test_example7():
    t1 = Task(1, 5)
    t2 = Task(6, 39)
    t3 = Task(16, 39)
    taskset = Taskset(t1, t2, t3)

    policy = rmLaxityPromotions(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=True,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert not history.hasDeadlineMiss()
예제 #20
0
def assertRMm1RM(taskset, success=True):
    raised = False
    try:
        policy = dichotomicPromotionSearch(taskset)
        if success:
            setup = SimulationSetup(taskset,
                                    taskset.hyperperiod,
                                    schedulingPolicy=policy,
                                    deadlineMissFilter=True)
            result = SimulationRun(setup).result()
            history = result.history
            assert not history.hasDeadlineMiss()
    except ValidPromotionNotFound:
        raised = True
    assert not raised if success else raised
예제 #21
0
def test_example5AnyPromo():
    t1 = Task(13, 51)
    t2 = Task(83, 128)
    t3 = Task(16, 183)
    taskset = Taskset(t1, t2, t3)

    policy = dichotomicPromotionSearch(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=False,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert not history.hasDeadlineMiss()
예제 #22
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()
예제 #23
0
def test_laurent1():
    t1 = Task(2, 11, displayName='t1')
    t2 = Task(9, 19, displayName='t2')
    t3 = Task(7, 21, displayName='t3')
    taskset = Taskset(t1, t2, t3)

    policy = rmLaxityPromotions(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=True,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert not history.hasDeadlineMiss()
예제 #24
0
def test_damien4():
    t1 = Task(8, 20, displayName='t1')
    t2 = Task(15, 28, displayName='t2')
    t3 = Task(8, 136, displayName='t3')
    taskset = Taskset(t1, t2, t3)

    policy = dichotomicPromotionSearch(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=True,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert not history.hasDeadlineMiss()
예제 #25
0
def test_example6():
    t1 = Task(22, 87)
    t2 = Task(131, 237)
    t3 = Task(53, 280)
    taskset = Taskset(t1, t2, t3)

    policy = rmLaxityPromotions(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=False,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert history.hasDeadlineMiss()
예제 #26
0
def test_damien1():
    t1 = Task(1, 4, displayName='t1')
    t2 = Task(2, 15, displayName='t2')
    t3 = Task(14, 23, displayName='t3')
    t4 = Task(1, 1380, displayName='t4')
    taskset = Taskset(t1, t2, t3, t4)

    policy = rmLaxityPromotions(taskset)
    setup = SimulationSetup(taskset,
                            taskset.hyperperiod,
                            schedulingPolicy=policy,
                            trackHistory=True,
                            trackPreemptions=False)
    result = SimulationRun(setup).result()
    history = result.history
    assert not history.hasDeadlineMiss()
예제 #27
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()
예제 #28
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()
예제 #29
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
예제 #30
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()