Skip to content

subhm2004/CoreBalance-Advanced-Multi-Core-Simulator

Repository files navigation

πŸš€ CoreBalance - Advanced Multi-Core Simulator

Interactive visualization tool for CPU scheduling algorithms with beautiful UI, real-time simulations, and comprehensive metrics.

Status License TypeScript Node.js C++


πŸ“‹ Table of Contents


✨ Features

🎯 Core Functionality

  • 4 Single-Core Algorithms: FCFS, SJF, Round Robin, Priority
  • 4 Dual-Core Algorithms: All algorithms with load balancing
  • Real-Time Visualization: Gantt charts, animations, and metrics
  • Algorithm Comparison: Run all algorithms simultaneously
  • Performance Metrics: Waiting time, turnaround time, CPU utilization
  • Random Process Generator: Instant test data generation

🎨 User Interface

  • Modern Design: Gradient backgrounds, smooth animations, emojis
  • Dark/Light Mode: Complete theme support
  • Responsive Layout: Works on desktop, tablet, mobile
  • Interactive Controls: Real-time process editor
  • Professional Charts: Chart.js visualizations
  • Live Updates: Instant visual feedback

⚑ Performance

  • Instant Calculations: <1ms for 100 processes
  • Optimized Bundle: Only ~200KB gzipped
  • Zero Latency: Client-side architecture
  • Smooth Animations: 60fps transitions

πŸš€ Quick Start

Option 1: Automated Setup

./build.sh    # Build all components
./start.sh    # Start all services
# Open http://localhost:3000

Option 2: Manual Setup

Terminal 1 - C++ Backend:

cd cpp && mkdir -p build && cd build
cmake .. && make

Terminal 2 - Node.js API:

cd api
npm install
node server.js
# Runs on http://localhost:3001

Terminal 3 - Frontend:

cd frontend
npm install
npm run dev
# Opens http://localhost:3000

πŸ—οΈ Architecture

Three-Tier Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Frontend (Next.js + React)       β”‚
β”‚    - Beautiful UI/UX                β”‚
β”‚    - Real-time visualization        β”‚
β”‚    - Interactive controls           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ HTTP REST API
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Backend (Node.js + Express)      β”‚
β”‚    - API routing                    β”‚
β”‚    - Process spawning               β”‚
β”‚    - Data formatting                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ IPC / Stdio
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Core (C++ Executables)           β”‚
β”‚    - Scheduling algorithms          β”‚
β”‚    - High-performance computation   β”‚
β”‚    - Process simulation             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸŽ“ Algorithms

FCFS (First Come First Served)

  • Complexity: O(n)
  • Best For: Simple workloads
  • Characteristics: Non-preemptive, FIFO queue

SJF (Shortest Job First)

  • Complexity: O(n log n)
  • Best For: Minimizing waiting time
  • Characteristics: Optimal for waiting time

Round Robin

  • Complexity: O(n)
  • Best For: Fair scheduling, time-sharing
  • Characteristics: Preemptive, time quantum based

Priority

  • Complexity: O(n)
  • Best For: Real-time systems
  • Characteristics: Priority queue based

🎨 UI/UX Highlights

🎭 Modern Design

  • Gradient backgrounds with smooth animations
  • Color-coded metrics (blue, purple, amber, green)
  • Responsive grid layout
  • Professional typography

πŸŒ™ Theme Support

  • Light mode with bright gradients
  • Dark mode with slate colors
  • Smooth theme transitions
  • Full accessibility

βš™οΈ Interactive Elements

  • Real-time process table editor
  • Drag-to-sort capabilities
  • Instant data validation
  • Visual feedback on interactions

πŸ“Š Visualizations

  • Animated Gantt charts
  • Performance metric cards
  • CPU utilization graphs
  • Memory usage gauges
  • Comparison tables

πŸ”Œ API Reference

POST /api/schedule

Run single-core scheduling

{
  "algorithm": "FCFS",
  "processes": [{ "id": 1, "arrivalTime": 0, "burstTime": 5, "priority": 1 }]
}

POST /api/schedule-dualcore

Run dual-core scheduling

{
  "algorithm": "DualCoreFCFS",
  "processes": [...],
  "timeQuantum": 2
}

POST /api/compare-dualcore

Compare all algorithms

{
  "processes": [...],
  "timeQuantum": 2
}

GET /api/generate-random?count=10

Generate random processes


πŸ“¦ Installation

Requirements

  • Node.js 18+
  • npm 9+
  • C++17 compiler (g++ or clang)
  • CMake 3.10+
  • macOS/Linux (tested on both)

Step-by-Step

  1. Clone Repository
git clone <repo-url>
cd OS-Project
  1. Install Dependencies
cd frontend && npm install
cd ../api && npm install
  1. Build C++ Backend
cd cpp
mkdir -p build && cd build
cmake ..
make
cd ../..
  1. Set Environment Variables (optional)
export NEXT_PUBLIC_API_URL=http://localhost:3001

πŸ’» Usage

Basic Workflow

  1. Configure Processes

    • Manually enter process details
    • OR use random generator
    • Set arrival times, burst times, priorities
  2. Select Algorithm

    • Choose from 4 algorithms
    • Set time quantum (for Round Robin)
    • Toggle single-core/dual-core/compare modes
  3. Run Simulation

    • Click "Run Schedule" button
    • Watch Gantt chart animate
    • View performance metrics
  4. Analyze Results

    • Compare average waiting time
    • Compare average turnaround time
    • Analyze total execution time
    • View CPU utilization
  5. Compare All

    • Run all algorithms simultaneously
    • Side-by-side comparison
    • Identify best algorithm for workload

πŸ“ Project Structure

OS Project/
β”œβ”€β”€ 🎨 frontend/              # Next.js + React + TypeScript
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx         # Main page
β”‚   β”‚   β”œβ”€β”€ layout.tsx       # Root layout
β”‚   β”‚   └── globals.css      # Global styles
β”‚   β”œβ”€β”€ components/          # 12+ React components
β”‚   β”œβ”€β”€ types/               # TypeScript definitions
β”‚   └── package.json
β”‚
β”œβ”€β”€ πŸ–₯️ api/                   # Node.js + Express
β”‚   β”œβ”€β”€ server.js            # API server
β”‚   └── package.json
β”‚
β”œβ”€β”€ βš™οΈ cpp/                   # C++ Core Engine
β”‚   β”œβ”€β”€ src/                 # Source files
β”‚   β”œβ”€β”€ build/               # Compiled binaries
β”‚   └── CMakeLists.txt
β”‚
β”œβ”€β”€ πŸ“š Documentation
β”‚   β”œβ”€β”€ README.md            # This file
β”‚   β”œβ”€β”€ QUICKSTART.md        # Quick start
β”‚   β”œβ”€β”€ PROJECT_STRUCTURE.md # Detailed structure
β”‚   └── FRONTEND_IMPROVEMENTS.md
β”‚
β”œβ”€β”€ πŸ› οΈ Scripts
β”‚   β”œβ”€β”€ build.sh             # Build everything
β”‚   └── start.sh             # Start services
β”‚
└── πŸ“„ Configuration
    β”œβ”€β”€ .gitignore
    └── package.json (root)

🎯 Key Components

Frontend Components (12)

  • AlgorithmSelector - Algorithm & mode selection
  • ProcessInput - Process table editor
  • GanttChart - Single-core Gantt visualization
  • DualCoreGanttChart - Dual-core visualization
  • MetricsTable - Performance metrics
  • ComparisonTable - Algorithm comparison
  • CPUUtilizationChart - CPU usage graph
  • MemoryGauge - Memory usage widget
  • RandomDataGenerator - Test data generator
  • ThemeToggle - Dark/Light mode switch
  • ThemeProvider - Theme context
  • ComparisonView - Comparison layout

C++ Algorithms

  • Single-Core: FCFS, SJF, RoundRobin, Priority
  • Dual-Core: DualCoreFCFS, DualCoreSJF, DualCoreRoundRobin, DualCorePriority
  • Utilities: Process, Scheduler, ProcessGenerator

πŸ“Š Performance

Metric Value
Frontend Bundle ~200KB (gzipped)
Calculation Time (10 processes) <1ms
Calculation Time (100 processes) <5ms
UI Response Time <16ms (60fps)
Memory Usage ~50MB
Startup Time ~2s

πŸŽ“ Learning Outcomes

After using this tool, you'll understand:

  • βœ… How CPU scheduling algorithms work
  • βœ… Trade-offs between different algorithms
  • βœ… Impact of time quantum on Round Robin
  • βœ… Importance of priority levels
  • βœ… Metrics: waiting time, turnaround time
  • βœ… Dual-core load balancing
  • βœ… Context switching overhead

🀝 Contributing

Contributions welcome! Areas for improvement:

  • Export results as PDF/CSV
  • Save/load simulations
  • More scheduling algorithms
  • Mobile app version
  • Performance benchmarking tools

πŸ“ License

MIT License - Feel free to use in personal/educational projects


πŸ‘¨β€πŸ’» Built With

  • React 18 - UI library
  • Next.js 14 - React framework
  • TypeScript 5.2 - Type safety
  • Tailwind CSS 3.3 - Styling
  • Chart.js 4.4 - Data visualization
  • Node.js 18 - Runtime
  • Express.js - Web framework
  • C++17 - Core algorithms
  • CMake - Build system

πŸ“§ Support

For issues, questions, or suggestions:

  • Check existing documentation
  • Review code comments
  • Create an issue in repository

πŸŽ‰ Acknowledgments

Built as an educational project to visualize and understand CPU scheduling algorithms in operating systems.

Status: Production Ready βœ… Last Updated: January 2026 Version: 1.0.0


Happy Scheduling! πŸš€

  • C++ Compiler: GCC/Clang with C++17 support
  • CMake: Version 3.10 or higher
  • Node.js: Version 18 or higher
  • npm or yarn

Setup Instructions

1. Build C++ Scheduler

cd cpp
mkdir -p build
cd build
cmake ..
make

The compiled binary will be at cpp/build/bin/scheduler.

2. Setup API Server

cd api
npm install

3. Setup Frontend

cd frontend
npm install

Running the Application

Quick Start (Single Command)

Start both servers with one command:

./start.sh

This will start:

  • API server on http://localhost:3001
  • Frontend on http://localhost:3000

Press Ctrl+C to stop both servers.

Manual Start (Separate Terminals)

  1. Start the API server (in one terminal):
cd api
npm run dev

The API will run on http://localhost:3001

  1. Start the Next.js frontend (in another terminal):
cd frontend
npm run dev

The frontend will run on http://localhost:3000

Production Mode

  1. Build the frontend:
cd frontend
npm run build
npm start
  1. Start the API server:
cd api
npm start

Usage

  1. Configure Processes: Add processes with their arrival time, burst time, and priority (if needed)
  2. Select Algorithm: Choose a scheduling algorithm (or compare all)
  3. Set Time Quantum: For Round Robin, specify the time quantum
  4. Run Schedule: Execute the algorithm and view results
  5. View Results:
    • Gantt chart showing process execution timeline
    • Performance metrics table
    • Comparison view (when comparing all algorithms)

API Endpoints

POST /api/schedule

Schedule processes using a single algorithm.

Request Body:

{
  "algorithm": "FCFS",
  "timeQuantum": 2,
  "processes": [
    { "id": 1, "arrivalTime": 0, "burstTime": 5, "priority": 2 },
    { "id": 2, "arrivalTime": 1, "burstTime": 3, "priority": 1 }
  ]
}

Response:

{
  "ganttChart": [...],
  "processes": [...],
  "avgWaitingTime": 2.5,
  "avgTurnaroundTime": 5.0,
  "totalTime": 8
}

POST /api/compare

Compare all algorithms with the same process set.

Request Body:

{
  "timeQuantum": 2,
  "processes": [...]
}

Response:

{
  "FCFS": {...},
  "SJF": {...},
  "RoundRobin": {...},
  "Priority": {...}
}

Algorithm Details

FCFS (First Come First Served)

  • Non-preemptive
  • Processes executed in order of arrival
  • Simple but may have high waiting times

SJF (Shortest Job First)

  • Non-preemptive
  • Process with shortest burst time executes first
  • Optimal for minimizing average waiting time

Round Robin

  • Preemptive
  • Each process gets a time quantum
  • Fair scheduling, prevents starvation

Priority Scheduling

  • Non-preemptive
  • Process with highest priority (lowest number) executes first
  • Priority can be static or dynamic

Technologies Used

  • C++: Core scheduling algorithms
  • Node.js/Express: API bridge
  • Next.js 14: React framework
  • Chart.js: Data visualization
  • Tailwind CSS: Styling
  • TypeScript: Type safety

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

An advanced Multi-Core CPU Scheduling Simulator bridging a high-performance C++ backend with a modern Next.js visualization dashboard. Simulates memory constraints, context-switching overhead, and aging logic.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors