ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

Similar documents
Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

CS370 Operating Systems

Page Replacement Algorithms

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

CSE 153 Design of Operating Systems

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

Basic Page Replacement

Operating Systems. Operating Systems Sina Meraji U of T

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28

CS 153 Design of Operating Systems Winter 2016

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Lecture 14 Page Replacement Policies

Locality of Reference

VIRTUAL MEMORY READING: CHAPTER 9

CS370 Operating Systems

Chapter 9: Virtual-Memory

Page Replacement. 3/9/07 CSE 30341: Operating Systems Principles

CSC Operating Systems Spring Lecture - XIV Virtual Memory - II. Tevfik Ko!ar. Louisiana State University. March 27 th, 2008.

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Marten van Dijk Syed Kamran Haider, Chenglu Jin, Phuong Ha Nguyen. Department of Electrical & Computer Engineering University of Connecticut

Chapter 9: Virtual Memory

Memory Management. Virtual Memory. By : Kaushik Vaghani. Prepared By : Kaushik Vaghani

Chapter 9: Virtual Memory

CS370 Operating Systems

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - XIV Virtual Memory - I. Louisiana State University.

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSC Operating Systems Spring 2007

Virtual Memory III. Jo, Heeseung

Virtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.

! What is virtual memory and when is it useful? ! What is demand paging? ! What pages should be. ! What is the working set model?

Unit 2 Buffer Pool Management

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Swapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Virtual Memory - Overview. Programmers View. Virtual Physical. Virtual Physical. Program has its own virtual memory space.

Swapping. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Last Class: Demand Paged Virtual Memory

Where are we in the course?

Readings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.

Chapter 10: Virtual Memory. Background

CS420: Operating Systems

Principles of Operating Systems

Past: Making physical memory pretty

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory

CSE 120 Principles of Operating Systems

Module 9: Virtual Memory

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Lecture 12: Demand Paging

Last Class. Demand Paged Virtual Memory. Today: Demand Paged Virtual Memory. Demand Paged Virtual Memory

Chapter 8: Virtual Memory. Operating System Concepts

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

Module 9: Virtual Memory

Chapter 9: Virtual Memory

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

All Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging

Unit 2 Buffer Pool Management

Chapter 4 Memory Management

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Virtual Memory Design and Implementation

Chapter 9: Virtual Memory

Background. Virtual Memory (2/2) Demand Paging Example. First-In-First-Out (FIFO) Algorithm. Page Replacement Algorithms. Performance of Demand Paging

Virtual Memory. Chapter 8

Operating System Concepts

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory Outline

ECE331: Hardware Organization and Design

Caching and Demand-Paged Virtual Memory

CIS Operating Systems Memory Management Page Replacement. Professor Qiang Zeng Spring 2018

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Reminder: Mechanics of address translation. Paged virtual memory. Reminder: Page Table Entries (PTEs) Demand paging. Page faults

SMD149 - Operating Systems - VM Management

Chapter 8 Virtual Memory

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Chapter 9: Virtual-Memory Management. Operating System Concepts 8 th Edition,

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

1. Background. 2. Demand Paging

OPERATING SYSTEM. Chapter 9: Virtual Memory

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

CIS Operating Systems Memory Management Cache Replacement & Review. Professor Qiang Zeng Fall 2017

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

CS370 Operating Systems

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

Lecture 14: Cache & Virtual Memory

CPE300: Digital System Architecture and Design

Operating Systems Lecture 6: Memory Management II

Role of OS in virtual memory management

Transcription:

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 with as much memory as is available in the cheapest technology at the speed offered by the fastest technology Processor 4-8 bytes (word) Increasing distance from the processor in access time L1$ 8-32 bytes (block) L2$ 1 to 4 blocks Main Memory 1,024+ bytes (disk sector = page) Secondary Memory (Hard Disk) (Relative) size of the memory at each level 2

Management of Buffer Cache in Main Memory Less constraints on buffer cache in main memory (managed by software) Allow fully-associative mapping Any disk blocks can be placed at any memory block address in a buffer cache Allow complex data structure Processor cache: address manipulation for indices to tables Buffer cache: use advanced data structure such as hash table and radix tree to search blocks/pages of a give address. Allow complex algorithm for replacement decision Processor cache: LRU for 2-way, random or approximate LRU for higher ways Buffer cache: LRU and other more advanced replacement algorithms. The objective of buffer cache management Leverage intelligent replacement algorithms to minimize I/O time. 3

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 its page replacement algorithm to select a victim frame (if the frame is dirty, it needs to be written back) 3) Bring the desired page into the (newly) free frame; update the page and frame tables 4) Restart the process 4

Page Replacement Algorithms One objective: lowest page-fault rate (or miss rate) Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string The reference string is like: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 5

Graph of Page Faults Versus The Number of Frames 6

FIFO Page Replacement FIFO: Evict oldest page: Problem: completely ignores usage pattern first pages loaded are often frequently accessed 7

Belady s Anomaly For some page replacement algorithms, the page fault rate may increase as the number of page frames increases. Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 with FIFO: (1) Using 3 page frames, there are 9 page faults (2) Using 4 page frames, there are 10 page faults 8

Optimal Algorithm The MIN algorithm: replace the page that is accessed the farthest in the future, e.g. that won t be accessed for the longest time Problem: don t know what are the future references Used for measuring how well a practical algorithm performs 9

LRU: Least Recently Used (LRU) Algorithm OS maintains ordered list of physical pages by reference time. When page is referenced: move the page to front of list When need victim: pick page at back of list (least-recently-used page) Trade-off: slow on memory reference, fast on replacement LRU is designed according to the temporal locality A page recently accessed is likely to be accessed again in the near future Good performance if past is predictive of future. Major problem: would have to keep track of recency on every access, either timestamp, or move to front of a list OK with I/O access via sys-call unaffordable with hits in process address space 10

LRU Algorithm Implementation Stack implementation keep a stack of page numbers in a double link form: Page referenced: move it to the top requires 6 pointers to be changed No search for replacement Use of a stack to record the most recent page references 11

Clock Algorithm an LRU Approximation Hardware support Keep reference bit for each page frame When page is referenced, set the bit Operating System Page replacement: look for page with reference bit cleared (has not been referenced for a while) Implementation: Treat pages as circular buffer Keep pointer to last examined frame Traverse pages in circular buffer Clear reference bits as search Stop when find page with cleared reference bit, replace this page. 12

Illustration of the Clock Algorithm In what cases, the clock hand sweeps very slow? And very fast? What are the issues with the cases? 13

Replace multiple pages at once Clock Extensions Intuition: Expensive to run replacement algorithm to get a single page frame or to write single page to disk Find multiple victims each time Two-handed clock Intuition: If takes long time for clock hand to sweep through pages, then all uses might be set Traditional clock cannot differentiate between usage of different pages in this case. Allow smaller time between clearing reference bit and testing First hand: clears reference bit periodically (timing not determined solely by miss events) Second hand: looks for victim page with reference bit still cleared. 14

Replacement Examples 15

Other Replacement Algorithms LFU Algorithm: Keep a counter of the number of references that have been made to each page and replaces page with smallest count MRU Algorithm: replace most-recently-used page 16