Virtual Memory in Operating System

Virtual Memory in OS img

Virtual Memory in Operating System

The Primary Memory (such as RAM) is expensive and limited in the system, however, the secondary memory is cheaper and large and can be extended easily. Virtual memory concept offers unique solution for apparent primary memory expansion, in this we secondary memory can be accessed as if it were the part of the main memory. One of the techniques to extend this is to transfer the inactive RAM storage to secondary storage temporarily. 

Virtual Memory

It essentially with the help of Operating System, and the software and hardware installed on the system, helps to access more memory than what actually is installed on the system, by transferring data from the RAM to the to disk.

  • Primary Memory – RAM
    • The entry application or program in the system first loads into the RAM (Random Access Memory), this makes the application faster to load and access, than the secondary memory and is readily available
  • Secondary Memory – Hard Disk and Storage devices
virtual memory in os

In what Form Virtual Memory is stored?

The memory is stored in form of units that we call as pages in Operating System, these are atomic units where large programs can be stored.

For a program there may a large set of storage in physical addresses. All of those are not required to be loaded as only certain programs are used, for an application.

Imagine playing a game like FIFA on your desktop. The game itself maybe stored in hard disk (secondary device), but while playing all the installed space would not be loaded into RAM. But only certain programs that are required for the application (Game) to run .

Benefits of having Virtual Memory

  1. Large programs can be written, as virtual space available is huge compared to physical memory.
  2. Less I/O required, leads to faster and easy swapping of processes.
  3. More physical memory available, as programs are stored on virtual memory, so they occupy very less space on actual physical memory.

How it works?

The Addressing scheme that is provided by the system and total available space in the secondary storage device is what limits the size of the virtual storage, not the size of Primary storage as RAM. If the storage is unlimited (as in the case of cloud systems), some applications can behave as if they have unlimited primary memory available to them.

We use both of these of the system –

  • Hardware
  • Software

Both work together to map virtual Addresses to physical addresses, with the help of MMU, i.e. Memory Management Units. 

  1. What system or uses sees are essentially logical addresses not the actual physical address. These logical addresses may be translated dynamically at the load, execute or compile time. Depending on the requirement or definition of the system.
  2. In actual scenario, the processes and resources stored in the memory are not continuous, however are broken down and are scattered and stored at various places in the physical memory. With the help of dynamic run-time address translation and page or segment table we can easily do this. That even though they actually may be scatterly stored but to the user it looks like they are stored contiguously.

Demand Paging

Virtual memory concept is also swiftly enabled by demand paging. Read more about Demand Paging here

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription