CSE 120 Spring 2002 Homework 3

Solutions

Problem 1

Consider a system that uses demand paging. The backing store is stored on a disk that is used only for backing store.

Define the utilization of a resource (over some period of time) to be the percentage of time that the resource is being used. When you measure the utilizations of different resources in the system, you find that the utilization of the CPU is 20%, the utilization of the backing store disk is at 99%, and the utilizations of the other devices (such as the other disks and the network adaptor) are 5% or lower.

  1. What phenomenon would most likely result in these characteristics?

  2. The system is thrashing: a majority of the time is being spent waiting for pages to be transfered between backing store and main memory.
     

  3. What effect would each of the following actions have on the CPU utilization?
    1. Increasing the speed of the CPU. This would decrease the utilization, since the time between page faults would correspondingly decrease.
    2. Increasing the capacity of the paging disk. This should have no effect on CPU utilization unless, for some odd reason, a larger disk had different effective data transfer performance.
    3. Increasing the page size. The effect of this is hard to predict. It might decrease CPU utilization for a demand paging system, since in doing so the virtual memory system would be reducing the number of read requests. On the other hand, a larger page size reduces the number of page frames making it harder to share what physical memory there is among the processes.
    4. Increasing the amount of physical memory. If the mix of processes is left unchanged, then this should increase the CPU utilization.
    5. Decreasing the degree of multiprogramming. This will increase the CPU utilization (assuming that there is more than one process running originally!).

Problem 2

Assume a fixed amount of physical memory and assume LRU demand paging. Give a reference string that has the following two properties: Consider the infinite sequence of addresses

0 100 200 300 400 500 0 100 200 300 400 500 ...

Let there be 400 bytes of physical memory.

If the page size is 100 bytes, then there are four page frames and the page reference string is 0 1 2 3 4 5 0 1 2 3 4 5 ... Each page reference will result in a page fault: starting with the fifth reference, a reference to page i forces page (i + 4) mod 6 to be discarded. In particular, for any positive integer k after 6k references there will be 6k page faults.

If we double the page size to 200 bytes, then there are two page frames, and the page reference string is 0 0 1 1 2 2 0 0 1 1 2 2  ... There are stuttered references in this string, and each stuttered sequence results in only one page fault. Hence, for any positive integer k after 6k references there will be 3k page faults: the page fault rate is halved.

If we halve the page size to 50 bytes, then there are eight page frames, and the page reference string is 0 2 4 6 8 10 0 2 4 6 8 10 ... There are only five distinct pages in this string, and so there will be only five page faults for any prefix of this string whose length is at least five.


Problem 3

Consider the following information about a virtual memory system that employs both paging and segmentation. Let |s1|, |s2|, |p| and |w| denote the length, in bits, of each of the four address components. Hence, n = |s1| + |s2| + |p| + |w|.
  1. What is the value of |w|? 9, since the page size is 29.
  2. What is the maximum number of pages per segment and what is the corresponding value of |p|?

  3.  

     

    The limit on this value comes from the requirement that a page table consume no more than one page. Since a page table entry consumes one word (there's a lot of wasted bits here!), a page table can cover up to 512 pages. Hence, |p| is also 9.
     

  4. Using the determined values of |w| and |p|, which of the following is choices for |s1| and |s2| is preferable?
    1. |s1| = |w| and |s2| = n - |p| - |w|
      or |s2| = |w| and |s1| = n - |p| - |w|


    Substituting, we have either |s1| = 9 and |s2| = n - 18 or |s1| = n - 18 and |s2| = 9. Thus, n must be at least 19. If n = 27 then the question is trivial: both fields have length 9, and so neither is preferable. If n != 18 then the question reduces to is it better to have |s1| larger than |s2| or not? and we instantiate the choice of rules above depending on the answer to this question and whether n is at least 20 or not.

    In either case, there will be one segment table with a maximum size of 2|s1|words and 2|s1| second level segment tables, each of a maximum size of 2|s2| words. Hence, the maximum space that can be consumed by segment tables is 2|s1| + 2|s1| + |s2|. With no other information to go on, choosing a smaller |s1| results in less physical memory being devoted to segment tables.

    One can imagine, however, a management scheme in which one had more first level segments, each devoted to a process. If a process never requires more than 2|s2|+|p|+|w| words of virtual memory, this scheme simplifies page and segment table management.

    Would either choice result in a larger virtual address space? Explain.

    Neither choice, of course, will result in a larger virtual address space: in either case, there are 2n addressable words.


Problem 4

If a large number of programs is kept in main memory, then there is almost always another ready program when a page fault occurs. Thus, CPU utilization is kept high. If, however, we allocate a large memory space to each of a few programs, then each program produces a smaller number of page faults. Thus, CPU utilization is kept high.

Are these two arguments correct? Which policy, if either, should be preferred? Why?

Both arguments are correct to a point, and neither should be preferred because each doesn't address the issue of thrashing. The degree of multiprogramming should be adjusted to ensure that each process can obtain its working set of page frames.


last edited 28 May 2002 by kam