Skip to content

Commit 53d89cc

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 15f913a commit 53d89cc

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

scheduling/cpu_scheduling_interface.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def _simulate_sjf_np(self):
5555
done = 0
5656
while done < len(processes):
5757
ready = [
58-
p
59-
for p in processes
60-
if p["arrival"] <= t and "completion" not in p
58+
p for p in processes if p["arrival"] <= t and "completion" not in p
6159
]
6260

6361
if not ready:
@@ -78,11 +76,7 @@ def _simulate_sjf_p(self):
7876
processes = sorted(self.processes, key=lambda p: p["arrival"])
7977
done = 0
8078
while done < len(processes):
81-
ready = [
82-
p
83-
for p in processes
84-
if p["arrival"] <= t and p["remaining"] > 0
85-
]
79+
ready = [p for p in processes if p["arrival"] <= t and p["remaining"] > 0]
8680
if not ready:
8781
t += 1
8882
yield (t, None, [])
@@ -102,9 +96,7 @@ def _simulate_priority_np(self):
10296
done = 0
10397
while done < len(self.processes):
10498
ready = [
105-
p
106-
for p in self.processes
107-
if p["arrival"] <= t and "completion" not in p
99+
p for p in self.processes if p["arrival"] <= t and "completion" not in p
108100
]
109101

110102
if not ready:
@@ -125,9 +117,7 @@ def _simulate_priority_p(self):
125117
done = 0
126118
while done < len(self.processes):
127119
ready = [
128-
p
129-
for p in self.processes
130-
if p["arrival"] <= t and p["remaining"] > 0
120+
p for p in self.processes if p["arrival"] <= t and p["remaining"] > 0
131121
]
132122

133123
if not ready:
@@ -180,9 +170,7 @@ def _calculate_stats(self):
180170
arrival = p["arrival"]
181171
burst = p["burst"]
182172
completion = p["completion"]
183-
first_exec = next(
184-
(t for t, pid2 in self.timeline if pid2 == pid), arrival
185-
)
173+
first_exec = next((t for t, pid2 in self.timeline if pid2 == pid), arrival)
186174
tat = completion - arrival
187175
wt = tat - burst
188176
rt = first_exec - arrival
@@ -301,8 +289,7 @@ def add_process(self):
301289
messagebox.showerror("Error", "Invalid input")
302290

303291
def delete_process(self):
304-
sel = self.tree.selection()
305-
if sel:
292+
if sel := self.tree.selection():
306293
pid = self.tree.item(sel[0])["values"][0]
307294
self.processes = [p for p in self.processes if p["pid"] != pid]
308295
self.tree.delete(sel[0])
@@ -365,9 +352,9 @@ def show_results(self):
365352
n = len(self.engine.stats) or 1
366353
self.avg_label.config(
367354
text=(
368-
f"AVG WT = {total_wt/n:.2f} | "
369-
f"AVG TAT = {total_tat/n:.2f} | "
370-
f"AVG RT = {total_rt/n:.2f}"
355+
f"AVG WT = {total_wt / n:.2f} | "
356+
f"AVG TAT = {total_tat / n:.2f} | "
357+
f"AVG RT = {total_rt / n:.2f}"
371358
)
372359
)
373360

scheduling/cpuschedulinginterface.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
</div>
66

7-
A **GUI-based CPU Scheduling Algorithm Visualizer** built using **Python**, **Tkinter**, and **Matplotlib**.
7+
A **GUI-based CPU Scheduling Algorithm Visualizer** built using **Python**, **Tkinter**, and **Matplotlib**.
88
It allows users to add custom processes and simulate various scheduling algorithms with **real-time Gantt chart animation**, **ready queue visualization**, and **performance statistics**.
99

1010
---
1111

1212
## 🚀 Features
1313

14-
✅ Interactive **Tkinter GUI**
15-
✅ Supports multiple **CPU scheduling algorithms**
16-
✅ Real-time **Gantt chart animation** using Matplotlib
17-
✅ Displays **Ready Queue** (for Round Robin & Preemptive algorithms)
18-
✅ Shows **average waiting time**, **turnaround time**, and **response time**
19-
✅ Add or delete processes dynamically
20-
✅ Clean and responsive design
14+
✅ Interactive **Tkinter GUI**
15+
✅ Supports multiple **CPU scheduling algorithms**
16+
✅ Real-time **Gantt chart animation** using Matplotlib
17+
✅ Displays **Ready Queue** (for Round Robin & Preemptive algorithms)
18+
✅ Shows **average waiting time**, **turnaround time**, and **response time**
19+
✅ Add or delete processes dynamically
20+
✅ Clean and responsive design
2121

2222
---
2323

@@ -60,7 +60,7 @@ Displays process execution in timeline order, showing process IDs along the time
6060

6161
## 🧠 Working
6262

63-
1. Enter process details (`PID`, `Arrival`, `Burst`, `Priority`)
63+
1. Enter process details (`PID`, `Arrival`, `Burst`, `Priority`)
6464
2. Choose your desired **Scheduling Algorithm**
6565
3. (Optional) Enter Quantum value (for Round Robin)
6666
4. Click **Run**
@@ -72,9 +72,9 @@ Displays process execution in timeline order, showing process IDs along the time
7272
## 🛠️ Tech Stack
7373

7474
- **Python 3.8+**
75-
- **Tkinter** → GUI Framework
76-
- **Matplotlib** → Animation and Gantt Chart
77-
- **Threading** → Live simulation without freezing GUI
75+
- **Tkinter** → GUI Framework
76+
- **Matplotlib** → Animation and Gantt Chart
77+
- **Threading** → Live simulation without freezing GUI
7878

7979
---
8080

@@ -115,4 +115,4 @@ Shashwat
115115

116116
Made with ❤️ using Python & Tkinter
117117

118-
</div>
118+
</div>

0 commit comments

Comments
 (0)