Coder Social home page Coder Social logo

chiragobhan / cpu-scheduling Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 50 KB

C program for FCFS and SJF that reads input from input.txt and writes the executed output in output.txt.

License: MIT License

C 100.00%
c fcfs sjf cpu-scheduling input-output gcc first-come-first-serve shortest-job-first

cpu-scheduling's Introduction

CPU Scheduling using FCFS and SJF

C program for FCFS and SJF that reads input from input.txt and writes the executed output in output.txt. The file is compiled using GCC-TDM and hence can be directly executed using program.exe. Our goal is to determine the average waiting time and average turnaround time for each method using the same input values. This will help us understand the concept of CPU Scheduling in a better way.

Input

The input for the program should be supplied in "input.txt" as the following format:
<process_id>,<arrival_time>,<burst_time>
We will be using the following values for this example.

input

Execution

Once the values are entered, simply run program.exe to execute the algorithms.

FCFS

First Come First Serve simply queues processes in the order they arrive in the ready queue. Here, the process that comes first will be executed first and next process will start only after the previous gets fully executed.

  1. Completion Time: Time at which process completes its execution.
  2. Turn Around Time: Time Difference between completion time and arrival time. (Turn Around Time = Completion Time – Arrival Time)
  3. Waiting Time: Time Difference between turn around time and burst time. (Waiting Time = Turn Around Time – Burst Time)

So, after executing program.exe, following will be the output for FCFS:

fcfs

SJF

Shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next. SJN is a non-preemptive algorithm.

  1. Completion Time: Time at which process completes its execution.
  2. Turn Around Time: Time Difference between completion time and arrival time. (Turn Around Time = Completion Time – Arrival Time)
  3. Waiting Time: Time Difference between turn around time and burst time. (Waiting Time = Turn Around Time – Burst Time)

Following is the output for SJF:

sjf

Output

By now your output should be written in "output.txt". (If this file does not exist, the program will create a new file. Otherwise it will override the existing file).

output

cpu-scheduling's People

Contributors

chiragobhan avatar

Stargazers

 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.