CSE 120 -- Homework #3.5

Out: 11/14/00
In: 11/21/00

[15 pts] In Project #2, part 1, you need to create a page table for a new address space, allocate physical memory for the address space, and then load the program code and data segments into the address space. This worksheet is intended to give you practice with Nachos page tables so that you are comfortable implementing these operations. The context of this worksheet is the AddrSpace constructor (i.e., interpret references to variables in the context of the AddrSpace constructor method).

For the purposes of this worksheet, assume that PageSize is 128 bytes, the program being loaded requires 4 pages, and physical memory has 8 pages. In the diagram below, we have assigned a set of physical pages (from machine->mainMemory) to virtual pages (in pageTable).

  1. What is the value of the AddrSpace variable numPages?

  2. What is the value of size?

  3. What is the value of NumPhysPages?

  4. What are the values of the pageTable mappings?

  5. What is the virtual address of virtual page 2 (the start of virtual page 2 in the virtual address space)?

  6. What is the physical address of virtual page 2?

  7. What physical page does the virtual address 298 reside in?

  8. What is the offset of the virtual address 298?

  9. What is the physical address of the virtual address 298?

    In the diagram below, we want to load the code segment from the executable file into the virtual address space of the process. Assume that the code segment is two pages long.

  10. What is the value of code.size?

  11. Assume that code.inFileAddr points to page three in the executable file. What is the value of code.inFileAddr?

  12. Assume that code.virtualAddr points to page one in the virtual address space. What is the value of code.virtualAddr?

  13. What is the physical address that corresponds to code.virtualAddr?

  14. What physical page is the first code page loaded into?

  15. What physical page is the second code page loaded into?


voelker@cs.ucsd.edu