memory management Vaibhav Bajpai

Similar documents
CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Introduction to Operating Systems

Page 1. Goals for Today" Virtualizing Resources" Important Aspects of Memory Multiplexing" CS162 Operating Systems and Systems Programming Lecture 20

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

Page 1. Goals for Today" Important Aspects of Memory Multiplexing" Virtualizing Resources" CS162 Operating Systems and Systems Programming Lecture 9

Midterm 1. Administrivia. Virtualizing Resources. CS162 Operating Systems and Systems Programming Lecture 12. Address Translation

CS162 Operating Systems and Systems Programming Lecture 12. Protection (continued) Address Translation

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

Goals of Memory Management

CS399 New Beginnings. Jonathan Walpole

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

Virtual to physical address translation

16 Sharing Main Memory Segmentation and Paging

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

Page Tables. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Memory Management. Dr. Yingwu Zhu

15 Sharing Main Memory Segmentation and Paging

Address Translation. Tore Larsen Material developed by: Kai Li, Princeton University

Main Memory: Address Translation

Today: Segmentation. Last Class: Paging. Costs of Using The TLB. The Translation Look-aside Buffer (TLB)

CS162 Operating Systems and Systems Programming Lecture 12. Protection (continued) Address Translation

Memory Management. Goals of Memory Management. Mechanism. Policies

Today. Process Memory Layout. CSCI 4061 Introduction to Operating Systems. Where does the memory come from?

Last Class: Deadlocks. Where we are in the course

Chapter 9 Memory Management

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

! What is main memory? ! What is static and dynamic allocation? ! What is segmentation? Maria Hybinette, UGA. High Address (0x7fffffff) !

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

Chapter 8 Main Memory

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

Memory management: outline

Memory management: outline

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

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

CS307 Operating Systems Main Memory

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

Classifying Information Stored in Memory! Memory Management in a Uniprogrammed System! Segments of a Process! Processing a User Program!

Principles of Operating Systems

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

Lecture 13: Address Translation

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

CS 134: Operating Systems

Chapter 8: Main Memory

Chapter 8: Memory-Management Strategies

Memory Management. Memory

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

CIS Operating Systems Non-contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Virtual Memory. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

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

CS370 Operating Systems

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

Memory Management. Memory Management

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Memory Management. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Chapter 8: Main Memory

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

CS5460: Operating Systems Lecture 14: Memory Management (Chapter 8)

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

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

Hardware Address Binding Memory Allocation References. Physical Memory. Daniel Bosk 1

Chapter 8 Memory Management

Operating System Support

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Memory Management. An expensive way to run multiple processes: Swapping. CPSC 410/611 : Operating Systems. Memory Management: Paging / Segmentation 1

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

Chapter 8: Main Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 8: Main Memory

Virtual Memory. Today. Segmentation Paging A good, if common example

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

EECS 482 Introduction to Operating Systems

Chapter 9: Memory Management. Background

How to create a process? What does process look like?

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

COS 318: Operating Systems. Virtual Memory and Address Translation

CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

Chapter 8: Memory Management Strategies

CS307: Operating Systems

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

Chapter 8: Memory Management

Transcription:

memory management Vaibhav Bajpai OS 2013

motivation virtualize resources: multiplex CPU multiplex memory (CPU scheduling) (memory management) why manage memory? controlled overlap processes should NOT overlap in physical memory translation allows to give uniform view of memory to programs CPU virtual address MMU physical address RAM protection a process should NOT access other process memory read-only memory locations: (kernel, process code, et al.)

memory management base-bound registers segmentation paging segmentation + paging multi-level page tables inverted page tables

base and bound registers base CPU virtual address + physical address RAM limit <? error! dynamic address translation: issues: no inter-process sharing cannot load a process bigger than an available hole maybe load only a part of the process in memory? heap and stack cannot grow within a process not all processes are of same size: leads to external fragmentation

segmentation idea: divide each process into multiple segments each with their own BASE and LIMIT registers stack code code stack advantages: segments can be shared! a part of a process can also be in memory heap and stack can grow within a process data heap heap data process address space memory

segmentation 3bits 5bits segment # offset <? error! base0 limit0 V base1 limit1 V base2 limit2 V YES! 8bits base3 limit3 V + physical address base4 limit4 N base5 limit5 N base6 limit6 N base7 limit7 V v? access error! the segment table is stored in processor; not memory the segment table should be protected from processes issues: each segment differs in size, leads to external fragmentation swapping requires a complete segment to be written to disk

paging idea: divide the physical memory into fixed size chunks (pages) use a bit vector to handle allocation perspectives: with 4GiB of physical memory, and 4KiB of pages, what should be the size of the bit vector? 220KiB use small page size to avoid huge internal fragmentation advantages: no external fragmentation! only small-sized pages need to be swapped to disk

paging virtual page # offset pagetableptr page0 page1 physical page # offset pagetablesize <? YES! page2 page3 page4 page5 n v? access error! access error! there is a page table for each process page table resides in physical memory offset represents the size of a page; for a 4K page, how many offset bits do we need? 12 bits for a 4K page, for a 32 bit address space, how many page numbers are possible? 1m why are we not checking limit for the offset?all pages are of same size! can data structures be allocated that span more than a page? yes! would it be contiguous in physical memory? not guaranteed! why do we have a page table size? the page table grows... can stack/heap grow in this scheme? no! requires allocation of each page table entry

process A paging virtual page # offset pagetableptr page0 page1 page2 page3 page4 page5 n shared page pagetableptr page0 page1 virtual page # offset process B sharing pages: page2 page3 process B can only read; however process A can read/write note: virtual address of a physical address can be different across processes what do we need on a process context switch? page table pointer page table size

paging issues: cannot handle sparse address space segmentation had this feature! page tables reside in memory and they can get REALLY big! it s possible to swap out individual pages to disk would be nice to swap parts of page table to disk!

segmentation + paging virtual seg # virtual page # offset base0 limit0 V page0 physical page # offset base1 limit1 V page1 base2 limit2 V page2 base3 limit3 V page3 base4 limit4 N base5 limit5 V page4 page5 n v? access error! base6 limit6 N base7 limit7 V <? access error! idea: v? access error! create a multi-level translation lowest-level is a page-table higher-levels are segmented advantages: whole segments can be shared! can handle sparse address space what do we need on a process context switch? highest level segment table

segmentation + paging process A virtual seg # virtual page # offset base0 limit0 V base1 limit1 V base2 limit2 V base3 limit3 V base4 limit4 N base5 limit5 V base6 limit6 N base7 limit7 V page0 page1 page2 page3 page4 n page5 shared segment base0 limit0 V base1 limit1 V base2 limit2 V base3 limit3 V base4 limit4 N base5 limit5 V base6 limit6 N base7 limit7 V sharing: virtual seg # virtual page # offset process B whole segments can be shared! individual pages can be shared as well!

two-level page table 10 bits 10 bits 12 bits virtual P1 # virtual P2 # offset page0 physical page # offset page0 page1 page2 page3 page4 n page1 page2 page3 page4 page5... n } 4KiB page5 page6 n page0 page1 } page7 n page2 4 bytes 4 bytes all the levels of page table and pages themselves are 4K! allows to transparently swap out parts of the page table! issues: two (or more) level lookups become expensive (use a TLB)

inverted page table virtual page # offset physical page # offset hash table page table size becomes independent of virtual address space becomes directly related to the amount of physical memory very attractive for 64-bit virtual address spaces issues: complexity of managing a hash table in hardware

summary base-bound registers segmentation paging complete process contiguously loaded in physical memory external fragmentation, no inter-process sharing part of a process can be loaded into memory external fragmentation, large segments swapped to disk no external fragmentation, flexible sharing cannot handle sparse addresses, page tables can grow BIG! segmentation + paging can handle sparse addresses complete segments or individual pages can be shared two-level page tables portion of the page-table can be swapped to disk inverted page tables page-table size directly related to size of physical memory complexity to manage hash table in hardware