Chapter 8 Main Memory

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

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

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Memory Management. Dr. Yingwu Zhu

Chapter 8: Main Memory

Chapter 8: Main Memory

Basic Memory Management

Chapter 8: Memory Management Strategies

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

Module 8: Memory Management

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

Memory Management. Memory Management

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

Chapters 9 & 10: Memory Management and Virtual Memory

Chapter 9: Memory Management. Background

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

Module 8: Memory Management

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

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

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

Memory Management. Dr. Yingwu Zhu

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

Chapter 8: Memory Management

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Chapter 4 Memory Management

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

Logical versus Physical Address Space

Goals of Memory Management

Memory Management and Protection

Operating System 1 (ECS-501)

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY

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

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

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

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

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

CS 143A - Principles of Operating Systems

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

Chapter 9: Virtual-Memory

Chapter 8 Memory Management

Module 9: Virtual Memory

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

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

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

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

Main Memory (Part II)

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

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

Lecture 8 Memory Management Strategies (chapter 8)

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

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

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


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

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

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

Module 9: Virtual Memory

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

a. What is a lower bound on the number of page faults? b. What is an upper bound on the number of page faults?

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

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

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

Chapter 8: Memory- Management Strategies

Introduction to Virtual Memory Management

Principles of Operating Systems

Virtual Memory COMPSCI 386

Chapter 9 Memory Management

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

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

Compile: compiler. Load: loader. compiler linker loader memory. source object load code module module 2

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

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

Chapter 8: Main Memory

VII. Memory Management

Chapter 4 Memory Management. Memory Management

Chapter 8: Main Memory

Virtual Memory Outline

CS450/550 Operating Systems

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

CS420: Operating Systems. Paging and Page Tables

Main Memory (Part I)

Chapter 8: Memory-Management Strategies

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

Chapter 9: Virtual Memory

Memory management, part 2: outline

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Chapter 8: Virtual Memory. Operating System Concepts

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

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

CS370 Operating Systems

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

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

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

Chapter 8: Memory Management

Chapter 9: Virtual Memory

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018

Virtual Memory. Chapter 8

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

Transcription:

Chapter 8 Main Memory 8.1, 8.2, 8.3, 8.4, 8.5 Chapter 9 Virtual memory 9.1, 9.2, 9.3 https://www.akkadia.org/drepper/cpumemory.pdf Images from Silberschatz Pacific University 1

How does the OS manage memory? Allocation Swapping Hardware support Assume the entire process must be in memory! Virtual Memory chapter 9 Does not make this assumption Pacific University 2

Memory Access Basics Register Cache Stall Main Memory Disk Protection Pacific University 3

Software (Basic) Mapping + Protection Thinks it can access address zero to limit Hardware Two registers Base Limit Privileged instructions Kernel mode! On error Trap! Pacific University 4

Pacific University 5

Address Bind Time When are addresses in the executable set? Compile time Must always be in the same location Load time Can be loaded anywhere Execution time Can be moved during execution! Pacific University 6

Logical vs Physical Addresses Logical Address (Virtual Address) Software only ever sees this! Physical Address Memory Management Unit Generalization of the base/limit register method Relocation register Pacific University 7

Linking at execution time Dynamic Linking Static linking stub Shared libraries.dll or.so Pacific University 8

Swapping Not all processes fit in physical memory Chapter 9: not all of a single process will fit into physical memory Physical memory <==> Backing store Swap back into memory Same location Different location Context Switch Time Size * Transfer rate How does this affect time slices? Pacific University 9

Contiguous Memory Allocation Two Partitions OS User Processes Pacific University 10

Allocation of Memory Allocate part of User Space partition to each process Hole (technical term) First Fit Best Fit Worst Fit Best Fit/First Fit found (experimentally) to be better than Worst Fit in terms of time and memory utilization What happens if 5 & 2 terminate? Pacific University 11

Fragmentation External Internal Compaction 50% Rule Pacific University 12

Paging! Noncontiguous memory allocation Frame Physical memory Page Logical memory Allocate an entire page at a time Page table Internal Fragmentation Pacific University 13

Page and Frame size are determined by the hardware Pacific University 14

Address Translation Logical Address to Page Number + Offset Logical address space 2 m and page size 2 n Pacific University 15

32 byte memory 4 byte pages No guarantee of ordering What happens char *pchar = 0x7; pchar ++; print pchar; Pacific University 16

Page Table Pages are not always reloaded to the same frame?? Contains base address of each page in physical memory Per process (usually) Which frame is it in In main memory Hardware (not per process) Page table base register (PTBR) Page table length register (PRLR) Translation look-aside buffers (TLBs) Address space identifiers (ASIDs) protection Pacific University 17

Pacific University 18

Protection Add valid/invalid bit to each page table entry ASIDs in TLBs denote which process owns each frame Pacific University 19

Shared Pages.dll /.so Share read only code pages Shm Shared read/write data pages Pacific University 20

What do you think? Problems with page tables Pacific University 21

Multilevel Page Tables Page the page table Forward mapped page table Pacific University 22

Hashed Page Tables Address spaced > 32 bits Use Virtual address to hash into the table Chain of pages Pacific University 23

Inverted Page Table One entry per frame in physical memory One page table for the entire system Track pid in the table Problem? Solution? Pacific University 24

Chapter 9 Virtual Memory Images from Silberschatz Pacific University 25

Virtual Memory Processes do not need to be completely in memory to execute data code data set can be larger than physical memory Demand Paging Pacific University 26

Big Virtual Memory space Process View Only allocated needed pages Empty pages are ignored Empty Until Needed Pacific University 27

Sharing Memory Pacific University 28

Demand Paging Load pages as they are needed lazy swapping (pager) less I/O (up front) less memory used at once faster response more processes fit into memory mark pages as in memory or not (similar to valid/invalid) Pacific University 29

New Page Table Pacific University 30

Hardware Support Accessing an out-of-memory page causes a page fault trap OS handles this and brings the page into memory Also must check for invalid address Pure Demand Paging Locality of reference Page fault may occur anywhere in an instruction may backup and rerun something Pacific University 31

Page Fault! Pacific University 32

Copy-on-Write When do processes share pages? Only copy (create a new page) when one process writes to a shared page faster vfork()/exec() Pacific University 33

Page Replacement Remove page from physical memory to make room swap out a process/frame Two I/O operations out then in time consuming page may still be on disk dirty bit! Pacific University 34

Goal: Few page faults Frame Allocation Algorithms Page Replacement Pacific University 35

FIFO First In, First Out Ref String: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Belady's Anomaly: more frames, more faults Pacific University 36

Optimal Replacement Algo Replace the page that will not be used for the longest period of time Problems with this? Pacific University 37

Approximate Optimal LRU LRU-Approximate reference bit may be also FIFO (second chance) LRU-Additional-Reference -Bits many (8?) bits Enhanced Second Chance referenced, modified bits Pacific University 38

Count references per page rarely used in real world Counting Algorithms Least Frequently Used Most Frequently Used Pacific University 39

Global replacement Global vs Local Local replacement Pacific University 40

Thrashing Furiously swapping pages in and out Problems? CPU utilization is low, so OS adds more processes more frames are used Poor data layout in your application Pacific University 41

Pacific University 42