1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions.

Slides:



Advertisements
Similar presentations
Page Table Implementation
Advertisements

CMPT 300 Introduction to Operating Systems
EECS 470 Virtual Memory Lecture 15. Why Use Virtual Memory? Decouples size of physical memory from programmer visible virtual memory Provides a convenient.
Virtual Memory Chapter 18 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
CS 153 Design of Operating Systems Spring 2015
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Nov. 17, 2003 Topic: Virtual Memory.
Chapter 8.3: Memory Management
Memory Management (II)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Memory Problems Prof. Sin-Min Lee Department of Mathematics and Computer Sciences.
Principle Behind Hierarchical Storage  Each level memorizes values stored at lower levels  Instead of paying the full latency for the “furthermost” level.
Answers to the VM Problems Spring First question A computer has 32 bit addresses and a virtual memory with a page size of 8 kilobytes.  How many.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Carnegie Mellon 1 Virtual Memory / : Introduction to Computer Systems 10 th Recitation, October 29th, 2012 Grant Skudlarek Section G.
CS 241 Section Week #12 (04/22/10).
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
Memory Management Ch.8.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Address Translation Mechanism of 80386
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 08 Main Memory (Page table questions)
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
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.
A NEW PAGE TABLE FOR 64-BIT ADDRESS SPACES M. Talluri, M. D. Hill, Y. A. Kalidi University of Wisconsin, Madison Sun Microsystems Laboratories.
Operating Systems COMP 4850/CISG 5550 Page Tables TLBs Inverted Page Tables Dr. James Money.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Paging Example What is the data corresponding to the logical address below:
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Virtual Memory 1 1.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Paging Paging is a memory-management scheme that permits the physical-address space of a process to be noncontiguous. Paging avoids the considerable problem.
Carnegie Mellon Introduction to Computer Systems / Spring 2009 March 23, 2009 Virtual Memory.
Page Table Implementation. Readings r Silbershatz et al:
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Operating Systems, Winter Semester 2011 Practical Session 9, Memory 1.
CS 162 Discussion Section Week 6. Administrivia Project 2 Deadlines – Initial Design Due: 3/1 – Review Due: 3/5 – Code Due: 3/15.
Memory: Page Table Structure CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Memory: Page Table Structure
Memory Management Virtual Memory.
Virtual Memory Chapter 7.4.
Section 8 Address Translation March 10th, 2017 Taught by Joshua Don.
Lecture Topics: 11/19 Paging Page tables Memory protection, validation
Virtual Memory - Part II
From Address Translation to Demand Paging
From Address Translation to Demand Paging
Day 21 Virtual Memory.
Day 22 Virtual Memory.
Memory Hierarchy Virtual Memory, Address Translation
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
CSCI206 - Computer Organization & Programming
Paging Lecture November 2018.
FIGURE 12-1 Memory Hierarchy
Page that info back into your memory!
Lecture 29: Virtual Memory-Address Translation
Lecture 36 Syed Mansoor Sarwar
Virtual Memory Hardware
Practical Session 9, Memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
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
Lecture 34 Syed Mansoor Sarwar
CSE 451: Operating Systems Winter 2005 Page Tables, TLBs, and Other Pragmatics Steve Gribble 1.
Virtual Memory 1 1.
Presentation transcript:

1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions

0. Page Table  Q: Consider a system with 32-bit virtual address. The virtual memory is implemented by paging, and the page size is 4KB. A user process generates the virtual address 0x What is the page table index for this virtual address?  A: Since the page size is 2^12, the page table size is 2^20. The virtual address in binary form is The low-order 12 bits are used as the offset into the page, while the remaining 20 bits are used as the index into the page table, or 0x

1.1 Inverted Page Table  Consider a system with 32-bit virtual address space, and 4 MB of physical memory. The page size is 8KB (8192-byte). The system uses an Inverted Page Table (IPT).  Q: How many bits is each VPN? How many bits is each PPN? Describe what PTE (page table entry) looks like. How many PTEs (page table entries) does the IPT contain? (Remember: PT is indexed by VPN and contains PPN; IPT is indexed by PPN and contains VPN.)  A: The virtual address consists of VPN: 19 bits; Offset: 13 bits  2^13=8KB, hence offset is 13 bits; the total virtual address length is 32 bits, hence VPN is 32-3=19 bits.  There are a total of 4MB/8KB=512 physical pages, hence the PPN is 9 bits (2^9=512). The IPT contains 512 PTEs.  IPT maps from PPN to VPN. It contains 512 PTEs. Each PTE contains a 19-bit field for VPN, plus another field for Process ID, plus additional bits for protection etc. (Offset is not stored in page tables) 3

1.2 Page Table  Consider a system with 32-bit virtual address space, and 4 MB of physical memory. The page size is 8KB (8192-byte). The system uses a regular Page Table.  Q: How many bits is each VPN? How many bits is each PPN? Describe what PTE (page table entry) looks like. How many PTEs (page table entries) does the PT contain?  A: Same as before, VPN: 19 bits; PPN: 9 bits.  Each PTE contains a 9-bit field for PPN, plus additional protection bits for protection etc.  There are a total of 2^32/2^13=2^19 virtual pages, hence the PT contains 2^19 PTEs.  Q: Why is there not a field for Process ID?  A: Each process has its own separate page table. 4

2. 1 Page Table  Consider a system with 32-bit virtual address using two-level page tables for address translation. The format of the virtual address, physical address, and PTE (page table entry) are as shown. Assume each PTE in both 1 st and 2 nd level PTs is 2 bytes, including all permission bits. Size of physical memory is 4MB.  Q: How large is each page? How many physical pages in total? How many bits in PPN?  A: Page size: 2^12 bytes =4 KB; Total number of physical pages is 4MB/4KB=1K=2^10  # bits in PPN is KB 1K PTEs 1K PTEs 32-bit address: P1 indexP2 indexpage offset 10 12

2. 2 Page Table  Q: What is the largest possible memory needed for storing all page tables?  A: There is one page table at the first level, and up to 2^10 = 1K page tables at the 2 nd level. Each PTE is 2 bytes. Size of the 1 st level page table is 2*(2^10) bytes = 2KB. Size of each 2 nd level table is also 2*(2^10) bytes = 2KB. All in all, the page tables use 2KB * 2KB = 2050 KB of memory. 6 4KB 1K PTEs 1K PTEs 32-bit address: P1 indexP2 indexpage offset 10 12

2. 3 Page Table  Q: Consider a process that is using 512KB of physical memory. What is the minimum number of page tables used by this process? What is the maximum number of page tables this process might use?  A: The process uses 512KB / 4 KB = 128 physical pages. Since each 2 nd level page can hold up to 1K PTEs, in the best case scenario the process is covered by a single 2 nd level PT. we use only 2 page tables: 1st level PT + a 2nd level PT.  In the worst case, the process may use a little bit of every physical page (e.g., 0.5 KB of each physical page), and all page tables will be populated. Thus, the process ends up using = 1025 page tables. 7 4KB 1K PTEs 1K PTEs 32-bit address: P1 indexP2 indexpage offset 10 12

2. 4 Page Table  Q: Assume that instead of two-level PTs, we use an inverted PT for address translation. How many entries are used in the inverted table by a process using 512KB of physical memory?  A: The inverted table contains one entry per physical page, hence it has 2^10=1K entries. In the worst case, the process uses all physical pages, which yields 1K entries. In the best case, the process fully uses each physical page, which yields 128 entries.

3. TLB  Consider a system with the page tables stored in memory. If a memory reference takes 200 nanoseconds, how long does a paged memory reference take? If we add a TLB, and 75 percent of all page-table references are found in the TLB, what is the effective memory reference time? (Assume that finding a page-table entry in the TLB takes zero time, if TLB hit.)  A: 400 ns; 200 ns to access the page table and 200 ns to access the word in memory.  Effective access time = 0.75 (200 ns) (400 ns) = 250 ns. 9