1111class _NonPreemptivePriorityScheduling :
1212
1313 processList = []
14-
14+ process_Timing = {}
1515 # Function to get the user input for processes
1616 def User_Input (self , Num_Process ):
1717 for IDprocess in range (1 , Num_Process + 1 ):
@@ -51,21 +51,21 @@ def Random_Input(self, Num_Process, Max_Burst):
5151
5252 # Execution of the Algorithm
5353 def Execute (self , processList ):
54- table = Table (title = "Non-Preemptive Priority Scheduling" , style = "bold white" )
55- table .add_column ("Process ID" , style = "bold cyan" , justify = "center" )
56- table .add_column ("Arrival Time" , style = "bold cyan" , justify = "center" )
57- table .add_column ("Burst Time" , style = "bold cyan" , justify = "center" )
58- table .add_column ("Priority Level" , style = "bold cyan" , justify = "center" )
59-
60- for process in self .processList :
61- table .add_row (process [0 ], str (process [1 ]), str (process [2 ]), str (process [3 ]))
54+ # Gin comment out ko anay kay dire gamit
55+ # table = Table(title="Non-Preemptive Priority Scheduling", style="bold white")
56+ # table.add_column("Process ID", style="bold cyan", justify="center")
57+ # table.add_column("Arrival Time", style="bold cyan", justify="center")
58+ # table.add_column("Burst Time", style="bold cyan", justify="center")
59+ # table.add_column("Priority Level", style="bold cyan", justify="center")
60+
61+ # for process in self.processList:
62+ # table.add_row(process[0], str(process[1]), str(process[2]), str(process[3]))
63+
6264
63- # console.print(table)
64-
6565 currentTime = 0
6666 ProcessComplete = []
6767 MemoryQueue = []
68-
68+ process_timings = {}
6969 print ("\n \n --------Gantt Chart Simulation--------" ) # Simulation or displaying of process of the algorithm
7070 while len (ProcessComplete ) < len (self .processList ):
7171 for process in self .processList :
@@ -86,10 +86,13 @@ def Execute(self, processList):
8686
8787 current_process = MemoryQueue .pop (0 ) # pops the first elemnt stored in the memory queue
8888 ProcessComplete .append (current_process )
89+ self .process_Timing [current_process [0 ]] = (currentTime , currentTime + current_process [2 ])
90+ print (f"{ current_process [0 ]} : { currentTime } - { currentTime + current_process [2 ]} " )
8991 currentTime += current_process [2 ]
9092
93+
9194 console .print (f"Running: { current_process [0 ]} " )
92- console .print (f"Burst Time: 0 " )
95+ console .print (f"Burst Time: { current_process [ 2 ] } " )
9396 console .print (f"Priority lvl: { current_process [3 ]} \n " )
9497 console .rule (style = "green" , characters = "-" )
9598 sleep (1 )
@@ -108,20 +111,22 @@ def Execute(self, processList):
108111 WT = totalWT / len (self .processList ) # Waiting time
109112 TT = totalTT / len (self .processList ) # Turnaround TIme
110113
111- table2 = Table (title = "Results" , style = "bold white" )
112- table2 .add_column ("Process ID" , style = "bold cyan" , justify = "center" )
113- table2 .add_column ("Waiting Time" , style = "bold cyan" , justify = "center" )
114- table2 .add_column ("Turnaround Time" , style = "bold cyan" , justify = "center" )
115114
116- for process in self .processList :
117- waitingTime = currentTime - process [1 ] - process [2 ]
118- turnarroundTime = waitingTime + process [2 ]
119- table2 .add_row (process [0 ], str (waitingTime ), str (turnarroundTime ))
115+ return self .process_Timing
116+ # table2 = Table(title="Results", style="bold white")
117+ # table2.add_column("Process ID", style="bold cyan", justify="center")
118+ # table2.add_column("Waiting Time", style="bold cyan", justify="center")
119+ # table2.add_column("Turnaround Time", style="bold cyan", justify="center")
120+
121+ # for process in self.processList:
122+ # waitingTime = currentTime - process[1] - process[2]
123+ # turnarroundTime = waitingTime + process[2]
124+ # table2.add_row(process[0], str(waitingTime), str(turnarroundTime))
120125
121- console .print (table2 )
126+ # console.print(table2)
122127
123- console .print (f"WT average: { WT } " )
124- console .print (f"TT average: { TT } \n \n " )
128+ # console.print(f"WT average: {WT}")
129+ # console.print(f"TT average: {TT}\n\n")
125130
126131
127132# Main Function of the program
@@ -142,4 +147,4 @@ def mainFunction():
142147
143148
144149
145- mainFunction ()
150+ # mainFunction()
0 commit comments