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

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 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 29 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 29 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 29 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 29 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 29 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 29 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 SystemsReview: Page Replacement PoliciesReview: Clock Algorithm: Not Recently UsedReview: Nth Chance version of Clock AlgorithmReview: Second-Chance List Algorithm (VAX/VMS)Goals for TodayAllocation of Page Frames (Memory Pages)Fixed/Priority AllocationPage-Fault Frequency AllocationThrashingLocality In A Memory-Reference PatternWorking-Set ModelWhat about Compulsory Misses?AdministriviaThe Requirements of I/OModern I/O SystemsExample Device-Transfer Rates (Sun Enterprise 6000)The Goal of the I/O SubsystemWant Standard Interfaces to DevicesHow Does User Deal with Timing?Main components of Intel Chipset: Pentium 4How does the processor actually talk to the device?Example: Memory-Mapped Display ControllerTransfering Data To/From ControllerA Kernel I/O StructureDevice DriversLife Cycle of An I/O RequestI/O Device Notifying the OSSummaryCS162Operating Systems andSystems ProgrammingLecture 16Page Allocation and Replacement (con’t)I/O SystemsOctober 26, 2005Prof. John Kubiatowiczhttp://inst.eecs.berkeley.edu/~cs162Lec 16.210/26/05 Kubiatowicz CS162 ©UCB Fall 2005Review: 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.Lec 16.310/26/05 Kubiatowicz CS162 ©UCB Fall 2005Review: Clock Algorithm: Not Recently UsedSet of all pagesin MemorySingle Clock Hand:Advances only on page fault!Check for pages not used recentlyMark pages as not used recently•Clock Algorithm: pages arranged in a ring–Hardware “use” bit per physical page:»Hardware sets use bit on each reference»If use bit isn’t set, means not referenced in a long time»Nachos hardware sets use bit in the TLB; you have to copy this back to page table when TLB entry gets replaced–On page fault:»Advance clock hand (not real time)»Check use bit: 1used recently; clear and leave alone0selected candidate for replacementLec 16.410/26/05 Kubiatowicz CS162 ©UCB Fall 2005Review: Nth Chance version of Clock Algorithm•Nth chance algorithm: Give page N chances–OS keeps counter per page: # sweeps–On page fault, OS checks use bit:»1clear use and also clear counter (used in last sweep)»0increment counter; if count=N, replace page–Means that clock hand has to sweep by N times without page being used before page is replaced•How do we pick N?–Why pick large N? Better approx to LRU»If N ~ 1K, really good approximation–Why pick small N? More efficient»Otherwise might have to look a long way to find free page•What about dirty pages?–Takes extra overhead to replace a dirty page, so give dirty pages an extra chance before replacing?–Common approach:»Clean pages, use N=1»Dirty pages, use N=2 (and write back to disk when N=1)Lec 16.510/26/05 Kubiatowicz CS162 ©UCB Fall 2005Review: Second-Chance List Algorithm (VAX/VMS)•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 listDirectlyMapped PagesMarked: RWList: FIFOSecond Chance ListMarked: InvalidList: LRULRU victimPage-inFrom diskNewActivePagesAccessNewSCVictimsOverflowLec 16.610/26/05 Kubiatowicz CS162 ©UCB Fall 2005Goals for Today•Finish Page Allocation Policies•Working Set/Thrashing•I/O Systems–Hardware Access–Device DriversNote: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and GagneLec 16.710/26/05 Kubiatowicz CS162 ©UCB Fall 2005Allocation 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 framesLec 16.810/26/05 Kubiatowicz CS162 ©UCB Fall 2005Fixed/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 framesai = allocation for pi = •Priority Allocation:–Proportional scheme using priorities rather than size»Same type of computation as previous scheme–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?mSsiLec 16.910/26/05 Kubiatowicz CS162 ©UCB Fall 2005Page-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?Lec 16.1010/26/05 Kubiatowicz CS162 ©UCB Fall 2005Thrashing•If a process does not have “enough”


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?