Virtual Memory
From its inception, computers as always been hardware and software working together. In managing the memory of the computer, we see this same principle of hardware and software working together. Computers come with two main types of memory - primary memory and secondary memory. Through the operation system (OS), we get a whole new concept of memory called virtual memory (VM). According to Wikipedia, “Virtual memory is a system where all physical memory is controlled by the operating system”. The basic idea is to simulate more memory than is physically available on a computer. This virtualization makes it possible to run multiple programs at the same time. In addition, we can load programs that requires more memory than is physically available on the computer.??
How does virtual Memory extend memory?
Virtual memory gives the ability to run programs larger than the machine’s physical memory by rapidly moving pieces back and forth between RAM and disk (Tanenbaum & Bos, 2015). In this approach, the operating system (OS) is in control, and processes have no direct communication with the hardware. The basic idea behind virtual memory is that each program has its own address space, which is broken up into chunks called pages. By using this technique applications are relieved from the responsibility of managing memory, there is memory isolation that provides better security, and the computer can reference more memory than physically present.
The techniques available for the implementation of virtual memory are Demand Paging or Demand Segmentation. The general idea behind Demand Paging and how virtual memory extends the memory available to processes is to maintain a mapping table with the address space mapping to physical memory. With virtual memory, each program address gets mapped to a RAM Address. Once the system runs out of Physical RAM, the oldest process is placed on disk storage. This process is called a page out. The new program then takes the address space of the process that was placed on disk storage. This cycle can be repeated as many times as needed and gives the program the impression that there’s unlimited amount of memory available.
Drawbacks of a page fault
Of course, with programs getting swapped-in and out of memory there are a few drawbacks. One of these problems that must be handle is Page Fault. A Page Fault occurs when a program requests an address that is not in the current set of memory resident (Marcho, 2019). When this occurs, the program must be placed in a waiting state until the OS find “the specific page and restore it to physical memory”. You can see the draw back. The page needs to be fetched from secondary memory to primary memory. While the transfer will only take a few milliseconds to restore to primary memory, this is a draw back and the performance will be impacted because it could take millions of cycles to restore the page to primary memory.
Virtual memory is a popular topic. There are many articles and videos out there that covers the subject very well. (Black-Schaffer, 2014) YouTube video does a good job explaining the idea of virtual memory. This video was useful in getting to understand the subject. The reason why I find it so helpful: The video was short, the video started by showing the problem with RAM by itself, the video then explains virtual memory, and gives a concise example of how memory virtualization is accomplished. In comparison, (Karaniroy, n.d.) article explains virtual memory well and provides good details. While both sources give a good and concise definition of virtual memory and the implementation, the (Karaniroy, n.d.) article provides a good explanation of Page Faults. Plus, I appreciate the clarification given that while Page Faults may sound like an error, “page faults are common and are part of the normal way computers handle virtual memory”. ?
So (Black-Schaffer, 2014) did a good job explaining the subject of virtual memory, but (Karaniroy, n.d.) covered all the information needed to get a reasonable understanding of virtual memory and Page Faults. After going through both articles and the textbook, I do get the basic ideas, but I still need to do some more research on the subjects, especially, Demand Segmentation because none of my references looked at the pros and cons of Demand Segmentation over Demand Paging.
领英推荐
In conclusion, when it comes to computer memory, it’s faster to rely upon RAM, but having virtual memory as a fallback when RAM is filled is a good design because virtual memory creates the illusion that you have more memory than is physically available. This allows you to run more programs at the same time and to use more than your total amount of physical RAM available to run large programs. The fact that virtual memory eliminates external fragmentation and do not allow processes to interfere with each other address space is also a great benefit.
?Reference:
Black-Schaffer, David. Virtual Memory: 3 What is Virtual Memory?. (July 14, 2014). Retrieved from, https://www.youtube.com/watch?v=qlH4-oHnBb8
Karaniroy, Devi. Explain Virtual memory and Page Faults. (.n.d.). Retrieved from,?https://www.ques10.com/p/25246/explain-virtual-memory-and-page-faults/
Marcho, Craig. The Basics of Page Faults. (Mar 15, 2019). Retrieved from, https://techcommunity.microsoft.com/t5/ask-the-performance-team/the-basics-of-page-faults/ba-p/373120
Tanenbaum, A. S, & Bos, H. (2015). Modern Operating Systems (4th ed.). Pearson Education. Inc.
Wikipedia. Computer memory. (n.d.). Retrieved from https://en.wikipedia.org/wiki/Computer_memory