Nachos Project Assignment 3 Virtual Memory TA Assignment

  • Slides: 15
Download presentation
Nachos Project Assignment 3 Virtual Memory TA: 吳哲榮

Nachos Project Assignment 3 Virtual Memory TA: 吳哲榮

Assignment ¡ Test case l l /test/matmult. c /test/sort. c Both test programs are

Assignment ¡ Test case l l /test/matmult. c /test/sort. c Both test programs are greater than whole memory. ¡ Goal – run this two programs concurrently, and get the correct result. ¡ Under RR scheduling. ¡

Hints File system – swap space ¡ Add some table to help you record

Hints File system – swap space ¡ Add some table to help you record all the information. ¡ l l l Page. Table Frame. Table Swap. Table Catch Page. Fault. Exception ¡ Construct your Virtual Memory Manager ¡

Hints ¡ swap = new Synch. Disk l l All headers you need to

Hints ¡ swap = new Synch. Disk l l All headers you need to see are in /filesys/ Use this disk to be the swap space

Hints ¡ Page. Table l ¡ Frame. Table l ¡ one pagetable per process

Hints ¡ Page. Table l ¡ Frame. Table l ¡ one pagetable per process Record every physical page information Swap. Table l Record every sector’s information in swap.

Hints ¡ Page. Table l ¡ decide your virtual page number Translation. Entry{ unsigned

Hints ¡ Page. Table l ¡ decide your virtual page number Translation. Entry{ unsigned int virtual. Page; unsigned int physical. Page; bool valid; //whether in physical memory bool read. Only; bool use; //whether been referenced or modified bool dirty; //whether been modified }

Hints ¡ Frame. Table l ¡ Each frame represent one physical page Frame. Info.

Hints ¡ Frame. Table l ¡ Each frame represent one physical page Frame. Info. Entry { bool valid; bool lock; unsigned int vpn; //which virtual page is in this frame Addr. Space *addr. Space; //which process is using this frame };

Hints ¡ Swap. Table l l ¡ The number of entries in swap. Table

Hints ¡ Swap. Table l l ¡ The number of entries in swap. Table is the same as swap sectors. Each entry represent one frame in the disk. Frame. Info. Entry { bool valid; bool lock; unsigned int vpn; //whether entry been used //which virtual page is in this entry Addr. Space *addr. Space; //which process is using this entry ¡ }; Access virtual memory in the disk by kernel->swap>Write. Sector and kernel->swap->Read. Sector.

Hints Virtual Address Map to Physical Address ¡ Physical Address = page. Table[(virtual address

Hints Virtual Address Map to Physical Address ¡ Physical Address = page. Table[(virtual address / Page. Size)]. physical. Page * Page. Size + (virtual address % Page. Size) ¡

Hints ¡ Modify Addrspace: : Load(char *file. Name) l load one page once ¡

Hints ¡ Modify Addrspace: : Load(char *file. Name) l load one page once ¡ 1. acquire one page l When all physical memory frames are occupied, please design a page replacement method to get a frame. 2. Map virtual address to physical address ¡ Invoke ‘executable->Read. At(&(kernel>machine->main. Memory[physical address]), size. To. Load. Now, in. File. Addr)’ ¡

Virtual Memory Manager ¡ Public: l int Translate. Addr(Addr. Space *space, int virt. Addr);

Virtual Memory Manager ¡ Public: l int Translate. Addr(Addr. Space *space, int virt. Addr); // translate virtual address to physical address l bool Acquire. Page(Addr. Space *space, unsigned int vpn); // get a frame l void Release. Page(Addr. Space *space, unsigned int vpn); // release a page l void Page. Fault. Handler(void); // manage page fault

Page. Fault. Handler ¡ Page. Fault. Handler l l Put the pages in swaptable

Page. Fault. Handler ¡ Page. Fault. Handler l l Put the pages in swaptable into frametable. When all physical memory frames are occupied, please design a page replacement method to get a frame.

Assignment Requirements ¡ Assignment Report (1/20 on the class) ¡ ¡ ¡ How you

Assignment Requirements ¡ Assignment Report (1/20 on the class) ¡ ¡ ¡ How you modified Nachos to make it support virtual memory – important code segments Test cases and demonstration to show the correctness of your design Everything you consider important

Hand in your reports. ¡ Please compress following with zip. source code l Final

Hand in your reports. ¡ Please compress following with zip. source code l Final report l power-point file tar zcvf b 99901000. tar. gz l E-mail your code and presentation files(report) to TA (b 93901098@ntu. edu. tw). ¡ Deadline: 2011/1/20 23: 59 ¡

Grading Policy Correct Result ¡ Report ¡ 30% 70%

Grading Policy Correct Result ¡ Report ¡ 30% 70%