Code Monkey home page Code Monkey logo

paging-simulation's Introduction

Paging-simulation

We simulate a paging system. Two processes read two trace files in an alternating pattern. Each processes has its own page table (represented as a hash). Two swapping policies can be tested {LRU / Second chance}. The trace files contain addresses and the character R if it's a reading request , or W if it's a writing request respectively.

Note : this was a university assignment.

How to compile:

  • make

Ho to run:

  • ./prog
  • The trace files should be in the parent directory (parametric files not supported).

Arguments:

  • a : algorithm LRU / SC
  • f : number of frames
  • qr : q references per iteration
  • am : maximum number of references to be read in the simulation

Example:

./prog -a LRU -f 1000 -qr 80 -qm 13900

Implementation details:

A double linkedlist and a hashtable are used. The hashtable is used for the Page-table representation whereas the linked list for the LRU / SC "stack/queue"

The trace struct represent the currently read trace , having its type {read/rite} and the address it is trying to access.

The frame struct represents a page in memory. It has 2 member variables , currentPageNumber and currentPID. We require the PID of each active page so we know which page table to alter if a page fault occurs in said frame's page. (We remove page table entries that are not active in memory , so when a new reference comes we only need to see if the entry is contained in the page table , if not a page fault occurs.)

Finaly a page entry struct represents the info a newly added page contains. It contains its frameNumber (index) in a corresponding array of frames if it a write has occursed (the page is dirty) and if it has been recentlyRead (used by SC)

Results:

We print the number of Page faults and Disk writes before and after the final cleanup. (when the simulation ends there are still pages in memory). We dont print Disk reads since a page fault is followed by a page read so we know page reads == page faults.

paging-simulation's People

Contributors

timospal avatar

Stargazers

 avatar

Watchers

 avatar

paging-simulation's Issues

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.