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

Similar documents
CS307: Operating Systems

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

CS3600 SYSTEMS AND NETWORKS

CS370 Operating Systems

Chapter 8 Main Memory

Chapter 8 Memory Management

Chapter 8: Memory-Management Strategies

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

Lecture 8 Memory Management Strategies (chapter 8)

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

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

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

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

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

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

Chapter 8: Main Memory

Chapter 9 Memory Management

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) Advantages of Multi-level Page Tables

Chapter 8: Memory Management

Main Memory (Part II)

Memory Management (2)

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

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

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

Chapter 8: Memory- Management Strategies

Operating Systems, Fall Lecture 5 1

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

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

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

Memory Addressing. Pradipta De

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

Chapter 8: Main Memory

Page Size Page Size Design Issues

CS307 Operating Systems Main Memory

Memory and multiprogramming

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

SHANDONG UNIVERSITY 1

CS 3733 Operating Systems:

Module 8: Memory Management

Main Memory (II) Operating Systems. Autumn CS4023

Logical versus Physical Address Space

Chapter 8: Main Memory

Chapter 9: Memory Management. Background

Chapter 8: Main Memory

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

SE-292 High Performance Computing. Memory Hierarchy. R. Govindarajan

Chapter 8: Memory Management Strategies

Memory Management. Memory Management

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

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

1. Creates the illusion of an address space much larger than the physical memory

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

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

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

Module 8: Memory Management

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

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

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

Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

143A: Principles of Operating Systems. Lecture 6: Address translation. Anton Burtsev January, 2017

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

Operating Systems, Fall Lecture 5, Tiina Niklander 1

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Virtual Memory. CS 351: Systems Programming Michael Saelee

CIS Operating Systems Memory Management Address Translation. Professor Qiang Zeng Fall 2017

Principles of Operating Systems

CSE 120 Principles of Operating Systems

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

Virtual memory Paging

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

CS370 Operating Systems

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

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

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

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

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

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

2-Level Page Tables. Virtual Address Space: 2 32 bytes. Offset or Displacement field in VA: 12 bits

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

CS 153 Design of Operating Systems Winter 2016

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

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

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

Memory Management. Dr. Yingwu Zhu

Memory Management. Memory

Virtual Memory. Today. Handling bigger address spaces Speeding translation

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

Topic 18: Virtual Memory

CS162 Operating Systems and Systems Programming Lecture 14. Caching (Finished), Demand Paging

CS 134: Operating Systems

CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs"

238P: Operating Systems. Lecture 5: Address translation. Anton Burtsev January, 2018

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

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

Chapter 3 - Memory Management

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

Memory management, part 3: outline

CS399 New Beginnings. Jonathan Walpole

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

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Transcription:

Lecture 21 Case study guidelines posted Case study assignments Third project (virtual memory simulation) will go out after spring break. Extra credit fourth project (shell program) will go out after that. Questions? Monday, February 28 CS 470 Operating Systems - Lecture 21 1

Outline Effective memory access time Very large address spaces Segmentation Combining paging and segmentation Monday, February 28 CS 470 Operating Systems - Lecture 21 2

Address Translation with TLB f log. addr. phys. addr. CPU p d TLB p# f# f d d p f TLB hit TLB miss p f main memory page table Monday, February 28 CS 470 Operating Systems - Lecture 21 3

Address Translation with TLB When there is a TLB hit, the frame number is obtained nearly instantaneously. When there is a TLB miss, the page table must be consulted, resulting in an extra memory access. The frame number is then loaded into the TLB, possibly replacing an existing entry. The TLB must be flushed on a context switch. Monday, February 28 CS 470 Operating Systems - Lecture 21 4

Effective Memory Access Time The effect of a TLB is calculated based on the hit ratio of memory accesses. I.e., the percentage of times the desired page number is in the TLB. For example, assume 100ns to access memory, 20ns to search the TLB, and 80% hit ratio. Mapped memory access (TLB hit) takes 120ns (TLB search + memory access). Unmapped memory access (TLB miss) takes 220ns (TLB search + PT access + memory access) Monday, February 28 CS 470 Operating Systems - Lecture 21 5

Effective Memory Access Time Effective memory access time (emat) is computed by weighting each case by its probability: emat = TLB hit % * TLB hit time + TLB miss % * TLB miss time =.80 * 120ns +.20 * 220ns = 140ns A 40% slowdown over direct mapped access, but better than 100% slowdown without TLB. Monday, February 28 CS 470 Operating Systems - Lecture 21 6

Effective Memory Access Time What is the emat if the hit ratio is increased to 98%? Hit ratio depends on size of TLB. Studies have shown that 16-512 entries can get 80-98%. Motorola 68020 has 22 entries. Intel 486 has 32 entries and claimed 98% hit ratio. Monday, February 28 CS 470 Operating Systems - Lecture 21 7

Paging Issues Sharing is easy. Can set up PTs of multiple processes to have same entries for shared parts of the logical address space. Especially good for code segments, as long as they are reentrant (i.e., program does not modify itself). Most modern OS's support very large address spaces that require very large PTs. 32-bit addresses are common. 64-bit is becoming so. Monday, February 28 CS 470 Operating Systems - Lecture 21 8

Very Large Address Spaces For example, 32-bit address space with 4KB pages results in 20 bits of page number and 12 bits of displacement. If each PT entry is 32 bits (4 bytes), need 4MB for the PT alone! Must divide the PT into smaller pieces using paging. Then have a PT to find the actual PT. For 32-bit addressing, need two levels of paging. Monday, February 28 CS 470 Operating Systems - Lecture 21 9

Very Large Address Spaces Logical address: pp pd d Page number part is divided into the page table page number (pp) and the page table displacement (pd). pp is used to index the PT's PT to find the location of the part of the PT containing the needed page number. pd is used to index the obtained part of the PT to get the frame number Monday, February 28 CS 470 Operating Systems - Lecture 21 10

Very Large Address Spaces For a 64-bit address space, need four levels of PTs. Under same assumptions as before: Unmapped memory access (TLB miss) is 520ns (20ns for TLB search + 400ns for 4 PT accesses + 100ns for memory access) For a 98% hit ratio emat =.98 * 120ns +.02 * 520ns = 128 ns Only slightly slower than the 1 level case! Shows the importance of TLB hardware. Monday, February 28 CS 470 Operating Systems - Lecture 21 11

Segmentation Paging makes a very clear distinction between the user's logical view of memory and the actual physical memory. But generally, users tend to think of memory in segments related to the purpose or part of a program rather than as a linear array of bytes. E.g., objects, functions, global data, etc. Users do not care where in memory each segment is in relation to each other, and the segments are variable in length. Monday, February 28 CS 470 Operating Systems - Lecture 21 12

Segmentation This idea can be used as a storage organization and management scheme called segmentation. Logical address space is a collection of segments. Each segment has a "name" and a length. Logical addresses are of the form <s, d>, where s is the segment's name (usually a segment number) and d is the displacement. The MMU consists of a segment table (ST) of <base address, limit> pairs. Monday, February 28 CS 470 Operating Systems - Lecture 21 13

Address Translation log. addr. b CPU s d s base limit l d < l yes no trap invalid address b l d main memory Monday, February 28 CS 470 Operating Systems - Lecture 21 14

Segmentation Example Segment Description 0 Func 1 sqrt 2 main 3 stack 4 symbol table Segment Table Base Addr Limit 1400 1000 6300 400 4300 400 3200 1100 4700 1000 Translate the following addresses: < 2, 53 > < 3, 852 > < 0, 1222 > Monday, February 28 CS 470 Operating Systems - Lecture 21 15

Segmentation Implementation of segment table is similar to a page table. If small, stored directly in hardware. If large, stored in memory. Use TLB to cache mappings. Also need a segment table length register to check if segment number is valid. Monday, February 28 CS 470 Operating Systems - Lecture 21 16

Combining Paging and Segmentation Often systems combine paging and segmentation. The most common way is to divide (fairly large) segments into pages. Example: Multics - 36-bit word, 34-bit addresses divided into 18-bit segment number and 16-bit displacement. Maximum size segment is 64KB, rather large. Divide the logical address displacement into pages: s dp dd Monday, February 28 CS 470 Operating Systems - Lecture 21 17

Combining Paging and Segmentation The pages are 1KB, so dp is 6 bits, and dd is 10 bits. The ST entries contain a pointer to the segment's PT rather than a base address. 18 bits of segment number is large, too, so the ST is paged as well. sp sd dp dd Monday, February 28 CS 470 Operating Systems - Lecture 21 18

Combining Paging and Segmentation Address translation is now sp indexes ST page table to get appropriate page of the ST sd indexes ST page to get the PT of segment s dp indexes the PT of segment s to get the appropriate page of physical memory dd is the displacement into the page Monday, February 28 CS 470 Operating Systems - Lecture 21 19

Combining Paging and Segmentation Example: Intel Pentium - supports pure segmentation and segmentation with paging CPU generates 48-bit <s, d> logical addresses, where s is 16 bits and d is 32 bits, that are translated into 32-bit linear addresses. s is used to index the ST to get the base address of a segment, then the 32 bit displacement is added to create a 32-bit linear address. These are then paged in either 4KB or 4MB pages. Monday, February 28 CS 470 Operating Systems - Lecture 21 20

Combining Paging and Segmentation Example: Linux on Pentium - Linux is designed to be multi-platform, so cannot depend on any particular hardware support. On a Pentium, Linux had 6 segments: Kernel code Kernal data User code - shared by all user processes User data - shared by all user processes Task-state segment (TSS) - stores contexts for switches Default local descriptor table (LDT) segment - generally unused Monday, February 28 CS 470 Operating Systems - Lecture 21 21

Combining Paging and Segmentation Effectively, each segment is the physical memory begin managed for its category. Linux is designed for 3 levels of paging, since it can run on 64-bit architectures. The number of bits for each level depends on the architecture. Since a Pentium is a 32-bit architecture, only need two levels, so the middle level has 0 bits, effectively bypassing it. Monday, February 28 CS 470 Operating Systems - Lecture 21 22