CMPSCI 377: Operating Systems
Homework 4: Memory Management
Due: November 9

VIP Students: Due one week from when you receive the assignment

  1. Consider a segmented memory system with memory allocated as shown below.
    Suppose the following actions occur:
    • Process E starts and requests 300 memory units.
    • Process A requests 400 more memory units.
    • Process B exits.
    • Process F starts and requests 800 memory units.
    • Process C exits.
    • Process G starts and requests 900 memory units.

    1. (3 pts.) Describe the contents of memory after each action using the first-fit algorithm.

    2. (3 pts.) Describe the contents of memory after each action using the best-fit algorithm.

    3. (3 pts.) How would worst fit allocate memory?

    4. (1 pt.) For this example, which algorithm is best?

  2. Most modern operating systems support copy-on-write. Copy-on-write allows two processes to share a page in memory that contains data that can be modified but for which the processes do not want to see the changes made by each other. If a page is marked as copy-on-write and there is an attempt to write to that page, a trap occurs. The trap handler copies the page, updating the process's page table and re-executes the instruction that caused the trap.

    1. (5 pts.) What will the effect of re-execution be?

    2. (5 pts.) Describe one situation in which you believe copy-on-write would be useful.

  3. Suppose we have virtual memory containing 8 pages with 512 bytes per page and physical memory with 16 page frames.

    1. (2 pts.) How long is a virtual address?

    2. (2 pts.) How long is a physical address?

    3. (1 pt.) Given the following page table, what is the physical address corresponding to the virtual address of page 4, byte 241?

      VirtualPage
      PageFrame
      00
      18
      211
      36
      43
      51
      67
      710

  4. (10 pts.) Is it easier for processes to share code pages in a pure paging system or in a system that includes segmentation? Explain your answer.

  5. Consider a paging system with the page table stored in memory.

    1. (2 pts.) If a memory reference takes 150 nanoseconds, how long does a paged memory reference take?

    2. (3 pts.) If we add associative registers (a TLB), what percent of page table references need to hit in the TLB to get an effective access rate of 155 nanoseconds? Assume that a TLB lookup has zero overhead.