DOC PREVIEW
Princeton COS 318 - lecture 11

This preview shows page 1-2-15-16-31-32 out of 32 pages.

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

Unformatted text preview:

Competing For MemoryMechanicsThe Big PictureLessons From Enhanced FIFOx86 Page Table EntryProgram BehaviorsObservations re Working SetWorking SetWSClock Paging AlgorithmSimulating Modify Bit with Access BitsImplementing LRU without Reference BitDemand PagingSpeed and SluggishnessMemory PressureDisk AddressImagine a Global LRUSource of Disk AccessPartitioning MemoryFile Access EfficiencyResult: Memory-Mapped FilesLazy Versus EagerSemantics: How Things BehaveBeing Too Smart…Amdahl’s LawNT x86 Virtual Address Space LayoutsVirtual Address Space in Win95 and Win98Details with VM ManagementPage States (NT)Dynamics in NT VMShared MemoryCopy-On-WriteIssues of Copy-On-WriteCompeting For MemoryVivek Pai / Kai LiPrinceton University2MechanicsFeedback optionally anonymousNo real retribution anywayDo it to make me happyQuiz 1 Question 2 answer(s)#regs != #bitsRegisters at top of memory hierarchyLots of acceptable answersLast Quiz, Feedback still being digested3The Big PictureWe’ve talked about single evictionsMost computers are multiprogrammedSingle eviction decision still neededNew concern – allocating resourcesHow to be “fair enough” and achieve good overall throughputThis is a competitive world – local and global resource allocation decisions4Lessons From Enhanced FIFOObservationsit’s easier to evict a clean page than a dirty pagesometimes the disk and CPU are idleOptimization: when system’s “free”, write dirty pages back to disk, but don’t evictCalled flushing – often falls to pager daemon5x86 Page Table EntryValidWritableOwner (user/kernel)Write-throughCache disabledAccessed (referenced)DirtyPDE maps 4MBGlobalPage frame number DLGlCwPU A Cd Wt O W VReserved31126Program Behaviors80/20 rule> 80% memory references are made by < 20% of codeLocalitySpatial and temporalWorking setKeep a set of pages in memory would avoid a lot of page faults # pages in memory# page faultsWorking set7Observations re Working SetWorking set isn’t staticThere often isn’t a single “working set”Multiple plateaus in previous curveProgram coding style affects working setWorking set is hard to gaugeWhat’s the working set of an interactive program?8Working SetMain ideaKeep the working set in memory An algorithmOn a page fault, scan through all pages of the processIf the reference bit is 1, record the current time for the pageIf the reference bit is 0, check the “last use time”If the page has not been used within , replace the pageOtherwise, go to the nextAdd the faulting page to the working set9WSClock Paging AlgorithmFollow the clock handIf the reference bit is 1, set reference bit to 0, set the current time for the page and go to the nextIf the reference bit is 0, check “last use time”If page has been used within , go to the nextIf page hasn’t been used within  and modify bit is 1Schedule the page for page out and go to the nextIf page hasn’t been used within  and modified bit is 0Replace this page10Simulating Modify Bit with Access BitsSet pages read-only if they are read-writeUse a reserved bit to remember if the page is really read-onlyOn a read faultIf it is not really read-only, then record a modify in the data structure and change it to read-writeRestart the instruction11Implementing LRU without Reference BitSome machines have no reference bitVAX, for exampleUse the valid bit or access bit to simulateInvalidate all valid bits (even they are valid)Use a reserved bit to remember if a page is really validOn a page faultIf it is a valid reference, set the valid bit and place the page in the LRU listIf it is a invalid reference, do the page replacementRestart the faulting instruction12Demand PagingPure demand paging relies only on faults to bring in pagesProblems?Possibly lots of faults at startupIgnores spatial localityRemediesLoading groups of pages per faultPrefetching/preloadingSo why use it?13Speed and SluggishnessSlow is > .1 seconds (100 ms)Speedy is << .1 secondsMonitors tend to be 60+ Hz =<16.7ms between screen paintsDisks have seek + rotational delaySeek is somewhere between 7-16 msAt 7200rpm, one rotation = 1/120 sec = 8ms. Half-rotation is 4msConclusion? One disk access OK, six are bad14Memory Pressure“Swap” spaceRegion of disk used to hold “overflow”Contains only data pages (stack/heap/globals). Why?Swap may exist as “regular file,” but dedicated region of disk more common15Disk AddressUse physical memory as a cache for diskWhere to find a page on a page fault?PPage# field is a disk addressObservation: OS knows that pages are real but not in memoryVirtualaddressspaceinvalidPhysicalmemory16Imagine a Global LRUGlobal – across all processesIdea – when a page is needed, pick the oldest page in the systemProblems? Process mixes?Interactive processesActive large-memory sweep processesMitigating damage?17Source of Disk AccessVM SystemMain memory caches - full image on diskFilesystemEven here, caching very usefulNew competitive pressure/decisionsHow do we allocate memory to these two?How do we know we’re right?18Partitioning MemoryOriginally, specified by administrator20% used as filesystem cache by defaultOn fileservers, admin would set to 80%Each subsystem owned pages, replaced themObservation: they’re all basically pagesWhy not let them compete?Result: unified memory systems – file/VM19File Access Efficiencyread(fd, buf, size)Buffer in process’s memoryData exists in two places – filesystem cache & process’s memoryKnown as “double buffering”Various scenariosMany processes read same fileProcess wants only parts of a file, but doesn’t know which parts in advance20Result: Memory-Mapped FilesFileProcess AFileProcess BFileProcess CMapProcess AMapProcess BMapProcess CFile21Lazy Versus EagerEager: do things right awayread(fd, buf, size) – returns # bytes readBytes must be read before read completesWhat happens if size is big?Lazy: do them as they’re neededmmap(…) – returns pointer to mappingMapping must exist before mmap completesWhen/how are bytes read?What happens if size is big?22Semantics: How Things BehaveWhat happens whenTwo process obtain data (read


View Full Document

Princeton COS 318 - lecture 11

Documents in this Course
Overview

Overview

25 pages

Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download lecture 11
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 11 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 11 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?