CSCI 3500: Studio

Page Replacement Algorithms


When memory is full, a paged memory system must have a mechanism in place to evict some page currently in memory. Ideally, this is a page that is not currently needed by any process, and will not be needed for a long while. To approximate this principle, a variety of page replacement algorithms are used to guess at which page in memory will be the least needed in the future.

In this studio, you will:

  1. Apply the clarivoyant (optimal) page replacement algorithm
  2. Apply the FIFO page replacement algorithm
  3. Apply the LRU page replacement algorithm

Please complete the required exercises below, as well as any optional enrichment exercises that you wish to complete.

As you work through these exercises, please record your answers in a text file. When finished, submit your work via the Git repository.

Make sure that the name of each person who worked on these exercises is listed in the first answer, and make sure you number each of your responses so it is easy to match your responses with each exercise.


Required Exercises

  1. As the answer to the first exercise, list the names of the people who worked together on this studio.

  2. Suppose your machine has three physical page frames. At system start, no frames contain any pages. Then, you run a program that makes accesses that require the following pages.

    A F B B C E A E D D C B B A F

    Before considering any specific replacement algorithm, what is the minimum number of page faults that will occur during this sequence?

  3. Compute the sequence of page faults using the clarivoyant (optimal) algorithm. How many total faults occurred?

  4. Compute the sequence of page faults using the FIFO algorithm. How many total faults occurred?

  5. Compute the sequence of page faults using the LRU algorithm. How many total faults occurred?

  6. Suppose your program is running slowly, and after some investigation you realize that the program is generating a lot of page faults. Give two possible solutions generating fewer page faults.

  7. Suppose a smart programmer comes along and rearranges the accesses of your program so that it now accesses pages in the following order:

    A F B B C C B B A E E D D A F

    Why is this always advantageous, regardless of what page replacement algorithm is used?

  8. Suppose you're working with the following sequence of page accesses. Assume again that your machine has three physical page frames. Compute the number of faults using the FIFO algorithm:

    D C B A D C E D C B A E

  9. Thinking that you could make your program faster if you just spent a little more money, you upgrade your machine so that it now has four physical page frames. Re-compute the number of faults using the FIFO algorithm.

  10. Was the result from the last exercise expected or unexpected? Can you explain the result?

  11. This counter-intuitive result is called Belady's Anomaly. In general, anomalies in computer science are results that show that an intuitive solution to fixing a performance problem (i.e. add more memory, make the processor faster, reduce system utilization) can actually make things worse than better.

    Suppose you're paid the big bucks by a company to implement and maintain performance-critical algorithms. Knowing what you know about the possibilities of anomalies, how should you proceed when the company wants to buy new machines?

Optional Enrichment Exercises

  1. No optional exercises