Coder Social home page Coder Social logo

zizo001 / poisson-page-fault-detection Goto Github PK

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

Program that aims to illustrate the difference between page fault detection algorithms depending on how their respective queues are managed by the OS

C++ 100.00%
algorithms-and-data-structures page-replacement poisson-distribution lru-replacement-algorithm fifo-page-replacement clock-replacement-algorithm operating-system-learning operating-system-concep memory-management

poisson-page-fault-detection's Introduction

Poisson Page Fault Detection

Table of Contents

Overview

The program compares the effectiveness of page replacement algorithms and tallies up the number of faults generated. It uses Poisson distribution with λ = 10 to generate 1000 page numbers. This is ran through three different algorithms: FIFO, LRU, and Clock/Second Chance. A total of 1000 experiments is performed for each algorithm. Furthermore, each experiment will have each algorithm use a working set size from 2 to 20. The average number of faults is plotted using Microsoft Excel and will be shown in the results section.

Background

Managing memory is a task that occurs in the background of all modern operating systems. Taking a closer look at the inner works of virtual memory management allows us to examine just how complex and involved the task actually is. This program aims to take a look at memory paging and how different algorithms can affect the effeciency of the OS. Memory paging is a memory management scheme in which secondary storage is used to store and retrieve data for later use in main memory. The OS retrieves data in equally-sized chunks known as pages. This allows programs to use secondary memory to exceed the amount of available physical memory.

Random Number Generation

The program generates a 1000 random numbers each time an experiment is performed. This random number generation is done using the built-in C++ Poisson distribution function with λ = 10. Poisson distribution is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time if these events occur with a known constant mean rate (10 in this case) and independently of the time since the last event. Here is an example of the distribution of 1,000,000 randomly generated numbers by the program:

As you can see, the random numbers center around the variable λ regardless of how many are generated. This ensures that every time we perform our experiment, our 'randomness' will have some consistency.

Replacement Algorithms

Operating systems commonly use paging mechanisms for memory management. Various algorithms are used in dictating the logic/order of page replacement when virtual address space is full. Depending on the situation, some algorithms can be more effecient than others. The replacement algorithms used in the program are:-

  • FIFO: The simplest page replacement algorithm. In this algorithm, the OS forms a queue in which the oldest page will always be in the front of the queue. When a page replacement is going to occur, the front of the queue is selected for removal.

  • LRU: In this algorithm, the OS forms a queue that is similar to FIFO, but keeps track of which page has been recently used. The least recently used page is selected for removal when the queue is full.

  • Clock (or second chance): The most complex out of the three algorithms. It centers around using a ‘use bit’ in each frame (which can either be 0 or 1). It associates the use bit with each page depending on the state of use. This is used to determine whether a page will be replaced.

Results

An example of the output of the average faults throughout the 1000 experiments after the data set has been graphed:

If you made it this far, I hope this was informative. I believe that this program can serve as a low-level look at memory management using paging. All 3 algorithms are very similar, yet small changes do make a huge difference in effeciency. I highly suggest you try to create a program centering around simulating memory management as I have learned a lot from this one. If you are interested in learning more, then I highly suggest checking out some of the links below.

https://www.geeksforgeeks.org/paging-in-operating-system/

https://www.geeksforgeeks.org/page-replacement-algorithms-in-operating-systems/

https://en.wikipedia.org/wiki/Cache_replacement_policies

http://www.mathcs.emory.edu/~cheung/Courses/355/Syllabus/9-virtual-mem/SC-replace.html

poisson-page-fault-detection's People

Contributors

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