Topics we cover in this article:
- What is virtual memory?
- Why virtual memory?
- Explanation using neat diagram
- Where we use virtual memory?
- What is Demand paging?
- Advantages and disadvantages of machine learning.
In this article, we will clearly know about virtual memory and how it works and why we are using, and we know the advantages and disadvantages of using virtual memory.
What is virtual memory?
In Virtual memory we able to store immense programs within the sort of pages whenever the execution requires pages or processors are loaded into main memory. This method is very useful when user is having very small physical memory then the virtual memory concept comes into the picture.
And we can also understand in a simple way that computer is having large amount of memory than physically that is in the system, and this extra amount of memory is called virtual memory
Before going to learn why we use virtual memory we basically must know about memory and it is nothing but storing information temporarily or permanently here temporarily in the sense suppose you are working on a WordPad suddenly power losses and information will miss nothing but volatile.
Why virtual memory?
The main reason why we use virtual memory is we can execute our program is larger than physical memory and we can also extend our physical memory using disk along with that it will also protect the memory because each virtual address is translated into physical address.
Now we will see how virtual address is translated into physical address:
Now, this translation job will be done by MMU nothing but memory management unit.
Most important feature that virtual memory provides is all the programs that you want to execute is no need of loading into main memory and developed for kernel of operating systems. we can load and execute programs simultaneously and it allows each program to execute because it is having infinite memory and it is more cost effective If we buy any additional RAM.
Explanation using neat diagram about virtual memory:
Here the page table holds the information about page loaded to which frame.
Firstly, all the pages are stored in the logical memory and marked as A-H and all those 8 pages are available in the disk. Suppose I am looking for A that is page no is 0 loaded into Frame no 4 and again if you see C that is loaded into frame no and page no 5 that is F loaded into frame no 9. out of 8 pages only 3 pages are loaded into the computers memory whenever it calls for page which is not in the memory and that page must be brought and load into memory is no issue, but main memory is available for only 3 pages to have the 4th page available then we must go for page replacement concept nothing but page replacement algorithm.
By observing the above process, we can easily know that no need of loading all programs into main memory for execution we can load a certain page on to the computers frame whenever it has been asked for so that the effective loading will be minimum. Finally, user feel the smooth execution thinks that he is working in huge space, but the real scenario is working in a very limited amount of space in computers memory because the whole program is not loaded initially that is the reason we call it as virtual memory.
Where we use virtual memory?
Earlier we have learnt that virtual memory is for kernel operating system and mainly it will be useful when software allows programs to execute and the physical memory shortages by temporarily transferring data from RAM to disk then the concept of virtual memory is needed.
Now we will see where actually virtual memory is located and how it works.
By observing this process, you can easily understand where virtual memory is located and what is the use.