Virtual memory in OS

What is Virtual Memory?

Virtual Memory is a space where large programs can store themselves in form of pages while their execution and only the required pages or portions of processes are loaded into the main memory. 
This technique is useful as large virtual memory is provided for user programs when a very small physical memory is there.
Virtual memory Is a storage scheme that provides user an illusion of having a very big main memory. This is done by treating  a part of secondary memory as the main memory .
Instead of loading one big process in main memory, operating system loads the different parts of more then one process in the main memory.
By doing this, the degree of multiprogramming will be increased  and therefore CPU utilisation will be also increased.
In real scenarios, most processes never need all their pages at once, for following reasons :
  • Error handling code is not needed unless that specific error occurs, some of which are quite rare.
  • Arrays are often over-sized for worst-case scenarios, and only a small fraction of the arrays are actually used in practice.
  • Certain features of certain programs are rarely used.
  • Less number of I/o would be needed to load or swap each user program into main memory. 
  • Each user program could take less physical memory ,more program could run at the same time with a corresponding increase in CPU utilisation and throughput .


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.

Disadvantages of Virtual Memory

  1. The system becomes slower since swapping takes time.
  2. It takes more time in switching between applications.
  3. The user will have the lesser hard disk space for its use.

Demand Paging

  • Demand Paging is a popular method of virtual memory management. In demand paging, the pages of a process which are least used, get stored in the secondary memory.
  • A page is copied to the main memory when its demand is made or page fault occurs. There are various page replacement algorithms which are used to determine the pages which will be replaced.
  • Virtual memory is implemented using  demand paging and demand segmentation.





  1. If CPU try to refer a page that is currently not available in the main memory, it generates an interrupt indicating memory access fault.
  2. The OS puts the interrupted process in a blocking state. For the execution to proceed the OS must bring the required page into the memory.
  3. The OS will search for the required page in the logical address space.
  4. The required page will be brought from logical address space to physical address space. The page replacement algorithms are used for the decision making of replacing the page in physical address space.
  5. The page table will updated accordingly.
  6. The signal will be sent to the CPU to continue the program execution and it will place the process back into ready state.
Hence whenever a page fault occurs these steps are followed by the operating system and the required page is brought into memory.
Thank you viewers...
This is distributed by soumy Sinha..


Comments

Popular posts from this blog

INTRODUCTION OF DBMS

Introduction of Digital computer

DEVELOPED, UNDEVELOPED AND DEVELOPING ECONOMIES || LIST, GDP, UNEMPLOYMENT