Code Monkey home page Code Monkey logo

cpu-scheduling-simulator's Introduction

CPU Scheduling Algorithms Visualizer

This web application visualizes various CPU scheduling algorithms. It supports First Come First Serve (FCFS), Shortest Job First (SJF), Shortest Remaining Time First (SRTF), Highest Response Ratio Next (HRRN), and Round Robin (RR) algorithms. The visualizer computes and displays the Gantt chart, average turnaround time, and average waiting time for a given set of processes.

Features

  • Algorithm Selection: Choose from FCFS, SJF, SRTF, HRRN, and RR algorithms.
  • Input Fields: Enter arrival and burst times for processes.
  • Time Quantum: Input for Round Robin algorithm.
  • Result Display: Shows completion time, turnaround time, and waiting time for each process.
  • Gantt Chart: Visual representation of process execution.
  • Average Times: Displays average turnaround and waiting times.

Getting Started

Prerequisites

  • A modern web browser (e.g., Chrome, Firefox, Edge)

Installation

Clone the repository:

git clone https://github.com/4syedalihassan/CPU-Scheduling-Simulator.git

Navigate to the project directory:

cd CPU-Scheduling-Simulator

Usage

  • Open index.html in your browser.
  • Select a scheduling algorithm from the dropdown menu.
  • Enter the arrival times and burst times of the processes in the respective input fields.
  • If you selected Round Robin, enter the time quantum.
  • Click the "Solve" button to see the results.
cpu-scheduling-visualizer/
├── algorithms/       # Algorthms
    ├── fcfs.js
    ├── sjf.js
    ├── srtf.js
    ├── rr.js
    ├── hrrn.js
├── index.html       # Main HTML file
├── styles.css       # CSS file for styling
└── script.js        # JavaScript file containing the logic

Code Explanation

  • Event Listener: Initializes the form and output fields when the DOM content is loaded.
  • Toggle Time Quantum Field: Displays the time quantum input field only for Round Robin algorithm.
  • Solve Function: Validates inputs and calls the appropriate scheduling algorithm function.
  • Validate and Parse Input: Utility functions for input validation and parsing.
  • Display Result: Renders the results, including the Gantt chart and average times.
  • Clear Output: Resets the output fields.

Scheduling Algorithms Functions

** Implement the following functions to calculate scheduling metrics:

  • FCFS (First Come First Serve)
  • SJF (Shortest Job First)
  • SRTF (Shortest Remaining Time First)
  • HRRN (Highest Response Ratio Next)
  • RR (Round Robin)

These functions should return an array of objects with process details including completion time, turnaround time, and waiting time.

function solveFCFS(arrivalTimes, burstTimes) {
    // Implement FCFS algorithm
    return result;
}

License

Distributed under the MIT License. See LICENSE for more information.

cpu-scheduling-simulator's People

Contributors

4syedalihassan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.