U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
CS 311 – Lecture 21 Outline Memory management in UNIX
Operating Systems CMPSCI 377 Lecture 11: Memory Management
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management.
Chapter 3.2 : Virtual Memory
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Chapter 7: Main Memory CS 170, Fall Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
A. Frank - P. Weisberg Operating Systems Simple/Basic Paging.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 8: Main Memory.
Chapter 8 Main Memory Bernard Chen Spring Objectives To provide a detailed description of various ways of organizing memory hardware To discuss.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Memory Management -1 Background Swapping Memory Management Schemes
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Review of Memory Management, Virtual Memory CS448.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 8 Operating Systems.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Operating Systems Chapter 8
Chapter 8 Memory Management Dr. Yingwu Zhu. Outline Background Basic Concepts Memory Allocation.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-8 Memory Management (2) Department of Computer Science and Software.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
CE Operating Systems Lecture 14 Memory management.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
Memory Management Operating Systems CS550. Memory Manager Memory manager - manages allocation and de-allocation of main memory Plays significant impact.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Memory.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
W4118 Operating Systems Instructor: Junfeng Yang.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition, Chapter 8: Memory- Management Strategies.
Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.
Non Contiguous Memory Allocation
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture 12: Paging

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Last Time Memory Management Uniprogramming vs. Multiprogramming Segments Memory allocation First-fit, best-fit, worst-fit... Compaction Relocation

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 Today: Paging Motivation Fragmentation Page Tables Hardware Support Other Benefits

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 Segmentation, Revisited As processes enter system, grow & terminate, OS must track available and in-use memory Can leave holes OS must decide where to put new processes

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 Motivation: Problems with Segments Processes don’t (usually) use entire space in memory all the time Fragmentation problematic Internal & external Compaction expensive

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Alternative: Paging Divide memory into fixed- sized pages (4K, 8K) Allocates pages to frames in memory OS manages pages Moves, removes, reallocates Pages copied to and from disk A

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 Example: Page Layout How does this help?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 Paging Advantages Most programs obey 90/10 “rule” 90% of time spent accessing 10% of memory Exploiting this rule: Only keep “live” parts of process in memory A B A B

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 Paging Advantages “Hole-fitting problem” vanishes! Logical memory contiguous Physical memory not required to be Eliminates external fragmentation But not internal (why not?) But: Complicates address lookup...

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 Example: Page Layout So how do we resolve addresses?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 Today: Paging Motivation Fragmentation Page Tables Hardware Support Other Benefits

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 Paging Hardware Processes use virtual addresses Addresses start at 0 or other known address OS lays process down on pages MMU (memory-management unit): Hardware support for paging Translates virtual to physical addresses Uses page table to keep track of frame assigned to memory page

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 Paging Hardware: Diagram

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Paging Hardware: Intuition Paging: form of dynamic relocation Virtual address bound by paging hardware to physical address Page table ¼ set of relocation registers One per frame Mapping – invisible to process OS maintains mapping H/W does translation Protection – provided by same mechanisms as in dynamic relocation

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Paging Hardware: Nitty-Gritty Page size (= frame size): Typically power of 2 between 512 & 8192 bytes Linux, Windows: 4K; Solaris: 8K Support for larger page sizes varies (e.g., 128K) Use of powers of 2 simplifies translation of virtual to physical addresses

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 16 Address Translation Powers of 2: Virtual address space: size 2 m Page size 2 n High-order m-n bits of virtual address select page Low order n bits select offset in page

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Address Translation: Example How big is page table? How many bits per address? (assume 1 byte addressing) What part is p, d? Given virtual address 24, do virtual to physical translation

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 18 Address Translation: Example How many bits per address? (assume 4 byte addressing) What part is p, d? Given virtual address 13, do virtual to physical translation

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 Making Paging Efficient Where should the page table go? Registers: Pros? Cons? Memory: Pros? Cons?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 20 Translation Lookaside Buffer (TLB) TLB: fast, fully associative memory Stores page numbers (key) and frame (value) in which they are stored Assumption: locality of reference Locality in memory accesses ) locality in address translation TLB sizes: 8 to 2048 entries

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 21 TLB: Diagram v = valid bit: entry is up-to-date

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Cost of Using TLB Measure in terms of memory access cost What is cost if: Page table is in memory? Page table managed with TLB? Large TLB: Improves hit ratio Decreases average memory cost

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 23 Managing the TLB: Process Initialization & Execution Process arrives, needs k pages If k page frames free, allocate; else free frames that are no longer needed OS: puts pages in frames puts frame numbers into page table marks all TLB entries as invalid (flush) starts process loads TLB entries as pages are accessed, replaces entries when full

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 24 Managing the TLB: Context Switches Extend Process Control Block (PCB) with: Page table Copy of TLB (optional) Context switch: Copy page table base register value to PCB Copy TLB to PCB (optional) Flush TLB Restore page table base register Restore TLB (optional) Use multilevel paging if tables too big

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 25 Today: Paging Motivation Fragmentation Page Tables Hardware Support Other Benefits

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 26 Sharing Paging allows sharing of memory across processes Shared pages –different virtual addresses, point to same physical address Compiler marks “text” segment (i.e., code) of applications (e.g., emacs) - read-only OS: keeps track of such segments Reuses if another instance of app arrives Can greatly reduce memory requirements

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 27 Summary: Paging Advantages Paging: big improvement over segmentation Eliminates external fragmentation (thus avoiding need for compaction) Allows sharing of code pages across processes Reduces memory demands Enables processes to run when only partially loaded in main memory

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 28 Summary: Paging Disadvantages Paging: some costs Translating from virtual addresses to physical addresses efficiently requires hardware support Larger TLB ) more efficient, but more expensive More complex operating system required to maintain page table More expensive context switches Why?