Пример #1
0
    def collectStat(self, ticks):
        tasks = self.scheduler.getAllTaks()

        alpha = self.scheduler.getAlpha()

        wFeatures = WorkloadFeatures(tasks)
        features = wFeatures.getFeatures()

        objVal = Metric.objFunction(tasks, self.scheduler.getCurTime())

        self.objValFile.write("%d %f\n" % (ticks, objVal))
        self.alphaFile.write("%d %s\n" % (ticks, str(alpha)))
        self.workloadFile.write("%d %s\n" % (ticks, str(features)))
Пример #2
0
 def test_objFunction(self):
     ioList1 = IOList([IO(10, 5), IO(13, 7)])
     ioList2 = IOList([IO(1, 3), IO(2, 6), IO(5, 8), IO(6, 8)])
     t1 = Task("Task 1", 0, 3, 20, ioList1)
     t2 = Task("Task 1", 0, 5, 40, ioList2)
     t1.setUsedCpuTime(14)
     t1.setTimesBlocked(2)
     t1.setTotalReadyWait(4)
     t1.setTimesScheduled(2)
     t2.setUsedCpuTime(7)
     t2.setTimesBlocked(4)
     t2.setTotalReadyWait(4)
     t2.setTimesScheduled(2)
     tasks = [t1, t2]
     self.assertTrue(isclose(11.1428, Metric.objFunction(tasks, 10)))
Пример #3
0
    def probe(self):

        # nothing to do
        if not self._isProbing:
            return False

        tasks = self.scheduler.getAllTaks()

        alpha = self.getCurAlpha()

        # first probe
        if self.alpha is None:
            self.alpha = alpha
            self.scheduler.setAlpha(alpha)
            return False

        wFeatures = WorkloadFeatures(tasks)

        objVal = Metric.objFunction(tasks, self.scheduler.getCurTime())

        self.relation.append((wFeatures, alpha, objVal))

        isOverflow = self.incCurIndices()
        alpha = self.getCurAlpha()

        self.scheduler.setAlpha(alpha)
        self.alpha = alpha

        # end probing phase
        if isOverflow:
            self.nPasses += 1

            if self.nPasses == WorkloadProber.AlphaMult:
                self._isProbing = False

                return True

        return False