If you’ve noticed guides on virtual memory, this guide will help. Virtual memory is a feature of the operating system that allows a computer to compensate for a lack of physical memory by transferring pages of data from memory to hard disk space. This process is temporary and is a combination of RAM and hard disk space.
A computer can address more memory than is physically installed on the system. This extra memory is called virtual memory and is a portion of the hard disk that is configured to mimic the computer’s RAM.
The main apparent advantage of this scheme is that programs can be larger than physical memory. Virtual memory has two purposes. First of all, we can expand the use of physical memory by using the hard drive. Secondly, we can have memory protection because every virtual address is converted to a physical address.
These are situations where you do not need to completely load the entire program into main memory.
User-written error handling routines are used only if an error occurs in data or calculations.
Some parameters and functions of the program may be rarely used.
Many tables are assigned a fixed address space, although only a small portion of the table is actually used.
Ability to runHaving a program that is only partially in memory negates many of the benefits.
Less I / O is required to load or replace each user program in memory.
The program is no longer limited by the available physical memory.
Each user program can require less physical memory and more programs can run concurrently, resulting in a corresponding increase in CPU usage and bandwidth.
Modern general purpose microprocessors, the memory management unit or MMU, are built into the hardware. The role of the MMU is to translate virtual addresses into physical addresses. A basic example can be found below –
Virtual memory is usually implemented through paging on demand. This can also be implemented in a segmentation system. Requirement segmentation can also be used to provide virtual memory.
What Is Paging On Demand?
The basic idea behind paging a request isis that when you outsource a process, not all of its pages are paginated at the same time. Rather, they are exchanged only when the process needs them (on demand). This is known as lazy exchange, although pager is a more accurate term.
Only those pages that immediately require a process are loaded initially.
Pages not moved into memory are marked invalid in the page table. If the entry is invalid, the rest of the table is empty. Pages loaded into memory are marked valid with information about where the page is being exchanged.
If a process requires a page that is not loaded into memory, a page break is triggered and the following steps are performed:
- The memory address requested by the process is first checked to verify the request made by the process.
- If it turns out to be invalid, the process will end.
- If the process request is valid, there is a free frame, possibly from the free list, into which the requested page is being moved.
- A new operation is planned By moving the required page from disk to the specified location. (This usually causes the process to hang while waiting for I / O so that another process can use the CPU in the meantime.)
- On completion of the I / O operation, the process page table is updated with a new frame number and an invalid bit is replaced with a valid one.
- The statement that caused the page error now needs to be restarted from the beginning.
There are cases when the page is not initially loaded into memory. Pages are only loaded when requested by the process, resulting in page errors. This is called pure on-demand paging.
The only major issue with on-demand paging is that the process starts over after loading a new page. This is not a big deal for small programs, but it has a significant impact on the performance of large programs.
Here are some important ways to replace pages