Exemplo n.º 1
0
def generateTaskSetBase(taskPeriod, taskUtil, systemSize):
    tg = tasks.TaskGenerator(taskPeriod, taskUtil)
    ts = tg.make_task_set(max_tasks=systemSize)
    ts = [t for t in ts if t.cost != 0]
    " scale the parameters such that we always consider times in microseconds "
    for i in range(0, len(ts)):
        ts[i].id = i
        ts[i].cost *= 1000
        ts[i].period *= 1000
    " initialize the resources in the model "
    resources.initialize_resource_model(ts)
    return ts
Exemplo n.º 2
0
    def _create_taskset(self, params, periods, utils, max_util = None):

        if 'max_util' in params:
            max_util = float(params['max_util'])
            if (max_util < 0.0) or (max_util > float(params['cpus'])):
                raise Exception('Incorrect max_util')

            tg = tasks.TaskGenerator(period=periods, util=utils)
            ts = tg.make_task_set(max_tasks = None, max_util=max_util, squeeze=True)
            ts = [t for t in ts if t.cost > 0]
            #print ('#%d tasks' % len(ts))
            return ts
        else:
            return super(RUNGenerator, self)._create_taskset(params, periods, utils, float(params['cpus']))
Exemplo n.º 3
0
    def test_generator(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(list(g.tasks(max_tasks=10))), 10)
        self.assertLessEqual(len(list(g.tasks(max_util=10))), 100)

        ts1 = g.tasks(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.tasks(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(sum([t.utilization() for t in ts1]),
                               10,
                               places=2)
        self.assertNotEqual(sum([t.utilization() for t in ts2]), 10)
Exemplo n.º 4
0
    def test_task_system_creation(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(g.make_task_set(max_tasks=10)), 10)
        self.assertLessEqual(len((g.make_task_set(max_util=10))), 100)

        ts1 = g.make_task_set(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.make_task_set(max_util=10,
                              squeeze=False,
                              time_conversion=ms2us)

        self.assertAlmostEqual(ts1.utilization(), 10, places=2)
        # Not strictly impossible, but very unlikely
        self.assertNotEqual(ts2.utilization(), 10)
Exemplo n.º 5
0
 def _create_taskset(self, params, periods, utils, max_util=None):
     tg = tasks.TaskGenerator(period=periods, util=utils)
     ts = []
     tries = 0
     while len(ts) != params['tasks'] and tries < 100:
         ts = tg.make_task_set(max_tasks=params['tasks'], max_util=max_util)
         tries += 1
     if len(ts) != params['tasks']:
         print(("Only created task set of size %d < %d for params %s. " +
                "Switching to light utilization.") %
               (len(ts), params['tasks'], params))
         print("Switching to light util. This usually means the " +
               "utilization distribution is too agressive.")
         return self._create_taskset(params, periods,
                                     NAMED_UTILIZATIONS['uni-light'],
                                     max_util)
     return ts
Exemplo n.º 6
0
    def _create_taskset(self, params, periods, utils, max_util=None):
        if 'max_util' in params:
            max_util = float(params['max_util'])
            if (max_util < 0.0) or (max_util > float(params['cpus'])):
                raise Exception('Incorrect max_util')

            tries = 0
            tg = tasks.TaskGenerator(period=periods, util=utils)
            print max_util
            ts = tg.make_task_set(max_tasks=None, max_util=max_util)
            while len(ts) <= 0 and tries < 100:
                print 'try: {0}'.format(tries)
                ts = tg.make_task_set(max_tasks=None, max_util=max_util)
                tries += 1
            print ts.utilization()
            return ts

        else:
            return super(GedfGenerator,
                         self)._create_taskset(params, periods, utils,
                                               float(params['cpus']))
    def __init__(self, periodDistr, utilDistr, resDistr, resWeight, resNumber,
                 reqNumber, utilLimit, cpuLimit):
        ''' periodDistr and utilDistr functions used to generate independent task set.
        resDistr:  real number in [0, 1], determines the percentage of tasks that use the resource.
        resWeight: real number in (0, 1), determines the time spent in using a resource by a task.
        resNumber: integer representing the number of resources used by the system.
        reqNumber: integer representing the number of requests made towards a resource.
        utilLimit: limit for the total utilization of the system.
        cpuLimit:  number of CPU available to schedule the system
        Resources are distributed sequentially to the tasks until the limit of resDistr is reached. '''
        self._tg = tasks.TaskGenerator(periodDistr, utilDistr)
        self._rd = resDistr
        self._rw = resWeight
        self._rn = resNumber
        self._qn = reqNumber
        self._ul = utilLimit
        self._cl = cpuLimit

        # temporary data structures for support:
        # 1) the task set
        # 2) the servers
        self._ts = []
        self._rs = {}
Exemplo n.º 8
0
def mkgen(utils, periods, deadlines=None):
    if deadlines is None:
        g = gen.TaskGenerator(periods, utils)
    else:
        g = gen.TaskGenerator(periods, utils, deadlines)
    return partial(g.make_task_set)