diff --git a/README.md b/README.md index 93f088a53..5902a0d71 100644 --- a/README.md +++ b/README.md @@ -1,7 +1 @@ -# Buffer-7.0 -The themes for Buffer 7.0 are - - -1. Enterprise Systems & Process Optimization -2. GreenTech -3. Cybersecurity and Digital Defense -4. Open Innovation +# Smart-CPU-Scheduling-Analyzer \ No newline at end of file diff --git a/VID_20260417_163035.mp4 b/VID_20260417_163035.mp4 new file mode 100644 index 000000000..94276d308 Binary files /dev/null and b/VID_20260417_163035.mp4 differ diff --git a/about.html b/about.html new file mode 100644 index 000000000..427f5a523 --- /dev/null +++ b/about.html @@ -0,0 +1,549 @@ + + + + + + + SchedViz | About Us + + + + + + + + +
+
+
Who We Are
+

About Smart CPU Scheduling Analyzer

+

Empowering students, educators, and developers to master CPU scheduling through interactive visualization and real-time analytics.

+
+ +
+
+

Our Mission

+

We believe that understanding CPU scheduling algorithms shouldn't be difficult. Our mission is to provide an intuitive, interactive platform that transforms complex scheduling concepts into visual, hands-on learning experiences. Whether you're a computer science student preparing for exams, an educator teaching operating systems, or a developer optimizing system performance, Smart CPU Scheduling Analyzer gives you the tools to simulate, compare, and analyze algorithms in real-time.

+
+ +
+

Our Core Values

+
+
+
+

Education First

+

Making complex OS concepts accessible through interactive visualization and real-time feedback.

+
+
+
+

Data-Driven

+

Providing detailed metrics and analytics to help users understand performance trade-offs.

+
+
+
+

Open Innovation

+

Continuously improving with new algorithms, multi-core support, and advanced features.

+
+
+
+

Community Driven

+

Built by developers, for learners — incorporating feedback to create the best learning tool.

+
+
+
+ +
+

Meet the Team

+
+
+
+

Mahi Sheth

+
IT Student
+
+
+
+

Surabhi Singh

+
IT Student
+
+
+
+

Vaidehi Sonawane

+
IT Student
+
+
+
+ +
+
+
6+
+
Scheduling Algorithms
+
+
+
10K+
+
Active Users
+
+
+
99%
+
Accuracy Rate
+
+
+
24/7
+
Simulation Access
+
+
+ +
+

Ready to Master CPU Scheduling?

+

Join thousands of students and developers using our platform to understand scheduling algorithms.

+ +
+
+ + + + + + \ No newline at end of file diff --git a/about2.html b/about2.html new file mode 100644 index 000000000..ba5f0bdf8 --- /dev/null +++ b/about2.html @@ -0,0 +1,609 @@ + + + + + + Smart CPU Scheduler | About Us + + + + + + + + +
+
+
Who We Are
+

About Smart CPU Scheduling Analyzer

+

Empowering students, educators, and developers to master CPU scheduling through interactive visualization and real-time analytics.

+
+ +
+
+

Our Mission

+

We believe that understanding CPU scheduling algorithms shouldn't be difficult. Our mission is to provide an intuitive, interactive platform that transforms complex scheduling concepts into visual, hands-on learning experiences. Whether you're a computer science student preparing for exams, an educator teaching operating systems, or a developer optimizing system performance, Smart CPU Scheduling Analyzer gives you the tools to simulate, compare, and analyze algorithms in real-time.

+
+ +
+

Our Core Values

+
+
+
+

Education First

+

Making complex OS concepts accessible through interactive visualization and real-time feedback.

+
+
+
+

Data-Driven

+

Providing detailed metrics and analytics to help users understand performance trade-offs.

+
+
+
+

Open Innovation

+

Continuously improving with new algorithms, multi-core support, and advanced features.

+
+
+
+

Community Driven

+

Built by developers, for learners — incorporating feedback to create the best learning tool.

+
+
+
+ +
+

Meet the Team

+
+
+
+

Mahi Sheth

+
IT Student
+
+
+
+

Surabhi Singh

+
IT Student
+
+
+
+

Vaidehi Sonawane

+
IT Student
+
+
+
+ +
+
+
6+
+
Scheduling Algorithms
+
+
+
10K+
+
Active Users
+
+
+
99%
+
Accuracy Rate
+
+
+
24/7
+
Simulation Access
+
+
+ +
+

Ready to Master CPU Scheduling?

+

Join thousands of students and developers using our platform to understand scheduling algorithms.

+ +
+
+ + + + + + \ No newline at end of file diff --git a/advanced.html b/advanced.html new file mode 100644 index 000000000..b14ccaf79 --- /dev/null +++ b/advanced.html @@ -0,0 +1,911 @@ + + + + + + SchedViz | Advanced Features + + + + + + + +
+
+
+

MLFQ Configuration

+
+
+
+ Queue 1 (Highest Priority) + Quantum: 2 +
+ +
Round Robin with higher priority (shorter quantum)
+
+
+
+ Queue 2 + Quantum: 4 +
+ +
Round Robin (medium quantum)
+
+
+
+ Queue 3 (Lowest Priority) + Quantum: 8 +
+ +
FCFS with large quantum
+
+
+ +
+ +
+

Multi-core Simulation

+
+
+
+ CPU Core 1 + Idle +
+
No process running
+
+
+
+
+ CPU Core 2 + Idle +
+
No process running
+
+
+
+
+ CPU Core 3 + Idle +
+
No process running
+
+
+
+
+ CPU Core 4 + Idle +
+
No process running
+
+
+
+ +
+
+ +
+

Dynamic Process Controls

+
+
+ + + + +
+
+ + +
+
+
+
+ +
+

Simulation Results

+
+
Add processes and click "Simulate MLFQ"
+
+
+
+
+
Avg Turnaround Time
+
+
+
+
Avg Waiting Time
+
+
+
+
CPU Utilization
+
+
+
+
Throughput
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 000000000..70114c92e --- /dev/null +++ b/app.py @@ -0,0 +1,91 @@ +from flask import Flask, request, jsonify +from flask_cors import CORS +import subprocess +import sys + +app = Flask(__name__) +CORS(app) + +@app.route('/run', methods=['POST']) +def run_scheduler(): + data = request.json + + processes = data["processes"] + algorithm = data["algorithm"] + quantum = data.get("quantum", 2) + + # 🔹 Convert input to C++ format + input_data = str(len(processes)) + "\n" + + for p in processes: + input_data += f"{p['pid']} {p['arrival']} {p['burst']} {p['priority']}\n" + + input_data += algorithm + "\n" + + if algorithm == "RR": + input_data += str(quantum) + "\n" + + print("Sending to C++:", input_data) # Debug + + # 🔹 Run C++ program + result = subprocess.run( + ["./scheduler.exe"], + input=input_data, + text=True, + capture_output=True + ) + + print("C++ stdout:", result.stdout) # Debug + print("C++ stderr:", result.stderr) # Debug + + lines = result.stdout.strip().split("\n") + + gantt = [] + metrics = {} + + i = 0 + + # 🔹 READ GANTT DATA (C++ outputs: pid start end for each block) + while i < len(lines) and lines[i] != "---": + if lines[i].strip() == "": + i += 1 + continue + parts = lines[i].split() + if len(parts) >= 3: + # Check if it's a valid Gantt line (all numbers) + try: + pid = int(parts[0]) + start = int(parts[1]) + end = int(parts[2]) + gantt.append({ + "pid": f"P{pid}", + "start": start, + "end": end + }) + except ValueError: + pass # Skip non-numeric lines (like algorithm name) + i += 1 + + # skip --- + i += 1 + + # 🔹 READ METRICS + if i < len(lines): + try: + vals = lines[i].split() + if len(vals) >= 2: + metrics = { + "avg_waiting": float(vals[0]), + "avg_turnaround": float(vals[1]) + } + except: + metrics = {"avg_waiting": 0, "avg_turnaround": 0} + + return jsonify({ + "gantt": gantt, + "metrics": metrics + }) + + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/comparison.html b/comparison.html new file mode 100644 index 000000000..15c706ce5 --- /dev/null +++ b/comparison.html @@ -0,0 +1,703 @@ + + + + + + Smart CPU Scheduler | Comparison + + + + + + + + +
+
+

Process Configuration

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PIDArrival TimeBurst TimePriorityAction
+
+
+ + +
+
+ +
+
+

Average Waiting Time Comparison

+ +
+
+

Average Turnaround Time Comparison

+ +
+
+ +
+

Detailed Metrics Comparison

+ + + + + + + + + + + + + +
AlgorithmAvg Waiting TimeAvg Turnaround TimeCPU UtilizationThroughput
Click "Compare Algorithms" to see results
+
+
+ + + + \ No newline at end of file diff --git a/guide.html b/guide.html new file mode 100644 index 000000000..1d0a2ebf2 --- /dev/null +++ b/guide.html @@ -0,0 +1,415 @@ + + + + + + SchedViz | User Guide + + + + + + + + +
+
+
+ 🤖 +
+

🎮 How to Use SchedViz

+

Your friendly guide to mastering CPU scheduling algorithms! Let's get started on this fun learning journey.

+
+ +
+
+
+
STEP 1
+

Create Your Account

+

Click on Sign Up and create your free account using your Gmail address. Already have an account? Just Login!

+
+ +
+
+
STEP 2
+

Configure Processes

+

Add processes with their PID, Arrival Time, Burst Time, and Priority. You can also use the Random Generate button for quick testing!

+
+ +
+
+
STEP 3
+

Choose Algorithm

+

Pick from 6+ algorithms: FCFS, SJF, SRTF, Round Robin, Priority, or MLFQ. Each one behaves differently!

+
+ +
+
+
STEP 4
+

Watch the Gantt Chart

+

See your processes come to life! The Gantt Chart shows exactly when each process runs on the CPU.

+
+ +
+
+
STEP 5
+

Analyze Metrics

+

Check Average Waiting Time, Turnaround Time, CPU Utilization, and Throughput to compare algorithm performance.

+
+ +
+
+
STEP 6
+

Compare Algorithms

+

Visit the Comparison page to see bar charts and pie charts comparing all algorithms side-by-side!

+
+
+ +
+

Pro Tips & Tricks

+
+
+
+
🎲 Use Random Generate to quickly create test processes!
+
+
+
+
🖱️ Hover over Gantt chart blocks to see detailed timing info!
+
+
+
+
🥧 The pie chart shows percentage distribution of turnaround times!
+
+
+
+
💻 Multi-core simulation shows how processes distribute across CPU cores!
+
+
+
+
⚙️ MLFQ quantums can be adjusted in the Advanced page!
+
+
+
+
🔄 Reset button brings back the default 4 processes!
+
+
+
+ + + +
+

+ Need help? Check out the About Us page or contact the team! +

+
+
+ + + + + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 000000000..e297ad6d4 --- /dev/null +++ b/index.html @@ -0,0 +1,375 @@ + + + + + + SchedViz | Home + + + + + + + + +
+ +
+
+ +
+ + +
+
v2.4 · Real-time Simulation
+

Smart CPU Scheduling
Analyzer

+
Simulate, visualize, and analyze CPU scheduling algorithms in real-time. Understand performance trade-offs with interactive Gantt charts and detailed metrics.
+
+ + +
+ +
+
+
+

Real-time Simulation

+

Watch processes execute step-by-step with live CPU state updates and interactive controls.

+
+
+
+

Gantt Chart Visualization

+

Color-coded process timelines with zoom, scroll, and hover tooltips for detailed analysis.

+
+
+
+

Algorithm Comparison

+

Compare FCFS, SJF, SRTF, Round Robin, Priority, and MLFQ side-by-side with metrics.

+
+
+
+

Multi-core Support

+

Simulate parallel execution across multiple CPU cores with load balancing.

+
+
+
+ +
+
+
6+
+
Scheduling Algorithms
+
+
+
Real-time
+
Interactive Gantt Charts
+
+
+
Multi-core
+
Parallel Simulation
+
+
+
100%
+
Performance Metrics
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/index2.html b/index2.html new file mode 100644 index 000000000..935e50836 --- /dev/null +++ b/index2.html @@ -0,0 +1,573 @@ + + + + + + SchedViz | Home + + + + + + + + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ + +
+

Smart CPU Scheduling
Analyzer

+
Simulate, visualize, and analyze CPU scheduling algorithms in real-time. Understand performance trade-offs with interactive Gantt charts and detailed metrics.
+
+ + +
+ + +
+ +
+
+
+

Real-time Simulation

+

Watch processes execute step-by-step with live CPU state updates and interactive controls.

+
+
+
+

Gantt Chart Visualization

+

Color-coded process timelines with zoom, scroll, and hover tooltips for detailed analysis.

+
+
+
+

Algorithm Comparison

+

Compare FCFS, SJF, SRTF, Round Robin, Priority, and MLFQ side-by-side with metrics.

+
+
+
+

Multi-core Support

+

Simulate parallel execution across multiple CPU cores with load balancing.

+
+
+
+ +
+
+
6+
+
Scheduling Algorithms
+
+
+
Real-time
+
Interactive Gantt Charts
+
+
+
Multi-core
+
Parallel Simulation
+
+
+
100%
+
Performance Metrics
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/input.txt b/input.txt new file mode 100644 index 000000000..e69de29bb diff --git a/login.html b/login.html new file mode 100644 index 000000000..f26c76b73 --- /dev/null +++ b/login.html @@ -0,0 +1,528 @@ + + + + + + Smart CPU Scheduler | Login + + + + + +
+ + + +
+

LOGIN

+

Enter your credentials to access the simulator

+
+ + +
+
+ + +
+
+ + +
+ + +
+
+ Only accounts created via Sign Up can login +
+
+ + + +
+ + + + \ No newline at end of file diff --git a/scheduler.cpp b/scheduler.cpp new file mode 100644 index 000000000..f3d2489d9 --- /dev/null +++ b/scheduler.cpp @@ -0,0 +1,340 @@ +#include +#include +#include +#include +#include +using namespace std; + +struct Process { + int pid, arrival, burst, remaining, priority; + int completion = 0, waiting = 0, turnaround = 0; +}; + +struct GanttBlock { + int pid, start, end; +}; + +void reset(vector &p, vector &gantt) { + gantt.clear(); + for (auto &x : p) { + x.remaining = x.burst; + x.completion = x.waiting = x.turnaround = 0; + } +} + +//////////////////// FCFS //////////////////// +void fcfs(vector &p, vector &gantt) { + sort(p.begin(), p.end(), [](auto &a, auto &b){ return a.arrival < b.arrival; }); + + int time = 0; + for (auto &x : p) { + if (time < x.arrival) time = x.arrival; + int start = time; + time += x.burst; + + gantt.push_back({x.pid, start, time}); + + x.completion = time; + x.turnaround = time - x.arrival; + x.waiting = x.turnaround - x.burst; + } +} + +//////////////////// SJF //////////////////// +void sjf(vector &p, vector &gantt) { + int n = p.size(), time = 0, completed = 0; + vector done(n, false); + + while (completed < n) { + int idx = -1, minB = INT_MAX; + + for (int i = 0; i < n; i++) { + if (!done[i] && p[i].arrival <= time && p[i].burst < minB) { + minB = p[i].burst; + idx = i; + } + } + + if (idx == -1) { time++; continue; } + + int start = time; + time += p[idx].burst; + + gantt.push_back({p[idx].pid, start, time}); + + p[idx].completion = time; + p[idx].turnaround = time - p[idx].arrival; + p[idx].waiting = p[idx].turnaround - p[idx].burst; + + done[idx] = true; + completed++; + } +} + +//////////////////// SRTF //////////////////// +void srtf(vector &p, vector &gantt) { + int n = p.size(), time = 0, completed = 0, prev = -1; + + while (completed < n) { + int idx = -1, minR = INT_MAX; + + for (int i = 0; i < n; i++) { + if (p[i].arrival <= time && p[i].remaining > 0 && p[i].remaining < minR) { + minR = p[i].remaining; + idx = i; + } + } + + if (idx == -1) { time++; continue; } + + if (prev != idx) + gantt.push_back({p[idx].pid, time, time}); + + gantt.back().end++; + p[idx].remaining--; + time++; + prev = idx; + + if (p[idx].remaining == 0) { + p[idx].completion = time; + p[idx].turnaround = time - p[idx].arrival; + p[idx].waiting = p[idx].turnaround - p[idx].burst; + completed++; + } + } +} + +//////////////////// ROUND ROBIN //////////////////// +void roundRobin(vector &p, vector &gantt, int q) { + int n = p.size(), time = 0, completed = 0; + queue qu; + vector added(n, false); + + // Sort by arrival time initially + sort(p.begin(), p.end(), [](auto &a, auto &b) { return a.arrival < b.arrival; }); + + qu.push(0); + added[0] = true; + + while (!qu.empty()) { + int i = qu.front(); qu.pop(); + + int start = time; + int exec = min(q, p[i].remaining); + + time += exec; + p[i].remaining -= exec; + + gantt.push_back({p[i].pid, start, time}); + + // Add newly arrived processes + for (int j = 0; j < n; j++) { + if (!added[j] && p[j].arrival <= time) { + qu.push(j); + added[j] = true; + } + } + + if (p[i].remaining > 0) { + qu.push(i); + } else { + p[i].completion = time; + p[i].turnaround = time - p[i].arrival; + p[i].waiting = p[i].turnaround - p[i].burst; + completed++; + } + } +} + +//////////////////// PRIORITY //////////////////// +void priority_np(vector &p, vector &gantt) { + int n = p.size(), time = 0, completed = 0; + vector done(n, false); + + while (completed < n) { + int idx = -1, best = INT_MAX; + + for (int i = 0; i < n; i++) { + if (!done[i] && p[i].arrival <= time && p[i].priority < best) { + best = p[i].priority; + idx = i; + } + } + + if (idx == -1) { time++; continue; } + + int start = time; + time += p[idx].burst; + + gantt.push_back({p[idx].pid, start, time}); + + p[idx].completion = time; + p[idx].turnaround = time - p[idx].arrival; + p[idx].waiting = p[idx].turnaround - p[idx].burst; + + done[idx] = true; + completed++; + } +} + +//////////////////// MLFQ (FIXED) //////////////////// +void mlfq(vector &p, vector &gantt) { + int n = p.size(); + int time = 0; + int completed = 0; + queue q1, q2, q3; + vector inQueue(n, false); + vector originalBurst(n); + + // Initialize processes + for (int i = 0; i < n; i++) { + originalBurst[i] = p[i].burst; + p[i].remaining = p[i].burst; + p[i].waiting = 0; + p[i].turnaround = 0; + p[i].completion = 0; + } + + // Sort by arrival time + sort(p.begin(), p.end(), [](auto &a, auto &b) { return a.arrival < b.arrival; }); + + while (completed < n) { + // Add newly arrived processes to q1 + for (int i = 0; i < n; i++) { + if (!inQueue[i] && p[i].arrival <= time && p[i].remaining > 0) { + q1.push(i); + inQueue[i] = true; + } + } + + int currentIdx = -1; + int quantum = 0; + string currentQueue = ""; + + if (!q1.empty()) { + currentIdx = q1.front(); + q1.pop(); + quantum = 2; + currentQueue = "q1"; + } + else if (!q2.empty()) { + currentIdx = q2.front(); + q2.pop(); + quantum = 4; + currentQueue = "q2"; + } + else if (!q3.empty()) { + currentIdx = q3.front(); + q3.pop(); + quantum = INT_MAX; + currentQueue = "q3"; + } + else { + // No process available, jump to next arrival + int nextArrival = INT_MAX; + for (int i = 0; i < n; i++) { + if (p[i].remaining > 0 && p[i].arrival < nextArrival) { + nextArrival = p[i].arrival; + } + } + if (nextArrival != INT_MAX) { + time = nextArrival; + } + continue; + } + + int execTime = min(quantum, p[currentIdx].remaining); + int start = time; + int end = time + execTime; + + gantt.push_back({p[currentIdx].pid, start, end}); + time = end; + p[currentIdx].remaining -= execTime; + + // Add newly arrived processes during this execution + for (int i = 0; i < n; i++) { + if (!inQueue[i] && p[i].arrival <= time && p[i].remaining > 0) { + q1.push(i); + inQueue[i] = true; + } + } + + if (p[currentIdx].remaining > 0) { + // Move to lower queue + if (currentQueue == "q1") { + q2.push(currentIdx); + } else if (currentQueue == "q2") { + q3.push(currentIdx); + } else { + q3.push(currentIdx); + } + } else { + // Process completed + p[currentIdx].completion = time; + p[currentIdx].turnaround = p[currentIdx].completion - p[currentIdx].arrival; + p[currentIdx].waiting = p[currentIdx].turnaround - originalBurst[currentIdx]; + completed++; + } + } +} + +//////////////////// MAIN //////////////////// +int main() { + int n; + cin >> n; + + vector p(n); + for (int i = 0; i < n; i++) { + cin >> p[i].pid >> p[i].arrival >> p[i].burst >> p[i].priority; + p[i].remaining = p[i].burst; + } + + string algo; + cin >> algo; + + vector gantt; + reset(p, gantt); + + if (algo == "FCFS") { + fcfs(p, gantt); + } + else if (algo == "SJF") { + sjf(p, gantt); + } + else if (algo == "SRTF") { + srtf(p, gantt); + } + else if (algo == "RR") { + int q; + cin >> q; + roundRobin(p, gantt, q); + } + else if (algo == "PRIORITY") { + priority_np(p, gantt); + } + else if (algo == "MLFQ") { + mlfq(p, gantt); + } + + // OUTPUT for backend + // Gantt output + for (auto &g : gantt) { + cout << g.pid << " " << g.start << " " << g.end << endl; + } + + cout << "---" << endl; + + // Calculate metrics + double total_waiting = 0, total_turnaround = 0; + for (auto &x : p) { + total_waiting += x.waiting; + total_turnaround += x.turnaround; + } + + double avg_waiting = total_waiting / n; + double avg_turnaround = total_turnaround / n; + + cout << avg_waiting << " " << avg_turnaround << endl; + + return 0; +} \ No newline at end of file diff --git a/scheduler.exe b/scheduler.exe new file mode 100644 index 000000000..ef9effe5e Binary files /dev/null and b/scheduler.exe differ diff --git a/signup.html b/signup.html new file mode 100644 index 000000000..41f4c2c0f --- /dev/null +++ b/signup.html @@ -0,0 +1,437 @@ + + + + + + SchedViz | Sign Up + + + + + + + + + + \ No newline at end of file diff --git a/simulator.html b/simulator.html new file mode 100644 index 000000000..2821e117b --- /dev/null +++ b/simulator.html @@ -0,0 +1,772 @@ + + + + + + Smart CPU Scheduler | Simulator + + + + + + + +
+
+
+

CPU Scheduling Simulator

+ + + + + +

Process Queue

+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ + +
+ +
+
+

Gantt Chart

+ FCFS +
+ +
+
+
Run simulation to see Gantt chart
+
+
+ +
+
+
+
Average Waiting Time
+
+
+
+
Average Turnaround Time
+
+
+
+
+
+ + + + + +