Virtual Memory – Advantages and disadvantages
- Virtual memory is a technique of executing program instructions that may not fit entirely in the system memory.
- In this scheme, the programs can be larger than the actual physical memory available. This is because of the fact that the logical memory space available to the program is totally independent of the physical memory space.
- The basic concept of virtual memory is to store instruction & data of a program in the secondary memory and to load them in the main memory when they are required.
- It means it is not necessary to load all of a process into main memory during its execution. Only those portions (page or segments) which are actually being used at any instant need to be present in memory. The rest of program kept in secondary memory. If the flow of execution move to a page that is not in memory, the operating system loads the required page from secondary storage into the memory before execution can proceed. Thus each process can be larger than the available real memory.
- Virtual memory enhances the CPU utilization and throughput by executing as many programs as possible almost simultaneously. Useful in a multitasking operating system, where the main memory divided among several user programs and every program has to compete for its memory requirement.
Virtual memory concept
- The ‘virtual memory concept‘ called so because instead of holding the entire program. The main memory holds only a portion of the program currently executed. As a result it provides virtual effect.
- Thus user has extremely large virtual_memory when only a small physical memory is available.
- Figure shows that logical or virtual memory is large, physical memory limited in size. And does not contain all the pages of a process at any instant of time. Some of the pages on secondary storage and brought into main memory as and when needed.
- Virtual_memory thus separates the user’s logical memory from physical memory.
- Virtual_memory commonly implemented by demand paging and demand segmentation.
- Unlimited address space : A program is no longer constrained by the amount of physical memory that is available. Using virtual_memory user is able to write programs for a very large virtual address space and this simplifies the programmer’s task.
- Increased degree of multiprogramming : With the implementation of virtual memory, each user program occupies less physical memory; as a result more programs can run at the same time. Thus, CPU utilization and throughput increases.
- Reduced I/O : Less I/O needed to load or swap each user program into memory, so each user program will run faster.
Disadvantages of Virtual Memory
- It requires additional hardware support for address translation.
- Another disadvantage of virtual memory is the possibility of thrashing due to excessive paging and page faults.