CS703 - Advanced Operating Systems

Slides:



Advertisements
Similar presentations
CS 153 Design of Operating Systems Spring 2015
Advertisements

Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
Virtual Memory Chapter 8.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
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.
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 ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
CSE451 Operating Systems Winter 2012 Memory Management Mark Zbikowski Gary Kimura.
Operating Systems ECE344 Ding Yuan Memory Management Lecture 7: Memory Management.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Virtual Memory 1 1.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.
Virtual Memory.  Next in memory hierarchy  Motivations:  to remove programming burdens of a small, limited amount of main memory  to allow efficient.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
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.
Computer Architecture Lecture 12: Virtual Memory I
Virtual Memory Chapter 8.
Memory: Page Table Structure
Translation Lookaside Buffer
Lecture 11 Virtual Memory
CSE 120 Principles of Operating
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
Section 9: Virtual Memory (VM)
CSE451 Operating Systems Winter 2011
Today How was the midterm review? Lab4 due today.
CSE 451: Operating Systems Winter 2010 Module 10 Memory Management
CS 704 Advanced Computer Architecture
CSE 451: Operating Systems Winter 2014 Module 11 Memory Management
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory Partially Adapted from:
CSE 451: Operating Systems Winter 2011 Page Table Management, TLBs, and Other Pragmatics Mark Zbikowski Gary Kimura 1.
EECE.4810/EECE.5730 Operating Systems
CS 105 “Tour of the Black Holes of Computing!”
Operating System Main Memory
CS399 New Beginnings Jonathan Walpole.
Virtual Memory Hardware
Virtual Memory Nov 27, 2007 Slide Source:
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2004 Memory Management
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2004 Page Tables, TLBs, and Other Pragmatics Hank Levy 1.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS444/CS544 Operating Systems
CS 105 “Tour of the Black Holes of Computing!”
Computer Architecture
CSE 451: Operating Systems Autumn 2009 Module 10 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management CSE451 Andrew Whitaker.
CS 105 “Tour of the Black Holes of Computing!”
CSE 451: Operating Systems Winter 2004 Module 10 Memory Management
Paging and Segmentation
CS703 - Advanced Operating Systems
CSE 451: Operating Systems Winter 2005 Page Tables, TLBs, and Other Pragmatics Steve Gribble 1.
CSE 153 Design of Operating Systems Winter 2019
CSE451 Operating Systems Winter 2009
CSE 451: Operating Systems Autumn 2010 Module 10 Memory Management
Design of Digital Circuits Lecture 25b: Virtual Memory
Virtual Memory 1 1.
Presentation transcript:

CS703 - Advanced Operating Systems By Mr. Farhan Zaidi

Lecture No. 24

Overview of today’s lectures Paging Address translation Page tables and Page table entries Multi-level address translation Page faults and their handling

Modern technique: Paging Solve the external fragmentation problem by using fixed sized units in both physical and virtual memory virtual address space physical address space page 0 frame 0 page 1 frame 1 page 2 frame 2 page 3 … … frame Y page X

User’s perspective virtual address space (VAS) Processes view memory as a contiguous address space from bytes 0 through N virtual address space (VAS) In reality, virtual pages are scattered across physical memory frames – not contiguous as earlier virtual-to-physical mapping this mapping is invisible to the program Protection is provided because a program cannot reference memory outside of its VAS the virtual address 0x356AF maps to different physical addresses for different processes Note: Assume for now that all pages of the address space are resident in memory – no “page faults”

Address translation Translating virtual addresses a virtual address has two parts: virtual page number & offset virtual page number (VPN) is index into a page table page table entry contains page frame number (PFN) physical address is PFN::offset Page tables managed by the OS map virtual page number (VPN) to page frame number (PFN) VPN is simply an index into the page table one page table entry (PTE) per page in virtual address space i.e., one PTE per VPN

A System with paging based hardware support Examples: workstations, servers, modern PCs, etc. Memory 0: 1: N-1: Page Table Virtual Addresses Physical Addresses 0: 1: CPU P-1: Disk Address Translation: Hardware converts virtual addresses to physical addresses via OS-managed lookup table (page table)

Mechanics of address translation virtual address virtual page # offset physical memory page frame 0 page table page frame 1 physical address page frame 2 page frame # page frame # offset page frame 3 … page frame Y

Example of address translation Assume 32 bit addresses assume page size is 4KB (4096 bytes, or 212 bytes) VPN is 20 bits long (220 VPNs), offset is 12 bits long Let’s translate virtual address 0x13325328 VPN is 0x13325, and offset is 0x328 assume page table entry 0x13325 contains value 0x03004 page frame number is 0x03004 VPN 0x13325 maps to PFN 0x03004 physical address = PFN::offset = 0x03004328

Page Table Entries (PTEs) 1 1 1 2 20 V R M prot page frame number PTE’s control mapping the valid bit says whether or not the PTE can be used says whether or not a virtual address is valid it is checked each time a virtual address is used the referenced bit says whether the page has been accessed it is set when a page has been read or written to the modified bit says whether or not the page is dirty it is set when a write to the page has occurred the protection bits control which operations are allowed read, write, execute the page frame number determines the physical page physical page start address = PFN

Paging advantages Easy to allocate physical memory physical memory is allocated from free list of frames to allocate a frame, just remove it from the free list external fragmentation is not a problem! managing variable-sized allocations is a huge pain Leads naturally to virtual memory entire program need not be memory resident take page faults using “valid” bit but paging was originally introduced to deal with external fragmentation, not to allow programs to be partially resident

Paging disadvantages Can still have internal fragmentation process may not use memory in exact multiples of pages Memory reference overhead 2 references per address lookup (page table, then memory) solution: use a hardware cache to absorb page table lookups translation lookaside buffer (TLB) – Memory required to hold page tables can be large need one PTE per page in virtual address space 32 bit AS with 4KB pages = 220 PTEs = 1,048,576 PTEs 4 bytes/PTE = 4MB per page table OS’s typically have separate page tables per process 25 processes = 100MB of page tables solution: page the page tables (!!!)

Page Faults (like “Cache Misses”) What if an object is on disk rather than in memory? Page table entry indicates virtual address not in memory OS exception handler invoked to move data from disk into memory current process suspends, others can resume OS has full control over placement, etc. Before fault After fault Memory Memory Page Table Page Table Virtual Addresses Physical Addresses Virtual Addresses Physical Addresses CPU CPU Disk Disk

Servicing a Page Fault (1) Initiate Block Read Processor Signals Controller Read block of length P starting at disk address X and store starting at memory address Y Read Occurs Direct Memory Access (DMA) Under control of I/O controller I / O Controller Signals Completion Interrupt processor OS resumes suspended process Processor Reg (3) Read Done Cache Memory-I/O bus (2) DMA Transfer I/O controller Memory disk Disk Disk disk

Example: suppose page size is 4 bytes.

Fragmentation: wasted space What if page size is very small? For example, VAX had a page size of 512 bytes. Means lots of space taken up with page table entries. What if page size is really big? Why not have an infinite page size? Would waste unused space inside of page. Example of internal fragmentation. external -- free gaps between allocated chunks internal -- free gaps because don't need all of allocated chunk With segmentation need to re-shuffle segments to avoid external fragmentation. Paging suffers from internal fragmentation.

Multi-Level Page Tables Given: 4KB (212) page size 32-bit address space 4-byte PTE Problem: Would need a 4 MB page table! 220 *4 bytes Common solution multi-level page tables e.g., 2-level table (P6) Level 1 table: 1024 entries, each of which points to a Level 2 page table. Level 2 table: 1024 entries, each of which points to a page Level 1 Table ...