Memory Management: Main Memory

Similar documents
Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

OPERATING SYSTEMS MEMORY MANAGEMENT

OPERATING SYSTEM - MEMORY MANAGEMENT

Chapter 7 Memory Management

Lecture 17: Virtual Memory II. Goals of virtual memory

W4118: segmentation and paging. Instructor: Junfeng Yang

CS 61C: Great Ideas in Computer Architecture Virtual Memory Cont.

Chapter 7 Memory Management

COS 318: Operating Systems. Virtual Memory and Address Translation

Virtual Memory. Virtual Memory. Paging. CSE 380 Computer Operating Systems. Paging (1)

Virtual vs Physical Addresses

Operating Systems, 6 th ed. Test Bank Chapter 7

Chapter 12. Paging an Virtual Memory Systems

Full and Para Virtualization

Operating System Overview. Otto J. Anshus

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

Computer Architecture

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

The Reduced Address Space (RAS) for Application Memory Authentication

Introduction to Virtual Machines

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Board Notes on Virtual Memory

Instruction Set Architecture (ISA)

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University


1 File Management. 1.1 Naming. COMP 242 Class Notes Section 6: File Management

Republic Polytechnic School of Information and Communications Technology C226 Operating System Concepts. Module Curriculum

I/O. Input/Output. Types of devices. Interface. Computer hardware

W4118 Operating Systems. Instructor: Junfeng Yang

System Virtual Machines

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

An Overview of Virtual Machine Architectures

Addendum Intel Architecture Software Developer s Manual

An Implementation Of Multiprocessor Linux

A Unified View of Virtual Machines

Uses for Virtual Machines. Virtual Machines. There are several uses for virtual machines:

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Chapter 10: Virtual Memory. Lesson 03: Page tables and address translation process using page tables

Virtual Machines. COMP 3361: Operating Systems I Winter

CS5460: Operating Systems

Virtual Memory. How is it possible for each process to have contiguous addresses and so many of them? A System Using Virtual Addressing

Virtualization. Dr. Yingwu Zhu

Two Parts. Filesystem Interface. Filesystem design. Interface the user sees. Implementing the interface

Part III Storage Management. Chapter 11: File System Implementation

Cloud Computing. Dipl.-Wirt.-Inform. Robert Neumann

CS 695 Topics in Virtualization and Cloud Computing. More Introduction + Processor Virtualization

How To Write A Page Table

Memory management. Chapter 4: Memory Management. Memory hierarchy. In an ideal world. Basic memory management. Fixed partitions: multiple programs

Computer Systems Structure Input/Output

Operating System Tutorial

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Virtualization. Explain how today s virtualization movement is actually a reinvention

A3 Computer Architecture

Memory Management CS 217. Two programs can t control all of memory simultaneously

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

@ )nventor; Radin Qeorge 26 Franklin Piermont New York 10968{US)

Operating Systems Overview

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

Virtualization. Pradipta De

Segmentation Segmentation: Generalized Base/Bounds

SAP HANA - Main Memory Technology: A Challenge for Development of Business Applications. Jürgen Primsch, SAP AG July 2011

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Paging: Introduction A Simple Example And Overview

Operating Systems. Virtual Memory

On Demand Loading of Code in MMUless Embedded System

18-548/ Associativity 9/16/98. 7 Associativity / Memory System Architecture Philip Koopman September 16, 1998

In-Memory Databases Algorithms and Data Structures on Modern Hardware. Martin Faust David Schwalb Jens Krüger Jürgen Müller

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

We r e going to play Final (exam) Jeopardy! "Answers:" "Questions:" - 1 -

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

Introduction to RISC Processor. ni logic Pvt. Ltd., Pune

OPERATING SYSTEM - VIRTUAL MEMORY

VxWorks Guest OS Programmer's Guide for Hypervisor 1.1, 6.8. VxWorks GUEST OS PROGRAMMER'S GUIDE FOR HYPERVISOR

Chapter 5 Cloud Resource Virtualization

Effective Java Programming. efficient software development

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Computer Engineering and Systems Group Electrical and Computer Engineering SCMFS: A File System for Storage Class Memory

COS 318: Operating Systems. File Layout and Directories. Topics. File System Components. Steps to Open A File

Design Cycle for Microprocessors

Hardware Assisted Virtualization

Understanding Full Virtualization, Paravirtualization, and Hardware Assist. Introduction...1 Overview of x86 Virtualization...2 CPU Virtualization...

Chapter 2: Computer-System Structures. Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General System Architecture

COS 318: Operating Systems. Virtual Machine Monitors

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

The Classical Architecture. Storage 1 / 36

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Amoeba Distributed Operating System

VIRTUAL MEMORY IN CONTEMPORARY MICROPROCESSORS

hp ProLiant network adapter teaming

Chapter 11: File System Implementation. Operating System Concepts with Java 8 th Edition

Introduction to Virtual Machines

4.1 PAGING MODES AND CONTROL BITS

Virtual Machines. Virtualization

LSN 2 Computer Processors

Chapter 2: OS Overview

Chapter 11 I/O Management and Disk Scheduling

Computer Organization and Architecture

Transcription:

Memory Management: Main Memory It s all about bookkeeping The von Neumann model: fetch instructions from memory; decode instructions; possibly read or write data to or from memory; rinse and repeat In this model, we abstract memory completely as a linear, addressed array the reality is more complex Common hardware elements: memory hierarchy (register/cache/main memory); hardware protection through base and limit registers Address Binding When does a memory address in code become truly an address in physical memory? As in programming languages and compiler construction, binding refers to when a decision is made about a particular entity in this case, memory Compile-time binding sets an absolute address in code Load-time binding sets addresses once, on load code is therefore said to be relocatable Execution-time binding determines an address as instructions are executed needs hardware support

Logical vs. Physical Addresses To facilitate execution-time binding, we must differentiate between addresses generated by the CPU (the logical or virtual address) from the actual address that gets accessed (the physical address) Current systems do this in hardware; that is, this mapping is not performed by the CPU but by a separate memory management unit (MMU) User code never sees the physical address the process is completely transparent Loading, Linking, and Sharing Additional wrinkles before going deeper into main memory management: Programs seldom need all of their code in memory all the time, so dynamic loading is useful only load code into memory as you need it Reusable code (e.g., system libraries) should not have to exist in every program (static linking); dynamic linking enables one in-memory copy for multiple processes Shared libraries extend dynamic linking to allow multiple versions of the same library to co-exist

Memory Allocation Basics As with most operating system techniques, memory allocation started simple and grew in sophistication: Since multiprogramming really only runs a single process at a time, swapping has been used to keep processes in a backing store outside main memory Contiguous memory allocation devotes entire partitions of memory to processes; start with just the OS at the bottom at the stack at the top, with a large hole in the middle, then divide that hole among processes using some algorithm (e.g., first fit, best fit, worst fit) Fragmentation A key issue with contiguous memory allocation that remains relevant today is fragmentation essentially, wasted memory (allocated but unused) When there is enough total available memory but no single hole is large enough for a pending request, we have external fragmentation Since it is impractical to allocate partitions down tothe-byte, we usually have a larger minimum allocation unit (or block) when not all of that block is used by a process, we have internal fragmentation

Paging Paging is one of two complementary memory management techniques that are widely used in current systems (the other is segmentation, which we will discuss next) The main trick in paging: add a level of indirection between logical and physical addresses so that a process s address space is (transparently) no longer physically contiguous Logical memory is divided into pages, and physical memory is divided into frames of the same size Logical addresses are now partitioned into a page number (or p for page ) and a page offset (or d for delta or displacement ) since we re talking bits, it should be easy to see that page/frame sizes are powers of 2, and for an m-bit logical address space, a page size of 2 n results in 2 m n possible pages Every process gets a page table that maps a logical page to a physical frame whenever the CPU uses a logical address, the page value of that address is converted into the corresponding frame value, as indicated by the page table; this is the final, physical address Behind the scenes, the OS tracks which frame corresponds to which page of which process, using a frame table data structure

Hardware Support for Paging Page-to-frame translation is done in hardware it is part of a new CPU or architecture s specifications For small page tables, hardware used to provide a dedicated set of registers With today s huge memory spaces, the page tables themselves stay in main memory, with a page table base register (PTBR) pointing to it But main memory is slow, so we add a translation lookaside buffer (TLB) essentially a page table cache Page Protection and Sharing Paging can be used beyond just page-to-frame mapping to provide additional memory management features Memory protection: One or more bits can indicate readonly, read-write, or execute-only pages; another validinvalid bit can indicate whether or not a page may be accessed by a process at all Shared pages: Shared libraries can be implemented via paging by letting multiple page tables point to the same frames the ones with reentrant or pure code, such as what we would find in system libraries

Page Table Implementation: Hierarchical Paging Today s large address spaces 32 going on 64 bits and more make a single-level page table impractical: either too many entries or pages that are too large (resulting in lots of internal fragmentation) Hierarchical paging pages the pages page table becomes a tree of page entries, resulting in multiple levels of indirection 2-level paging is sensible for 32-bit spaces (e.g., 10/10/12 results in 1024-entry tables with 4K pages); we need more for 64-bit Hashed, Clustered, and Inverted Page Tables An alternative to a hierarchical page table is a hashed page table a standard hash table based on the page number, leading to a linked list of page table entries (for all pages that hash to the same value) Another alternative is a clustered page table, where a single hash table entry actually consists of multiple page-to-frame mappings Finally, we have an inverted page table instead of having one page table per process, we just keep one overall table, storing the process that has each frame

Segmentation Complementary to paging, segmentation divides a process s address space by function or role, such as the stack, certain libraries, static variables, etc. Instead of a single linear array, a logical address space is now a collection of named segments; an individual address is now a tuple instead of a single value Translation to a physical address (which, of course, is still a linear space) is accomplished through a segment table: for each segment, the table stores a segment base address and a segment [size] limit The segment component of the logical address indicates the entry in the segment table, with the second component being the displacement (or offset, or delta) of the address within that segment Thus, the final physical address is segment base + displacement, with displacement < segment limit being required or else we get an addressing error trap Note how segmentation and paging can be combined for example, in the Intel Pentium family, logical addresses use segmentation, but the linear addresses that they generate can be subsequently viewed as page + displacement addresses, to be converted one more time into the final physical address

Main Memory Examples Intel Pentium D (IA-32) Up to 16K segments per program of up to 4G in size, with 6 segment registers available (1 code, 1 stack, 4 data) Paging may be enabled, with page sizes of 4K, 2M, or 4M, with separate TLBs for instructions and data In 64-bit mode, segmentation is disabled, and the address space is completely flat/linear IBM PowerPC 970fx (a.k.a. G5 ) Natively 64-bit processor, with 32-bit compatibility Code can access a full 64-bit address space, which the MMU maps to a 42-bit physical address space Segmentation is optimized with a segment lookaside buffer (SLB) Page sizes of 4K or 16M with a unified TLB (combined instructions and data)