1 / 26

Nachos Project Assignment 3 Memory Management

Nachos Project Assignment 3 Memory Management. TA: Chien -Wen, Huang. Advisor: Farn , Wang. 2015/12/16. Outline. Memory Management Report Grading Policy & Late Policy. Reference. Memory Management. About the virtual memory manager, swap, page fault handler…. The Goal of Project 3.

zahi
Download Presentation

Nachos Project Assignment 3 Memory Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Nachos Project Assignment 3Memory Management TA: Chien-Wen, Huang. Advisor: Farn, Wang. 2015/12/16

  2. Outline • Memory Management • Report • Grading Policy& Late Policy. • Reference.

  3. Memory Management About the virtual memory manager, swap, page fault handler…

  4. The Goal of Project 3. • Have you run these test cases in the test folder? • /test/matmult.c • /test/sort.c • Both the test cases require lots of memory. • Larger than the physical memory! • Goal: Run this two programs concurrently, and get the correct result. • Remember to specify the scheduling algorithm you used in the report. • No way to pass this project by simply modify the memory size in “machine”.

  5. Some Hints. • File system – swap space. • Maintain three tables to record the information. • PageTable • FrameTable • SwapTable • Think how to “load” the page correctly. • Deal with the PageFaultException. • Design your own “Virtual Memory Manager".

  6. Swap Space - Create Disk. • swap = new SynchDisk in your kernel. • Use the disk as the swap space. • Access the virtual memory in the disk by… • kernel->swap->WriteSector • kernel->swap->ReadSector • See “synchdisk.cc” and other files in /filesys for details! • Read the header in those files first.

  7. Maintain Three Tables. • PageTable • One page table per process. • Decide your virtual page number. • FrameTable • Record every physical page’sinformation. • Each frame represent one physical page. • SwapTable • Record every sector’s information in swap. • The number of entries in SwapTable is the same as the swap sectors. • Each entry represent one frame in the disk.

  8. Maintain Three Tables. Physical memory FrameTable 1 2 3 4 PageTable 1 2 3 4 SwapTable 1 2 3 4

  9. Maintain Three Tables - PageTable • For each entry in PageTable • TranslationEntry { unsigned intvirtualPage; //virtual memory page unsigned intphysicalPage; //if in physical memory bool valid; //if in physical memory bool use; //been used(read or write) bool dirty; //been modified };

  10. Maintain Three Tables - FrameTable • For each entry in FrameTable • FrameInfoEntry { Bool valid; //if being used Bool lock; AddrSpace *addrSpace; //which process is using this page Unsigned intvpn; //which virtual page of the process is stored in this page };

  11. Maintain Three Tables - SwapTable • For each entry in SwapTable • FrameInfoEntry { Bool valid; //if being used Bool lock; AddrSpace *addrSpace; //which process is using this page Unsigned intvpn; //which virtual page of the process is stored in this page }; // same as the FrameTable

  12. Back to Nachos - Addrspace::Load • Note: Load 1 page a time. • First ask for 1 page, if the FrameTable is full, select 1 frame and put it into SwapTable. • Design your own page replacement method to get the frame. • Specify the method in your report. • Mapping virtual address to physical address. • Invoke “executable->ReadAt(&(kernel->machine->mainMemory[physical address]), sizeToLoadNow, inFileAddr)”

  13. Address Mapping • Map the Virtual Address to Physical Address. • Like the way you used in project 1. • Physical Address = pageTable[(virtual address / PageSize)].physicalPage * PageSize + (virtual address % PageSize)

  14. One Possible Way to Implement:Create a new class “Memory Manager” • Class MemoryManager { IntTransAddr(AddrSpace *space, intvirtAddr); //return phyAddr (translated from virtAddr) Bool AcquirePage(AddrSpace *space, intvpn); //ask a page (frame) for vpn Bool ReleasePage(AddrSpace *space, intvpn); //free a page Void PageFaultHandler(); //will be called when manager want to swap a page from SwapTable to FrameTable and the FrameTable is full. };

  15. Page-Fault Handler? • Put the pages in SwapTable into FrameTable. • When all physical memory frames are occupied, design a page replacement method to get a frame. • Remember to specify it in your report! • You can do this work in your own way.

  16. Some files that might be useful. • For the disk usage details, see: • /filesys/synchdisk.h • /filesys/synchdisk.cc • Other files in /filesys (Optional). • For the swap space initialization: • /userprog/userkernel.h • /userprog/userkernel.cc • For the table maintaining, see: • /machine/machine.h and /machine/machine.cc • /machine/translate.h and /machine/translate.cc

  17. Some files that might be useful. • For the table maintaining, see: • /machine/machine.h and /machine/machine.cc • /machine/translate.h and /machine/translate.cc • For the loading of pages. • userprog/addrspace.h • userprog/addrspace.cc • Always see the header and comments first. • Based on your implementation, there might be different files that your need to see and modify.

  18. Report & Policy Report contents, grading policy, late policy and the summary.

  19. Report • Report • Motivation and the problem analysis. • What’s your plan to deal with the problem(high-level). • How you really implement to solve the problem in Nachos. • You can including some (not all) important code segments and comments. • Experiment result and some discussion. • Extra effort or observation. • Please saved as [Student ID]_NachOS_report.pdf • E.g. r04942044_NachOS_report.pdf • NOT [r04942044]_NachOS_report.pdf

  20. Extra effort as Bonus • The replacement method you design. • Extra observation or modification on nachos. • Please write it down on your report if you did.

  21. Hand in source code & report • Source Code • tar zcvf [Student ID]_Nachos3.tar.gz ./nachos-4.0 • E.g. r04942044_Nachos3.tar.gz • NOT .gz or .rar. • Please include ALL the nachos code. • Mail your source code and report to r04942044@ntu.edu.tw • One pdf file as report and one tar.gz file as source code. • Deadline: Jan.20.2016, 23:59:59.

  22. Grading PolicyWith presentation • Nachos source code: (30%) • Report: (30%) • Correct format: (20%) • Presentation: (20%) • Bonus

  23. Grading PolicyWithout presentation • Nachos source code: (40%) • Report: (40%) • Correct format: (20%) • Bonus

  24. Late Policy • 10% penalty per day. • Late penalty only holds for a week • After 7 days, you will get 70% penalty, but no more penalty after that. • That is, after n(n>=7) days, you will still get 70% penalty. • Don’t give up! • No plagiarism.

  25. Summary • Implement the memory manager (mainly the virtual memory). • Write the report. • Send to TA in the correct format before the deadline. • Jan.20.2016, 23:59:59 • Prepare the presentation if you should.

  26. Reference • Nachos Beginner’s Guide: • https://www.ida.liu.se/~TDDI12/material/begguide/ • Nachos Virtual Memory Slides: • http://www.ittc.ku.edu/~dmitchell/EECS678/labs/old-labs/lab12/NachosVM.pdf • Search Engine as your friends. 

More Related