Comp111: Operating Systems
Classroom Exercise 11 Answers
Virtual Memory
Fall 2017

In class, we've studied the basic function of virtual memory. Recall that a frame is a unit of allocatable memory from the operating system, while a page represents a need for memory in a process. Let's explore these concepts further.

  1. Why is it practical to relocate a frame to another physical address? What must one do?
    A frame gets mapped to a page. Its physical address can thus be moved and the logical address stays the same. In fact, this always happens when the page is recovered from disk.
  2. Why is it impractical to relocate a heap page to another address?
    We don't know which pointers point to it from elsewhere. The runtime system can't distinguish a pointer from an integer! Thus we could not correct the pointers that point to it.
  3. Does keeping lots of processes dormant (with no pages swapped in) slow down the OS? Why or why not?
    Just a little. The pages for the process will all swap out. The processes will not be in the run queue. However, the process page tables will remain in memory and will slow down things a tiny bit.
  4. What memory do dormant processes consume when they're not running?
    As above, the page table remains in memory even when the process is not running.
  5. (Advanced) Current wisdom is to allocate lots of swap space on a workstation, but use none at all on a server. Why might this be a good strategy?
    A workstation can have lots of dormant processes, e.g., word processors, image editors, and other things waiting for user input.

    By contrast, a typical server answers requests with processes that never wait for I/O.

    Thus, there is little need for a server request handler to ever go dormant, so there is little need to have it swap out of memory.

    Thus, we tend to put as much memory into servers as possible, and almost no swap space on disk.

  6. (Advanced) The OS doesn't store the page table as an array. What data structure would be more appropriate? How would it be structured?
    It's actually a kind of tree. The reason for this is that the page table isn't a dense structure. There are lots of holes. Thus we don't want to store the whole page table as an array.
  7. (Advanced) Why did the IA64 architecture do away with segment descriptors? It seems like they would save space over recording a protection bit for each page.
    This is really deep. A segment descriptor encodes the operating systems's idea of protection for a page. In the page table, this is an attribute of the page rather than the segment. Thus, although the OS needs to keep track of the segment, the CPU does not. It can simply look at the page protection word instead. The real reason that it does this concerns how the page table is stored in the CPU, which is the subject of this lecture.