Coder Social home page Coder Social logo

fcfs-sjfs-program's Introduction

CPU Scheduling Algorithm

This project implements two CPU scheduling algorithms: First Come First Serve (FCFS) and Shortest Job First (SJF). The program takes input parameters such as the number of processes, arrival time, and burst time for each process. It then computes the waiting time, turnaround time, average waiting time, and average turnaround time for each process.

Features

  • First Come First Serve (FCFS): Processes are executed in the order they arrive.
  • Shortest Job First (SJF): Processes with the shortest burst time are executed first, allowing for efficient resource utilization.

Program Input

The program prompts the user to choose an algorithm and input the following parameters:

  • Number of processes
  • Arrival time and burst time for each process

Installation

  1. Clone the repository:

    git clone https://github.com/your_username/cpu-scheduling-algorithm.git
  2. Compile the program:

    g++ main.cpp ProcessScheduler.cpp Process.cpp -o scheduler
  3. Run the program:

    ./scheduler

Usage

  1. Choose an algorithm: FCFS or SJF.
  2. Enter the number of processes.
  3. Enter the arrival time and burst time for each process.
  4. View the scheduling results, including waiting time, turnaround time, and Gantt chart.

Example

Choose an algorithm:
[1] - First Come First Serve (FCFS)
[2] - Shortest Job First (SJF)
> 2

Enter number of processes:
> 4

Enter the arrival time and burst time for Process 1:
Arrival Time: > 0
Burst Time: > 7

Enter the arrival time and burst time for Process 2:
Arrival Time: > 2
Burst Time: > 4

Enter the arrival time and burst time for Process 3:
Arrival Time: > 4
Burst Time: > 1

Enter the arrival time and burst time for Process 4:
Arrival Time: > 5
Burst Time: > 4

PROCESS         ARRIVAL TIME    BURST TIME      WAITING TIME    TURNAROUND TIME
P1              0               7               0               7
P3              1               4               3               4
P2              2               4               6               10
P4              4               5               7               12

Average Waiting Time: 4
Average Turnaround Time: 8

GANTT CHART
|P1|****P3****|****P2****|******P4******|
0   7        11       15               20

Save this content in a file named README.md in the root directory of your project. You can also include the installation steps, usage instructions, and example output specific to your project.

fcfs-sjfs-program's People

Contributors

danishfirhan 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.