Portions of The Virtual Memory Space

Added on - 13 Sep 2019

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 3 of 6 pages
1 OverviewThis machine problem involves implementation of part of a virtual memorysubsystem for Nachos. The code for the test case is a set of array operationsthat span large portions of the virtual memory space. This virtual memoryspace is mapped into 20 physical frames of memory. Address translation andpage table structures are given by the machine implementation (in machinedirectory). The purpose of this MP is to implement the routines that handlepage faults. This will involve swapping pages to and from the backing storewhen appropriate. In an effort to minimize the number of page faults and I/Oswaps from memory to disk, you will be implementing a page bufferingscheme and three page replacement algorithms, First In First Out (FIFO),Least Recently Used (LRU - Approximation using Additional-Referencebits), and Enhanced Second Chance (ESC).2 PreparationMaterials: The given code for this MP can be extracted with the usual tarcommand with the appropri- ate command line arguments as in the previousprojects. Once you unzip and untar the archive the source code will be in the“mp3given” directory. For this MP, you will be working in the “userprog”subdirec- tory. Look at the files filesys/OpenFile.java,filesys/OpenFileStub.java, machine/TranslationEntry.java, ma-chine/Timer.java, userprog/NoffHeader.java, and userprog/BitMap.java. Itwill be helpful to understand the additional functions added to the List classin threads/List.java as well (note that these functions are not optimized butare given for your convenience in programming). In this assignment you willneed to modify only MemManager.java (in userprog directory).Structures: As you know, each address space has a page table associated withit. Each entry in the page table is an instance of a TranslationEntry. The threeprimary fields that we will be working with in this MP are the USE, DIRTY,and VALID fields. These are described thoroughly inmachine/TranslationEntry.java.The structure AddrSpace consists of all the information about the address
space of a nachos process - the page table, its length, etc, and functions tomanipulate the address space. When a new process is created this structure isinstantiated, initialized and associated with the process. The code suppliedimplementsdemand paging. In this paging scheme a page is read into thephysical memory from the source (executable) file only if the processaccesses it during its execution. So initially when the process is created allthe entries in the page table are initialized to invalid (the valid bit of the allpage table entries is set to false). However, in general, it may not be legal toaccess certain pages (the ones that do not belong to any program segment).While initializing the table a note is made about which pages are legal toaccess and which are not (the legal field). Every executable file starts with aheader which specifies the virtual address range of all the segments of theprogram. Read AddrSpace.AddrSpace() and the comments inNoffHeader.java for further details.Beginnings: The AddrSpace.readSourcePage() function is called to read asingle page from the exe- cutable file into the physical memory. Note thatthis function is called only when a virtual page is accessed for the first timeby the process. For subsequent accesses, if the page is not in physicalmemory the swap file rather than the source file is searched. The swap file isa single file, consisting of frames of memory just like MainMemory, exceptthat they are stored on a disk. An array of TranslationEntry pointers namedCSCI 40300/ECE 40800 1 Project 3“swapOwners” is used to keep track of the page table entries that refer to thepage stored there in the swap file. A similar structure, “coreOwners”, existsfor pages in main memory. Read AddrSpace.readSourcePage() andMemManager.pageIn() for further details.Execution: During execution, the machine emulation will handle setting theappropriate bits in the Trans- lationEntry such as DIRTY=TRUE when awrite occurs or USE=TRUE when a read or write occurs. If the machineemulator processes a memory request on a TranslationEntry that has aLEGAL=TRUE, but VALID=FALSE, it will trap to MemManager.faultIn().This is the entry point for your implementation.Given the faultingTranslationEntry, use pageIn(), pageOut(), and methods that you will
implement to clear the exception by loading the appropriate buffer into aframe of memory, updating the TranslationEntry and returning control to thevirtual machine.Read the code for MemManager.pageFaultExceptionHandler(). This is calledby Nachos.exceptionHandler() when it receives a page fault exception. Thedetails about how to implement MemManager.faultIn along witha few hintsare given as comments in MemManager.pageFaultExceptionHandler(). Notethat you should not increment the program counter in this function. After theexception is handled and the control is returned back to the faulting processthe instruction which caused the page fault should be re-executed.Anatomy: While “faultIn” is the “handler”, various other methodsencapsulate important functionality. pageOut is responsible for writing a pageto the backing store. It is assumed that only dirty pages are given to pageOutbecause the others can be overwritten, since they are already on the backingstore or are unchanged from their original state. pageIn is responsible forreading a page into a specified frame. If the page is not in the backing store, itis loaded from the original file. MemManager.makeFreeFrame is responsiblefor choosing avictimwith the appropriate page replacement algorithm whenno free frames are available. MemManager.recordHistory is a timer interrupthandler that updates history information from the appropriate bits in theTranslationEntry.3 Reading GuideRead this handout, then read userprog/AddrSpace.java,userprog/MemManager.java, and threads/Nachos.java (methodexceptionHandler). Look in machine/TranslationEntry.java for thedeclaration of class Translatio- nEntry. You may also want to look atuserprog/Bitmap.java. Look at MemManager.pageIn and MemMan-ager.pageOut also. Make a paper design before starting to code.4 Problem: Various Page Replacement Algorithms.4.1Prerequisite: RecordHistoryImplement the Interrupt Service Routing ( MemManager.recordHistory ) torecord the state of the USE bit from each TranslationEntry that has a frame
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access