Skip to content

Parv2606/OS_Simulator

Repository files navigation

OS Simulator

License: MIT React Vite

An interactive web-based Operating System Simulator built with React. This application provides a comprehensive platform for learning and visualizing key OS concepts including CPU scheduling algorithms, synchronization problems, deadlock detection, and more.

🚀 Features

CPU Scheduling Simulator

  • Algorithms Supported:
    • First Come First Served (FCFS)
    • Shortest Job First (SJF) - Non-Preemptive & Preemptive
    • Round Robin
    • Priority Scheduling
  • Real-time Visualization: Interactive Gantt charts showing process execution over time
  • Process Management: Add, edit, and manage processes with custom arrival times, burst times, and priorities
  • Queue Visualization: Live updates of ready and waiting queues
  • Controls: Play, pause, reset, and single-step execution

Synchronization Modules

  • Producer-Consumer Problem: Bounded buffer simulation with semaphores
  • Readers-Writers Problem: Shared resource access with reader/writer priorities
  • Dining Philosophers: Resource allocation and deadlock prevention
  • Critical Section: Demonstration of race conditions with and without mutex

Deadlock Detection

  • Banker's Algorithm: Safe state checking and resource request handling
  • Resource Allocation Graph: Visual representation of resource dependencies

Additional Features

  • Analytics Dashboard: Performance metrics and algorithm comparison
  • Dark/Light Theme: Toggle between themes for better visibility
  • Responsive Design: Works on desktop and mobile devices
  • Export Functionality: Generate PDFs of simulation results
  • Preset Scenarios: Pre-loaded examples for quick testing

🛠 Tech Stack

  • Frontend Framework: React 18 with Hooks
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • Charts: Recharts
  • Icons: Lucide React
  • Animations: Framer Motion
  • PDF Generation: jsPDF + html2canvas
  • Routing: React Router DOM

📋 Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn

🚀 Getting Started

  1. Clone the repository:

    git clone https://github.com/Parv2606/OS_Simulator.git
    cd OS_Simulator
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev
  4. Open your browser: Navigate to http://localhost:5173

📖 Usage

CPU Scheduling

  1. Navigate to the CPU Scheduling simulator
  2. Select an algorithm from the dropdown
  3. Add processes using the process editor (specify arrival time, burst time, priority if applicable)
  4. Click "Start" to begin the simulation
  5. Use controls to pause/resume or step through execution
  6. View the Gantt chart and metrics in real-time

Synchronization Problems

  1. Choose a synchronization module (Producer-Consumer, Readers-Writers, Dining Philosophers, Critical Section)
  2. Adjust parameters (buffer size, number of philosophers, etc.)
  3. Run the simulation to observe synchronization behavior
  4. Monitor semaphore states and process interactions

Deadlock Detection

  1. Go to the Banker's Algorithm section
  2. Define available resources and process requirements
  3. Simulate resource requests
  4. View safety checks and allocation graphs

📁 Project Structure

src/
├── components/          # Reusable UI components
├── pages/              # Main application pages
├── engine/             # Simulation logic and algorithms
├── data/               # Presets and theoretical content
├── utils/              # Helper functions
└── App.jsx             # Main application component

🤝 Contributing

Contributions are welcome! Please follow these steps:

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

Development Guidelines

  • Follow React best practices
  • Use meaningful component and variable names
  • Add comments for complex logic
  • Test your changes thoroughly

📄 License

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

🙏 Acknowledgments

  • Built for educational purposes to help students understand OS concepts
  • Inspired by various OS textbooks and online resources
  • Special thanks to the open-source community

📞 Support

If you have any questions or issues, please open an issue on GitHub or contact the maintainers.


Note: This simulator is designed for educational purposes and may not reflect real-world OS implementations perfectly. Use it as a learning tool alongside theoretical study.

Synchronization Modules

  • Producer Consumer with bounded buffer, mutex, and counting semaphores
  • Readers Writers with shared-reader and exclusive-writer behavior
  • Dining Philosophers with resource ordering to prevent deadlock
  • Critical Section with and without a mutex to demonstrate race conditions

Project Structure

src/
  components/
    Controls.jsx
    GanttChart.jsx
    QueueView.jsx
  data/
    scenarios.js
  engine/
    processModel.js
    scheduler.js
    simulationEngine.js
  sync/
    mutex.js
    semaphore.js

Run Locally

npm install
npm run dev

Production Build

npm run build

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages