[16 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).
In the diagram below, we want to load the code (".text") and initialized data (".rdata") segments from the executable file into the virtual address space of the process. Assume that code.inFileAddr has the value 0xF0 as an offset in the executable file, code.virtualAddr is 0x00 in the virtual address space, and code.size is 0x130 bytes. Also assume that initData.inFileAddr is 0x220 in the executable file, initData.virtualAddr is 0x130 in the virtual address space, and initData.size is 0x010 bytes.