Operating Systems, Fall

Similar documents
Operating Systems, Fall

Registers Cache Main memory Magnetic disk Magnetic tape

Chapter 4 Memory Management

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

12: Memory Management

Memory management: outline

Memory management: outline

Chapter 4 Memory Management. Memory Management

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Motivation. Memory Management. Memory Management. Computer Hardware Review

SMD149 - Operating Systems - Memory

Memory Management Prof. James L. Frankel Harvard University

CS399 New Beginnings. Jonathan Walpole

Preview. Memory Management

CS450/550 Operating Systems

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

Memory and multiprogramming

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

Operating Systems, Fall

Operating Systems, Fall

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

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

CS307: Operating Systems

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Memory Management. Dr. Yingwu Zhu

Operating Systems, Fall Lecture 5, Tiina Niklander 1

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

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

Memory management OS

Processes and Tasks What comprises the state of a running program (a process or task)?

Virtual Memory (VM) Ch Copyright Teemu Kerola Teemu s Cheesecake

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

Chapter 3 - Memory Management

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

Operating Systems, Fall Lecture 5 1. Overhead due to page table and internal fragmentation. Tbl 8.2 [Stal05] 4.

Operating Systems, Fall Lecture 5 1

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

CS 3733 Operating Systems:

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

Memory Management. Memory Management

Operating Systems, Fall

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

The memory of a program. Paging and Virtual Memory. Swapping. Paging. Physical to logical address mapping. Memory management: Review

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

Page Size Page Size Design Issues

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

Virtual Memory: Mechanisms. CS439: Principles of Computer Systems February 28, 2018

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

Chapter 9 Memory Management

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

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

CS307 Operating Systems Main Memory

Chapter 9: Memory Management. Background

Chapter 8: Main Memory

Module 8: Memory Management

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

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

Operating System Support

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

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

UNIT III MEMORY MANAGEMENT

CS370 Operating Systems

CS 550 Operating Systems Spring Memory Management: Paging

Chapter 8 Memory Management

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

Memory Management Virtual Memory

Chapter 8: Memory-Management Strategies

Chapter 8 Main Memory

Virtual Memory (VM) Ch 7.3

Memory Management. Today. Next Time. Basic memory management Swapping Kernel memory allocation. Virtual memory

Teemu s Cheesecake. Virtual Memory (VM) Ch 7.3. Other Problems Often Solved with VM (3) Virtual Memory Ch 7.3

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

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

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

MEMORY MANAGEMENT/1 CS 409, FALL 2013

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

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

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

Chapter 8: Memory- Management Strategies

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Week 2: Tiina Niklander

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

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

Chapter 8: Main Memory

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

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

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

Chapter 8: Main Memory

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

Module 8: Memory Management

Chapter 8: Main Memory

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Memory Management. Motivation

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

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

Logical versus Physical Address Space

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

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

Transcription:

Operating Systems: Memory management Fall 2008 Basic Memory Management: One program Monoprogramming without Swapping or Paging Tiina Niklander No memory abstraction, no address space, just an operating system with one user process 4 Memory Management Programmer wants memory to be Indefinitely large Indefinitely fast Non volatile Memory hierarchy Registers Cache Main memory Magnetic disk Magnetic tape small amount of fast, expensive memory cache some medium-speed, medium price main memory gigabytes of slow, cheap disk storage Memory manager handles the memory hierarchy Requirements for memory management Logical and physical organization Protection and sharing Multiprogramming with Fixed Partitions OS places one process in one partition Internal fragmentation (whole partition allocated to a smaller process) 2 5 Memory management Programs use logical addresses of their own address space (0..MAX) OS kernel usually in a fixed location using physical memory addresses directly Rest of the physical memory for user processes and other OS parts OS task: memory allocation and process relocation Hardware task: address translation (to protect memory) MMU memory management unit 3 Fixed partitions Process queue for partition on disk In shared queue for all partitions or In multiple queues for different sizes, No free partition, OS can swap Move one process to disk PCB always in memory Program too large for any partition; programmer has to design solution Overlaying: keep just part of the program in memory Write the program to control the part swapping between memory and disk 6 Lecture 3 1

Relocation and Protection Cannot be sure where program will be loaded in memory address locations of variables, code routines cannot be absolute must keep a program out of other processes partitions Use base and limit values address locations added to base value to map to physical addr address locations larger than limit value is an error Address translation by MMU 7 Swapping (2) (a) Allocating space for growing data segment (b) Allocating space for growing stack & data segment 10 Sharing Dynamic partitions Access to shared code / data No violation of the protections! Shared code must be reentrant, not to change during execution Just one copy of the shared code (e.g. library) Shared data Processes co-operate operate and share data structures E.g. shared buffer of producer and consumer Solution: system calls between processes, threads within a process (in virtual memory alt. solution) 8 No fixed predetermined partition sizes External fragments: : 6M + 6M + 4M = 14M OS must occasionally reorganize the memory (compaction) 11 Swapping (1) Memory Management: bookkeeping allocations and free areas Memory allocation changes as processes come into memory leave memory Shaded regions are unused memory 9 Part of memory with 5 processes, 3 holes tick marks show allocation units shaded regions are free (b) Corresponding bit map (c) Same information as a list 12 Lecture 3 2

Combining freed areas Four neighbor combinations for the terminating process X 13 Sta Fig 7.11 0000001111111111 0000010000000000 Paging OS: the program split to pages Page location stored in page table Process location Logical address always the same MMU translates logical address to physical address using page table Each page relocated separately 16 Allocation Where to place the new process? Goal: avoid external fragmentation and compaction Some alternatives: Best-fit First-fit Next-fit Worst-fit Sta Fig 7.5 Quick-fit 14 Paging Each process has own page table Contains the locations (frame numbers) of allocated frames Page table location stored in PCB, copied to PTR for execution OS maintains a table (or list) of page frames, to know which are unallocated 17 Virtual memory (using paging) Paging: Address Translation 15 MMU has one special register, Page Table Register (PTR), for address translation 18 Lecture 3 3

Paging: Address Translation Page Tables Internal operation of MMU with 16 4 KB pages Sta 8.3 19 22 Page table Translation Lookaside Buffer TLB 20 23 Page table Typical Page Table Entry, Fig. 3.11 TLB Translation Lookaside Buffer Each process has its own page table Each entry has a present bit, since not all pages need to be in the memory all the time -> page faults Remember the locality principle Logical address space can be much larger than the physical 21 Goal is to speed up paging TLB is a cache in MMU for page table entries 24 Lecture 3 4

TLB translation lookaside buffer Part of memory management unit (MMU) Cache for used page table entries to avoid extra memory access during address translation Associative search Compare with all elements at the same time (fast) Each TLB element contains: page number, page table entry, validity bit Each process uses the same page numbers 0, 1, 2,, stored on different page frames TLB must be cleared during process switch At least clear the validity bits (this is fast) 25 Sta Fig. 8.10 TLB and cache 28 Operation of Paging and TLB Multilevel and Inverted Page Tables Sta Fig 8.8. Fig. 5.47 from Hennessy-Patterson, Computer Architecture DEC Alpha AXP 21064 memory hierarchy Fully assoc, 12 entry instruction TLB 8 KB, direct mapped, 256 line (each 32B) instruction cache More? -> course Computer Organisation II 2 MB, 64K line (each 32B) direct mapped, unified, write-back L2 cache Fully assoc, 32 entry data TLB 8 KB, direct mapped, 256 line (each 32B) data cache main memory paging disk (dma) 27 Multilevel page table Large virtual address space Logical address could be 32- or 64-bits Each process has a large page table Using 32-bit address and frame size 4KB (12 bit offset), means 2 20 = 1M of page tables entries for a single process Each entry requires several bytes (lets say 4 bytes), so the final size of page table could be for example 4 MB Thus the page table is divided to several pages also and part of it can be on the disk Only the part of the page table that covers the pages used currently in the execution of the process is in memory 30 Lecture 3 5

Two-level hierarchical page table Top most level in one page and always in the memory Inverted Page Tables 1 K entries (= 1024 = 2 10 ) 1K * 1K = 1M entries Comparison of a traditional page table with an inverted page table 31 34 Address translation with two levels Virtual Address: PCB (Fig 4-12 [Tane01]) 32 FA Inverted page table Physical memory often smaller than the virtual address space of processes Invert booking: Store for each page frame what page (of which process) is stored there Only one global table (inverted page table), one entry for each page frame. Search for the page based on the content of the table Inefficient, if done sequentially, Use hash to calculate the location, start search from there If page not found, page fault Useful, only if TLB is large 35 Address translation with two levels Inverted page table Sta Fig 8.6 Frame number Index of the table Not stored in the entry j Sta Fig 8.5 33 36 Lecture 3 6