Nachos Project 3
Goal Make Nachos can run following test cases in the same time /test/matmult.c /test/sort.c The problem is that both of the test cases require a lot of memory(larger then physical memory)
Create Disk swap = new SynchDisk Use the disk as the swap space Access the disk by kernel->swap->WriteSector kernel->swap->ReadSector See “synchdisk.cc” and other files in /filesys
Maintain Three Tables Physical memory FrameTable 1 2 3 4 PageTable 1 2 SwapTable 1 2 3 4
PageTable For each entry in PageTable unsigned int virtualPage; //virtual memory page unsigned int physicalPage; //if in physical memory bool valid; //if in physical memory bool use; //been used(read or write) bool dirty; //been modified
FrameTable For each entry in FrameTable Bool valid; //if being used Bool lock; AddrSpace *addrSpace; //which process is using this page Unsigned int vpn; //which virtual page of the process is stored in this page
SwapTable For each entry in SwapTable Bool valid; //if being used Bool lock; AddrSpace *addrSpace; //which process is using this page Unsigned int vpn; //which virtual page of the process is stored in this page (same as the FrameTable)
Address Mapping Physical Address = pageTable[(virtual address / PageSize)].physicalPage * PageSize + (virtual address % PageSize)
Addrspace::Load Load 1 page a time Ask for 1 page, if the FrameTable is full, select 1 frame and put it into SwapTable Mapping Address
Create new class “Memory Manager” Int TransAddr(AddrSpace *space, int virtAddr); //return phyAddr Bool AcquirePage(AddrSpace *space, int vpn); //ask a page for vpn Bool ReleasePage(AddrSpace *space, int vpn); //free the page Void PageFaultHandler(); //will be called when manager want to swap a page from SwapTable to FrameTable and the FrameTable is full
Hand in report Report Mail your code and report to yyergg@gmail.com tar zcvf b99xxxxxx.tar.gz ./nachos-4.0 Report Why the result is not congruent with expected How you modified Nachos to make it support multiprogramming – important code segments Mail your code and report to yyergg@gmail.com Deadline Jan.7.2014