Presentation is loading. Please wait.

Presentation is loading. Please wait.

VIRTUAL MEMORY Virtual Address Space. In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating.

Similar presentations


Presentation on theme: "VIRTUAL MEMORY Virtual Address Space. In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating."— Presentation transcript:

1 VIRTUAL MEMORY Virtual Address Space

2 In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating systems such as OpenVMS, UNIX, Linux, and Windows NT.address spacememory operating systemsOpenVMSUNIXLinux Windows NT This is beneficial for different purposes, one is security through process isolation. An address generated by the process is called logical address (virtual address) and it is mapped to the virtual address space.process isolationlogical address Source: Wikipedia

3 Page translation in books You write a manuscript that is 325 lines long. You give it to a publisher and they publish it in a book that has pages with 32 lines each. Example) If you wanted to find line 135 in your manuscript and you have a copy of your book, where would the line be (assuming the first page is page 0 and the first line on each page is line 0)? Answer) use page translation Page = RoundUp(135/32) - 1 = page 4 (the 5 th page) Offset into the page = 135 mod 32 = 7 (the 8 th line) So it is on page 4, then go to line 7.

4 Section Table for a Process

5

6 Page table for a process

7 Memory picture

8 Paging/Segmented System

9

10 Fragmentation In computer storage, fragmentation is a phenomenon in which storage space is used inefficiently, reducing capacity and often performance. Fragmentation leads to storage space being "wasted", and the term also refers to the wasted space itself.computer storage Source: wikipedia

11 Minimizing Fragmentation

12

13 Address Translation

14 Questions on address translation

15 Storage selection for segments/pages Best Fit Find the open block of consecutive page frames in MM that best fits the storage incoming storage location. Advantages: Finds tightly fitted locations which will allow large open consecutive blocks for larger processes that may come in later Disadvantages: - Must check all open blocks of page frames which will take processing time First Fit Find the open block of consecutive page frames in MM that first fits (starting from the beginning of memory to the end) Advantages: Does not need to check all available spaces, since as soon as the first on is found. Worst fit Find the open block of consecutive page frames in MM that worst fits (biggest block of available free page frames) storage the incoming storage location. Advantages: Finds tightly fitted locations which will allow large open consecutive blocks for larger processes that may come in later Disadvantages: - Must check all open blocks of page frames, which will take processing time.

16 Example: contiguous storage

17 Page Replacement Suppose the OS allocates a fixed number of page frames to a process. If a page from a process is referenced by the process, and it is not currently in memory (this is called a page fault) then a page frame from that process must be selected for removal so the newly referenced page can be put in memory. Which page frame should be selected? Local Replacement When a process needs to bring in a page to memory, the page selected for removal is chosen from the set of pages currently in memory for that same process. Global Replacement When a process needs to bring in a page to memory, the page selected for removal is chosen from the set of all pages currently in memory for any process.

18 First or Last in First Out FIFO (First In First Out) Method: Select the frame that has been in MM the longest and remove it to make room. Implementation: maintain a linked list of all pages currently in MM and remove the page that is pointed to by the head of the linked list LIFO (Last In First Out) Method: Select the frame that has been in MM the shortest and remove it to make room. Implementation: maintain a linked list of all pages currently in MM and remove the page that is pointed to by the tail of the linked list.

19 Statistics based (Least Recently used) LRU (Least Recently Used) Method: Select the frame that has been referenced the least recently of all frames in MM. Implementation: Maintain a linked list of all pages currently in MM and each time a page is referenced, move the page to the front of the linked list.

20 Not Used Recently NUR (Not Used Recently) Method: Select the frame that has been referenced the somewhat least recently of all frames in MM. This method is that same idea as LRU but the implementation is much simpler. Implementation: Maintain an array of bits for each page, when a page is referenced, set the bit to 1. At the time when a page reference will set all bits to 1 (meaning every page in MM has a bit of 1) then set all reference bits to zero to start the whole reference recording over. At the time of removal selection, pages that have not been referenced recently will have the reference bit set to 0.

21 Second Chance Method: Same as NUR but with 2 bits. At the time when a page is selected, it is given a second chance, the second chance bit is turned on and it not selected for removal. Implementation: Maintain 2 arrays of bits for each page, just like the NUR but when a page is selected, check if the second chance bit is set, if not, set it, and skip over this process an continue the selections process.

22 Optimal Page Replacement Optimal Method: Look into the future at the pages that will be referenced, and of all the pages currently in memory, select the page that’s next reference will be the furthest in the future. Implementation: Predict the future. The OS must know the exact sequence of referenced that the process will make. Not feasible if the program has if…then…else statements. Possible if the process is a straight process without decisions. Comment: Although this is not realistic to implement, it is the benchmark to check other algorithms against. That is, if the optimal algorithm produces x page faults, you would compare other algorithms against x.

23 Example: page reference string Consider a process in MM where the OS has given the process 3 page frames of MM to process out of but the process has a total of four pages. When a process is running, the list of pages referenced in order is called the reference string for the process. Suppose the reference for this process is 1,2,3,4,3,4,2,1,3,4 and the following page replacements are used.

24 Example using FIFO

25 Example using LIFO

26 Example using LRU

27 Example using Optimal

28 Working Set (see queuing theory) The working set principle take into account that whichever page replacement algorithm used, to maximize overall throughput, the goal is to have the processor(s) running as close to 100% of the time. A state where all processes are waiting for the disk drives for a page and none are “ready to run” should be avoided.


Download ppt "VIRTUAL MEMORY Virtual Address Space. In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating."

Similar presentations


Ads by Google