DOC PREVIEW
CMU CS 15410 - Lecture

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15-410, F’04- 1 -Virtual Memory #1Oct. 6, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL15_VM115-410“...We are Computer Scientists!...”15-410, F’04- 2 -SynchronizationMid-term ExamMid-term ExamIn-class?Evening?“Mid-term week”: Wednesday 20th? Thursday 21st?“Project 3 week”: Wednesday 13th? Thursday 14th?You will soon receive coordination mail—act immediately!Reminder: Book reportReminder: Book reportPlease don't complain end-of-semester due date!Thinking about the futureThinking about the futureSummer internship with SCS Facilities?15-412, OS Practicum15-410, F’04- 3 -OutlineTextTextChapters 9, 10The Problem: logical vs. physicalThe Problem: logical vs. physicalContiguous memory mappingContiguous memory mappingFragmentationFragmentationPagingPagingType theoryA sparse map15-410, F’04- 4 -Logical vs. PhysicalIt's all about address spacesIt's all about address spacesGenerally a complex issueIPv4 ⇒ IPv6 is mainly about address space exhaustionReviewReviewCombining .o's changes addressesBut what about two programs?15-410, F’04- 5 -Every .o uses same address spacecodedatabsscodedatabss15-410, F’04- 6 -Linker Combines .o's, Changes Addressescodedatabsscodedatabss15-410, F’04- 7 -What about two programs?codedatabss000100000001020000010300stack FFFFF000codedatabss000100000001010000010300stack FFFFE00015-410, F’04- 8 -Logical vs. Physical AddressesLogical addressLogical addressEach program has its own address spacefetch: address ⇒ datastore: address, data ⇒ . As envisioned by programmer, compiler, linkerPhysical addressPhysical addressWhere your program ends up in memoryThey can't all be loaded at 0x10000!15-410, F’04- 9 -Reconciling Logical, PhysicalCould run programs at Could run programs at differentdifferent addresses addressesRequires using linker to “relocate one last time”Done by some old mainframe OSsSlow, complex, or bothPrograms could Programs could take turnstake turns in memory in memoryRequires swapping programs out to diskVery slowWe are computer scientists!We are computer scientists!Insert a level of indirectionWell, get the ECE folks to do it for us15-410, F’04- 10 -Type TheoryPhysical memory behaviorPhysical memory behaviorfetch: address ⇒ datastore: address, data ⇒ . Process thinks of memory as...Process thinks of memory as...fetch: address ⇒ datastore: address, data ⇒ . Goal: each process has “its own memory”Goal: each process has “its own memory”process-id ⇒ fetch: (address ⇒ data)process-id ⇒ store: (address, data ⇒ . )What What reallyreally happens happensprocess-id ⇒ (virtual-address ⇒ physical-address)15-410, F’04- 11 -Simple Mapping FunctionsP1P1If V > 8191 ERRORElse P = 1000 + VP2P2If V > 16383 ERRORElse P = 9292 + VAddress space ===Address space ===Base addressLimitProcess 3Process 2Process 1OS Kernel016383919225575081911000919109990999VirtualPhysical15-410, F’04- 12 -Contiguous Memory MappingProcessor contains two Processor contains two control registerscontrol registersMemory baseMemory limitEach memory access checksEach memory access checksIf V < limit P = base + V;Else ERROR /* what do we call this error? */Context switchContext switchSave/load user-visible registersAlso load process's base, limit registers15-410, F’04- 13 -Problems with Contiguous AllocationHow do we How do we growgrow a process? a process?Must increase “limit” valueCannot expand into another process's memory!Must move entire address spaces around Very expensiveFragmentationFragmentationNew processes may not fit into unused memory “holes”Partial memory residencePartial memory residenceMust entire program be in memory at same time?15-410, F’04- 14 -Can We Run Process 4?Process exit creates Process exit creates “holes”“holes”New processes may be New processes may be too largetoo largeMay require moving entire May require moving entire address spacesaddress spacesProcess 3Process 4OS KernelProcess 115-410, F’04- 15 -Term: External FragmentationFree memory is small Free memory is small chunkschunksDoesn't fit large objectsDoesn't fit large objectsCan “disable” lots of Can “disable” lots of memorymemoryCan fixCan fixCostly “compaction” aka “Stop & copy”Process 4Process 1OS KernelProcess 215-410, F’04- 16 -Term: Internal FragmentationAllocators often round upAllocators often round up8K boundary (some power of 2!)Some memory is wasted Some memory is wasted insideinside each segment each segmentCan't fix via compactionCan't fix via compactionEffects often non-fatalEffects often non-fatalProcess 3Process 4Process 1OS Kernel081921100929215-410, F’04- 17 -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 Not runnable Blocked on implicit I/O request (e.g., “swapread”)“Swap daemon” shuffles process in & outCan take seconds per process Modern analogue: laptop suspend-to-disk15-410, F’04- 18 -Contiguous Allocation ⇒ PagingSolve multiple problemsSolve multiple problemsProcess growth problemFragmentation compaction problemLong delay to swap a whole processDivide memory more finelyDivide memory more finelyPage = small region of virtual memory (4K)Frame = small region of physical memory[I will get this wrong, feel free to correct me]Key idea!!!Key idea!!!Any page can map to (occupy) any frame15-410, F’04- 19 -Per-process Page MappingP0 code 0OS KernelP1 code 0P0 data 0P1 data 0P1 stack 0P0 stack 0P1 data 1P0 code 1P0 code 0P0 code 1P0 data 0P0 stack 0P1 code 0P1 data 0P1 data 1P1 stack 015-410, F’04- 20 -Problems Solved by 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- 21 -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- 22 -New Data StructureContiguous allocationContiguous allocationEach process described by


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?