CS372H Spring 2011 Homework 3

Problem 1

Suppose a program references pages in the following sequence:
ACBDBAEFBFAGEFA
Suppose the computer on which this program is running has 4 pages of physical memory.
  1. Show how LRU-based demand paging would fault pages into the four frames of physical memory.
  2. Show how OPT (or MIN) based demand paging would fault pages into the four frames of physical memory.
  3. Show how clock-based demand paging would fault pages into the four frames of physical memory.

Problem 2

Assume that you have a page reference string for a process. Let the page reference string have length p with n distinct page numbers occurring in it. Let m be the number of page frames that are allocated to the process (all the page frames are initially empty). Let n > m.
  1. What is the lower bound on the number of page faults?
  2. What is the upper bound on the number of page faults?
Hint: Your answer is independent of the page replacement scheme that you use.
 

Problem 3

Belady's anomaly: Intuitively, it seems that the more frames the memory has, the fewer page faults a program will get. Surprisingly enough, this is not always true. Belady (1969) discovered an example in which FIFO page replacement causes more faults with four page frames than with three. This strange situation has become known as Belady's anomaly. To illustrate, a program with five virtual pages numbered from 0 to 4 references its pages in the order:
0 1 2 3 0 1 4 0 1 2 3 4
  1. Using FIFO replacement, compute the number of page faults with 3 frames. Repeat for 4 frames.
  2. Compute the number of page faults under LRU, NRU, the clock algorithm, and the optimal algorithm.

Problem 4

Explain the steps that an operating system goes through when the CPU receives an interrupt.