{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PagingSimulator.java

PagingSimulator.java - Homework 4 Paging [email protected]

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * Homework 4 - Paging Simulator * @author Michael Riha * * This program simulates the FIFO, second chance, LRU, and random pick * paging algorithms based on various parameters: * * -Processes consist of 10 pages numbered 0 to 9 * -Physical memory has 4 page frames * -Disk has 6 page frames * -Process makes random references to pages * * Each algorithm is ran 5 times with 100 page references per run. The average * hit ratio of pages in memory is calculated during the simulation and printed. * For each reference we print the page numbers of the pages in memory, * which page needed to be paged, and which page was evicted */ public class PagingSimulator { public static final int SIM_RUNS = 5; private static class Simulator { private Pager page; private String pageStr; private double hitRatioSum; public Simulator(Pager page, String pageStr) { this.page = page; this.pageStr = pageStr; this.hitRatioSum = 0.0; } } public static void main(String[] args) { Simulator[] sims = new Simulator[] { new Simulator(new FirstInFirstOutPager(), "First In First Out"),
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern