Memory Management: from Absolute Addresses to Demand Paging

Memory Management: from Absolute Addresses to Demand Paging

Modern Virtual Memory Systems Daniel Sanchez Computer Science and Artificial Intelligence Laboratory M.I.T. September 20, 2021 MIT 6.823 Fall 2021 L04-1 A Problem in Early Sixties • There were many applications whose data could not fit in the main memory, e.g., payroll – Paged memory system reduced fragmentation but still required the whole program to be resident in the main memory • Programmers moved the data back and forth from the secondary store by overlaying it repeatedly on the primary store tricky programming! September 20, 2021 MIT 6.823 Fall 2021 L04-2 Manual Overlays 40k bits main 640k bits drum Central Store Ferranti Mercury 1956 September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main 640k bits drum Central Store Ferranti Mercury 1956 September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum Central Store Ferranti Mercury 1956 September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Ferranti Mercury 1956 September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Brooker’s interpretive coding, 1960 Ferranti Mercury 1956 September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Brooker’s interpretive coding, 1960 Ferranti Mercury 1956 Problems? September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Brooker’s interpretive coding, 1960 Ferranti Mercury 1956 Problems? September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Brooker’s interpretive coding, 1960 Ferranti Mercury 1956 Problems? Method1: Difficult, error prone September 20, 2021 MIT 6.823 Fall 2021 L04-3 Manual Overlays • Assume an instruction can address all the storage on the drum 40k bits main • Method 1: programmer keeps track of addresses in the main memory and initiates an I/O transfer when required 640k bits drum • Method 2: automatic initiation of I/O Central Store transfers by software address translation Brooker’s interpretive coding, 1960 Ferranti Mercury 1956 Problems? Method1: Difficult, error prone Method2: Inefficient September 20, 2021 MIT 6.823 Fall 2021 L04-3 Demand Paging in Atlas (1962) “A page from secondary storage is brought into the primary storage whenever it is (implicitly) demanded by the processor.” Tom Kilburn Primary 32 Pages 512 words/page Secondary Central (Drum) Memory 32x6 pages September 20, 2021 MIT 6.823 Fall 2021 L04-4 Demand Paging in Atlas (1962) “A page from secondary storage is brought into the primary storage whenever it is (implicitly) demanded by the processor.” Tom Kilburn Primary 32 Pages 512 words/page Primary memory as a cache for secondary memory Secondary Central (Drum) Memory 32x6 pages September 20, 2021 MIT 6.823 Fall 2021 L04-4 Demand Paging in Atlas (1962) “A page from secondary storage is brought into the primary storage whenever it is (implicitly) demanded by the processor.” Tom Kilburn Primary 32 Pages 512 words/page Primary memory as a cache for secondary memory Secondary Central (Drum) User sees 32 x 6 x 512 words Memory 32x6 pages of storage September 20, 2021 MIT 6.823 Fall 2021 L04-4 Hardware Organization of Atlas Effective 16 ROM pages system code 0.4 ~1 sec Address Initial (not swapped) Address Decode 2 subsidiary pages system data PARs 1.4 sec (not swapped) 48-bit words 0 Main Drum (4) 512-word pages 8 Tape decks 32 pages 192 pages 88 sec/word 1.4 sec 1 Page Address 31 Register (PAR) <effective PN , status> per page frame September 20, 2021 MIT 6.823 Fall 2021 L04-5 Hardware Organization of Atlas Effective 16 ROM pages system code 0.4 ~1 sec Address Initial (not swapped) Address Decode 2 subsidiary pages system data PARs 1.4 sec (not swapped) 48-bit words 0 Main Drum (4) 512-word pages 8 Tape decks 32 pages 192 pages 88 sec/word 1.4 sec 1 Page Address 31 Register (PAR) <effective PN , status> per page frame Compare the effective page address against all 32 PARs match normal access no match page fault save the state of the partially executed instruction September 20, 2021 MIT 6.823 Fall 2021 L04-5 Atlas Demand Paging Scheme • On a page fault: – Input transfer into a free page is initiated – The Page Address Register (PAR) is updated – If no free page is left, a page is selected to be replaced (based on usage) – The replaced page is written on the drum • to minimize the drum latency effect, the first empty page on the drum was selected – The page table is updated to point to the new location of the page on the drum September 20, 2021 MIT 6.823 Fall 2021 L04-6 Caching vs. Demand Paging secondary memory primary primary CPU cache CPU memory memory Caching Demand paging cache entry page frame cache block (~32 bytes) page (~4K bytes) cache miss rate (1% to 20%) page miss rate (<0.001%) cache hit (~1 cycle) page hit (~100 cycles) cache miss (~100 cycles) page miss (~5M cycles) a miss is handled a miss is handled in hardware mostly in software September 20, 2021 MIT 6.823 Fall 2021 L04-7 Modern Virtual Memory Systems Illusion of a large, private, uniform store Protection & Privacy OS several users, each with their private address space and one or more shared address spaces useri page table name space Swapping Demand Paging Store Provides the ability to run programs Primary larger than the primary memory Memory Hides differences in machine configurations The price is address translation on each memory reference VA mapping PA TLB September 20, 2021 MIT 6.823 Fall 2021 L04-8 Linear Page Table Data Pages • Page Table Entry (PTE) Page Table contains: PPN PPN – A bit to indicate if a page DPN exists PPN – PPN (physical page number) Data word for a memory-resident page – DPN (disk page number) for Offset a page on the disk Status bits for protection – DPN and usage PPN • OS sets the Page Table PPN Base Register DPN DPN whenever active user VPN process changes DPN PPN PPN PT Base Register VPN Offset Virtual address September 20, 2021 MIT 6.823 Fall 2021 L04-9 Size of Linear Page Table With 32-bit addresses, 4 KB pages & 4-byte PTEs: 220 PTEs, i.e, 4 MB page table per user 4 GB of swap space needed to back up the full virtual address space September 20, 2021 MIT 6.823 Fall 2021 L04-10 Size of Linear Page Table With 32-bit addresses, 4 KB pages & 4-byte PTEs: 220 PTEs, i.e, 4 MB page table per user 4 GB of swap space needed to back up the full virtual address space Larger pages? • Internal fragmentation (Not all memory in a page is used) • Larger page fault penalty (more time to read from disk) September 20, 2021 MIT 6.823 Fall 2021 L04-10 Size of Linear Page Table With 32-bit addresses, 4 KB pages & 4-byte PTEs: 220 PTEs, i.e, 4 MB page table per user 4 GB of swap space needed to back up the full virtual address space Larger pages? • Internal fragmentation (Not all memory in a page is used) • Larger page fault penalty (more time to read from disk) What about 64-bit virtual address space??? • Even 1MB pages would require 244 8-byte PTEs (35 TB!) September 20, 2021 MIT 6.823 Fall 2021 L04-10 Size of Linear Page Table With 32-bit addresses, 4 KB pages & 4-byte PTEs: 220 PTEs, i.e, 4 MB page table per user 4 GB of swap space needed to back up the full virtual address space Larger pages? • Internal fragmentation (Not all memory in a page is used) • Larger page fault penalty (more time to read from disk) What about 64-bit virtual address space??? • Even 1MB pages would require 244 8-byte PTEs (35 TB!) What is the “saving grace”? September 20, 2021 MIT 6.823 Fall 2021 L04-10 Hierarchical Page Table Virtual Address 31 22 21 12 11 0 p1 p2 offset 10-bit 10-bit L1 index L2 index offset Root of the Current Page Table p2 p1 (Processor Level 1 Register) Page Table Level 2 page in primary memory Page Tables page in secondary memory PTE of a nonexistent page Data Pages September 20, 2021 MIT 6.823 Fall 2021 L04-11 Address Translation & Protection Virtual Address Virtual Page No.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    88 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us