コード例 #1
0
ファイル: taskGenerator.py プロジェクト: dliul/EERT
def generateTasks(utilization, taskNum):
    """
        Generate synthetic taskset based on utilization and task Num
    """
    v = uuniFast(taskNum, utilization)
    taskset = []
    for i in range(len(v)):
        T = periodGenerator(20,200,1)
        C = math.floor(T * v[i])
        if C == 0:
            C = 1
        taskset.append(task(i, C, T))
    return taskset
コード例 #2
0
ファイル: taskGenerator.py プロジェクト: dliul/EERT
def main():
    taskset = []
    taskset.append(task(1,6000,31000,18000))
    taskset.append(task(2,2000,9800,9000))
    taskset.append(task(3,1000,17000,12000))
    taskset.append(task(4,90,4200,3000))
    taskset.append(task(5,8,96,78))
    taskset.append(task(6,2,12,16))
    taskset.append(task(7,10,280,120))
    taskset.append(task(8,26,660,160))

        
    for i in taskset:
        print i.print_task()
    print QPA(taskset)
コード例 #3
0
ファイル: toDo.py プロジェクト: misterrager8/toDo-Py
    def addButtonMouseClicked(self, event):
        taskName = self.taskField.getText()
        notes = self.notesField.getText()

        self.taskField.setText("")
        self.notesField.setText("")

        if taskName == "":
            JOptionPane.showMessageDialog(None, "Empty field")
        else:
            x = task(taskName, notes, currentDate, False)
            taskDB.append(x)
            self.taskTable.getModel().addRow(
                [taskName, notes, currentDate,
                 str(False)])
コード例 #4
0
ファイル: toDo.py プロジェクト: misterrager8/toDo-Py
    def exitButtonMouseClicked(self, event):
        del taskDB[:]
        boolVal = None

        for i in range(0, self.taskTable.getRowCount()):
            if str(self.taskTable.getValueAt(i, 3)) == "False":
                boolVal = 0
            else:
                boolVal = 1

            taskDB.append(
                task(str(self.taskTable.getValueAt(i, 0)),
                     str(self.taskTable.getValueAt(i, 1)),
                     str(self.taskTable.getValueAt(i, 2)), bool(boolVal)))

        csvData = []
        for i in taskDB:
            csvData.append([i.taskName, i.notes, i.dateCreated, int(i.done)])

        with open("toDoList.csv", "wb") as f:
            writer = csv.writer(f)
            writer.writerows(csvData)

        sys.exit()
コード例 #5
0
ファイル: binPacking.py プロジェクト: dliul/EERT
def FFD_split(taskset, clusters):
    tasks = sorted(taskset, key=lambda x: x.utilization, reverse=True)
    clusters.reset_map()
    for t in tasks:
        ##        print t.print_task()
        map_flag = False  # use this flag to check whether the task is mapped
        for p in clusters.get_allProcessors():
            if p.get_totalUtil() + t.get_utilization() <= 1:
                p.map_one_task(t)
                if sa.QPA(p.get_alltasks()) == -1:
                    break
                p.remove_task(t)
            else:
                """
                    1. Set the total Utilization = 0.99, then compute the corresponding wcet for the first
                    part of split task. Derive the respective parameters according to the paper
                """
                # mappedTasks = p.get_alltasks()
                if p.get_split_1():
                    continue
                leftCapacity = 0.99 - p.get_totalUtil()
                wcet_1 = leftCapacity * t.get_period()
                # Once wcet_1 is not equal to 0, the algorithm tries to reduce wcet
                while wcet_1 != 0:
                    spt_1 = task("%s-1" % t.get_id(), wcet_1, t.get_period(), wcet_1, t.get_coefficient())
                    # Check the total utilization less than 1
                    # No split part 1 on the same processor
                    if p.get_totalUtil() + spt_1.get_utilization() <= 1 and not p.get_split_1():
                        p.map_one_task(spt_1)
                        # Use QPA to test the schedulability of the new mapping
                        # variable result is to store the result
                        # if schedulable, it equals -1
                        # if unschedulable, it equals the time instance failing QPA
                        result = sa.QPA(p.get_alltasks())
                        if result == -1:
                            p.set_split_1()
                            # p.map_one_task(spt_1)
                            wcet_2 = t.get_wcet() - wcet_1
                            spt_2 = task("%s-2" % t.get_id(), wcet_2, t.get_period(), wcet_2)
                            for n in clusters.get_allProcessors():
                                if n.get_totalUtil() + spt_2.get_utilization() <= 1 and not spt_1 in n.get_alltasks():
                                    # mapTasks_2 = n.get_alltasks()
                                    n.map_one_task(spt_2)
                                    if sa.QPA(n.get_alltasks()) == -1:
                                        # remove the mapped task
                                        # mapTasks_2.remove(spt_2)
                                        # n.map_one_task(spt_2)
                                        map_flag = True
                                        break
                                    else:
                                        n.remove_task(spt_2)
                            break
                        else:
                            # cannot pass the QPA test
                            # c1 = (result - oth)/ math.ceil((result + i.get_period() - c1) / i.get_period()) - 1
                            oth = sum(
                                [
                                    (math.ceil((result + i.get_period() - i.get_deadline()) / i.get_period()))
                                    * i.get_wcet()
                                    for i in p.get_alltasks()
                                    if i != spt_1
                                ]
                            )
                            wcet_1 = compute_new_wcet(oth, spt_1, result)
                            p.remove_task(spt_1)
                    else:
                        if p.get_split_1():
                            break
                if map_flag:
                    break  # complete the mapping
    return clusters
コード例 #6
0
ファイル: binPacking.py プロジェクト: dliul/EERT
def main():
    proc_test = processor(1, "ARM Cortex A15", 3.0e-9, 2.261, 0.5, [1000, 2000, 3000])
    proc_test.map_one_task(task(1, 6000, 31000, 18000))
    proc_test.map_one_task(task(2, 2000, 9800, 9000))
コード例 #7
0
ファイル: binPacking.py プロジェクト: dliul/EERT
def FFD_split_after(taskset, clusters):
    mapped = []
    # sorted in order of decreasing utilization
    tasks = sorted(taskset, key=lambda x: x.utilization, reverse=True)
    # need to reset clusters in order to remove the previous mapping results
    clusters.reset_map()
    for p in clusters.get_allProcessors():
        """
            First, map as many tasks as possible to processor p
        """
        for t in tasks:
            if not t.get_id() in mapped and p.get_totalUtil() + t.get_utilization() <= 1:
                p.map_one_task(t)
                mapped.append(t.get_id())
        """
            Second, start to split one task
        """
        for t in tasks:
            if not t.get_id() in mapped:
                leftCapacity = 0.99 - p.get_totalUtil()
                wcet_1 = leftCapacity * t.get_period()
                # Once wcet_1 is not equal to 0, the algorithm tries to reduce wcet
                while wcet_1 > 1:
                    spt_1 = task("%s-1" % t.get_id(), wcet_1, t.get_period(), wcet_1, t.get_coefficient())
                    # Check the total utilization less than 1
                    # No split part 1 on the same processor
                    if p.get_totalUtil() + spt_1.get_utilization() <= 1 and not p.get_split_1():
                        p.map_one_task(spt_1)
                        # Use QPA to test the schedulability of the new mapping
                        # variable result is to store the result
                        # if schedulable, it equals -1
                        # if unschedulable, it equals the time instance failing QPA
                        result = sa.QPA(p.get_alltasks())
                        if result == -1:
                            p.set_split_1()
                            # p.map_one_task(spt_1)
                            wcet_2 = t.get_wcet() - wcet_1
                            spt_2 = task("%s-2" % t.get_id(), wcet_2, t.get_period(), wcet_2)
                            for n in clusters.get_allProcessors():
                                if n.get_totalUtil() + spt_2.get_utilization() <= 1 and not spt_1 in n.get_alltasks():
                                    # mapTasks_2 = n.get_alltasks()
                                    n.map_one_task(spt_2)
                                    if sa.QPA(n.get_alltasks()) == -1:
                                        # remove the mapped task
                                        # mapTasks_2.remove(spt_2)
                                        # n.map_one_task(spt_2)
                                        map_flag = True
                                        mapped.append(t.get_id())
                                        break
                                    else:
                                        n.remove_task(spt_2)
                            break
                        else:
                            # cannot pass the QPA test
                            # c1 = (result - oth)/ math.ceil((result + i.get_period() - c1) / i.get_period()) - 1
                            oth = sum(
                                [
                                    (math.ceil((result + i.get_period() - i.get_deadline()) / i.get_period()))
                                    * i.get_wcet()
                                    for i in p.get_alltasks()
                                    if i != spt_1
                                ]
                            )
                            wcet_1 = compute_new_wcet(oth, spt_1, result)
                            p.remove_task(spt_1)
                    else:
                        if p.get_split_1():
                            break
    ##                    if sa.QPA(p.get_alltasks()) != -1:
    ##                        p.get_alltasks().remove(t)
    ##                        mapped.remove(t.get_id())
    ##                        break # move to the next processor
    ##                else:

    return clusters
コード例 #8
0
ファイル: scheduleAnalysis.py プロジェクト: dliul/EERT
def main():
    taskset = []
    taskset.append(task(1,2,12,16))
    print DBF(16984,taskset)
    print compute_dmax(16984,taskset)
    return 0
コード例 #9
0
ファイル: toDo.py プロジェクト: misterrager8/toDo-Py
    def initComponents(self):

        self.bgPanel = JPanel(mouseDragged=self.bgPanelMouseDragged,
                              mousePressed=self.bgPanelMousePressed)
        self.exitButton = JLabel(mouseClicked=self.exitButtonMouseClicked)
        self.addButton = JLabel(mouseClicked=self.addButtonMouseClicked,
                                mouseEntered=self.addButtonMouseEntered,
                                mouseExited=self.addButtonMouseExited)
        self.deleteButton = JLabel(mouseEntered=self.deleteButtonMouseEntered,
                                   mouseExited=self.deleteButtonMouseExited,
                                   mouseClicked=self.deleteButtonMouseClicked)
        self.clearButton = JLabel(mouseClicked=self.clearButtonMouseClicked,
                                  mouseEntered=self.clearButtonMouseEntered,
                                  mouseExited=self.clearButtonMouseExited)
        self.jScrollPane1 = JScrollPane()
        self.taskTable = JTable()
        self.taskField = JTextField(focusGained=self.taskFieldFocusGained)
        self.notesField = JTextField(focusGained=self.notesFieldFocusGained)
        self.taskLabel = JLabel()
        self.notesLabel = JLabel()

        self.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
        self.setUndecorated(True)

        self.bgPanel.setBackground(Color(51, 153, 255))

        self.exitButton.setText("X")
        self.exitButton.setCursor(Cursor(Cursor.HAND_CURSOR))

        self.addButton.setBackground(Color(51, 204, 255))
        self.addButton.setHorizontalAlignment(SwingConstants.CENTER)
        self.addButton.setText("Add Task")
        self.addButton.setCursor(Cursor(Cursor.HAND_CURSOR))
        self.addButton.setOpaque(True)

        self.deleteButton.setBackground(Color(51, 204, 255))
        self.deleteButton.setHorizontalAlignment(SwingConstants.CENTER)
        self.deleteButton.setText("Delete Task")
        self.deleteButton.setCursor(Cursor(Cursor.HAND_CURSOR))
        self.deleteButton.setOpaque(True)

        self.clearButton.setBackground(Color(51, 204, 255))
        self.clearButton.setHorizontalAlignment(SwingConstants.CENTER)
        self.clearButton.setText("Delete All")
        self.clearButton.setCursor(Cursor(Cursor.HAND_CURSOR))
        self.clearButton.setOpaque(True)

        self.taskTable.setModel(
            table.DefaultTableModel([],
                                    ["Task", "Notes", "Date Created", "Done"]))

        self.jScrollPane1.setViewportView(self.taskTable)

        self.taskLabel.setText("Task")

        self.notesLabel.setText("Note(s)")

        bgPanelLayout = GroupLayout(self.bgPanel)
        self.bgPanel.setLayout(bgPanelLayout)
        bgPanelLayout.setHorizontalGroup(
            bgPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(bgPanelLayout.createSequentialGroup().addContainerGap(
            ).addGroup(
                bgPanelLayout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).addGroup(
                        bgPanelLayout.createSequentialGroup().addGap(
                            0, 0, sys.maxint).addComponent(self.exitButton)).
                addGroup(bgPanelLayout.createSequentialGroup().addGroup(
                    bgPanelLayout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.addButton, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, sys.maxint).addComponent(
                                self.deleteButton, GroupLayout.DEFAULT_SIZE,
                                204, sys.maxint).addComponent(
                                    self.clearButton, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.DEFAULT_SIZE, sys.maxint).
                    addGroup(
                        GroupLayout.Alignment.TRAILING,
                        bgPanelLayout.createSequentialGroup().addGroup(
                            bgPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.LEADING,
                                False).addComponent(
                                    self.taskLabel,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    sys.maxint).addComponent(
                                        self.notesLabel,
                                        GroupLayout.DEFAULT_SIZE, 51,
                                        sys.maxint)).
                        addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED).addGroup(
                                bgPanelLayout.createParallelGroup(
                                    GroupLayout.Alignment.LEADING).
                                addComponent(self.taskField).addComponent(
                                    self.notesField)))
                ).addPreferredGap(
                    LayoutStyle.ComponentPlacement.RELATED).addComponent(
                        self.jScrollPane1, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))).addContainerGap()))
        bgPanelLayout.setVerticalGroup(
            bgPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(bgPanelLayout.createSequentialGroup().addContainerGap(
            ).addComponent(self.exitButton).addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED).addGroup(
                    bgPanelLayout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).
                    addGroup(bgPanelLayout.createSequentialGroup().addGroup(
                        bgPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.taskField, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.taskLabel)
                    ).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addGroup(
                            bgPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.notesField,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE).
                            addComponent(self.notesLabel)).addPreferredGap(
                                LayoutStyle.ComponentPlacement.RELATED).
                             addComponent(
                                 self.addButton, GroupLayout.PREFERRED_SIZE,
                                 34,
                                 GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                     LayoutStyle.ComponentPlacement.RELATED,
                                     144, sys.maxint).addComponent(
                                         self.deleteButton,
                                         GroupLayout.PREFERRED_SIZE, 34,
                                         GroupLayout.PREFERRED_SIZE).
                             addPreferredGap(
                                 LayoutStyle.ComponentPlacement.
                                 RELATED).addComponent(
                                     self.clearButton,
                                     GroupLayout.PREFERRED_SIZE, 34,
                                     GroupLayout.PREFERRED_SIZE)).addComponent(
                                         self.jScrollPane1,
                                         GroupLayout.PREFERRED_SIZE, 0,
                                         sys.maxint)).addContainerGap()))

        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setHorizontalGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.bgPanel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE, sys.maxint))
        layout.setVerticalGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.bgPanel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE, sys.maxint))

        self.pack()
        self.setLocationRelativeTo(None)

        with open("toDoList.csv", "r") as f:
            reader = csv.reader(f)
            for row in reader:
                taskDB.append(task(row[0], row[1], row[2], bool(int(row[3]))))

        for i in taskDB:
            self.taskTable.getModel().addRow(
                [i.taskName, i.notes, i.dateCreated,
                 str(i.done)])