CS 153 Design of Operating Systems Spring 18

Similar documents
CS 153 Design of Operating Systems

CS153: Memory Management 1

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems Spring 18

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

CS 153 Design of Operating Systems

VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Spring 18

Virtual Memory I. Jo, Heeseung

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems Spring 18

Goals of memory management

Recap: Memory Management

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems Spring 18

CS153: Final Review1. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

Memory Management. Goals of Memory Management. Mechanism. Policies

(2, 4) Tree Example (2, 4) Tree: Insertion

CS 153 Design of Operating Systems Spring 18

Lecture 11: IPv6. CSE 123: Computer Networks Alex C. Snoeren. HW 2 due FRIDAY

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 550 Operating Systems Spring Memory Management: Paging

EXAMINATIONS 2010 END OF YEAR NWEN 242 COMPUTER ORGANIZATION

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Exceptions and interrupts

Lecture 8: Memory Management

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

EXAMINATIONS 2003 END-YEAR COMP 203. Computer Organisation

Review. A single-cycle MIPS processor

CSE 141 Computer Architecture Summer Session I, Lectures 10 Advanced Topics, Memory Hierarchy and Cache. Pramod V. Argade

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS153: Process. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

EEC 483 Computer Organization. Branch (Control) Hazards

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.

VirtuOS: an operating system with kernel virtualization

Tdb: A Source-level Debugger for Dynamically Translated Programs

Networks An introduction to microcomputer networking concepts

EECS 487: Interactive Computer Graphics f

What do we have so far? Multi-Cycle Datapath

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

EEC 483 Computer Organization

Lecture 10: Addressing

Requirements Engineering. Objectives. System requirements. Types of requirements. FAQS about requirements. Requirements problems

The single-cycle design from last time

The extra single-cycle adders

Multi-lingual Multi-media Information Retrieval System

Prof. Kozyrakis. 1. (10 points) Consider the following fragment of Java code:

CS399 New Beginnings. Jonathan Walpole

PART I: Adding Instructions to the Datapath. (2 nd Edition):

CSC 369 Operating Systems

Lecture 13: Exceptions and Interrupts

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

Review Multicycle: What is Happening. Controlling The Multicycle Design

Page Tables. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

MEMORY MANAGEMENT. Jo, Heeseung

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The multicycle datapath. Lecture 10 (Wed 10/15/2008) Finite-state machine for the control unit. Implementing the FSM

Memory Management. Jo, Heeseung

Isilon InsightIQ. Version 2.5. User Guide

Instruction fetch. MemRead. IRWrite ALUSrcB = 01. ALUOp = 00. PCWrite. PCSource = 00. ALUSrcB = 00. R-type completion

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

Introduction to Operating Systems

Computer Architecture. Lecture 8: Virtual Memory

Memory Management - Demand Paging and Multi-level Page Tables

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

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

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Lecture 7. Building A Simple Processor

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

The Disciplined Flood Protocol in Sensor Networks

Picking and Curves Week 6

Virtual Memory. 11/8/16 (election day) Vote!

A sufficient condition for spiral cone beam long object imaging via backprojection

Principles of Operating Systems

The final datapath. M u x. Add. 4 Add. Shift left 2. PCSrc. RegWrite. MemToR. MemWrite. Read data 1 I [25-21] Instruction. Read. register 1 Read.

Winter 2013 MIDTERM TEST #2 Wednesday, March 20 7:00pm to 8:15pm. Please do not write your U of C ID number on this cover page.

This chapter is based on the following sources, which are all recommended reading:

Introduction to Windows Server Copyright 2018 NY SYSTEMS INC.

4.13 Advanced Topic: An Introduction to Digital Design Using a Hardware Design Language 345.e1

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

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

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

memory management Vaibhav Bajpai

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

MVM-BVRM Video Recording Manager v2.21

UNIT III MEMORY MANAGEMENT

Pipelining. Chapter 4

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

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Transcription:

CS 153 Design of Operating Systems Spring 18 Lectre 15: Virtal Address Space Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian

OS Abstractions Applications Process File system Virtal memory Operating System CPU Hardware Disk RAM CS 153 Lectre 15 Virtal Address Space 2

Need for Virtal Memory Rewind to the days of second-generation compters Programs se physical addresses directly OS loads job, rns it, nloads it Mltiprogramming changes all of this Want mltiple processes in memory at once» Overlap I/O and CPU of mltiple jobs How to share physical memory across mltiple processes?» Many programs do not need all of their code and data at once (or ever) no need to allocate memory for it» A program can rn on machine with less memory than it needs CS 153 Lectre 15 Virtal Address Space 3

Virtal Addresses To make it easier to manage the memory of processes rnning in the system, we re going to make them se virtal addresses (logical addresses) Virtal addresses are independent of the actal physical location of the data referenced OS determines location of data in physical memory Instrctions exected by the CPU isse virtal addresses Virtal addresses are translated by hardware into physical addresses (with help from OS) The set of virtal addresses that can be sed by a process comprises its virtal address space CS 153 Lectre 15 Virtal Address Space 4

Virtal Addresses virtal addresses physical addresses processor vmap physical memory Many ways to do this translation Need hardware spport and OS management algorithms Reqirements Need protection restrict which addresses jobs can se Fast translation lookps need to be fast Fast change pdating memory hardware on context switch CS 153 Lectre 15 Virtal Address Space 5

Fixed Partitions Physical memory is broken p into fixed partitions Size of each partition is the same and fixed Hardware reqirements: base register Physical address = virtal address + base register Base register loaded by OS when it switches to a process Physical Memory P1 P2 P3 P4 P5 CS 153 Lectre 15 Virtal Address Space 6

Fixed Partitions Physical Memory Base Register P4 s Base P1 P2 Virtal Address Offset + P3 P4 How do we provide protection? P5 CS 153 Lectre 15 Virtal Address Space 7

Fixed Partitions Advantages Easy to implement» Need base register» Verify that offset is less than fixed partition size Fast context switch Problems? Internal fragmentation: memory in a partition not sed by a process is not available to other processes Partition size: one size does not fit all (very large processes?) CS 153 Lectre 15 Virtal Address Space 8

Variable Partitions Natral extension physical memory is broken p into variable sized partitions Hardware reqirements: base register and limit register Physical address = virtal address + base register Why do we need the limit register? Protection: if (virtal address > limit) then falt CS 153 Lectre 15 Virtal Address Space 9

Variable Partitions Base Register P3 s Base Limit Register P3 s Limit P1 P2 Virtal Address Offset < Yes? + P3 No? Protection Falt CS 153 Lectre 15 Virtal Address Space 10

Variable Partitions Advantages No internal fragmentation: allocate jst enogh for process Problems? External fragmentation: job loading and nloading prodces empty holes scattered throghot memory P1 P2 P3 P4 CS 153 Lectre 15 Virtal Address Space 11

Segmentation Segmentation: partition memory into logically related nits Modle, procedre, stack, data, file, etc. Units of memory from ser s perspective Natral extension of variable-sized partitions Variable-sized partitions = 1 segment/process Segmentation = many segments/process Fixed partition : Paging :: Variable partition : Segmentation Hardware spport Mltiple base/limit pairs, one per segment (segment table) Segments named by #, sed to index into table Virtal addresses become <segment #, offset> CS 153 Lectre 15 Virtal Address Space 12

Segment Lookps Segment Table Physical Memory limit base Segment # Offset Virtal Address < Yes? + No? Protection Falt CS 153 Lectre 15 Virtal Address Space 13

Paging New Idea: split virtal address space into mltiple partitions Each can go anywhere! Virtal Memory Page 1 Page 2 Page 3 Physical Memory Page N Paging solves the external fragmentation problem by sing fixed sized nits in both physical and virtal memory CS 153 Lectre 15 Virtal Address Space Bt need to keep track of where things are! 14

Process Perspective Processes view memory as one contigos address space from 0 throgh N Virtal address space (VAS) In reality, pages are scattered throghot physical storage The mapping is invisible to the program Protection is provided becase a program cannot reference memory otside of its VAS The address 0x1000 maps to different physical addresses in different processes CS 153 Lectre 15 Virtal Address Space 15

Paging Translating addresses Virtal address has two parts: virtal page nmber and offset Virtal page nmber (VPN) is an index into a page table Page table determines page frame nmber (PFN) Physical address is PFN::offset Page tables Map virtal page nmber (VPN) to page frame nmber (PFN)» VPN is the index into the table that determines PFN One page table entry (PTE) per page in virtal address space» Or, one PTE per VPN CS 153 Lectre 15 Virtal Address Space 16

Page Lookps Physical Memory Virtal Address Page nmber Offset Page Table Physical Address Page frame Offset Page frame CS 153 Lectre 15 Virtal Address Space 17

Paging Example Pages are 4KB Offset is 12 bits (becase 4KB = 2 12 bytes) VPN is 20 bits (32 bits is the length of every virtal address) Virtal address is 0x7468 Virtal page is 0x7, offset is 0x468 Page table entry 0x7 contains 0x2000 Page frame nmber is 0x2000 Seventh virtal page is at address 0x2000 (2nd physical page) Physical address = 0x2000 + 0x468 = 0x2468 CS 153 Lectre 15 Virtal Address Space 18

Page Table Entries (PTEs) 1 1 1 2 20 M R V Prot Page Frame Nmber Page table entries control mapping The Modify bit says whether or not the page has been written» It is set when a write to the page occrs The Reference bit says whether the page has been accessed» It is set when a read or write to the page occrs The Valid bit says whether or not the PTE can be sed» It is checked each time the virtal address is sed (Why?) The Protection bits say what operations are allowed on page» Read, write, execte (Why do we need these?) The page frame nmber (PFN) determines physical page CS 153 Lectre 15 Virtal Address Space 19

Paging Advantages Easy to allocate memory Memory comes from a free list of fixed size chnks Allocating a page is jst removing it from the list External fragmentation not a problem» All pages of the same size Simplifies protection All chnks are the same size Like fixed partitions, don t need a limit register Simplifies virtal memory later CS 153 Lectre 15 Virtal Address Space 20

Paging Limitations Can still have internal fragmentation Process may not se memory in mltiples of a page Memory reference overhead 2 references per address lookp (page table, then memory) What can we do? Memory reqired to hold page table can be significant Need one PTE per page 32 bit address space w/ 4KB pages = 2 20 PTEs 4 bytes/pte = 4MB/page table 25 processes = 100MB jst for page tables! What can we do? CS 153 Lectre 15 Virtal Address Space 21

Paging Qestion Can we serve a process asking for more memory than we physically have? Virtal Memory of Process 1 Page 1 Physical Memory Page 2 Page 3 Page N CS 153 Lectre 15 Virtal Address Space 22

Segmentation and Paging Can combine segmentation and paging The x86 spports segments and paging Use segments to manage logically related nits Modle, procedre, stack, file, data, etc. Segments vary in size, bt sally large (mltiple pages) Use pages to partition segments into fixed size chnks Makes segments easier to manage within physical memory» Segments become pageable rather than moving segments into and ot of memory, jst move page portions of segment Need to allocate page table entries only for those pieces of the segments that have themselves been allocated Tends to be complex CS 153 Lectre 15 Virtal Address Space 23

Smmary Virtal address space Developers se virtal address Processes se virtal address OS + hardware translate VA into PA Varios techniqes Fixed partitions Variable partitions Segmentation Paging CS 153 Lectre 15 Virtal Address Space 24

Next class More on Paging Preparation Read Modle 18 and 19 CS 153 Lectre 15 Virtal Address Space 25