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).
- What is the value of the AddrSpace variable numPages?
- What is the value of size?
- What is the value of NumPhysPages?
- What are the values of the pageTable mappings?
- pageTable[0].virtualPage =
- pageTable[0].physicalPage =
- pageTable[1].virtualPage =
- pageTable[1].physicalPage =
- pageTable[2].virtualPage =
- pageTable[2].physicalPage =
- pageTable[3].virtualPage =
- pageTable[3].physicalPage =
- What is the virtual address of virtual page 2 (the start of virtual page 2 in the virtual address space)?
- What is the physical address of virtual page 2?
- What physical page does the virtual address 298 reside in?
- What is the offset of the virtual address 298?
- 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.
- What is the value of code.size?
- Assume that code.inFileAddr points to page three
in the executable file. What is the value of code.inFileAddr?
- Assume that code.virtualAddr points to page one in the
virtual address space. What is the value of code.virtualAddr?
- What is the physical address that corresponds to code.virtualAddr?
- What physical page is the first code page loaded into?
- What physical page is the second code page loaded into?