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

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 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 33 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 33 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 33 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 33 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 33 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 33 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 33 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 AlgorithmGoals for TodaySecond-Chance List Algorithm (VAX/VMS)Second-Chance List Algorithm (con’t)Free ListDemand Paging (more details)Allocation of Page Frames (Memory Pages)Fixed/Priority AllocationAdministriviaPage-Fault Frequency AllocationThrashingLocality In A Memory-Reference PatternWorking-Set ModelWhat about Compulsory Misses?Demand Paging SummaryThe 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 27, 2008Prof. John Kubiatowiczhttp://inst.eecs.berkeley.edu/~cs162Lec 16.210/27/08 Kubiatowicz CS162 ©UCB Fall 2008Review: 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/27/08 Kubiatowicz CS162 ©UCB Fall 2008Review: 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/27/08 Kubiatowicz CS162 ©UCB Fall 2008Review: 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/27/08 Kubiatowicz CS162 ©UCB Fall 2008Goals 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 Gagne Note: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from my lecture notes by Kubiatowicz.Lec 16.610/27/08 Kubiatowicz CS162 ©UCB Fall 2008Second-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.710/27/08 Kubiatowicz CS162 ©UCB Fall 2008Second-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 anywayLec 16.810/27/08 Kubiatowicz CS162 ©UCB Fall 2008Free List•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 faultSet of all pagesin MemorySingle Clock Hand:Advances as needed to keep freelist full (“background”)DDFree PagesFor ProcessesLec 16.910/27/08 Kubiatowicz CS162 ©UCB Fall 2008Demand 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 


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?