1 / 13

Project 3: Demand Paging

Project 3: Demand Paging. Tingxin Yan 4/13/2011. Processor. Control. Tertiary Storage (Tape). Secondary Storage (Disk). Second Level Cache (SRAM). Main Memory (DRAM). On-Chip Cache. Datapath. Registers. 10,000,000s (10s ms). Speed (ns):. 1s. 10s-100s. 100s.

doane
Télécharger la présentation

Project 3: Demand Paging

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. Project 3: Demand Paging Tingxin Yan 4/13/2011

  2. Processor Control Tertiary Storage (Tape) Secondary Storage (Disk) Second Level Cache (SRAM) Main Memory (DRAM) On-Chip Cache Datapath Registers 10,000,000s (10s ms) Speed (ns): 1s 10s-100s 100s 10,000,000,000s (10s sec) Size (bytes): 100s Ks-Ms Ms Gs Ts Memory Hierarchy of a Modern Computer System • Take advantage of the principle of locality to:

  3. Caching Applied to Address Translation • TLB (Translation Lookaside Buffer)

  4. Nachos: Software-Loaded TLB • How can a process run without access to page table? • Fast path (TLB hit with valid=1): • Translation to physical page done by hardware • Slow path (TLB hit with valid=0 or TLB miss) • Hardware receives a “TLB Fault” • What does OS do on a TLB Fault? • Traverse page table to find appropriate PTE • If valid=1, load page table entry into TLB, continue thread • If valid=0, perform “Page Fault” detailed previously • Continue thread • Everything is transparent to the user process: • It doesn’t know about paging to/from disk • It doesn’t even know about software TLB handling

  5. Virtual Memory Access @Override handleRead(int a0,int a1,int a2) • Check if address is valid (already provided!) • Look up address • UtilizeVMKernelvmk • VMKernal method: lookupAddress(intpid, intvpn) • Pin the read page to avoid swapping out. • Call super.handleRead • Pin Pages • Unpin the read page. (Similar to a lock) • 5 lines of code. • handleWrite: very similar.

  6. Virtual Memory Access @Override readVirtualMemory(intvaddr, byte[] data, int offset, int length) • Check if address is valid (already provided!) • Set Used Bits • Call member function directly. • call the original readVirtualMemory in the UserProcess class. • Super.readVirtualMemory()… • 2 lines of code.

  7. Swap pages Memory Swap file

  8. Swap pages Memory Swap file

  9. Swap pages Memory Swap file

  10. Swap pages in swapInPage(intpid, intvpn) • Find the file position in swap file (denoted by swapfilepositions) • Read the page from the file. • Get a new free physical page, swapping something else out if needed. • Copy contents of the read-in page to memory. • Place a new entry in the global page table for thenew page. • Remove the page from the list of swapped out pages. • ~ 20 lines of code

  11. Swap Page in – Data Structures • OpenFileswapFile: Stores pages that needed to be written to disk. • freeSwapPages: Stores a list of available swap pages in the swap fileso that pages can be written to disk • LinkedList<Integer> • swapPagePositions: Keeps track of where a given page is stored in the swap file • HashMap<PageId, Integer> • pagesInSwap: Stores all of the pages that are currently swapped out to disk • HashMap<PageId, TranslationEntry> • TranslationEntrygetFreePage(): method to get a free physical page. • swappablePages: Stores a list of swappable pages • ArrayList<TranslationEntry>

  12. Swap page out • Find one page from swappablePages to swap out. • Opposite sequence of operations against swap page in. • Find and remove an entry in the global pagetable. • Copy the contents of the page in memory to a buffer for writing. • Write the page to a free position in the swap file. • Need to lock your operations. • Shared resources: swapPages, pinnedPages. • Notice that pinned pages should not be swapped out.

  13. TLB miss handler • Software traversed Page tables (like Nachos) • On TLB miss, processor receives TLB fault • handleException(int cause) • cause = Processor.exceptionTLBMiss • Again, use vmk.lookupAddress() to find the address. • handlePageFault.

More Related