Understanding Virtual Memory Concepts in Computer Systems

lecture 17 virtual memory n.w
1 / 26
Embed
Share

Learn about virtual memory, multiprocessing, address translation, base-and-bound memory organization, and how they contribute to efficient memory management and utilization in computer systems. Dive into exercises to solidify your understanding.

  • Virtual Memory
  • Multiprocessing
  • Memory Management
  • Address Translation
  • Base-and-Bound

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lecture 17: Virtual Memory CS 105 Fall 2020

  2. Multiprocessing: The Illusion Memory Memory Memory Stack Heap Data Stack Heap Data Stack Heap Data Code Code Code CPU CPU CPU Registers Registers Registers Process provides each program with two key abstractions: Logical control flow Each program seems to have exclusive use of the CPU Provided by kernel mechanism called context switching Private address space Each program seems to have exclusive use of main memory. Provided by kernel mechanism called virtual memory

  3. Multiprocessing: The Reality Computer runs many processes simultaneously Running program top on Mac System has 123 processes, 5 of which are active Identified by Process ID (PID)

  4. Virtual Memory Goals Isolation: don t want different process states collided in physical memory Efficiency: want fast reads/writes to memory Stack Sharing: want option to overlap for communication Heap Utilization: want best use of limited resource Data Virtualization: want to create illusion of more resources Code

  5. Address Translation Stack invalid Virtual Address Exception MMU Heap Data Physical Address Code Data

  6. Base-and-Bound Physical Memory Virtual Memory Stack Bound Heap Data Code Base

  7. Base-and-Bound Stack MMU vaddr > Bound vaddr Base Bound Exception Heap Data Code paddr = vaddr + Base Data

  8. Exercise 1: Base-and-Bound Assume that you are currently executing a process P with Base 0x1234 and Bound 0x100. What is the physical address that corresponds to the virtual address 0x47? What is the physical address that corresponds to the virtual address 0x123?

  9. Exercise 1: Base-and-Bound Assume that you are currently executing a process P with Base 0x1234 and Bound 0x100. What is the physical address that corresponds to the virtual address 0x47? What is the physical address that corresponds to the virtual address 0x123? invalid 0x127b

  10. Evaluating Base-and-Bound Isolation: don t want different process states collided in physical memory Efficiency: want fast reads/writes to memory Sharing: want option to overlap for communication Utilization: want best use of limited resource Virtualization: want to create illusion of more resources

  11. Segmentation Physical Memory DBound DBase Virtual Memory Stack Heap HBound HBase Data Code SBound SBase CBound CBase

  12. Segmentation MMU Stack Base Bound Access R,W R,W R,W R,X Exception offset > Bound[idx] or access not allowed idx offset vaddr Heap Data Code paddr = Base[idx] + offset Data

  13. Exercise 2: Segmentation Assume that you are currently executing a process P with the following segment table: Base 0x4747 0x2424 0x0023 0x1000 Bound 0x80 0x40 0x80 0x200 Access R,W R,W R,W R,X What is the physical address that corresponds to the virtual address 0x001? What is the physical address that corresponds to the virtual address 0xD47?

  14. Exercise 2: Segmentation Assume that you are currently executing a process P with the following segment table: Base 0x4747 0x2424 0x0023 0x1000 Bound 0x80 0x40 0x80 0x200 Access R,W R,W R,W R,X What is the physical address that corresponds to the virtual address 0x001? What is the physical address that corresponds to the virtual address 0xD47? 0x4748 00 0000000001 0x1147 11 0101000111

  15. Evaluating Segmentation Isolation: don t want different process states collided in physical memory Efficiency: want fast reads/writes to memory Sharing: want option to overlap for communication Utilization: want best use of limited resource Virtualization: want to create illusion of more resources

  16. Paging Physical Memory Frame 17 Virtual Memory Frame 16 Frame 15 Page 7 Frame 14 Stack Page 6 Frame 13 Page 5 Frame 12 Page 4 Frame 11 Page 3 Heap Frame 10 Page 2 Frame 9 Data Page 1 Frame 8 Code Page 0 Frame 7 Frame 6 Frame 5 Frame 4 Frame 3 Frame 2 Frame 1 Frame 0

  17. Paging MMU Stack Frame 47 NULL 13 42 Access R,W R,W R,W R,X Exception page# offset access not allowed vaddr Heap Data Code Frame[page#] offset paddr = Data

  18. Exercise 3: Paging Assume that you are currently executing a process P with the following page table on a system with 16 byte pages: Frame Access 0x47 R,W 0xF4 R,W NULL R,W 0x23 R,X 0x14 0x17 0x16 0x15 What is the physical address that corresponds to the virtual address 0x147? What is the physical address that corresponds to the virtual address 0x16E?

  19. Exercise 3: Paging Assume that you are currently executing a process P with the following page table on a system with 16 byte pages: Frame Access 0x47 R,W 0xF4 R,W NULL R,W 0x23 R,X 0x17 0x16 0x15 0x14 What is the physical address that corresponds to the virtual address 0x147? What is the physical address that corresponds to the virtual address 0x16E? 0x237 00010100 0111 0xF4E 00010110 1110

  20. Exercise 3: Paging Assume that you are currently executing a process P with the following page table on a system with 16 byte pages: Frame Access 0x47 R,W 0xF4 R,W NULL R,W 0x23 R,X Virtual Memory Physical Memory 0x17 0x16 Frame 0xF5 Page 22 Frame 0xF4 Frame 0xF3 Frame 0xF2 0x15 0x14 Frame 0xF1 Frame 0xF0 Frame 0x48 Page 23 Page 23 Frame0x47 Page 22 Frame 0x46 Page 21 0x147 0x237 Frame 0x45 Page 20 Frame 0x25 Frame 0x24 Page 20 Frame 0x23 Frame 0x22

  21. Memory as a Cache each page table entry has a valid bit for valid entries, frame indicates physical address of page in memory a page fault occurs when a program requests a page that is not currently in memory takes time to handle, so context switch evict another page in memory to make space (which one?) MMU v 1 0 0 1 Frame 47 NULL 13 42 Access R,W R,W R,W R,X

  22. Thrashing working set is the collection of a pages a process requires in a given time interval if it doesn't fit in memory, program will thrash

  23. Exercise 4: Paging Assume that you are currently executing a process P with the following page table on a system with 256 byte pages: v Frame Access 1 0x47 R,W 1 0x24 R,W 0 NULL R,W 0 0x23 R,X 247 250 249 248 What is the physical address that corresponds to the virtual address 0xF947? What is the physical address that corresponds to the virtual address 0xF700?

  24. Exercise 4: Paging Assume that you are currently executing a process P with the following page table on a system with 256 byte pages: v Frame Access 1 0x47 R,W 1 0x24 R,W 0 NULL R,W 0 0x23 R,X 247 250 249 248 What is the physical address that corresponds to the virtual address 0xF947? What is the physical address that corresponds to the virtual address 0xF700? 0x237 0xF9 0x47 0xF4E 0xF7 0x00

  25. Evaluating Paging Isolation: don t want different process states collided in physical memory Efficiency: want fast reads/writes to memory Sharing: want option to overlap for communication Utilization: want best use of limited resource Virtualization: want to create illusion of more resources

  26. Exercise 5: Feedback 1. Rate how well you think this recorded lecture worked 1. Better than an in-person class 2. About as well as an in-person class 3. Less well than an in-person class, but you still learned something 4. Total waste of time, you didn't learn anything 2. How much time did you spend on this video (including exercises)? 3. Do you have any particular questions you d like me to address in this week s problem session? 4. Do you have any other comments or feedback?

Related


More Related Content