@@ -88,10 +88,10 @@ def _simulate_sjf_np(self) -> Generator[tuple[int, str | None, list[str]]]:
8888 done = 0
8989 while done < len (processes ):
9090 ready = [
91- process
92- for process in processes
93- if process ["arrival" ] <= t and "completion" not in process
94- ]
91+ process
92+ for process in processes
93+ if process ["arrival" ] <= t and "completion" not in process
94+ ]
9595 if not ready :
9696 t += 1
9797 yield (t , None , [])
@@ -112,10 +112,10 @@ def _simulate_sjf_p(self) -> Generator[tuple[int, str | None, list[str]]]:
112112 done = 0
113113 while done < len (processes ):
114114 ready = [
115- process
116- for process in processes
117- if process ["arrival" ] <= t and process ["remaining" ] > 0
118- ]
115+ process
116+ for process in processes
117+ if process ["arrival" ] <= t and process ["remaining" ] > 0
118+ ]
119119 if not ready :
120120 t += 1
121121 yield (t , None , [])
@@ -136,10 +136,10 @@ def _simulate_priority_np(self) -> Generator[tuple[int, str | None, list[str]]]:
136136 done = 0
137137 while done < len (self .processes ):
138138 ready = [
139- process
140- for process in self .processes
141- if process ["arrival" ] <= t and "completion" not in process
142- ]
139+ process
140+ for process in self .processes
141+ if process ["arrival" ] <= t and "completion" not in process
142+ ]
143143 if not ready :
144144 t += 1
145145 yield (t , None , [])
@@ -159,10 +159,10 @@ def _simulate_priority_p(self) -> Generator[tuple[int, str | None, list[str]]]:
159159 done = 0
160160 while done < len (self .processes ):
161161 ready = [
162- process
163- for process in self .processes
164- if process ["arrival" ] <= t and process ["remaining" ] > 0
165- ]
162+ process
163+ for process in self .processes
164+ if process ["arrival" ] <= t and process ["remaining" ] > 0
165+ ]
166166 if not ready :
167167 t += 1
168168 yield (t , None , [])
@@ -261,15 +261,15 @@ def setup_ui(self) -> None:
261261 self .burst_e .grid (row = 2 , column = 1 )
262262 self .priority_e .grid (row = 3 , column = 1 )
263263 ttk .Button (
264- form ,
265- text = "Add" ,
266- command = self .add_process ,
267- ).grid (row = 4 , column = 0 , pady = 5 )
264+ form ,
265+ text = "Add" ,
266+ command = self .add_process ,
267+ ).grid (row = 4 , column = 0 , pady = 5 )
268268 ttk .Button (
269- form ,
270- text = "Delete" ,
271- command = self .delete_process ,
272- ).grid (row = 4 , column = 1 )
269+ form ,
270+ text = "Delete" ,
271+ command = self .delete_process ,
272+ ).grid (row = 4 , column = 1 )
273273 algo_frame = ttk .Frame (self .root )
274274 algo_frame .pack (pady = 10 )
275275 ttk .Label (algo_frame , text = "Algorithm:" ).pack (side = "left" )
@@ -291,10 +291,10 @@ def setup_ui(self) -> None:
291291 self .quantum_e .insert (0 , "2" )
292292 self .quantum_e .pack (side = "left" )
293293 ttk .Button (
294- algo_frame ,
295- text = "Run" ,
296- command = self .run_scheduling ,
297- ).pack (side = "left" , padx = 10 )
294+ algo_frame ,
295+ text = "Run" ,
296+ command = self .run_scheduling ,
297+ ).pack (side = "left" , padx = 10 )
298298 self .ready_label = ttk .Label (self .root , text = "Ready Queue:" )
299299 self .ready_list = tk .Listbox (self .root , height = 3 )
300300 self .ready_label .pack_forget ()
@@ -367,14 +367,14 @@ def animate(self) -> None:
367367 colors .setdefault (pid , plt .cm .tab20 (len (colors ) % 20 ))
368368 self .ax .barh (0 , 1 , left = x , color = colors [pid ])
369369 self .ax .text (
370- x + 0.5 ,
371- 0 ,
372- pid ,
373- ha = "center" ,
374- va = "center" ,
375- color = "white" ,
376- fontsize = 9 ,
377- )
370+ x + 0.5 ,
371+ 0 ,
372+ pid ,
373+ ha = "center" ,
374+ va = "center" ,
375+ color = "white" ,
376+ fontsize = 9 ,
377+ )
378378 x += 1
379379 self .ax .set_xticks (range (x + 1 ))
380380 self .ax .set_yticks ([])
@@ -400,11 +400,13 @@ def show_results(self) -> None:
400400 n = len (self .engine .stats ) or 1
401401 self .avg_label .config (
402402 text = (
403- f"AVG WT = { total_wt / n :.2f} | "
404- f"AVG TAT = { total_tat / n :.2f} | "
405- f"AVG RT = { total_rt / n :.2f} "
406- )
403+ f"AVG WT = { total_wt / n :.2f} | "
404+ f"AVG TAT = { total_tat / n :.2f} | "
405+ f"AVG RT = { total_rt / n :.2f} "
406+ )
407407 )
408+
409+
408410if __name__ == "__main__" :
409411 root = tk .Tk ()
410412 CPUSchedulerGUI (root )
0 commit comments