DOC PREVIEW
Berkeley COMPSCI 162 - Lecture 16 Page Allocation and Replacement I/O Systems

This preview shows page 1-2-3-26-27-28 out of 28 pages.

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

Unformatted text preview:

CS162 Operating Systems and Systems Programming Lecture 16 Page Allocation and Replacement con t I O Systems March 16 2010 Ion Stoica http inst eecs berkeley edu cs162 Review Page Replacement Policies FIFO First In First Out Throw out oldest page Be fair let every page live in memory for same amount of time Bad because throws out heavily used pages instead of infrequently used pages MIN Minimum Replace page that won t be used for the longest time Great but can t really know future Makes good comparison case however RANDOM Pick random page for every replacement Typical solution for TLB s Simple hardware Pretty unpredictable makes it hard to make real time guarantees LRU Least Recently Used Replace page that hasn t been used for the longest time Programs have locality so if something not used for a while unlikely to be used in the near future Seems like LRU should be a good approximation to MIN 3 16 10 CS162 UCB Spring 2010 Lec 16 2 Goals for Today Finish Page Allocation Policies Working Set Thrashing I O Systems Hardware Access Device Drivers Note Some slides and or pictures in the following are adapted from slides 2005 Silberschatz Galvin and Gagne Many slides generated from the lecture notes by Kubiatowicz 3 16 10 CS162 UCB Spring 2010 Lec 16 3 Second Chance Algorithm Approximate LRU Replace an old page not the oldest page FIFO with use bit Details A use bit per physical page On page fault check page at head of queue If use bit 1 clear bit and move page at tail give the page second chance If use bit 0 replace page Moving pages to tail still complex 3 16 10 CS162 UCB Spring 2010 Lec 16 4 Second Chance List Algorithm VAX VMS LRU victim Second Chance List Directly Mapped Pages Marked RW List FIFO Page in From disk Marked Invalid List LRU New Active Pages New SC Victims Split memory in two Active list RW SC list Invalid Access pages in Active list at full speed Otherwise Page Fault Always move overflow page from end of Active list to front of Second chance list SC and mark invalid Desired Page On SC List move to front of Active list mark RW Not on SC list page in to front of Active list mark RW page out LRU victim at end of SC list 3 16 10 CS162 UCB Spring 2010 Lec 16 5 Second Chance List Algorithm con t How many pages for second chance list If 0 FIFO If all LRU but page fault on every page reference Pick intermediate value Result is Pro Few disk accesses page only goes to disk if unused for a long time Con Increased overhead trapping to OS software hardware tradeoff With page translation we can adapt to any kind of access the program makes Later we will show how to use page translation protection to share memory between threads on widely separated machines Question why didn t VAX include use bit Strecker architect asked OS people they said they didn t need it so didn t implement it He later got blamed but VAX did OK anyway 3 16 10 CS162 UCB Spring 2010 Lec 16 6 Free List Single Clock Hand Advances as needed to keep freelist full background D Set of all pages in Memory D Free Pages For Processes Keep set of free pages ready for use in demand paging Freelist filled in background by Clock algorithm or other technique Pageout demon Dirty pages start copying back to disk when enter list Like VAX second chance list If page needed before reused just return to active set Advantage Faster for page fault Can always use page or pages immediately on fault 3 16 10 CS162 UCB Spring 2010 Lec 16 7 Demand Paging more details Does software loaded TLB need use bit Two Options Hardware sets use bit in TLB when TLB entry is replaced software copies use bit back to page table Software manages TLB entries as FIFO list everything not in TLB is Second Chance list managed as strict LRU Core Map Page tables map virtual page physical page Do we need a reverse mapping i e physical page virtual page Yes Clock algorithm runs through page frames If sharing then multiple virtual pages per physical page Can t push page out to disk without invalidating all PTEs 3 16 10 CS162 UCB Spring 2010 Lec 16 8 Allocation of Page Frames Memory Pages How do we allocate memory among different processes Does every process get the same fraction of memory Different fractions Should we completely swap some processes out of memory Each process needs minimum number of pages Want to make sure that all processes that are loaded into memory can make forward progress Example IBM 370 6 pages to handle SS MOVE instruction instruction is 6 bytes might span 2 pages 2 pages to handle from 2 pages to handle to Possible Replacement Scopes Global replacement process selects replacement frame from set of all frames one process can take a frame from another Local replacement each process selects from only its own set of allocated frames 3 16 10 CS162 UCB Spring 2010 Lec 16 9 Fixed Priority Allocation Equal allocation Fixed Scheme Every process gets same amount of memory Example 100 frames 5 processes process gets 20 frames Proportional allocation Fixed Scheme Allocate according to the size of process Computation proceeds as follows si size of process pi and S si m total number of frames ai allocation for pi Priority Allocation Possible behavior If process pi generates a page fault select for replacement a frame from a process with lower priority number Perhaps we should use an adaptive scheme instead What if some application just needs more memory 3 16 10 CS162 UCB Spring 2010 Lec 16 10 Administrivia We have an anonymous feedback link on the course homepage Please use to give feedback on course Would you like an extra 5 for your course grade Attend lectures and sections 5 of grade is participation Midterm was only 20 Should be working on Project 3 now You must rely on your tests not the autograder 3 16 10 CS162 UCB Spring 2010 Lec 16 11 Page Fault Frequency Allocation Can we reduce Capacity misses by dynamically changing the number of pages application Establish acceptable page fault rate If actual rate too low process loses frame If actual rate too high process gains frame Question What if we just don t have enough memory 3 16 10 CS162 UCB Spring 2010 Lec 16 12 Thrashing If a process does not have enough pages the pagefault rate is very high This leads to low CPU utilization operating system spends most of its time swapping to disk Thrashing a process is busy swapping pages in and out Questions How do we detect Thrashing What is best response to Thrashing 3 16 10 CS162 UCB Spring 2010 Lec 16 13 Locality In A Memory Reference Pattern Program


View Full Document

Berkeley COMPSCI 162 - Lecture 16 Page Allocation and Replacement I/O Systems

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Download Lecture 16 Page Allocation and Replacement I/O Systems
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 16 Page Allocation and Replacement I/O Systems 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 16 Page Allocation and Replacement I/O Systems 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?