@@ -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 ()
@@ -365,14 +365,14 @@ def animate(self) -> None:
365365 colors .setdefault (pid , plt .cm .tab20 (len (colors ) % 20 ))
366366 self .ax .barh (0 , 1 , left = x , color = colors [pid ])
367367 self .ax .text (
368- x + 0.5 ,
369- 0 ,
370- pid ,
371- ha = "center" ,
372- va = "center" ,
373- color = "white" ,
374- fontsize = 9 ,
375- )
368+ x + 0.5 ,
369+ 0 ,
370+ pid ,
371+ ha = "center" ,
372+ va = "center" ,
373+ color = "white" ,
374+ fontsize = 9 ,
375+ )
376376 x += 1
377377 self .ax .set_xticks (range (x + 1 ))
378378 self .ax .set_yticks ([])
@@ -398,11 +398,13 @@ def show_results(self) -> None:
398398 n = len (self .engine .stats ) or 1
399399 self .avg_label .config (
400400 text = (
401- f"AVG WT = { total_wt / n :.2f} | "
402- f"AVG TAT = { total_tat / n :.2f} | "
403- f"AVG RT = { total_rt / n :.2f} "
404- )
401+ f"AVG WT = { total_wt / n :.2f} | "
402+ f"AVG TAT = { total_tat / n :.2f} | "
403+ f"AVG RT = { total_rt / n :.2f} "
404+ )
405405 )
406+
407+
406408if __name__ == "__main__" :
407409 root = tk .Tk ()
408410 CPUSchedulerGUI (root )
0 commit comments