CS 153 Design of Operating Systems Spring 18
|
|
- Blanche Williams
- 5 years ago
- Views:
Transcription
1 CS 53 Design of Operating Systems Spring 8 Lectre 2: Virtal Memory Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian
2 Recap: cache Well-written programs exhibit a property called locality, this is the fondation of caching Basic concepts of cache Cache hit Cache miss Cache replacement policy is important CS 53 Lectre 2 Virtal Memory 2
3 Today Virtal memory Memory as cache Page/cache replacement policy CS 53 Lectre 2 Virtal Memory 3
4 VM as a Tool for Caching Virtal memory is an array of N contigos bytes stored on disk. The contents of the array on disk are cached in physical memory (DRAM cache) These cache blocks are called pages (size is P = 2 p bytes) Virtal memory Physical memory VP VP Unallocated Cached Uncached Unallocated Empty Empty PP PP Cached Uncached Empty n-p - Cached Uncached N- M- PP 2 m-p - Virtal pages (VPs) stored on disk Physical pages (PPs) cached in DRAM 4
5 Page Table Setp Valid PTEs map virtal pages to physical pages. Invalid PTEs map virtal pages to disk blocks PTE Valid Physical page nmber or disk address nll Physical memory VP VP 7 VP 4 PP PP 3 nll Virtal memory (disk) PTE 7 VP Memory resident page table VP 3 VP 4 CS 53 Lectre 2 Virtal Memory VP 6 5 VP 7
6 Page/Cache Hit Page hit: reference to VM word that is in physical memory (DRAM cache hit) Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 4 Virtal memory (disk) VP VP 3 VP 4 PP PP 3 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 6
7 Page Falt (Cache miss) Page falt: reference to VM word that is not in physical memory (DRAM cache miss) Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 4 Virtal memory (disk) VP VP 3 VP 4 PP PP 3 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 7
8 Handling Page Falt () Page miss cases page falt (an exception) Virtal address PTE Valid Physical page nmber or disk address nll Physical memory VP VP 7 VP 4 PP PP 3 nll Virtal memory (disk) PTE 7 Memory resident page table VP VP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 8
9 Handling Page Falt (2) Page falt handler selects a victim to be evicted (here VP 4) Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 4 Virtal memory (disk) VP VP 3 VP 4 VP 6 PP PP 3 CS 53 Lectre 2 Virtal Memory VP 7 9
10 Handling Page Falt (3) Evict the content of VP4 Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 4 Virtal memory (disk) VP VP 3 PP PP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7
11 Handling Page Falt (4) Update page table Virtal address Valid PTE PTE 7 Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 Empty Virtal memory (disk) VP VP 3 PP PP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7
12 Handling Page Falt (5) Load content of VP3 to DRAM Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 3 Virtal memory (disk) VP VP 3 PP PP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 2
13 Handling Page Falt (6) Update page table Virtal address Valid PTE PTE 7 Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 3 Virtal memory (disk) VP VP 3 PP PP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 3
14 Handling Page Falt (7) Restart the instrction: page hit! Virtal address PTE PTE 7 Valid Physical page nmber or disk address nll nll Memory resident page table Physical memory VP VP 7 VP 3 Virtal memory (disk) VP VP 3 PP PP 3 VP 4 VP 6 CS 53 Lectre 2 Virtal Memory VP 7 4
15 Today Virtal memory Memory as cache Page/cache replacement policy CS 53 Lectre 2 Virtal Memory 5
16 Page Replacement When a page falt occrs, the OS loads the falted page from disk into a page frame of memory At some point, the process has sed all of the page frames it is allowed to se This is likely (mch) less than all of available memory When this happens, the OS mst replace a page for each page falted in It mst evict a page to free p a page frame Written back only if it is has been modified (i.e., dirty )! CS 53 Lectre 2 Virtal Memory 6
17 Page replacement policy What we discssed so far (page falts, swap, page table strctres, etc ) is mechanisms Page replacement policy: determine which page to remove when we need a victim Does it matter? Yes! Page falts are sper expensive Getting the nmber down, can improve the performance of the system significantly CS 53 Lectre 2 Virtal Memory 7
18 Considerations Page replacement spport has to be simple dring memory accesses They happen all the time, we cannot make that part slow Bt it can be complicated/expensive when a page falt occrs why? Reason : if we are sccessfl, this will be rare Reason 2: when it happens we are paying the cost of I/O» I/O is very slow: can afford to do some extra comptation» Worth it if we can save some ftre page falts What makes a good page replacement policy? CS 53 Lectre 2 Virtal Memory 8
19 Locality to the Resce Recall that virtal memory works becase of locality Temporal and spatial Work at different scales: for cache, at a line level, for VM, at page level, and even at larger scales All paging schemes depend on locality What happens if a program does not have locality? High cost of paging is acceptable, if infreqent Processes sally reference pages in localized patterns, making paging practical CS 53 Lectre 2 Virtal Memory 9
20 Evicting the Best Page Goal is to redce the page falt rate The best page to evict is the one never toched again Will never falt on it Never is a long time, so picking the page closest to never is the next best thing Evicting the page that won t be sed for the longest period of time minimizes the nmber of page falts Proved by Belady We re now going to srvey varios replacement algorithms, starting with Belady s CS 53 Lectre 2 Virtal Memory 2
21 Belady s Algorithm Belady s algorithm Idea: Replace the page that will not be sed for the longest time in the ftre Optimal? How wold yo show? Problem: Have to predict the ftre Why is Belady s sefl then? Use it as a yardstick/pper bond Compare implementations of page replacement algorithms with the optimal to gage room for improvement» If optimal is not mch better, then algorithm is pretty good What s a good lower bond?» Random replacement is often the lower bond CS 53 Lectre 2 Virtal Memory 2
22 First-In First-Ot (FIFO) FIFO is an obvios algorithm and simple to implement Maintain a list of pages in order in which they were paged in On replacement, evict the one broght in longest time ago Why might this be good? Maybe the one broght in the longest ago is not being sed Why might this be bad? Then again, maybe it s not We don t have any info to say one way or the other FIFO sffers from Belady s Anomaly The falt rate might actally increase when the algorithm is given more memory (very bad) CS 53 Lectre 2 Virtal Memory 22
23 Least Recently Used (LRU) LRU ses reference information to make a more informed replacement decision Idea: We can t predict the ftre, bt we can make a gess based pon past experience On replacement, evict the page that has not been sed for the longest time in the past (Belady s: ftre) When does LRU do well? When does LRU do poorly? Implementation To be perfect, need to time stamp every reference (or maintain a stack) mch too costly So we need to approximate it CS 53 Lectre 2 Virtal Memory 23
24 Approximating LRU LRU approximations se the PTE reference bit Keep a conter for each page At reglar intervals, for every page do:» If ref bit =, increment conter» If ref bit =, zero the conter» Zero the reference bit The conter will contain the nmber of intervals since the last reference to the page The page with the largest conter is the least recently sed Some architectres don t have a reference bit Can simlate reference bit sing the valid bit to indce falts CS 53 Lectre 2 Virtal Memory 24
25 LRU Clock (Not Recently Used) Not Recently Used (NRU) Used by Unix Replace page that is old enogh Arrange all of physical page frames in a big circle (clock) A clock hand is sed to select a good LRU candidate» Sweep throgh the pages in circlar order like a clock» If the ref bit is off, it hasn t been sed recently What is the minimm age if ref bit is off?» If the ref bit is on, trn it off and go to next page Arm moves qickly when pages are needed Low overhead when plenty of memory If memory is large, accracy of information degrades» What does it degrade to?» One fix: se two hands (leading erase hand, trailing select hand) CS 53 Lectre 2 Virtal Memory 25
26 LRU Clock P3: P3: P2: P4: P2: P4: P: P5: P: P5: P8: P6: P8: P6: P7: P7: CS 53 Lectre 2 Virtal Memory 26
27 Example: gcc Page Replace CS 53 Lectre 2 Virtal Memory 27
28 Example: Belady s Anomaly CS 53 Lectre 2 Virtal Memory 28
29 Other ideas Victim bffer Add a bffer (death row!) we pt a page on when we decide to replace it Bffer is FIFO If yo get accessed while on death row clemency! If yo are the oldest page on death row replacement! CS 53 Lectre 2 Virtal Memory 29
30 Fixed vs. Variable Space In a mltiprogramming system, we need a way to allocate memory to competing processes Problem: How to determine how mch memory to give to each process? Fixed space algorithms» Each process is given a limit of pages it can se» When it reaches the limit, it replaces from its own pages» Local replacement Some processes may do well while others sffer Variable space algorithms» Process set of pages grows and shrinks dynamically» Global replacement One process can rin it for the rest CS 53 Lectre 2 Virtal Memory 3
31 Working Set Model A working set of a process is sed to model the dynamic locality of its memory sage Defined by Peter Denning in 6s Definition WS(t,w) = {set of pages P, sch that every page in P was referenced in the time interval (t, t-w)} t time, w working set window (measred in page refs) A page is in the working set (WS) only if it was referenced in the last w references CS 53 Lectre 2 Virtal Memory 3
32 Working Set Size The working set size is the nmber of pages in the working set The nmber of pages referenced in the interval (t, t-w) The working set size changes with program locality Dring periods of poor locality, yo reference more pages Within that period of time, the working set size is larger Intitively, want the working set to be the set of pages a process needs in memory to prevent heavy falting Each process has a parameter w that determines a working set with few falts Denning: Don t rn a process nless working set is in memory CS 53 Lectre 2 Virtal Memory 32
33 Example: gcc Working Set CS 53 Lectre 2 Virtal Memory 33
34 Working Set Problems Problems How do we determine w? How do we know when the working set changes? Too hard to answer So, working set is not sed in practice as a page replacement algorithm However, it is still sed as an abstraction The intition is still valid When people ask, How mch memory does Firefox need?, they are in effect asking for the size of Firefox s working set CS 53 Lectre 2 Virtal Memory 34
35 Page Falt Freqency (PFF) Page Falt Freqency (PFF) is a variable space algorithm that ses a more ad-hoc approach Monitor the falt rate for each process If the falt rate is above a high threshold, give it more memory» So that it falts less» Bt not always (FIFO, Belady s Anomaly) If the falt rate is below a low threshold, take away memory» Shold falt more» Bt not always Hard to se PFF to distingish between changes in locality and changes in size of working set CS 53 Lectre 2 Virtal Memory 35
36 Thrashing Page replacement algorithms avoid thrashing When most of the time is spent by the OS in paging data back and forth from disk No time spent doing sefl work (making progress) In this sitation, the system is overcommitted» No idea which pages shold be in memory to redce falts» Cold jst be that there isn t enogh physical memory for all of the processes in the system» Ex: Rnning Windows95 with 4 MB of memory Possible soltions» Swapping write ot all pages of a process» By more memory CS 53 Lectre 2 Virtal Memory 36
37 Smmary Page replacement algorithms Belady s optimal replacement (minimm # of falts) FIFO replace page loaded frthest in past LRU replace page referenced frthest in past» Approximate sing PTE reference bit LRU Clock replace page that is old enogh Working Set keep the set of pages in memory that has minimal falt rate (the working set ) Page Falt Freqency grow/shrink page set as a fnction of falt rate Mltiprogramming Shold a process replace its own page, or that of another? CS 53 Lectre 2 Virtal Memory 37
38 Next time Disk Drives Preparation Read Modle 35, 36, 37, 44 CS53 Lectre 6 Paging 38
CSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 18 Lecture 18/19: Page Replacement Memory Management Memory management systems Physical and virtual addressing; address translation Techniques: Partitioning,
More informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 18: Page Replacement Terminology in Paging A virtual page corresponds to physical page/frame Segment should not be used anywhere Page out = Page eviction
More informationCSE 120 Principles of Operating Systems
CSE 120 Principles of Operating Systems Fall 2016 Lecture 11: Page Replacement Geoffrey M. Voelker Administrivia Lab time This week: Thu 4pm, Sat 2pm Next week: Tue, Wed At Washington University in St.
More informationCS 153 Design of Operating Systems
CS 53 Design of Operating Systems Spring 8 Lectre 9: Locality and Cache Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationLecture 12: Demand Paging
Lecture 1: Demand Paging CSE 10: Principles of Operating Systems Alex C. Snoeren HW 3 Due 11/9 Complete Address Translation We started this topic with the high-level problem of translating virtual addresses
More informationAll Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging
3/14/2001 1 All Paging Schemes Depend on Locality VM Page Replacement Emin Gun Sirer Processes tend to reference pages in localized patterns Temporal locality» locations referenced recently likely to be
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 15: Virtal Address Space Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian OS Abstractions Applications
More informationOperating Systems. Operating Systems Sina Meraji U of T
Operating Systems Operating Systems Sina Meraji U of T Recap Last time we looked at memory management techniques Fixed partitioning Dynamic partitioning Paging Example Address Translation Suppose addresses
More informationPAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo
PAGE REPLACEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced
More informationCS 153 Design of Operating Systems
CS 53 Design of Operating Systems Spring 8 Lectre 6: Paging Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals by Dave
More informationReminder: Mechanics of address translation. Paged virtual memory. Reminder: Page Table Entries (PTEs) Demand paging. Page faults
CSE 451: Operating Systems Autumn 2012 Module 12 Virtual Memory, Page Faults, Demand Paging, and Page Replacement Reminder: Mechanics of address translation virtual address virtual # offset table frame
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 17: Advanced Paging Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationOperating Systems Virtual Memory. Lecture 11 Michael O Boyle
Operating Systems Virtual Memory Lecture 11 Michael O Boyle 1 Paged virtual memory Allows a larger logical address space than physical memory All pages of address space do not need to be in memory the
More informationVirtual Memory III. Jo, Heeseung
Virtual Memory III Jo, Heeseung Today's Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced virtual memory techniques Shared
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 23: File Systems (2) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time Abstractions for the
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 18: Memory Hierarchy Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationEvicMng the best page #2: FIFO. #1: Belady s Algorithm. CS 537 Lecture 11 Page Replacement Policies 11/1/11. Michael SwiF
EvicMng the best page CS 537 Lecture 11 Page Replacement Policies Michael The goal of the page replacement algorithm: reduce fault rate by selecmng best vicmm page to remove the best page to evict is one
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 25: Dynamic Memory (1) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 12: Deadlock Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Deadlock the deadly embrace! Synchronization
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 3: OS model and Architectral Spport Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time/today
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 8: Threads Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Processes P1 P2 Recall that Bt OS A process
More informationVirtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.
CSE 421/521 - Operating Systems Fall 2012 Lecture - XVI Virtual Memory - II Tevfik Koşar University at Buffalo October 25 th, 2012 1 Roadmap Virtual Memory Page Replacement Algorithms Optimal Algorithm
More informationPaging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1
Paging algorithms CS 241 February 10, 2012 Copyright : University of Illinois CS 241 Staff 1 Announcements MP2 due Tuesday Fabulous Prizes Wednesday! 2 Paging On heavily-loaded systems, memory can fill
More informationCSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management
CSE 120 July 18, 2006 Day 5 Memory Instructor: Neil Rhodes Translation Lookaside Buffer (TLB) Implemented in Hardware Cache to map virtual page numbers to page frame Associative memory: HW looks up in
More informationSwapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Swapping Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Swapping Support processes when not enough physical memory User program should be independent
More informationVirtual Memory Management
Virtual Memory Management CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum and from Operating
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 9: Synchronization (1) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Cooperation between Threads
More informationPage Replacement. (and other virtual memory policies) Kevin Webb Swarthmore College March 27, 2018
Page Replacement (and other virtual memory policies) Kevin Webb Swarthmore College March 27, 2018 Today s Goals Making virtual memory virtual : incorporating disk backing. Explore page replacement policies
More informationVirtual Memory Design and Implementation
Virtual Memory Design and Implementation To do q Page replacement algorithms q Design and implementation issues q Next: Last on virtualization VMMs Loading pages When should the OS load pages? On demand
More informationSwapping. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Swapping Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE0: Introduction to Operating Systems, Fall 07, Jinkyu Jeong (jinkyu@skku.edu) Swapping
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 26: Dynamic Memory (2) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationVIRTUAL MEMORY READING: CHAPTER 9
VIRTUAL MEMORY READING: CHAPTER 9 9 MEMORY HIERARCHY Core! Processor! Core! Caching! Main! Memory! (DRAM)!! Caching!! Secondary Storage (SSD)!!!! Secondary Storage (Disk)! L cache exclusive to a single
More informationVirtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms
Virtual Memory Today! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms Reminder: virtual memory with paging! Hide the complexity let the OS do the job! Virtual address
More informationCS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University
CS 333 Introduction to Operating Systems Class 14 Page Replacement Jonathan Walpole Computer Science Portland State University Page replacement Assume a normal page table (e.g., BLITZ) User-program is
More informationCS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University
CS 333 Introduction to Operating Systems Class 14 Page Replacement Jonathan Walpole Computer Science Portland State University Page replacement Assume a normal page table (e.g., BLITZ) User-program is
More informationOutline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28
Outline 1 Paging 2 Eviction policies 3 Thrashing 1 / 28 Paging Use disk to simulate larger virtual than physical mem 2 / 28 Working set model # of accesses virtual address Disk much, much slower than memory
More information(2, 4) Tree Example (2, 4) Tree: Insertion
Presentation for se with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 B-Trees and External Memory (2, 4) Trees Each internal node has 2 to 4 children:
More informationMemory: Paging System
Memory: Paging System Instructor: Hengming Zou, Ph.D. In Pursuit of Absolute Simplicity 求于至简, 归于永恒 Content Paging Page table Multi-level translation Page replacement 2 Paging Allocate physical memory in
More information!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?
Chapter 10: Virtual Memory Questions? CSCI [4 6] 730 Operating Systems Virtual Memory!! What is virtual memory and when is it useful?!! What is demand paging?!! When should pages in memory be replaced?!!
More informationCS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"
CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement" October 3, 2012 Ion Stoica http://inst.eecs.berkeley.edu/~cs162 Lecture 9 Followup: Inverted Page Table" With
More informationECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)
ECE7995 Caching and Prefetching Techniques in Computer Systems Lecture 8: Buffer Cache in Main Memory (I) 1 Review: The Memory Hierarchy Take advantage of the principle of locality to present the user
More informationMemory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Memory Management Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Topics Why is memory management difficult? Old memory management techniques: Fixed
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 11: Semaphores Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time Worked throgh software implementation
More informationLast Class: Demand Paged Virtual Memory
Last Class: Demand Paged Virtual Memory Benefits of demand paging: Virtual address space can be larger than physical address space. Processes can run without being fully loaded into memory. Processes start
More informationCS 550 Operating Systems Spring Memory Management: Page Replacement
CS 550 Operating Systems Spring 2018 Memory Management: Page Replacement 1 OS Involvement with Page Table Management Four times when OS deals with page-tables 1. Process creation create page table 2. Upon
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2016 Lecture 33 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ How does the virtual
More informationVirtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.
Virtual Memory Tom Kelliher, CS 240 May. 1, 2002 1 Administrivia Announcements Homework, toolboxes due Friday. Assignment From Last Time Introduction to caches. Outline 1. Virtual memory. 2. System support:
More informationAddress spaces and memory management
Address spaces and memory management Review of processes Process = one or more threads in an address space Thread = stream of executing instructions Address space = memory space used by threads Address
More informationVirtual Memory Design and Implementation
Virtual Memory Design and Implementation q q q Page replacement algorithms Design and implementation issues Next: Last on virtualization VMMs Loading pages When should the OS load pages? On demand or ahead
More information10: Virtual Memory Management
CSC400 - Operating Systems 10: Virtual Memory Management J. Sumey Introduction virtual memory management: concerned with the actual management operations of a virtual memory system fetch strategies: when
More information3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!
Post Project 1 Class Format" CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement" Mini quizzes after each topic Not graded Simple True/False Immediate feedback for
More informationLecture 14 Page Replacement Policies
CS 423 Operating Systems Design Lecture 14 Page Replacement Policies Klara Nahrstedt Fall 2011 Based on slides by YY Zhou and Andrew S. Tanenbaum Overview Administrative Issues Page Replacement Policies
More informationPast: Making physical memory pretty
Past: Making physical memory pretty Physical memory: no protection limited size almost forces contiguous allocation sharing visible to program easy to share data gcc gcc emacs Virtual memory each program
More informationCS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 15: Caching: Demand Paged Virtual Memory
CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2003 Lecture 15: Caching: Demand Paged Virtual Memory 15.0 Main Points: Concept of paging to disk Replacement policies
More informationCS 4410 Operating Systems. Page Replacement (2) Summer 2016 Cornell University
CS 4410 Operating Systems Page Replacement (2) Summer 2016 Cornell University Today Algorithm that approximates the OPT replacement algorithm. 2 Least Recently Used (LRU) Page Replacement A recently used
More informationVirtual Memory Design and Implementation
Virtual Memory Design and Implementation Today! Page replacement algorithms! Some design and implementation issues Next! Last on virtualization VMMs How can any of this work?!?!! Locality Temporal locality
More informationWeek 2: Tiina Niklander
Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Policies and methods Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka
More informationVirtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)
Virtual Memory - programmer views memory as large address space without concerns about the amount of physical memory or memory management. (What do the terms 3-bit (or 6-bit) operating system or overlays
More informationMEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019
MEMORY: SWAPPING Shivaram Venkataraman CS 537, Spring 2019 ADMINISTRIVIA - Project 2b is out. Due Feb 27 th, 11:59 - Project 1b grades are out Lessons from p2a? 1. Start early! 2. Sketch out a design?
More informationMemory management, part 2: outline
Memory management, part 2: outline Page replacement algorithms Modeling PR algorithms o Working-set model and algorithms Virtual memory implementation issues 1 Page Replacement Algorithms Page fault forces
More informationOperating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza
Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement May 05, 2008 Léon Mugwaneza http://www.it.uu.se/edu/course/homepage/os/vt08 Review: Multiprogramming (with
More informationCS450/550 Operating Systems
CS450/550 Operating Systems Lecture 4 memory Palden Lama Department of Computer Science CS450/550 Memory.1 Review: Summary of Chapter 3 Deadlocks and its modeling Deadlock detection Deadlock recovery Deadlock
More informationOperating Systems, Fall
Policies and methods Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 10: Lock Implementation Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Recap: Synchronization Race
More informationMove back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t
Memory Management Ch. 3 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Memory Hierarchy Cache CPU Main Swap Area Memory
More informationMemory Management Ch. 3
Memory Management Ch. 3 Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ 1 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ
More informationExceptions and interrupts
Eceptions and interrpts An eception or interrpt is an nepected event that reqires the CPU to pase or stop the crrent program. Eception handling is the hardware analog of error handling in software. Classes
More informationMemory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels
Memory management, part 2: outline 1 Page Replacement Algorithms Page fault forces choice o which page must be removed to make room for incoming page? Modified page must first be saved o unmodified just
More informationReadings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.
Readings and References Virtual Memory Reading Chapter through.., Operating System Concepts, Silberschatz, Galvin, and Gagne CSE - Computer Systems December, Other References Chapter, Inside Microsoft
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Midterm Review Midterm in class on Friday (May 4) Covers material from arch spport to deadlock Based pon lectre material and modles of the book indicated on
More informationEECS 482 Introduction to Operating Systems
EECS 482 Introduction to Operating Systems Fall 2017 Manos Kapritsos Slides by: Harsha V. Madhyastha Recap: Paging Both address spaces and physical memory broken up into fixed size pages Address Space
More informationOperating Systems Lecture 6: Memory Management II
CSCI-GA.2250-001 Operating Systems Lecture 6: Memory Management II Hubertus Franke frankeh@cims.nyu.edu What is the problem? Not enough memory Have enough memory is not possible with current technology
More informationThe final datapath. M u x. Add. 4 Add. Shift left 2. PCSrc. RegWrite. MemToR. MemWrite. Read data 1 I [25-21] Instruction. Read. register 1 Read.
The final path PC 4 Add Reg Shift left 2 Add PCSrc Instrction [3-] Instrction I [25-2] I [2-6] I [5 - ] register register 2 register 2 Registers ALU Zero Reslt ALUOp em Data emtor RegDst ALUSrc em I [5
More informationCIS Operating Systems Memory Management Page Replacement. Professor Qiang Zeng Spring 2018
CIS 3207 - Operating Systems Memory Management Page Replacement Professor Qiang Zeng Spring 2018 Previous class What is Demand Paging? Page frames are not allocated until pages are really accessed. Example:
More informationCS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018
CS 31: Intro to Systems Virtual Memory Kevin Webb Swarthmore College November 15, 2018 Reading Quiz Memory Abstraction goal: make every process think it has the same memory layout. MUCH simpler for compiler
More informationProf. Kozyrakis. 1. (10 points) Consider the following fragment of Java code:
EE8 Winter 25 Homework #2 Soltions De Thrsday, Feb 2, 5 P. ( points) Consider the following fragment of Java code: for (i=; i
More informationBasic Page Replacement
Basic Page Replacement 1. Find the location of the desired page on disk 2. Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select
More informationPage 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"
Goals for Today" CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement" Finish discussion on TLBs! Page Replacement Policies! FIFO, LRU! Clock Algorithm!! Working Set/Thrashing!
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 2: Historical Perspective Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time What is an OS?
More informationHow to create a process? What does process look like?
How to create a process? On Unix systems, executable read by loader Compile time runtime Ken Birman ld loader Cache Compiler: generates one object file per source file Linker: combines all object files
More informationChapter 4: Memory Management. Part 1: Mechanisms for Managing Memory
Chapter 4: Memory Management Part 1: Mechanisms for Managing Memory Memory management Basic memory management Swapping Virtual memory Page replacement algorithms Modeling page replacement algorithms Design
More informationThe single-cycle design from last time
lticycle path Last time we saw a single-cycle path and control nit for or simple IPS-based instrction set. A mlticycle processor fies some shortcomings in the single-cycle CPU. Faster instrctions are not
More informationMemory - Paging. Copyright : University of Illinois CS 241 Staff 1
Memory - Paging Copyright : University of Illinois CS 241 Staff 1 Physical Frame Allocation How do we allocate physical memory across multiple processes? What if Process A needs to evict a page from Process
More informationCS510 Operating System Foundations. Jonathan Walpole
CS510 Operating System Foundations Jonathan Walpole Page Replacement Page Replacement Assume a normal page table (e.g., BLITZ) User-program is executing A PageInvalidFault occurs! - The page needed is
More informationChapter 8. Virtual Memory
Operating System Chapter 8. Virtual Memory Lynn Choi School of Electrical Engineering Motivated by Memory Hierarchy Principles of Locality Speed vs. size vs. cost tradeoff Locality principle Spatial Locality:
More informationRecall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.
Paging 11/10/16 Recall from Tuesday Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS Process 3 Process 3 OS: Place Process 3 Process 1 Process
More informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Recap Paged MMU: Two main Issues Translation speed can be slow TLB Table size is big Multi-level page table
More informationChapter 4 Memory Management
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7
More informationChapter 4 Memory Management. Memory Management
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7
More informationECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management
ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Memory Management 1 Hardware background The role of primary memory Program
More informationPaging and Page Replacement Algorithms
Paging and Page Replacement Algorithms Section 3.4 Tanenbaum s book Kartik Gopalan OS Involvement with Page Table Management Four times when OS deals with page-tables 1. Process creation create page table
More informationLecture 14: Cache & Virtual Memory
CS 422/522 Design & Implementation of Operating Systems Lecture 14: Cache & Virtual Memory Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken from previous versions
More informationPage replacement algorithms OS
Page replacement algorithms OS 2007-08 1 When a page fault occurs OS has to choose a page to evict from memory If the page has been modified, the OS has to schedule a disk write of the page The page just
More informationCS153: Final Review1. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian
1 CS153: Final Review1 Chengyu Song Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian 2 Administrivia Final exam Thursday, June 15, 3:00 p.m. - 6:00 p.m. In this classroom (Sproul
More informationGlobal Replacement Algorithms (1) Ken Wong Washington University. Global Replacement Algorithms (2) Replacement Example (1)
Virtual Memory Part (CSE S) Ken Wong Washington University kenw@wustl.edu www.arl.wustl.edu/~kenw Global Replacement Algorithms () Example Page Reference Stream (String):»,,,,,,,,,,, Assume» ixed number
More informationMemory Management! Goals of this Lecture!
Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Why it works: locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware and
More informationToday. Adding Memory Does adding memory always reduce the number of page faults? FIFO: Adding Memory with LRU. Last Class: Demand Paged Virtual Memory
Last Class: Demand Paged Virtual Memory Benefits of demand paging: Virtual address space can be larger than physical address space. Processes can run without being fully loaded into memory. Processes start
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 1: Corse Introdction Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Teaching Staff Chengy Song I am
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L20 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 Questions from last time Page
More informationMemory Management! How the hardware and OS give application pgms:" The illusion of a large contiguous address space" Protection against each other"
Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Spatial and temporal locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware
More information