Ejemplo n.º 1
0
def main():
    if (len(sys.argv) != 3):
        print('usage: lcmTest number1 number2>')
        sys.exit(1)
    n1 = int(sys.argv[1])
    n2 = int(sys.argv[2])
    lcm = prime.lcm(n1, n2)
    print(lcm)
        elif len(line) == 4:
            name = 'Task'
        else:
            raise Exception('Invalid tasks.txt file structure')
        if int(line[0]) > 0:
            task_types.append(
                TaskType(period=line[0],
                         release=line[1],
                         execution=line[2],
                         deadline=line[3],
                         name=name))

    #Calculate hyperperiod
    for task_type in task_types:
        hyperperiod.append(task_type.period)
    hyperperiod = lcm(hyperperiod)

    #Sort types rate monotonic
    task_types = sorted(task_types, tasktype_cmp)

    #Create task instances
    for i in xrange(0, hyperperiod):
        for task_type in task_types:
            if (i - task_type.release
                ) % task_type.period == 0 and i >= task_type.release:
                start = i
                end = start + task_type.execution
                priority = start + task_type.deadline
                tasks.append(
                    TaskIns(start=start,
                            end=end,
        line = line.split(' ')  
        for i in range (0,4):
            line[i] = int(line[i])
        if len(line) == 5:
            name = line[4]
        elif len(line) == 4:
            name = 'Task'
        else:
            raise Exception('Invalid tasks.txt file structure')
        if int(line[0])>0:
            task_types.append(TaskType(period=line[0], release=line[1], execution=line[2], deadline=line[3], name=name))
        
    #Calculate hyperperiod
    for task_type in task_types:
        hyperperiod.append(task_type.period)
    hyperperiod = lcm(hyperperiod)

    #Sort types rate monotonic
    task_types = sorted(task_types, tasktype_cmp)


    #Create task instances 
    for i in xrange(0, hyperperiod):
        for task_type in task_types:
            if  (i - task_type.release) % task_type.period == 0 and i >= task_type.release:
                start = i
                end = start + task_type.execution
                priority = start + task_type.deadline - task_type.execution
                tasks.append(TaskIns(start=start, end=end, priority=priority, name=task_type.name))

    #Html output start
Ejemplo n.º 4
0
 def test_lcm(self):
     assert (prime.lcm(30, 18) == 90)