CS5460: Operating Systems



Similar documents
COS 318: Operating Systems. Virtual Memory and Address Translation

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

W4118: segmentation and paging. Instructor: Junfeng Yang

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

OPERATING SYSTEM - MEMORY MANAGEMENT

Virtual vs Physical Addresses

Chapter 7 Memory Management

Operating System Overview. Otto J. Anshus

How To Write A Page Table

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

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

Lecture 17: Virtual Memory II. Goals of virtual memory

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

Memories Are Made of This

Intel P6 Systemprogrammering 2007 Föreläsning 5 P6/Linux Memory System

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

W4118 Operating Systems. Instructor: Junfeng Yang

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Cloud Computing. Up until now

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

Segmentation Segmentation: Generalized Base/Bounds

Xen and the Art of. Virtualization. Ian Pratt

Introduction to Virtual Machines

Segmentation and Fragmentation

Outline: Operating Systems

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

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Chapter 7 Memory Management

OPERATING SYSTEMS MEMORY MANAGEMENT

Chapter 6, The Operating System Machine Level

Virtualization. Pradipta De

Virtual machines and operating systems

Types Of Operating Systems

ELEC 377. Operating Systems. Week 1 Class 3

Virtualization in Linux KVM + QEMU

COS 318: Operating Systems

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Lecture 25 Symbian OS

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

Multi-core Programming System Overview

Full and Para Virtualization

Tools Page 1 of 13 ON PROGRAM TRANSLATION. A priori, we have two translation mechanisms available:

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Operating Systems, 6 th ed. Test Bank Chapter 7

Paging: Introduction A Simple Example And Overview

Computer Architecture

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

Virtualization in the ARMv7 Architecture Lecture for the Embedded Systems Course CSD, University of Crete (May 20, 2014)

This Unit: Virtual Memory. CIS 501 Computer Architecture. Readings. A Computer System: Hardware

IOMMU: A Detailed view

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

1 The Java Virtual Machine

Eugene Tsyrklevich. Ozone HIPS: Unbreakable Windows

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Programming Embedded Systems

CS550. Distributed Operating Systems (Advanced Operating Systems) Instructor: Xian-He Sun

umps software development

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

x86 ISA Modifications to support Virtual Machines

CS5460: Operating Systems. Lecture: Virtualization 2. Anton Burtsev March, 2013

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Virtualization for Cloud Computing

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Chapter 12. Paging an Virtual Memory Systems

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

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 3. Operating Systems N/H/MWF@12

OPERATING SYSTEM - VIRTUAL MEMORY

Outline. Outline. Why virtualization? Why not virtualize? Today s data center. Cloud computing. Virtual resource pool

Knut Omang Ifi/Oracle 19 Oct, 2015

Java Garbage Collection Best Practices for Sizing and Tuning the Java Heap

CHAPTER 17: File Management

3 - Introduction to Operating Systems

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

WHITE PAPER Optimizing Virtual Platform Disk Performance

OS Concepts and structure

How To Develop A Powerpc/Powerpc/Ada 95/C++/Adma 83/C/C95/A95/C99/A83/A84/A85/A86/A75/A74

Virtualization. Dr. Yingwu Zhu

picojava TM : A Hardware Implementation of the Java Virtual Machine

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

Exploiting Transparent Remote Memory Access for Non-Contiguous- and One-Sided-Communication

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

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

Virtualization. Clothing the Wolf in Wool. Wednesday, April 17, 13

Secure Containers. Jan Imagination Technologies HGI Dec, 2014 p1

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

File-System Implementation

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

Chapter 5 Cloud Resource Virtualization

Memory Usage Performance Guidelines

Chapter 3 Operating-System Structures

Instruction Set Design

Transcription:

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

Where are we? Basic OS structure, HW/SW interface, interrupts, scheduling Concurrency Memory management Storage management Other topics

Example Virtual Address Space Typical address space has 4 parts : binary image of program Data: static variables (globals) : explicitly allocated data (malloc) : implicitly allocated data Kernel mapped into all processes MMU hardware: Remaps virtual addresses to physical Supports read-only, supervisor-only Detects accesses to unmapped regions How can we load two processes into memory at same time? Assume each has similar layout 0xFFFFFFFF SP HP Kernel User PC 0x80000000 User stack segment User heap User data segment User code segment Kernel heap Kernel data segment Kernel code segment 0x00000000

Mapping Addresses How can process (virtual) addresses be mapped to physical addresses? Compile time: Compiler generates physical addresses directly» Advantages: No MMU hardware, no runtime translation overhead» Disadvantages: Inflexible, hard to multiprogram, inefficient use of DRAM Load time: OS loader fixes addresses when it loads program» Advantages: Can support static multiprogramming» Disadvantages: MMU hardware, inflexible, hard to share data, Dynamic: Compiler generates address, but OS/HW reinterpret» Advantages: Very flexible, can use memory efficiently» Disadvantages: MMU hardware req d, runtime translation overhead For real OSes, processes only use virtual addresses Small-sized embedded systems use physical addresses

Uniprogramming (e.g., DOS) One process at a time User code compiled to sit in fixed range (e.g., [0,640 KB]) No hardware virtualization of addresses OS in separate addresses E.g., above 640KB Goals: Safety: None (good and bad) Efficiency: Poor (I/O and compute not overlapped, response time) 0xFFFFFFFF 0xA0000 SP HP PC 0x00000000 Reserved for DOS kernel (Dynamically allocated) Uninitialized data (BSS segment) Static data (Data segment) (Text segment)

Multiprogramming: Static Relocation OS loader relocates programs OS stored in reserved high region Compiler maps process starting at 0 When process started, OS loader:» Allocates contiguous physical memory» Uses relocation info in binary to fix up addresses to relocated region TSRs in DOS based on this technique Problems: Finding/creating contiguous holes Dealing with processes that grow/shrink Goals: Safety: None! à process can destroy other processes Efficiency: Poor à only one segment per process; slow load times; no sharing 0xFFFFFFFF SP 1 HP 1 PC 1 SP 0 HP 0 PC 0 0x00000000 Reserved for OS kernel Data Data

Idea: Dynamic Relocation Programs all laid out the same Relocate addresses when used Requires hardware support Two views of memory: Virtual: Process s view Physical: Machine s view Many variants Base and bounds Segmentation Paging Segmented paging Virtual Addresses 0xFFFFFFFF SP 0 HP 0 PC 0 0x00000000 0xFFFFFFFF SP 1 HP 1 PC 1 Data OS kernel Data OS kernel Physical Addresses Data Data OS kernel 0x00000000

Base and Bounds Each process mapped to contiguous physical region Two hardware registers Base: Starting physical address Bounds: Size in bytes On each reference: Check against bounds Add base to get physical address Evaluation: Good points: Bad points: OS handled specially Example: Cray-1 Virtual address P 1 VAs P 0 VAs Virtual Physical address 0x00000 0x7ffff 0x00000 0x7ffff 0x00000 Trap >? + OS kernel Data Data Bounds register Base register Physical 0xFFFFFFFF Bounds 1 Base 1 Bounds 0 Base 0 0x00000000

Base and Bounds Each process has private address space No relocation done at load time Operating system handled specially Runs with relocation turned off (i.e., ignores Base and Bounds) Only OS can modify Base and Bounds registers Good points: Very simple hardware Bad points: Only one contiguous segment per process à inhibits sharing External fragmentation à need to find or make holes Hard to grow segments

Segmentation Idea: Create N separate segments Each segment has separate base and bounds register Segment number is fixed portion of virtual address Seg# Offset >? Error! (Trap) Base Base Base Bounds Bounds Bounds + Physical address Base Base Bounds Bounds

Segmentation Example Virtual address space is 2000 bytes in size 4 segments up to 500 bytes each Starting at 0, 500, 1000, 1500 What if processor accesses VA 0 VA 1040 VA 1900 VA 920 VA 1898 What if we allocate: 100-byte segment 200-byte segment Base Bounds 0 1000 400 1 0 500 2 600 300 3 1500 400 Segment Table Virtual Address Physical Address 2000 Seg3 Seg2 Seg3 Seg0 1000 Seg1 Seg2 Seg0 Seg1 0

Good features: Segmentation Discussion More flexible than base and bounds à enables sharing (How?) Reduces severity of fragmentation (How?) Small hardware table (e.g., 8 segments) à can fit all in processor Problems: Still have fragmentation à How? What kind? Hard to grow segments à Why? Non-contiguous virtual address space à Real problem? Possible solutions: Fragmentation: Copy and compact Growing segments: Copy and compact Paging

Paging Problem w/ segmentation à variable-sized segments Solution à Paging! Insist that all chunks be the same size (typically 512-8K bytes) Call them pages rather than segments Allocation is done in terms of full page-aligned pages à no bounds MMU maps virtual page numbers to physical page numbers Virtual Page# Offset Wired concatenate Physical Page# Physical Page# Other Other Physical Page# Offset Physical address Physical Page# Physical Page# Other Other What other info?

How does this help? Paging Discussion No external fragmentation! No forced holes in virtual address space Easy translation à everything aligned on power-of-2 addresses Easy for OS to manage/allocate free memory pool What problems are introduced? What if you do not need entire page? Internal fragmentation Page table may be large» Where should we put it? How can we do fast translation if not stored in processor? How big should you make your pages?» Large: Smaller table, demand paging more efficient» Small: Less fragmentation, finer grained sharing, larger page table

Paging Examples Page Table Assume 1000-byte pages What if processor accesses: VA 0 VA 1040 VA 2900 VA 920 VA 4998 0 1 2 3 4 PPN Valid R/O Super 3 Y N Y 8 N N N 5 Y Y N 7 Y N N 1 N Y Y Virtual Address Physical Address VP1 VP3 VP4 VP3 VP2 VP1 VP0 VP2 VP0 VP4 Free List

x86 Paging x86 typically uses 4 KB pages Virtual addresses are 32 bits How big is the offset field of a virtual address? How big is the virtual page number field? How many pages are in a virtual address space? How big is a flat page table? Assume PTE (page table entry) is 32 bits

Key Idea From Today Address space virtualization Programs see virtual addresses Kernel can see both virtual and physical addresses Virtual and physical address spaces need not be the same size You must understand this to understand modern operating systems Kernel + HW supports the virtual to physical mapping Has to be fast There are different ways to do it Modern OSes use paging