CMPSCI 377: Operating Systems 
Homework 4:  Memory Management 
Due:  November 21, in class  
Due to the Thanksgiving weekend, you can get a free extenstion of one week. If you take
up this extension, your homework will be due on Monday Nov 27, 5pm.
-  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.  
-  (5 pts.) What will the effect of re-execution be?
 -  (5 pts.) Describe one situation in which you believe copy-on-write would
be useful.
 
 -  Suppose we have virtual memory containing 8 pages with 512
bytes per page and physical memory with 16 page frames.
-  (4 pts.) How long is a virtual address?
 -  (4 pts.) How long is a physical address?
 -  (2 pts.) Given the following page table, what is the physical
address corresponding to the virtual address of page 4, byte 241?
| Virtual | Page
 | 
|---|
| Page | Frame
 | 
|---|
| 0 | 0
 | 
| 1 | 8
 | 
| 2 | 11
 | 
| 3 | 6
 | 
| 4 | 3
 | 
| 5 | 1
 | 
| 6 | 7
 | 
| 7 | 10
 | 
 
 -  (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.
 -  Consider a paging system with the page table stored in
memory.
-  (4 pts.) If a memory reference takes 200 nanoseconds, how long does a
paged memory reference take?
 -  (6 pts.) If we add associative registers (a TLB), and 75 percent of all page 
table references are found in associative registers, what is the effective memory 
reference time? Assume that finding a page-table entry in the TLB takes zero time, 
if the entry is there.)