7.3 Virtual Memory


Virtual memory is a technique that allows the execution of processes that may not be completely in memory. All applications actually run in this physical memory. Usually this main memory is not enough to hold multiple applications concurrently. So the computer gives the application the impression that it has more memory than actually exists. This concept is called virtual memory. Virtual memory does not physically exist on a memory chip but it is implemented by the operating system in order to permit multitasking. The purpose of the virtual memory is to use the hard disk as an extension of RAM. So the operating system using some amount of disk space as if it were real memory. Virtual memory can be implemented by a technique called paging. This technique is specified as follows:
The main memory is divided into fixed size blocks and programs are divided into the same size blocks.
Suppose that there are some programs are running and need memory. The operating system determine
which program is using what portions of memory and allocating each program the amount of memory
that it needs.
If the programs need more memory and there is not enough memory available to satisfy a request of a
program, then the operating system may sweeps out a program's memory by writing the contents to disk
and then allocated to the program making the request.
When the program needs the swapped out memory back the operating system sweeps in the memory
by reading it back from the disk.

7.3 Virtual Memory


The area in the hard disk that is used as a virtual memory is called page file, and the operating system
uses a program called virtual memory manager (VMM) to manage this process.



Figure of a virtual memory