Chapter 18 Paging Chien-Chung Shen CIS, UD

Slides:



Advertisements
Similar presentations
Chapter 15 Address Translation Chien-Chung Shen CIS, UD
Advertisements

Lecture 7 Memory Management. Virtual Memory Approaches Time Sharing: one process uses RAM at a time Static Relocation: statically rewrite code before.
Chapter 19 Translation Lookaside Buffer Chien-Chung Shen CIS, UD
Allocating Memory.
CS 153 Design of Operating Systems Spring 2015
Memory Management Design & Implementation Segmentation Chapter 4.
Memory Management (II)
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management 2010.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
EECE476: Computer Architecture Lecture 27: Virtual Memory, TLBs, and Caches Chapter 7 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
Memory Management Ch.8.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Review of Memory Management, Virtual Memory CS448.
Operating Systems Chapter 8
Chapter 8 Memory Management Dr. Yingwu Zhu. Outline Background Basic Concepts Memory Allocation.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Virtual Memory CS Introduction to Operating Systems.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
1 Virtual Memory and Address Translation. 2 Review Program addresses are virtual addresses.  Relative offset of program regions can not change during.
PA0 due 60 hours. Lecture 4 Memory Management OSTEP Virtualization CPU: illusion of private CPU RAM: illusion of private memory Concurrency Persistence.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Chapter 21 Swapping: Mechanisms Chien-Chung Shen CIS, UD
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
PA1 due in one week TA office hour is 1-3 PM The grade would be available before that.
Lecture 7 TLB. Virtual Memory Approaches Time Sharing Static Relocation Base Base+Bounds Segmentation Paging.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
W4118 Operating Systems Instructor: Junfeng Yang.
Chapter 18 Paging Chien-Chung Shen CIS/UD
Main Memory: Paging and Segmentation CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
COMP 3500 Introduction to Operating Systems Paging: Basic Method Dr. Xiao Qin Auburn University Slides.
Chapter 21 Swapping: Mechanisms Chien-Chung Shen CIS/UD
Chapter 20 Smaller Tables Chien-Chung Shen CIS, UD
Chapter 15 Address Translation Chien-Chung Shen CIS/UD
Chapter 19 Translation Lookaside Buffer
Paging Review Page tables store translations from virtual pages to physical frames Issues: Speed - TLBs Size – Multi-level page tables.
Review: Memory Virtualization
Virtualization Virtualize hardware resources through abstraction CPU
Segmentation COMP 755.
CSE 120 Principles of Operating
CS703 - Advanced Operating Systems
Paging COMP 755.
Christo Wilson Lecture 7: Virtual Memory
Today How was the midterm review? Lab4 due today.
Chien-Chung Shen CIS/UD
PA1 is out Best by Feb , 10:00 pm Enjoy early
Paging Review: Virtual address spaces are broken into pages
Lecture 28: Virtual Memory-Address Translation
Lecture 6 Memory Management
Segmentation Lecture November 2018.
PA0 is due in 12 hours PA1 will be out in 12 hours
Virtual Memory Hardware
Translation Lookaside Buffer
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
Christo Wilson Lecture 7: Virtual Memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2004 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management CSE451 Andrew Whitaker.
CSE 451: Operating Systems Winter 2004 Module 10 Memory Management
CS 444/544 Operating Systems II Virtual Memory Translation
Presentation transcript:

Chapter 18 Paging Chien-Chung Shen CIS, UD

Introduction Our goal: to virtualize memory Segmentation (generalization of dynamic relocation) can do it, but has issues –managing free space with external fragmentation Fixed vs. variable sized units Paging: virtualize memory without segmentation e.g., 64-byte address space with 4 pages

Paging Page frame in physical memory Advantages: –flexibility – works, no matter how process uses its address space –simplicity of free space management How to record where each virtual page is placed in physical memory? –per-process page table

Address Translation Split address into virtual page # (VPN) and offset –64-byte address space –page size = 16 bytes –VA 21 –VPN indexes page table to get physical frame # (PFN) –offset stays the same

Where Are Page Tables Stored 32-bit address space with 4KB pages –20-bit VPN and 12-bit offset –4 bytes per page table entry (PTE): 4MB = 4×2 20 –page tables are stored in “kernel” memory

Structure of Page Table Linear page table (an array) –OS indexes the array by VPN to get PFN Bits associated with each PTE –valid –protection: for R, W, X –present –dirty –reference (access)

Paging Is Too Slow movl 21, %eax To fetch data in virtual address 21, translate 21 into physical address (117) –fetch PTE (in memory) to perform translate –where is the page table for the running process? page-table base register: physical address of the starting location of the page table VPN = (VirtualAddress & VPN_MASK) >> SHIFT PTEAddr = PageTableBaseRegister + (VPN * sizeof(PTE)) VPN_MAST = and SHIFT = 4 hardware fetches PTE from memory to get PFN and concatenate it with offset from the virtual address to form the desired physical address offset = VirtualAddress & OFFSET_MASK PhysAddr = (PFN << SHIFT) | offset –hardware fetch the desired data from memory and put it into eax

Summary // Extract the VPN from the virtual address VPN = (VirtualAddress & VPN_MASK) >> SHIFT // Form the address of the page-table entry (PTE) PTEAddr = PTBR + (VPN * sizeof(PTE)) // Fetch the PTE PTE = AccessMemory(PTEAddr) // Check if process can access the page if (PTE.Valid == False) RaiseException(SEGMENTATION_FAULT) else if (CanAccess(PTE.ProtectBits) == False) RaiseException(PROTECTION_FAULT) else // Access is OK: form physical address and fetch it offset = VirtualAddress & OFFSET_MASK PhysAddr = (PTE.PFN << PFN_SHIFT) | offset Register = AccessMemory(PhysAddr) For every memory reference (whether an instruction fetch or an explicit load or store), paging requires to perform one extra memory reference in order to first fetch the translation from the page table

Memory Trace int array[1000]; for (i = 0; i < 1000; i++) array[i] = 0; $ objdump –d a.out 0x1024 movl $0x0,(%edi,%eax,4) // move 0 into VA of array [edi]+4*[eax] 0x1028 incl %eax 0x102c cmpl $0x03e8,%eax // 0x03e8 = x1030 jne 0x1024 Virtual address space of size 64 KB and page size 1 KB Each instruction fetch generates 2 memory references: one to page table to find the physical frame that the instruction resides within, and one to instruction itself to fetch it to the CPU for processing movl adds another page table access and then the array access itself

Memory Trace of 1 st 5 Loops Page table: PA 1024 Code: VA Array: VA to (VPN 39-42) Page table: VPN 1 -> PFN 4 VPN 39 -> PFN 7 VPN 40 -> PFN 8 VPN 41 -> PFN 9 VPN 42 -> PFN 10

Summary Advantages (over segmentation) –no external fragmentation (with fixed sigze pages) –flexible to enable the sparse use of virtual address spaces Disadvantages –slow (extra memory accesses to access the page table) –memory waste (with memory filled with page tables instead of application data)