Beispiel #1
0
    def claculate(event):
        if s == "fcfs":
            f1 = fcfs()
            f1.list_process = list_of_process
            f1.calc()

            draw(f1.list_element)
        elif s == "sjf":
            pre = int(pree_entry.get())
            pree_entry.delete(0, END)
            f1 = Sjf()
            f1.preemptive = pre
            f1.list_process = list_of_process
            f1.calc()
            draw(f1.list_element)
        elif s == "priority":
            pre = int(pree_entry.get())
            pree_entry.delete(0, END)
            f1 = priority()
            f1.preemptive = pre
            f1.list_process = list_of_process
            f1.calc()
            draw(f1.list_element)
        elif s == "rr":
            f1 = round()
            f1.list_process = list_of_process
            f1.calc()
            draw(f1.list_element)
Beispiel #2
0
    def claculate(event):
        if s == "fcfs":
            f1 = fcfs()
            f1.list_process = list_of_process
            f1.real()
            f1.calc()
            wt=f1.waiting_time()
            f1.empty()
            draw(f1.list_element,wt)


        elif s == "sjf":
            pre=int(pree_entry.get())
            pree_entry.delete(0, END)
            f1 = Sjf()
            f1.preemptive=pre
            f1.list_process = list_of_process
            f1.real()
            f1.calc()
            wt=f1.waiting_time()
            f1.empty()
            draw(f1.list_element,wt)


        elif s == "priority":
            pre = int(pree_entry.get())
            pree_entry.delete(0, END)
            f1 = priority()
            f1.preemptive = pre
            f1.list_process = list_of_process
            f1.real()
            f1.calc()
            wt=f1.waiting_time()
            f1.empty()
            draw(f1.list_element,wt)

        elif s == "rr":
            q = int(q_entry.get())
            q_entry.delete(0, END)
            f1 = roound()
            f1.list_process = list_of_process
            f1.quantum=q
            f1.real()
            f1.calc()
            wt=f1.waiting_time()
            f1.empty()
            draw(f1.list_element,wt)
Beispiel #3
0
def main():
    print("Starting Simulator")
    parser = argparse.ArgumentParser()
    requiredArgs = parser.add_argument_group('required arguments')
    requiredArgs.add_argument(
        "-n",
        "--jobs",
        metavar="",
        help="Number of Jobs to be run on a scheduling Algorithm",
        type=int,
        required=True,
        action="store")
    requiredArgs.add_argument("-t",
                              "--cputime",
                              metavar="",
                              help="CPU Time",
                              required=True,
                              action="store",
                              type=int)

    args = parser.parse_args()

    njobs = args.jobs
    cpuTime = args.cputime

    if njobs > 0 and cpuTime > 0:
        # call the create jobs methods from the Jobs file

        job_List = Jobs.create_Jobs(njobs)
        print("Started Jobs execution through FCFS Scheduling")
        fcfs_job_list = fcfs().execute_fcfs(njobs, cpuTime, job_List)
        print("Finished Jobs execution through FCFS Scheduling")

        print("Started Jobs execution through Priority Scheduling")
        priority_job_list = priority().execute_priority(
            njobs, cpuTime, job_List)
        print("Finished Jobs execution through Priority Scheduling")

        # Display graphs
        sim = Simulator()
        sim.display_graphs(fcfs_job_list, priority_job_list, njobs)

    print("Simulator Exiting")
    def populate_y_axis_list(self, fcfs_job_list, priority_job_list, cfs_job_list, njobs, time_to_calculate):
        """
        This method calculates either wait time or completion time
        based on value time_to_calculate, and populates the y-axis list
        to draw a graph
        :param fcfs_job_list:
        :param priority_job_list:
        :param linux_job_list:
        :param njobs:
        :param time_to_calculate:
        :return:
        """
        y_axis_list = []
        if str(time_to_calculate).lower() == "wait":
            # Calculate the wait time for each algorithm
            fcfs_wait_time = self.calculate_avg_wait_time(fcfs_job_list, njobs)
            priority_wait_time = self.calculate_avg_wait_time(priority_job_list, njobs)
            cfs_wait_time = self.calculate_avg_wait_time(cfs_job_list, njobs)

            # Append each wait time in the y_axis list
            y_axis_list.append(fcfs_wait_time)
            y_axis_list.append(priority_wait_time)
            y_axis_list.append(cfs_wait_time)

            return y_axis_list

        elif str(time_to_calculate).lower() == "completion":
            # Calculate the completion time for each algorithm
            fcfs_completion_time = self.calculate_completion_time(fcfs_job_list, njobs)
            priority_completion_time = self.calculate_completion_time(priority_job_list, njobs)
            cfs_completion_time = self.calculate_completion_time(cfs_job_list, njobs)

            # Append each completion time in the y_axis list
            y_axis_list.append(fcfs_completion_time)
            y_axis_list.append(priority_completion_time)
            y_axis_list.append(cfs_completion_time)

            return y_axis_list

        elif str(time_to_calculate).lower() == "turnaround":
            # Calculate the turnaround time for each algorithm
            fcfs_turnaround_time = self.calculate_avg_turnaround_time(fcfs_job_list, njobs)
            priority_turnaround_time = self.calculate_avg_turnaround_time(priority_job_list, njobs)
            cfs_turnaround_time = self.calculate_avg_turnaround_time(cfs_job_list, njobs)

            # Append each turnaround time in the y_axis list
            y_axis_list.append(fcfs_turnaround_time)
            y_axis_list.append(priority_turnaround_time)
            y_axis_list.append(cfs_turnaround_time)

            return y_axis_list

        elif str(time_to_calculate).lower() == "throughput":
            # Get the throughput for each algorithm
            fcfs_throughput = deepcopy(fcfs().fcfs_throughput)
            priority_throughput = deepcopy(priority().priority_throughput)
            cfs_throughput = deepcopy(cfs().cfs_throughput)

            # Append each throughput in the y_axis list
            y_axis_list.append(fcfs_throughput)
            y_axis_list.append(priority_throughput)
            y_axis_list.append(cfs_throughput)

            return y_axis_list
Beispiel #5
0
p5.arrival_time = 4
p6.arrival_time = 5
p7.arrival_time = 6
p8.arrival_time = 30

p1.pr = 12
p2.pr = 10
p3.pr = 9
p4.pr = 4
p5.pr = 8
p6.pr = 2
p7.pr = 6
p8.pr = 1

p1.name = 'p1'
p2.name = 'p2'
p3.name = 'p3'
p4.name = 'p4'
p5.name = 'p5'
p6.name = 'p6'
p7.name = 'p7'
p8.name = 'p8'

list_p = [p1, p2, p3, p4, p5, p6, p7, p8]
x = priority()
x.preemptive = 0
x.n = 8
x.list_process = list_p
x.calc()
x.out()