[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 virtual addresses are 32 bits, PageSize is 128 bytes, the program being loaded requires 4 pages, and physical memory has 8 pages. Assume that no stack is necessary, and that you only need to load and map the code and data. 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 0xD0 as an offset in the executable file, code.virtualAddr is 0x00 in the virtual address space, and code.size is 0x144 bytes. Also assume that initData.inFileAddr is 0x3C0 in the executable file, initData.virtualAddr is 0x144 in the virtual address space, and initData.size is 0x020 bytes.