cs 423 operating system design virtual memory mgmt
play

CS 423 Operating System Design: Virtual Memory Mgmt Professor - PowerPoint PPT Presentation

CS 423 Operating System Design: Virtual Memory Mgmt Professor Adam Bates Spring 2018 CS 423: Operating Systems Design Goals for Today Learning Objective: Navigate the history of memory systems in OS Announcements, etc: MP1


  1. CS 423 
 Operating System Design: Virtual Memory Mgmt Professor Adam Bates Spring 2018 CS 423: Operating Systems Design

  2. Goals for Today • Learning Objective: • Navigate the history of memory systems in OS • Announcements, etc: • MP1 Due Tonight! • MP2 Out later This Week Reminder : Please put away devices at the start of class CS 423: Operating Systems Design 2

  3. Storage Hierarchy CPU Registers Size Performance 32-64 bits Cache 4-128 words Memory 512-16k words Secondary Storage CS 423: Operating Systems Design 3

  4. Problem Statement We have limited amounts of fast resources, and large amounts of slower resources… How to create the illusion of an abundant fast resource? CS 423: Operating Systems Design 4

  5. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay Area Overlay 3 12k Used when process memory requirement exceeded the physical memory space 5 CS 423: Operating Systems Design

  6. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay 1 Overlay 3 12k Used when process memory requirement exceeded the physical memory space 6 CS 423: Operating Systems Design

  7. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay Area Overlay 3 12k Used when process memory requirement exceeded the physical memory space 7 CS 423: Operating Systems Design

  8. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay 2 Overlay 3 12k Used when process memory requirement exceeded the physical memory space 8 CS 423: Operating Systems Design

  9. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay Area Overlay 3 12k Used when process memory requirement exceeded the physical memory space 9 CS 423: Operating Systems Design

  10. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay 3 Overlay 3 12k Used when process memory requirement exceeded the physical memory space 10 CS 423: Operating Systems Design

  11. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay Area Overlay 3 12k Used when process memory requirement exceeded the physical memory space 11 CS 423: Operating Systems Design

  12. History: Mem Overlays Secondary Storage 0K Overlay 1 Main Program 5k Overlay Manager Overlay 2 7k Overlay 1 Overlay 3 12k Used when process memory requirement exceeded the physical memory space 12 CS 423: Operating Systems Design

  13. History: Fixed Partitions 0k • Approach: Multiprogramming 4k with fixed memory partitions • Divides memory into n fixed partitions (possible unequal) 16k • Problem? 64k Free Space 128k CS 423: Operating Systems Design 13

  14. History: Fixed Partitions 0k • Approach: Multiprogramming 4k with fixed memory partitions Program 1 • Divides memory into n fixed partitions (possible unequal) • Problems? 16k Program 2 64k Free Space Program 3 128k CS 423: Operating Systems Design 14

  15. History: Fixed Partitions 0k • Approach: Multiprogramming 4k with fixed memory partitions Program 1 • Divides memory into n fixed partitions (possible unequal) • Problems? 16k • Internal Fragmentation! Also, Program 2 • Level of Multiprogramming 64k Free Space Program 3 128k CS 423: Operating Systems Design 15

  16. History: Fixed Partition Allocation Placement Algorithms for Fixed Partitions ■ Trivial for equal size partitions. For unequal… ■ Multiple Queues: ■ Assign (i.e., enqueue) each incoming job to the smallest partition within which it fits ■ Decreases fragmentation ■ when the queue for a large partition is empty but the queue for a small partition is full. Small jobs have to wait to get into memory even though plenty of memory is free. ■ Single Queue: ■ Assign each process to the smallest available partition within which it fits ■ Increases amount of multiprogramming on the expense of fragmentation CS 423: Operating Systems Design 16

  17. History: Relocation ■ Correct starting address when a program should start in the memory ■ Different jobs will run at different addresses When a program is linked, the linker must know at what address the ■ program will begin in memory. ■ Logical addresses Logical address space , range (0 to max) ■ Physical addresses, Physical address space range (R+0 to R+max) for ■ base value R. User program never sees the real physical addresses ■ ■ Relocation register Mapping requires hardware with the base register ■ CS 423: Operating Systems Design 17

  18. History: Relocation Register Base Register BA Physical Logical CPU Address Address + Instruction Memory MA MA+BA Address Relocation => “Variable Partition Allocation” CS 423: Operating Systems Design 18

  19. History: Variable Partition Allocation 1 Monitor Job 1 Job 2 Job 3 Job 4 Free 2 Monitor Job 1 Job 3 Job 4 Free 3 Monitor Job 1 Job 5 Job 3 Job 4 Free Free Monitor Job 5 Job 3 Job 4 Job 6 4 Free Monitor Job 7 Job 5 Job 3 Job 8 Job 6 5 Memory wasted by External Fragmentation CS 423: Operating Systems Design 19

  20. Bad Parking Analogy Source: https://xkcd.com/562/ CS 423: Operating Systems Design 20

  21. History: Storage Placement Strategy ■ Best Fit ■ Use the hole whose size is equal to the need, or if none is equal, the hole that is larger but closest in size. ■ Problem: Creates small holes that can't be used. ■ Worst Fit? ■ Use the largest available hole. ■ Problem: Gets rid of large holes making it difficult to run large programs. ■ First Fit ■ Use the first available hole whose size is sufficient to meet the need. ■ Problem: Creates average size holes. ■ Next Fit . ■ Minor variation of first fit: search from the last hole used. ■ Problem: slightly worse performance than first fit. CS 423: Operating Systems Design 21

  22. History: Example Policies • Allocate 12K block • Red is allocated 8K • Green is free 12K 26K 8K 20K Last allocation 8K 20K CS 423: Operating Systems Design 22

  23. History: Example Policies • Allocate 12K block • Red is allocated 8K • Green is free 12K 26K 8K Best Fit 20K Last allocation 8K 20K CS 423: Operating Systems Design 23

  24. History: Example Policies • Allocate 12K block • Red is allocated 8K • Green is free 12K Worst Fit 26K 8K Best Fit 20K Last allocation 8K 20K CS 423: Operating Systems Design 24

  25. History: Example Policies • Allocate 12K block • Red is allocated 8K • Green is free 12K Worst Fit 26K First Fit 8K Best Fit 20K Last allocation 8K 20K CS 423: Operating Systems Design 25

  26. History: Example Policies • Allocate 12K block • Red is allocated 8K • Green is free 12K Worst Fit 26K First Fit 8K Best Fit 20K Last allocation 8K Next Fit 20K CS 423: Operating Systems Design 26

  27. History: Summary Fixed Overlay Relocation Partitions • No multi- • Supports multi- • No internal programming programming fragmentation • Internal • Introduces support fragmentation external fragmentation CS 423: Operating Systems Design 27

  28. Virtual Memory ■ Provide user with virtual memory that is as big as user needs ■ Store virtual memory on disk ■ Cache parts of virtual memory being used in real memory ■ Load and store cached virtual memory without user program intervention CS 423: Operating Systems Design 28

  29. Paging Page Table VM Frame Memory 1 2 3 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 29 CS 423: Operating Systems Design

  30. Paging Request Page 3… Page Table VM Frame Memory 3 1 2 3 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 30 CS 423: Operating Systems Design

  31. Paging Request Page 1… Page Table VM Frame Memory 3 1 1 2 3 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 CS 423: Operating Systems Design 31

  32. Paging Request Page 6… Page Table VM Frame Memory 3 1 1 2 6 3 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 CS 423: Operating Systems Design 32

  33. Paging Request Page 2… Page Table VM Frame Memory 3 1 1 2 6 3 2 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 CS 423: Operating Systems Design 33

  34. Paging Request Page 8. Swap Page 1 to Disk First… Page Table VM Frame Memory 3 1 1 2 6 3 2 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 CS 423: Operating Systems Design 34

  35. Paging Request Page 8. … now load Page 8 into Memory. Page Table VM Frame Memory 3 1 8 2 6 3 2 4 1 2 3 4 Virtual Memory Stored on Disk 1 2 3 4 5 6 7 8 CS 423: Operating Systems Design 35

  36. Page Mapping Hardware Virtual Memory Virtual Address (P,D) Page Table P P D 0 D 1 4 Contents(P,D) 0 1 P → F 1 0 Physical Memory 1 F D F Physical Address (F,D) D Contents(F,D) CS 423: Operating Systems Design 36

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend