DOC PREVIEW
CORNELL CS 414 - Thrashing Working set Algorithm Dynamic Memory Management

This preview shows page 1-2-16-17-18-34-35 out of 35 pages.

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

Unformatted text preview:

Virtual Memory II: Thrashing Working Set Algorithm Dynamic Memory ManagementLast TimeExample: LRU, =3Goals for todayThrashingApproach 1: Working SetWorking SetsWorking Set ApproximationUsing the Working SetTheoretical asideKey insight in proofHow do WSOpt and WS differ?How do WS and LRU compare?Approach 2: Page Fault FrequencyWorking Sets and Page Fault RatesDynamic Memory ManagementAllocation and deallocationMemory allocation goalsMemory AllocatorImpossibility ResultsBest Fit AllocationBest Fit gone wrongA simple schemeWhich chunk to allocate?What happens on free?ExampleSlide 27Design featuresBuddy-Block SchemeSlide 30Slide 31How to get more space?Malloc & OS memory managementOther Issues – Program StructureOS and PagingVirtual Memory II: ThrashingWorking Set AlgorithmDynamic Memory Management2Last Time•We’ve focused on demand paging–Each process is allocated  pages of memory–As a process executes it references pages–On a miss a page fault to the O/S occurs–The O/S pages in the missing page and pages out some target page if room is needed•The CPU maintains a cache of PTEs: the TLB.•The O/S must flush the TLB before looking at page reference bits, or before context switching (because this changes the page table)3Example: LRU, =3R3 7 9 5 3 6 3 5 6 7 9 7 9 3 8 6 3 6 8 3 5 63 7 9 5 3 6 3 5 6 7 9 7 9 3 8 6 3 6 8 3 5 6S3 7 9 5 3 6 3 5 6 7 9 7 9 3 8 6 3 6 8 3 5 3 7 9 5 5 6 3 5 6 6 6 7 9 3 8 8 3 6 8 3In3 7 9 5 3 6  7 9 3 8 6   5 6Out  3 7 9  3 5 6 7 9   6 8R(t): Page referenced at time t. S(t): Memory state when finished doing the paging at time t. In(t): Page brought in, if any. Out(t): Page sent out. : None.While “filling” memory we are likely to get a page fault on almost every reference. Usually we don’t include these events when computing the hit ratioHit ratio: 9/19 = 47%Miss ratio: 10/19 = 53%4Goals for today•Review demand paging•What is thrashing?•Solutions to thrashing–Approach 1: Working Set–Approach 2: Page fault frequency•Dynamic Memory Management–Memory allocation and deallocation and goals–Memory allocator - impossibility result•Best fit•Simple scheme - chunking, binning, and free•Buddy-block scheme•Other issues5Thrashing•Def: Excessive rate of paging that occurs because processes in system require more memory –Keep throwing out page that will be referenced soon–So, they keep accessing memory that is not there•Why does it occur?–Poor locality, past != future–There is reuse, but process does not fit–Too many processes in the system6Approach 1: Working Set•Peter Denning, 1968–He uses this term to denote memory locality of a programDef: pages referenced by process in last  time-units comprise its working setFor our examples, we usually discuss WS in terms of , a “window” in the page reference string. But while this is easier on paper it makes less sense in practice! In real systems, the window should probably be a period of time, perhaps a second or two.7Working Sets•The working set size is num pages in the working set –the number of pages touched in the interval [t-Δ+1..t].•The working set size changes with program locality.–during periods of poor locality, you reference more pages.–Within that period of time, you will have a larger working set size.•Goal: keep WS for each process in memory.–E.g. If  WSi for all i runnable processes > physical memory, then suspend a process8Working Set Approximation•Approximate with interval timer + a reference bit•Example:  = 10,000–Timer interrupts after every 5000 time units–Keep in memory 2 bits for each page–Whenever a timer interrupts copy and sets the values of all reference bits to 0–If one of the bits in memory = 1  page in working set•Why is this not completely accurate?–Cannot tell (within interval of 5000) where reference occured•Improvement = 10 bits and interrupt every 1000 time units9Using the Working Set•Used mainly for prepaging–Pages in working set are a good approximation •In Windows processes have a max and min WS size–At least min pages of the process are in memory–If > max pages in memory, on page fault a page is replaced–Else if memory is available, then WS is increased on page fault–The max WS can be specified by the application10Theoretical aside•Denning defined a policy called WSOpt–In this, the working set is computed over the next  references, not the last: R(t)..R(t+ -1)•He compared WS with WSOpt.–WSOpt has knowledge of the future…–…yet even though WS is a practical algorithm with no ability to see the future, we can prove that the Hit and Miss ratio is identical for the two algorithms!11Key insight in proof•Basic idea is to look at the paging decision made in WS at time t+-1 and compare with the decision made by WSOpt at time t•Both look at the same references… hence make same decision–Namely, WSOpt tosses out page R(t-1) if it isn’t referenced “again” in time t..t+-1–WS running at time t+-1 tosses out page R(t-1) if it wasn’t referenced in times t...t+-112How do WSOpt and WS differ?•WS maintains more pages in memory, because it needs  time “delay” to make a paging decision–In effect, it makes the same decisions, but it makes them after a time lag–Hence these pages hang around a bit longer13How do WS and LRU compare?•Suppose we use the same value of –WS removes pages if they aren’t referenced and hence keeps less pages in memory–When it does page things out, it is using an LRU policy!–LRU will keep all  pages in memory, referenced or not•Thus LRU often has a lower miss rate, but needs more memory than WS14Approach 2: Page Fault Frequency•Thrashing viewed as poor ratio of fetch to work•PFF = page faults / instructions executed •if PFF rises above threshold, process needs more memory–not enough memory on the system? Swap out.•if PFF sinks below threshold, memory can be taken away15Working Sets and Page Fault RatesPage fault ratetransitionWorking setstable16Dynamic Memory Management•Notice that the O/S kernel can manage memory in a fairly trivial way:–All memory allocations are in units of “pages”–And pages can be anywhere in memory… so a simple free list is the only data structure needed•But for variable-sized objects, we need a heap:–Used for all dynamic memory


View Full Document

CORNELL CS 414 - Thrashing Working set Algorithm Dynamic Memory Management

Documents in this Course
Security

Security

49 pages

Processes

Processes

24 pages

Deadlocks

Deadlocks

57 pages

Threads

Threads

5 pages

Threads

Threads

29 pages

Deadlocks

Deadlocks

36 pages

Load more
Download Thrashing Working set Algorithm Dynamic Memory Management
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 Thrashing Working set Algorithm Dynamic Memory Management 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 Thrashing Working set Algorithm Dynamic Memory Management 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?