Code Monkey home page Code Monkey logo

cpu-scheduling-algorithms's Introduction

Process Scheduling Algorithms โš™๏ธ๐Ÿ’ป

This repository contains C++ implementations of various process scheduling algorithms:

  • First Come First Serve (FCFS)
  • Shortest Remaining Time First (SRT)
  • Round Robin (RR)
  • Shortest Job First (SJF)

Description ๐ŸŽฏ

Each algorithm is implemented in its respective file. The main program, main.cpp, reads process information from input files, simulates the scheduling algorithms, and prints out the results.

Files ๐Ÿ—‚

  • PCB.h: Defines the Process Control Block (PCB) structure used to represent individual processes.
  • PCBFuns.h: Contains helper functions used in scheduling algorithms.
  • algorithms.cpp: Contains implementations of the scheduling algorithms.
  • main.cpp: The main program that orchestrates the simulation and prints results.
  • processes/: Directory containing input files for different scheduling algorithms.

How to Use ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป

  1. Compilation: Compile the program using a C++ compiler. For example:
    g++ main.cpp -o scheduler

  2. Input Files: Prepare input files in the processes/ directory. Each input file should follow the format specified below:

    <context_switch_time> <quantum_time> 
    <process_id> <arrival_time> <CPU_burst_time> <size_in_bytes>
  3. Execution: Run the compiled program, providing the number of processes as a command-line argument. For example:

  4. Output: The program will display Gantt charts and various statistics for each scheduling algorithm.

Input File Format ๐Ÿ“‘

Each input file should contain the following information:

  • The first line specifies the context switch time and quantum time.

  • Each subsequent line represents a process, with the following fields separated by spaces:

      • Process ID
      • Arrival time
      • CPU burst time
      • Size in bytes
  • Example input file (FCFS.txt):

    2 4
    1 0 8 1024
    2 1 6 512
    3 3 10 2048

Output ๐Ÿ’ป

The program generates Gantt charts and calculates the following statistics for each scheduling algorithm:

  • Average Waiting Time
  • Average Turnaround Time
  • CPU Utilization Rate

cpu-scheduling-algorithms's People

Contributors

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