GithubHelp home page GithubHelp logo

madhurchhajed / fifo-first-in-first-out-algorithm-implementation Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 5 KB

Implementation of FIFO Algorithm in C

C 100.00%
firstinfirstout page-fault fifo fifo-algorithm frame-size hits frame-array pagefault operating-system

fifo-first-in-first-out-algorithm-implementation's Introduction

FIFO-First-in-First-Out-Algorithm-Implementation

The simplest page-replacement algorithm is a FIFO algorithm. The first-in, first-out (FIFO) page replacement algorithm is a low-overhead algorithm that requires little bookkeeping on the part of the operating system. In simple words, on a page fault, the frame that has been in memory the longest is replaced.

Inputs required –

  1. Input the no. of pages.
  2. Input size of frames.
  3. Input values of page value.

Procedure –

  1. Assign values in frame = -1 initially.

In Loop:

  1. For initial values we are comparing in if condition if value in frame array is 1 and loop variable i < frame size, here enqueuing of values will take place. Page Fault counter will increment here.

  2. When frame array is full and when new value come, we need to see if already present in frame array or not. Hit counter will increment here.

  3. If not in array z counter will increment and will be equal to frame size. Which will mean it’s new value and we need to enter that value in array and remove the value using FIFO concept. Page Fault counter will increment here.

Output –

  1. Frame array as it changes.
  2. Final Frame array.
  3. No. of hits.
  4. No. of page faults.

Example -

Enter the no. of pages : 7

Enter the size of frame : 3

Enter the pages value : 1 3 0 3 5 6 7

Current Frame: -1 -1 1

Current Frame: -1 3 1

Current Frame: 0 3 1

Current Frame: 0 3 1

Current Frame: 5 0 3

Current Frame: 6 5 0

Current Frame: 7 6 5

frame at the end : b[0] = 5 b[1] = 6 b[2] = 7 Page Fault = 6 Hit = 1

fifo-first-in-first-out-algorithm-implementation's People

Contributors

madhurchhajed avatar manas-shukl avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

manas-shukl

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.