DOC PREVIEW
CMU CS 15410 - lecture

This preview shows page 1-2-3-23-24-25-26-47-48-49 out of 49 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39Slide 40Slide 41Slide 42Slide 43Slide 44Slide 45Slide 46Slide 47Slide 48Slide 4915-410, F’04- 1 -Virtual Memory #2Oct. 8, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL16_VM215-410“...The cow and Zaphod...”15-410, F’04- 1 -SynchronizationProject 2 due tonightProject 2 due tonightPlease check “make html_doc” and “make print” are okPlease put your files in mygroup/p2not mygroup/p2/p2not mygroup/p2/our_project_2not mygroup/p2/p2_tar_fileUse the late-day request page to request late days (if)Don't mail us files15-410, F’04- 1 -Last TimeMapping problem: logical vs. physical addressesMapping problem: logical vs. physical addressesContiguous memory mapping (base, limit)Contiguous memory mapping (base, limit)Swapping – taking turns in memorySwapping – taking turns in memoryPagingPagingArray mapping page numbers to frame numbersObservation: typical table is sparsely occupiedResponse: some sparse data structure (e.g., 2-level array)15-410, F’04- 1 -SwappingMultiple user processesMultiple user processesSum of memory demands > system memoryGoal: Allow each process 100% of system memoryTake turnsTake turnsTemporarily evict process(es) to disk“Swap daemon” shuffles process in & outCan take seconds per processCreates external fragmentation problem15-410, F’04- 1 -External Fragmentation (“Holes”)Process 3Process 4Process 1OS KernelProcess 2Process 3Process 4Process 1OS KernelProcess 215-410, F’04- 1 -Benefits of PagingProcess growth problemProcess growth problemAny process can use any free frame for any purposeFragmentation compaction problemFragmentation compaction problemProcess doesn't need to be contiguousLong delay to swap a whole processLong delay to swap a whole processSwap part of the process instead!15-410, F’04- 1 -Partial ResidenceP0 code 0OS Kernel[free]P0 data 0P1 data 0P1 stack 0P0 stack 0P1 data 1[free]P0 code 0P0 code 1P0 data 0P0 stack 0P1 code 0P1 data 0P1 data 1P1 stack 015-410, F’04- 1 -Page Table Entry (PTE) flagsProtection bits – set by OSProtection bits – set by OSRead/write/executeValid/Present bit – set by OSValid/Present bit – set by OSFrame pointer is valid, no need to faultDirty bitDirty bitHardware sets 01 when data stored into pageOS sets 10 when page has been written to diskReference bitReference bitHardware sets 01 on any data access to pageOS uses for page eviction (below)15-410, F’04- 1 -OutlinePartial memory residence (demand paging) in actionPartial memory residence (demand paging) in actionThe task of the page fault handlerThe task of the page fault handlerBig speed hacksBig speed hacksSharing memory regions & filesSharing memory regions & filesPage replacement policiesPage replacement policies15-410, F’04- 1 -Partial Memory ResidenceError-handling code not used by every runError-handling code not used by every runNo need for it to occupy memory for entire duration...Tables may be allocated larger than usedTables may be allocated larger than usedplayer players[MAX_PLAYERS];Computer can run Computer can run veryvery large programs large programsMuch larger than physical memoryAs long as “active” footprint fits in RAMSwapping can't do thisPrograms can launch fasterPrograms can launch fasterNeedn't load whole program before running15-410, F’04- 1 -Demand PagingUse RAM frames as a cache for the set of all pagesUse RAM frames as a cache for the set of all pagesSome pages are fast to access (in a RAM frame)Some pages are slow to access (in a disk “frame”)Page tables indicate which pages are “resident”Page tables indicate which pages are “resident”Non-resident pages have “present=0” in page table entryMemory access referring to page generates page faultHardware invokes page-fault exception handler15-410, F’04- 1 -Page fault – Reasons, ResponsesAddress is invalid/illegal – deliver Address is invalid/illegal – deliver software exceptionsoftware exceptionUnix – SIGSEGVMach – deliver message to thread's exception port15-410 – kill threadProcess is growing stack – give it a new frameProcess is growing stack – give it a new frame““Cache misses” - fetch from diskCache misses” - fetch from diskWhere on disk, exactly?15-410, F’04- 1 -Satisfying Page FaultscodedatabssstackFilesystemPaging SpaceFree-frame pool15-410, F’04- 1 -Page fault story - 1Process issues memory referenceProcess issues memory referenceTLB: missPT: “not present”TrapTrap to OS kernel! to OS kernel!Processor dumps trap frameTransfers via “page fault” interrupt descriptor table entryRuns trap handler15-410, F’04- 1 -Page fault story – 2Classify fault addressClassify fault addressIllegal address  deliver an ouch, else...Code/rodata region of executable?Code/rodata region of executable?Determine which sector of executable fileLaunch read() from file into an unused framePreviously resident r/w data, paged outPreviously resident r/w data, paged out“somewhere on the paging partition”Queue disk read into an unused frameFirst use of bss/stack pageFirst use of bss/stack pageAllocate a frame full of zeroes, insert into PT15-410, F’04- 1 -Page fault story – 3Put process to sleep (for most cases)Put process to sleep (for most cases)Switch to running anotherHandle I/O-complete interruptHandle I/O-complete interruptFill in PTE (present = 1)Mark process runnableRestore registers, switch page tableRestore registers, switch page tableFaulting instruction re-started transparentlySingle instruction may fault more than once!15-410, F’04- 1 -Memory Regions vs. Page TablesWhat's a poor page fault handler to do?What's a poor page fault handler to do?Kill process?Copy page, mark read-write?Fetch page from file? Which? Where?Page table not a good data structurePage table not a good data structureFormat defined by hardwarePer-page nature is repetitiveNot enough bits to encode OS metadataDisk sector address can be > 32 bits15-410, F’04- 1 -Dual-view Memory ModelLogicalLogicalProcess memory is a list of


View Full Document

CMU CS 15410 - lecture

Download lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?