Chap 9 Quest
Chap 9 Quest
Chap 9 Quest
Practice Exercises
9.1 Under what circumstances do page faults occur? Describe the actions taken by the
operating system when a page fault occurs.
9.2 Assume that you have a page-reference string for a process with m frames (initially all
empty). The page-reference string has length p;n distinct page numbers occur in it. Answer
these questions for any page replacement algorithms:
9.3 Which of the following programming techniques and structures are “good” for a demand-
paged environment? Which are “not good”? Explain your answers.
a. Stack
b. Hashed symbol table
c. Sequential search
d. Binary search
e. Pure code
f. Vector operations
g. Indirection
9.4 Consider the following page-replacement algorithms. Rank these algorithms on five-point
scale from “bad” to “perfect” according to their page-fault rate. Separate those algorithms that
suffer from Belady’s anomaly from those that do not.
a. LRU replacement
b. FIFO replacement
c. Optimal replacement
d. Second-chance replacement
9.5 When virtual memory is implemented in a computing system, there are certain costs
associated with the technique and certain benefits. List the costs and the benefits. Is it possible
for the costs to exceed the benefits? If it is, what measures can be taken to ensure that this
does not happen?
9.6 An operating system supports a paged virtual memory, using a central processor with a
cycle time of 1 microsecond. It costs an additional 1 microsecond to access a page other than
the current one. Pages have 1000 words, and the paging device is a drum that rotates at 3000
revolutions per minute and transfers 1 million words per second. The following statistical
measurements were obtained from the system:
• 1 percent of all instructions executed accessed a page other than the current page.
• Of the instructions that accessed another page, 80 percent accessed a page already in
memory.
• When a new page was required, the replaced page was modified 50 percent of the time.
Calculate the effective instruction time on this system, assuming that the system is running
one process only and that the processor is idle during drum transfers.
9.9 Suppose that you want to use a paging algorithm that requires a reference bit (such as
second-chance replacement or working-set model), but the hardware does not provide one.
Sketch how you could simulate a reference bit even if one were not provided by the hardware,
or explain why it is not possible to do so. If it is possible, calculate what the cost would be.
9.10 You have devised a new page-replacement algorithm that you think may be optimal. In
some contorted test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain
your answer.
9.11 Segmentation is similar to paging but uses variable-sized “pages.” Define two segment-
replacement algorithms based on FIFO and LRU pagereplacement schemes. Remember that
since segments are not the same size, the segment that is chosen to be replaced may not be big
enough to leave enough consecutive locations for the needed segment. Consider strategies for
systems where segments cannot be relocated, and those for systems where they can.
9.13 We have an operating system for a machine that uses base and limit registers, but we
have modified the machine to provide a page table. Can the page tables be set up to simulate
base and limit registers? How can they be, or why can they not be?