Answer to Question 4 -- 20 points

  1. Virtual addresses are 32 bits, and split into two parts. The page number is the first 20 bits, and the offset within the page is the last 12 bits. The inverted page table is a mapping of physical addresses to virtual addresses. Memory is 4 megabytes, partitioned into 1024 pages. Therefore the inverted page table will consist of 1024 entries. Each of these entries must have: That makes a total of 42 bits or so.
  2. A virtual address is translated to a physical address by traversing the page table and looking for the virtual address. If it is found, and the owning process is equal to the current running process, then its index in the table is the frame number of the physical page. If it is not found, then a page fault must occur.

    You may be able to make this more efficient by hashing virtual addresses. Thus, in the normal case, the translation may be found in a few memory lookups rather than an entire table traversal.

  3. A translation lookaside buffer (TLB) is an associative memory that can perform fast lookup on virtual addresses and provide the translation in much less time than it takes to perform a memory access. TLB's are effective, especially when combined with caches, because programs tend to have locality in accessing pages.
  4. On a context switch, the TLB must be flushed. That's it.
  5. If a page fault occurs because a page is not resident in memory, a page in memory must be replaced. The steps that must be gone through are the following: