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

Similar documents
Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 Main Memory

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

VII. Memory Management

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

CSE325 Principles of Operating Systems. Virtual Memory. David P. Duggan. March 7, 2013

memory management Vaibhav Bajpai

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

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

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

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

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Chapter 8 Memory Management

CS370 Operating Systems

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

CS370 Operating Systems

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Chapters 9 & 10: Memory Management and Virtual Memory

Basic Memory Management

Chapter 9: Virtual-Memory

Operating System 1 (ECS-501)

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

Chapter 4 Memory Management

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

CS3600 SYSTEMS AND NETWORKS

Chapter 8: Virtual Memory. Operating System Concepts

CS 134: Operating Systems

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

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

Chapter 8: Memory-Management Strategies

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

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

Chapter 9: Virtual Memory

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

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

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

CS307: Operating Systems

Chapter 9 Memory Management

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

Chapter 4 Memory Management. Memory Management

Chapter 8: Main Memory

OPERATING SYSTEM. Chapter 9: Virtual Memory

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

Main Memory (Part II)

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

Memory Management. Memory Management

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

Chapter 9: Virtual Memory

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

Goals of Memory Management

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Chapter 6: Demand Paging

Chapter 8: Main Memory

CS307: Operating Systems

CS307 Operating Systems Main Memory

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

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

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

Introduction to Virtual Memory Management

Memory Management and Protection

Virtual Memory 1. To do. q Segmentation q Paging q A hybrid system

Memory Management Virtual Memory

VIRTUAL MEMORY II. Jo, Heeseung

Memory Management. Dr. Yingwu Zhu

Chapter 8 Main Memory

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

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

CSE 120 Principles of Operating Systems Spring 2017

Chapter 9: Virtual Memory


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

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

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

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Memory Management. Contents: Memory Management. How to generate code? Background

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

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

Chapter 8: Memory- Management Strategies

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

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

CSE 120 Principles of Operating Systems

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

Virtual Memory Outline

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

CS 3733 Operating Systems:

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

CS450/550 Operating Systems

Recap: Memory Management

CS 318 Principles of Operating Systems

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

CS370 Operating Systems

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

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

ECE 571 Advanced Microprocessor-Based Design Lecture 12

Chapter 8: Main Memory

Lecture 8 Memory Management Strategies (chapter 8)

Chapter 8: Main Memory

Transcription:

Operating Systems Lecture 6 Memory management 2 Memory Management 2 Overview Paging (contd.) Structure of page table Shared memory Segmentation Segmentation with paging Virtual memory Just to remind you... logical address page table physical address Paging...

Invalid bit in page table Pages not used by process no corresponding frame invalid bit set trap if addressed Structure of the page table Page table can be large spans the whole address space Example: 4kb pages and 32 bit address space 2^(32-2)=2^2 entries in page table if entry is 4 bytes (32 bits), table is 4MB 64 bits architechtures? have to do something! Solutions Page table length register Hierachical page table Hashed page table Inverted page table Hierarchical page table Divide logical address in several parts outer table index inner table index offset (as usual) requires less space invalid page of outer table no table at all for inner table requires more memory lookups hardware support logical address: p p2 d 2

Hierarchical page table Several levels of hierarchy possible SPARC support three levels MC683 support four levels Very large address space are still handled poorly 64-bit addresses would require seven levels Hashed page table table size no direct relation to size of address space used for very large address spaces Issues collision in hash table hash function Inverted page table Regular page table for each page in address space store frame number (map from pages to frames) very large table for large address spaces Logical address space larger than physical memory Inverted page table for each fram in physical memory store page number (map from frames to pages) table size depend on amount of physical memory 3

Inverted page table Map frames to pages but... we want to map pages to frames! how to do that? search the table in some way hash table could be used to speed up search Only one table in the system for all processes same page present several times for different processes include process id in table Used by several architechtures UltraSPARC, PowerPC,... Inverted page table TLB searched first then inverted table Searching the inverted table is very slow linear search Shared memory Code can be shared between processes several instances of the same program dynamic link library self-modifying code does not work! should never be used anyway must appear in the same memory location in each process why? program addresses becomes wrong otherwise Data can be shared can appear anywhere in the address space 4

Shared memory on paged system Map pages from different processes to the same (shared) frame big problem with inverted page table only one page entry per frame let the mem ref. trap handle the mapping in kernel slower Segmentation User memory divided into segments address specified as <segment number, offset> Motivation segments represent semantically defined portions of user memory: code, data, stack,... segments can be defined read, write, execute, just as pages Segments can be shared between processes Segmentation architecture Address: <segment, offset> the segment is often implicit set in a register in the cpu Each process has a segment table one entry in table is: base: physical address of start of segment limit: size of segment works in the same way as contiguous memory allocation MMU Segment-table base register (STBR) Segment-table length register (STLR) 5

Segmentation example memory holes same problem as contiguous allocation several logical address spaces one per segment Segmentation hardware similar to contiguous allocation use table instead of register memory protection segment size flags read/write/execu te... Shared segments Share segments code several instances of same program shared libraries data 6

Allocation of segments Segments can have different sizes dynamic storage allocation problem search for holes, first fit, bestr fit, etc... external fragmentation Solution to this? compaction? slow, but works IBM OS/2.3 uses this scheme not that slow though... better solution? Segmentation with paging Combine both segmentation and segmentation Segment table does not contain physical addresses page numbers Paging scheme solves external fragmentation Needs hardware support Best of two worlds? Segmentation with paging the i386 segmentation 2-level paging 7

Virtual memory Overview Virtual memory idea Demand paging page fault page replacement page replacement algorithms Virtual memory considerations memory over-allocation Working set model Efficient process creation yes it has to do with virtual memory! Memory mapped files Virtual memory Separate logical memory from physical memory earlier, we separated logical addresses from physical, now we separate the actual memory Only part of process need to be in physical memory transparent to the process Emulate more memory than is present use secondary storage performance is decrease if used carelessly performance is increased if used wisley better resource utilization Allows processes to share files efficiently More efficient process creation Implementation demand paging demand segmentation Idea of virtual memory Use disk as memory Transparent for user process load back into memory as needed 8

Demand paging Paging with swapping entire process is swapped in/out of memory process needs to be completely in memory in order to run swapper module swaps processes in/out Demand paging individuasl pages are moved to/from secondary storage as needed only small part (working set) of process needs to be in memory pager module moves pages to/from secondary storage reference to page not in memory traps to pager module Page table includes invalid bit indicates page not present either page not used by process (as previously) or... page not presently in physical memory needs to be loaded if needed Demand paging Page fault Acess to page marked invalid is called a page fault trap to kernel Actions taken by kernel on page fault decide if access is invalid or if page not in memory choose an empty frame (if there are any) load page from disk into the empty frame update page table and TLB and set valid-bit to restart instruction that caused the fault 9

Demand paging Demand paging Hardware must be able to restart instruction not as easy as it might look complex instructions might write to a valid page and then to an invalid page what to do with the completed write? Pure demand paging only bring requested pages into memory process started with zero pages in memory and immediately faults Performance of demand paging Costly to service page fault I/O is slow memory access time: to 2 ns disk access time ms Disk is a factor of ^6 slower than memory when it comes to access time Few page faults crucial Efficient swap space handling crucial swap space often handled separate from file systems increase performance a bit

No free frames Page replacement No free frames some frame needs to be replaced page replacement algorithm select page to be replaced Pages needs to be saved (paged out) before replaced by new pages is page not changed since load discard without save page table contains dirty bit maintained by hardware set on page write reduce i/o overhead only dirty pages are paged out Basic page replacement strategy Find location of desired page on disk Find free frame if exists use it in not find a victim frame (page replacement algo) write out the victim fram to disk, if dirty Read desired page into free frame Restart process Page replacement p pages frame valid dirty RAM (frames): swap space: p access

Page replacement algorithms What page to replace? Page replacement algo should give lowest page fault rate Algorithm evaluation run on a sequence of memory references compute number of page faults for that sequence Reference sequence generated using some distribution traces of actual memory references FIFO Page replacement algorithms Optimal LRU Counting algorithms Second chance enhanced second chance Page buffering Next lecture... More on virtual memory page replacement algorithms process allocation memory mapped files memory over-allocation 2