CS3600 SYSTEMS AND NETWORKS

Similar documents
Main Memory (Part II)

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

CS307: Operating Systems

CS307 Operating Systems Main Memory

CS370 Operating Systems

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

Chapter 8: Memory-Management Strategies

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

Chapter 8: Memory- Management Strategies

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

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

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

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

Chapter 8: Main Memory

Goals of Memory Management

Chapter 8: Main Memory

Main Memory (II) Operating Systems. Autumn CS4023

Memory Management. Memory Management

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

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

Chapter 8: Main Memory

Chapter 9: Memory Management. Background

Chapter 8: Memory Management

Chapter 8: Main Memory

Chapter 8 Main Memory

Chapter 8: Memory Management Strategies

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

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

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

Lecture 8 Memory Management Strategies (chapter 8)

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

Principles of Operating Systems

Chapter 8 Memory Management

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

Module 8: Memory Management

CS 3733 Operating Systems:

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

CS420: Operating Systems. Paging and Page Tables

Memory Management. Memory

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

Module 8: Memory Management

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

Logical versus Physical Address Space

Page Table Structure. Hierarchical Paging. Hashed Page Tables. Inverted Page Tables

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

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

Memory Management (2)

SHANDONG UNIVERSITY 1

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

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

P r a t t hr h ee e : e M e M m e o m r o y y M a M n a a n g a e g m e e m n e t 8.1/72

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

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

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

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

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Memory Management. Dr. Yingwu Zhu

Memory Management. Dr. Yingwu Zhu

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

Memory Management. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

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

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

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

Chapter 9 Memory Management

Background. Contiguous Memory Allocation

Paging & Segmentation

csci 3411: Operating Systems

Introduction to Operating Systems

Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

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

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

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

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

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

Basic Memory Management

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

CS370 Operating Systems

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

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

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

Virtual to physical address translation

CIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018

Fall 2015 COMP Operating Systems. Lab 06

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

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Memory Management and Protection

Virtual Memory. Today. Handling bigger address spaces Speeding translation

Lecture 21. Monday, February 28 CS 470 Operating Systems - Lecture 21 1

COSC Operating Systems Design, Fall 2001, Byunggu Yu. Chapter 9 Memory Management (Lecture Note #8) 1. Background

VII. Memory Management

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

UNIT-III VIRTUAL MEMORY

Virtual Memory 2. Today. Handling bigger address spaces Speeding translation

Hardware Address Binding Memory Allocation References. Physical Memory. Daniel Bosk 1

Virtual Memory 2. To do. q Handling bigger address spaces q Speeding translation

Operating System 1 (ECS-501)

Transcription:

CS3600 SYSTEMS AND NETWORKS SPRING 2013 Lecture 13: Paging Prof. Alan Mislove (amislove@ccs.neu.edu)

Paging Physical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available Divide physical memory into fixed-sized blocks called frames Size is power of 2, between 512 bytes and 16 Mbytes Keep track of all free frames Divide logical memory into blocks of same size called pages To run a program of size N pages, need to find N free frames and load program Set up a page table to translate logical to physical addresses Backing store likewise split into pages 2

Address Translation Scheme Address generated by CPU is divided into: Page number (p) used as an index into a page table which contains base address of each page in physical memory Page offset (d) combined with base address to define the physical memory address that is sent to the memory unit page number p m - n page offset d n For given logical address space 2 m and page size 2 n 3

Paging Hardware 4

Paging Model of Logical and Physical Memory 5

Paging Example n=2 and m=4 32-byte memory and 4-byte pages 6

Paging (Cont.) What is the internal fragmentation of paging? Page size = 2,048 bytes Process size = 72,766 bytes 35 pages + 1,086 bytes Internal fragmentation of 2,048-1,086 = 962 bytes Worst case fragmentation = 1 frame 1 byte Average fragmentation = 1 / 2 frame size So small frame sizes desirable? But each page table entry takes memory to track Page sizes growing over time Solaris supports two page sizes 8 KB and 4 MB Process view and physical memory now very different By implementation process can only access its own memory 7

Free Frames Before allocation After allocation 8

Implementation of Page Table Page table is kept in main memory Page-table base register (PTBR) points to the page table Page-table length register (PTLR) indicates size of the page table In this scheme every data/instruction access requires two memory accesses One for the page table and one for the data / instruction The two memory access problem can be solved by the use of a special fastlookup hardware cache called associative memory or translation lookaside buffers (TLBs) Some TLBs store address-space identifiers (ASIDs) in each TLB entry uniquely identifies each process to provide address-space protection for that process Otherwise need to flush at every context switch TLBs typically small (64 to 1,024 entries) On a TLB miss, value is loaded into the TLB for faster access next time Replacement policies must be considered Some entries can be wired down for permanent access 9

Associative Memory Associative memory parallel search Page # Frame # Address translation (p, d) If p is in associative register, get frame # out Otherwise get frame # from page table in memory 10

Paging Hardware With TLB 11

Associative Lookup = ε time unit Effective Access Time Can be < 10% of memory access time Hit ratio = α Hit ratio percentage of times that a page number is found in the associative registers; ratio related to number of associative registers Effective Access Time (EAT) (expr in terms of memory access time) EAT = (1 + ε) α + (2 + ε)(1 α) = 2 + ε α Consider α = 80%, ε = 20ns for TLB search, 100ns for memory access EAT = 0.80 x 120 + 0.20 x 220 = 140ns Consider slower memory but better hit ratio -> α = 98%, ε = 20ns for TLB search, 140ns for memory access EAT = 0.98 x 160 + 0.02 x 300 = 162.8ns 12

Memory Protection Memory protection implemented by associating protection bit with each frame to indicate if read-only or read-write access is allowed Can also add more bits to indicate page execute-only, and so on Valid-invalid bit attached to each entry in the page table: valid indicates that the associated page is in the process logical address space, and is thus a legal page invalid indicates that the page is not in the process logical address space Or use PTLR Any violations result in a trap to the kernel 13

Valid (v) or Invalid (i) Bit In A Page Table 14

Shared Pages Shared code One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems) Similar to multiple threads sharing the same process space Also useful for interprocess communication if sharing of readwrite pages is allowed Private code and data Each process keeps a separate copy of the code and data The pages for the private code and data can appear anywhere in the logical address space 15

Shared Pages Example 16

Structure of the Page Table Memory structures for paging can get huge using straightforward methods Consider a 32-bit logical address space as on modern computers Page size of 4 KB (2 12 ) Page table would have 1 million entries (2 32 / 2 12) If each entry is 4 bytes -> 4 MB of physical address space / memory for page table alone That amount of memory used to cost a lot Don t want to allocate that contiguously in main memory Hierarchical Paging Hashed Page Tables Inverted Page Tables 17

Hierarchical Page Tables Break up the logical address space into multiple page tables A simple technique is a two-level page table We then page the page table 18

Two-Level Page-Table Scheme 19

Two-Level Paging Example A logical address (on 32-bit machine with 1K page size) is divided into: a page number consisting of 22 bits a page offset consisting of 10 bits Since the page table is paged, the page number is further divided into: a 12-bit page number a 10-bit page offset Thus, a logical address is as follows: page number page offset p 1 p 2 d 12 10 10 20

Address-Translation Scheme 21

64-bit Logical Address Space Even two-level paging scheme not sufficient If page size is 4 KB (2 12 ) Then page table has 2 52 entries If two level scheme, inner page tables could be 2 10 4-byte entries outer page inner page page offset p 1 p 2 d 42 10 12 Outer page table has 2 42 entries or 2 44 bytes One solution is to add a 2 nd outer page table But in the following example the 2 nd outer page table is still 2 34 bytes in size And possibly 4 memory access to get to one physical memory location 22

Three-level Paging Scheme 23

Hashed Page Tables Common in address spaces > 32 bits The virtual page number is hashed into a page table This page table contains a chain of elements hashing to the same location Each element contains (1) the virtual page number (2) the value of the mapped page frame (3) a pointer to the next element Virtual page numbers are compared in this chain searching for a match If a match is found, the corresponding physical frame is extracted 24

Hashed Page Table 25

Segmentation Memory-management scheme that supports user view of memory A program is a collection of segments A segment is a logical unit such as: main program procedure function method object local variables, global variables common block stack symbol table arrays 26

User s View of a Program 27

Logical View of Segmentation 1 1 4 2 3 4 2 3 user space physical memory space 28

Segmentation Architecture Logical address consists of a two tuple: <segment-number, offset>, Segment table maps two-dimensional physical addresses; each table entry has: base contains the starting physical address where the segments reside in memory limit specifies the length of the segment Segment-table base register (STBR) points to the segment table s location in memory Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR 29

Segmentation Architecture (Cont.) Protection With each entry in segment table associate: validation bit = 0 illegal segment read/write/execute privileges Protection bits associated with segments; code sharing occurs at segment level Since segments vary in length, memory allocation is a dynamic storage-allocation problem A segmentation example is shown in the following diagram 30

Segmentation Hardware 31

Example of Segmentation 32