A comprehensive full-stack application for simulating and visualizing CPU scheduling algorithms. Built with Spring Boot backend and Next.js frontend, this project provides an interactive platform to understand different CPU scheduling mechanisms with real-time visualization.
- First Come First Served (FCFS) - Non-preemptive scheduling based on arrival time
- Shortest Job First (SJF) - Non-preemptive scheduling based on burst time
- Priority Scheduling - Non-preemptive scheduling based on process priority
- Round Robin (RR) - Preemptive scheduling with configurable time quantum
- Process Management: Add, remove, and manage processes with custom parameters
- Real-time Visualization: Interactive Gantt chart showing process execution timeline
- Performance Metrics: Calculate and display waiting time, turnaround time, and completion time
- Demo Data: Pre-loaded datasets for quick testing of algorithms
- Responsive Design: Modern UI that works on all devices
- Dark/Light Theme: Toggle between themes for better user experience
- Enhanced Gantt Chart: Animated timeline visualization with process execution blocks
- Process Results Table: Detailed breakdown of process execution metrics
- Statistics Dashboard: Average performance metrics and execution summary
- Algorithm Comparison: Side-by-side comparison of different scheduling approaches
src/main/java/com/scheduler/cpu_simulator/
βββ CpuSimulatorApplication.java # Main application entry point
βββ controller/
β βββ SchedulerController.java # REST API endpoints
β βββ SimulationRequest.java # Request DTOs
βββ model/
β βββ Process.java # Process entity model
βββ service/
βββ SchedulerService.java # Core scheduling algorithms
cpu-scheduler-frontend/src/
βββ app/
β βββ page.tsx # Main application page
β βββ layout.tsx # Root layout component
β βββ globals.css # Global styles
βββ components/
β βββ ui/ # Reusable UI components
β βββ DemoDataLoader.tsx # Demo data management
β βββ EnhancedGanttChart.tsx # Advanced Gantt visualization
β βββ GanttChart.tsx # Basic Gantt chart
β βββ ProcessInputForm.tsx # Process input interface
β βββ ProcessTable.tsx # Process management table
β βββ ResultsTable.tsx # Results display
β βββ SimpleProcessInput.tsx # Simplified input form
β βββ ThemeToggle.tsx # Theme switcher
βββ contexts/
β βββ ThemeContext.tsx # Theme management
βββ lib/
β βββ api.ts # API client for backend communication
β βββ utils.ts # Utility functions
βββ styles/
β βββ EnhancedGantt.module.css # Gantt chart specific styles
βββ types/
βββ process.ts # TypeScript type definitions
- Java 21 - Modern Java features and performance
- Spring Boot 3.5.3 - Enterprise-grade framework
- Spring Web - REST API development
- Spring DevTools - Development productivity
- Maven - Dependency management and build tool
- Lombok - Boilerplate code reduction
- Next.js 15 - React framework with server-side rendering
- TypeScript - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS framework
- Lucide React - Modern icon library
- Radix UI - Accessible component primitives
- Framer Motion - Animation library
- ESLint - Code linting
- PostCSS - CSS processing
- Maven Wrapper - Maven version management
- Java 21 or higher
- Node.js 18+ and npm
- Maven 3.6+ (or use included Maven wrapper)
- Git for version control
git clone https://github.com/Bhavesh0577/CpuSchedulingSimulator.git
cd CpuSchedulingSimulator# Navigate to project root
cd CpuSchedulingSimulator
# Build and run using Maven wrapper (recommended)
./mvnw spring-boot:run
# Or if you have Maven installed globally
mvn spring-boot:run
# Backend will start on http://localhost:8080# Navigate to frontend directory
cd cpu-scheduler-frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Frontend will start on http://localhost:3000- Launch the Application: Start both backend and frontend servers
- Access the Interface: Open
http://localhost:3000in your browser - Select Algorithm: Choose from FCFS, SJF, Priority, or Round Robin
- Configure Settings: Set time quantum for Round Robin if selected
-
Enter Process Details:
- Process ID (e.g., P1, P2, P3)
- Arrival Time (when process arrives)
- Burst Time (execution time required)
- Priority (for Priority scheduling, lower number = higher priority)
-
Use Demo Data: Click demo buttons for pre-configured test cases
-
Manage Processes: Add, remove, or clear processes as needed
- Execute Simulation: Click "Run Simulation" to process your data
- View Results: Analyze the comprehensive results including:
- Process execution timeline (Gantt chart)
- Individual process metrics
- Average waiting and turnaround times
- Total execution time
- Completion Time: When process finishes execution
- Turnaround Time: Total time from arrival to completion
- Waiting Time: Time spent waiting in ready queue
- Gantt Chart: Visual timeline of process execution order
POST /api/scheduler/fcfs
Content-Type: application/json
[
{
"pid": "P1",
"arrivalTime": 0,
"burstTime": 10,
"priority": 0
}
]POST /api/scheduler/sjf
Content-Type: application/json
[Process Array]POST /api/scheduler/priority
Content-Type: application/json
[Process Array]POST /api/scheduler/rr?quantum=2
Content-Type: application/json
[Process Array]interface Process {
pid: string; // Process identifier
arrivalTime: number; // Arrival time
burstTime: number; // Execution time
priority: number; // Process priority
completionTime?: number; // Calculated completion time
turnaroundTime?: number; // Calculated turnaround time
waitingTime?: number; // Calculated waiting time
}- Type: Non-preemptive
- Logic: Execute processes in order of arrival
- Advantage: Simple implementation, no starvation
- Disadvantage: High average waiting time
- Type: Non-preemptive
- Logic: Execute shortest process first
- Advantage: Minimum average waiting time
- Disadvantage: Starvation possible for long processes
- Type: Non-preemptive
- Logic: Execute highest priority process first
- Advantage: Important processes get preference
- Disadvantage: Starvation possible for low priority processes
- Type: Preemptive
- Logic: Each process gets fixed time quantum
- Advantage: Fair time sharing, no starvation
- Disadvantage: High context switching overhead
- Algorithm Selector: Dropdown to choose scheduling algorithm
- Process Input Form: Interactive form for process data entry
- Process List: Dynamic list of added processes
- Control Panel: Simulation controls and statistics
- Enhanced Gantt Chart: Animated timeline with process blocks
- Results Table: Detailed metrics for each process
- Statistics Cards: Summary of performance metrics
- Theme Toggle: Dark/light mode switcher
- Completion Time:
arrival_time + burst_time + waiting_time - Turnaround Time:
completion_time - arrival_time - Waiting Time:
turnaround_time - burst_time - Average Waiting Time:
sum(waiting_times) / process_count - Average Turnaround Time:
sum(turnaround_times) / process_count
The application allows you to compare different algorithms by:
- Running same process set with different algorithms
- Observing different execution patterns
- Comparing performance metrics
- Understanding trade-offs between algorithms
# Run in development mode
./mvnw spring-boot:run
# Run tests
./mvnw test
# Build for production
./mvnw clean package# Development server
npm run dev
# Type checking
npm run type-check
# Linting
npm run lint
# Production build
npm run build
npm start- Backend Port: 8080 (configurable in
application.properties) - Frontend Port: 3000 (configurable in
next.config.ts) - API Base URL:
http://localhost:8080/api/scheduler
- Fork the Repository
- Create Feature Branch:
git checkout -b feature/AmazingFeature - Commit Changes:
git commit -m 'Add some AmazingFeature' - Push to Branch:
git push origin feature/AmazingFeature - Open Pull Request
- Follow existing code style and conventions
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Ensure cross-platform compatibility
- Port 8080 already in use: Change port in
application.properties - Java version mismatch: Ensure Java 21+ is installed
- Maven build fails: Use Maven wrapper
./mvnwinstead ofmvn
- Node version: Ensure Node.js 18+ is installed
- Dependencies: Run
npm installin the frontend directory - Build failures: Clear
.nextfolder and rebuild
- API calls failing: Verify backend is running on port 8080
- CORS errors: Backend has CORS enabled for all origins
- Network issues: Check firewall and network settings
- Backend: Add
--debugflag when running Spring Boot - Frontend: Next.js provides detailed error messages in development mode
- Additional Algorithms: SRTF, Multi-level Queue, Multi-level Feedback Queue
- Advanced Features: Process aging, deadline scheduling
- Export Functionality: Save results as PDF or CSV
- Real-time Comparison: Side-by-side algorithm comparison
- Mobile App: React Native implementation
- Performance Analytics: Detailed performance analysis tools
For support and questions:
- GitHub Issues: Create an issue
- Email: samarthfirangi44@gmail.com
- Documentation: Check this README and inline code comments
Happy Scheduling! π―