Skip to content

gagan771/OS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ CPU Scheduling Algorithms Simulator

A comprehensive, interactive web application that simulates and visualizes various CPU scheduling algorithms with real-time Gantt charts and performance metrics.

CPU Scheduling Simulator Next.js React TypeScript Tailwind CSS

๐ŸŽฏ Overview

This project implements five fundamental CPU scheduling algorithms with an intuitive web interface, featuring a professional video background and comprehensive visualization tools. Perfect for students, educators, and professionals studying operating systems concepts.

โœจ Features

๐Ÿงฎ Implemented Algorithms

  • FCFS (First-Come, First-Served) - Non-preemptive scheduling based on arrival time
  • SJF (Shortest Job First) - Non-preemptive scheduling prioritizing shortest burst time
  • SRTF (Shortest Remaining Time First) - Preemptive version of SJF
  • Round Robin (RR) - Time-quantum based preemptive scheduling
  • Priority Scheduling (Preemptive) - Priority-based preemptive scheduling

๐ŸŽจ User Interface

  • Interactive Gantt Charts - Visual timeline of process execution
  • Real-time Performance Metrics - Average turnaround time and waiting time
  • Dynamic Form Inputs - Context-aware input fields based on selected algorithm
  • Professional Video Background - Full-screen looping animation
  • Responsive Design - Works seamlessly on desktop, tablet, and mobile
  • Dark Theme - Professional dark interface with excellent contrast

๐Ÿ“Š Visualizations

  • Color-coded Gantt Charts - Each process has a unique color
  • Process Timeline - Visual representation of execution order
  • Performance Summary - Statistical analysis of algorithm efficiency
  • Process Management Table - Easy addition and removal of processes

๐Ÿ› ๏ธ Technology Stack

  • Frontend Framework: Next.js 14 with React 18
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: Radix UI primitives
  • Icons: Lucide React
  • Build Tool: Next.js built-in bundler

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18 or higher
  • npm or pnpm package manager

Installation

  1. Clone the repository

    git clone https://github.com/gagan771/OS.git
    cd OS
  2. Install dependencies

    npm install
    # or
    pnpm install
  3. Run the development server

    npm run dev
    # or
    pnpm dev
  4. Open your browser Navigate to http://localhost:3000

Production Build

npm run build
npm start

๐Ÿ“– How to Use

1. Adding Processes

  1. Select your desired algorithm from the dropdown
  2. Fill in process details:
    • Process ID: Unique identifier (e.g., P1, P2)
    • Arrival Time: When the process arrives in the system
    • Burst Time: CPU execution time required
    • Priority: Only for Priority Scheduling (lower number = higher priority)
  3. Click "Add Process" to add to the simulation

2. Algorithm Configuration

  • Round Robin: Set the time quantum (default: 2)
  • Priority Scheduling: Assign priority values (1 = highest priority)

3. Running Simulation

  1. Click "Run Simulation" to execute the selected algorithm
  2. View the Gantt chart showing process execution timeline
  3. Analyze performance metrics in the results table

4. Results Analysis

  • Completion Time: When each process finishes execution
  • Turnaround Time: Total time from arrival to completion
  • Waiting Time: Time spent waiting in the ready queue
  • Average Metrics: Overall algorithm performance

๐Ÿงช Algorithm Details

FCFS (First-Come, First-Served)

Characteristics:
โœ… Simple implementation
โœ… Fair scheduling
โŒ Convoy effect with long processes
โŒ Poor average waiting time

SJF (Shortest Job First)

Characteristics:
โœ… Minimizes average waiting time
โœ… Optimal for non-preemptive scheduling
โŒ Starvation of long processes
โŒ Requires knowledge of burst times

SRTF (Shortest Remaining Time First)

Characteristics:
โœ… Optimal average waiting time
โœ… Preemptive nature prevents convoy effect
โŒ Higher context switching overhead
โŒ Starvation possible

Round Robin

Characteristics:
โœ… Fair time sharing
โœ… No starvation
โœ… Good response time
โŒ Higher turnaround time for short processes

Priority Scheduling (Preemptive)

Characteristics:
โœ… Allows importance-based scheduling
โœ… Suitable for real-time systems
โŒ Starvation of low-priority processes
โŒ Priority inversion possible

๐Ÿ“Š Example Usage

Sample Process Set

Process | Arrival Time | Burst Time | Priority
P1      | 0           | 6          | 2
P2      | 1           | 8          | 1
P3      | 2           | 7          | 3
P4      | 3           | 3          | 2

Expected Results (FCFS)

Process | Completion | Turnaround | Waiting
P1      | 6         | 6          | 0
P2      | 14        | 13         | 5
P3      | 21        | 19         | 12
P4      | 24        | 21         | 18

Average Turnaround Time: 14.75
Average Waiting Time: 8.75

๐Ÿ”ง Development

Project Structure

OS/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ globals.css          # Global styles
โ”‚   โ”œโ”€โ”€ layout.tsx           # Root layout
โ”‚   โ””โ”€โ”€ page.tsx             # Main application
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ ui/                  # Reusable UI components
โ”‚   โ””โ”€โ”€ theme-provider.tsx   # Theme configuration
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ utils.ts             # Utility functions
โ”œโ”€โ”€ public/                  # Static assets
โ””โ”€โ”€ styles/                  # Additional styles

Key Components

  • Algorithm Implementations: Five scheduling algorithms with comprehensive logic
  • UI Components: Form inputs, tables, charts, and buttons
  • State Management: React hooks for process management and results
  • Validation: Input validation and error handling

Testing

The project includes comprehensive test suites:

# Run production test suite
node production-test-suite.js

# Run specific algorithm tests
node test-priority-scheduling.js
node test-rr-fix.js

๐Ÿงช Test Coverage

  • โœ… 80+ Test Cases across all algorithms
  • โœ… Edge Case Testing (single process, concurrent arrivals, time gaps)
  • โœ… Mathematical Validation (formulas, calculations)
  • โœ… Gantt Chart Integrity (no overlaps, correct timing)
  • โœ… Input Validation (boundary conditions)

๐ŸŒ Browser Support

  • โœ… Chrome 60+
  • โœ… Firefox 55+
  • โœ… Safari 12+
  • โœ… Edge 79+

๐ŸŽจ Customization

Changing Colors

Modify the PROCESS_COLORS array in page.tsx:

const PROCESS_COLORS = [
  "#3b82f6", "#ef4444", "#10b981", // Add your colors
]

Video Background

Replace the video URL in the video element:

<source src="your-video-url.mp4" type="video/mp4" />

Algorithm Parameters

Adjust default values:

const [timeQuantum, setTimeQuantum] = useState<number>(2) // Round Robin
const [algorithm, setAlgorithm] = useState<Algorithm>("FCFS") // Default algorithm

๐Ÿ“š Educational Use

This simulator is perfect for:

  • Operating Systems Courses - Visual learning of CPU scheduling
  • Algorithm Analysis - Comparing performance metrics
  • Research Projects - Baseline implementation for extensions
  • Self-Study - Interactive learning experience

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Maintain test coverage for new features
  • Update documentation for algorithm changes
  • Ensure responsive design compatibility

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Gagan - @gagan771

๐Ÿ™ Acknowledgments

  • Pexels for the professional video background
  • Radix UI for accessible component primitives
  • Tailwind CSS for utility-first styling
  • Lucide for beautiful icons
  • Operating Systems community for algorithm specifications

๐Ÿ“ˆ Performance Metrics

  • Load Time: < 2 seconds on standard connections
  • Bundle Size: Optimized for production deployment
  • Memory Usage: Efficient algorithm implementations
  • Responsiveness: 60fps animations and interactions

๐Ÿ”ฎ Future Enhancements

  • Multi-level Queue Scheduling
  • Multi-level Feedback Queue
  • Real-time scheduling algorithms
  • Process synchronization visualization
  • Export results to PDF/CSV
  • Algorithm comparison mode
  • Interactive tutorial mode

โญ Star this repository if it helped you learn CPU scheduling algorithms! โญ

Demo โ€ข Documentation โ€ข Issues โ€ข Discussions

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published