Presentation is loading. Please wait.

Presentation is loading. Please wait.

Student : Yan Wang student ID:

Similar presentations


Presentation on theme: "Student : Yan Wang student ID:"— Presentation transcript:

1 Student : Yan Wang student ID: 104698
Virtual Memory Student : Yan Wang student ID:

2 Why Do We Need Virtual Memory?
* 07/16/96 Why Do We Need Virtual Memory? Storage allocation has always been an important consideration in computer programming - Cost - Space - Avoid overlay system - More and more complex programs make it difficult for programmer to handle the machine Storage allocation has always been an important consideration in computer programming cost (due to the high cost of main memory and relative abundance and lower cost secondary storage) Space (program code and data required for execution of a process must reside in main memory to exeuied, but main memory may not large enough to accomdate the needs of an entire process) Avoid overlay system (early computer programmers divided programs into sections that were transferred into main memory for a period of processing time. As the program proceeded, new section moved into main memory and replaced sections that were not needed at that time. In this early era of computing, the programmer was responsible for devising this overlay system) More and more complex programs, the programmer became difficult to to hander the machine. (As higher level languages became popular for writing more complex programs and the programmer became less with the machine, the efficiency of complex programs suffered from poor overlay systems.The problem of strage allocation became more complex) 2 *

3 Overview to Solve Storage Allocation
Static allocation memory resource and the memory reference can be predicted Dynamic allocation Opposite to static allocation. Relies on memory usage ,actual program needs, not on predicting memory needs Shortcomings of static and dynamic allocations 3

4 4 What is Virtual Memory? Logical memory
Uses secondary storage to increase the processor’s main memory Unified view for processes Technique that allows large processes to run Components: mapper, associative memory, page table and replacement policies 4

5 5 What does mapper do? Mapper
* 07/16/96 What does mapper do? Mapper Part of operating system that translates the logical page number into the physical page frame number where the main memory holds page The page table reveals that page is not resident in the main memory, the mapper issues a page fault to the operating system Execution is suspended on the process until the desired page can be read in from the secondary store and placed in main memory The mapper function must be very fast 5 *

6 6 Associative Memory Also called translation lookside buffers (TLBs)
* 07/16/96 Associative Memory Also called translation lookside buffers (TLBs) More efficiency to access the page Table. A special high-speed memory registers. Only the most frequently accessed pages are represented by associative memory A key and a value 6 *

7 How Associative Memory Works ?
* 07/16/96 How Associative Memory Works ? The key to associative memory registers checks the logic address when it enters If they match,the value corresponding to the key is output. Then it returns the value that contains two things: 1. The physical address of the logical page 2. The access code to indicate its presence in main memory, Example 7 *

8 8 Page Table Implementation of swapping in virtual memory
* 07/16/96 Page Table Implementation of swapping in virtual memory Each address space within the system is associated with a page table and a disk map Two tables describe an “entire address space” Page table Disk map 8 *

9 Page Table (continue) If the P flag is set, the page is currently in the main memory. Its location in memory is determined by the F value. F is the physical address number If the P flag is off, the address mapper will generate a page fault If a process attempts reference to the page, the page fault handler will use the disk map to the location of page on the disk and swap it into the main memory 9

10 Virtual Memory Components
Live demo A Java applet to show the components of Virtual Memory on the web from George Mason University. 10

11 Multi Level Page Table For large processes, the page table needs a lot of room in the memory so that it won’t squeeze the process out of the memory. One solution is to organize page tables into a multilevel hierarchy A part of page table in the main memory 11

12 12 Replacement Policies First In First Out ( FIFO)
Least Recently Use ( LRU) Last In First Out ( LIFO) Least Frequently Used ( LFU). Optimal (OPT or MIN) 12

13 LRU Replacement Policy
The policy is to replace the one that has not been referenced for the longer time The policy assumes that the recently used one will be the one immediately used in the future. The operating system keeps track of when each page was referenced by recording the time of reference or by maintaining a stack of reference Example algorithm of Least Recently Used 13

14 LRU Replacement Algorithm(cont.)
14

15 15 Conclusion Virtual memory is a very useful tool.
Main problems of virtual memory 1. Manage allocation 2. Manage relocation 3. Manage replacement policies in the memory. 15


Download ppt "Student : Yan Wang student ID:"

Similar presentations


Ads by Google