Virtual Memory-1
Virtual Memory-1
Virtual memory is a technique that allows the execution of process even when
the logical address space is greater than the available physical memory space.
For example : if a program size or logical address space is 15MB but the
available memory space is only 12MB, then the 12MB of the program is loaded
in main memory and the remaining 3MB is loaded in secondary memory. When
the 3MB is needed for the execution then swapping process is done. A 3MB of
the program is swap-out to secondary memory so that the requested 3MB is
swap-in to the main memory.
Advantage of virtual memory
Efficient main memory utilization by allowing partial programs to be loaded
and so more programs could run at the same time.
Efficient CPU utilization and better throughput.
DEMAND PAGING
Demand aging is the application of virtual memory. Virtual memory is
commonly implemented by demand paging.
It is the combination of paging and swapping.
The criteria of this scheme is “ a page is not loaded in to the main memory from
secondary memory until it is needed” , that is only on demand a page is loaded
in to main memory. This is called demand paging
For example: if a job size is 24KB and its page and frame size is 4KB then the
logical space is divided into 6 pages but the available memory space is only
12MB , i.e 3 frames are available and the remaining 3 pages are loaded in the
secondary storage device. Whenever these pages are on demand the OS swap-in
those pages in to main memory
PAGE FAULT
When the processor need to execute a particular page and that page is not available
in main memory this situation is said to be ‘page fault’. When the page fault is
happened the page replacement will be needed. Page replacement means select a
victim page in the main memory, replace that page with the required page from the
backing store
PAGE REPLACEMENT ALGORITHM
Page replacement algorithms are the technique which decides which memory
page to swap out, when a page of memory needs to be allocated.
Paging happens whenever a page fault occurs. When the page fault is happened
the page replacement will be needed.
The page replacement means select a victim page in the main memory, replace
that page with the required page from the backing store (disk).
This algorithm is easy to implement and replace page by looking backward in time
rather than forward as in optimal
Criteria of this algorithm:
“Replace a page which has not been used for the longest period of
time in main memory is selected for replacement.”
LRU replacement associates with each page the time of that page's last use.
o The FIFO algorithm uses the time when a page was brought into
memory;
o The OPT algorithm uses the time when a page is to be used.
o In LRU replace the page that has not been used for the longest period
of time.
Example:
Page with the smallest count is the one which will be selected for
replacement.
This algorithm suffers from the situation in which a page is used heavily
during the initial phase of a process, but then is never used again and
remains in memory because it has the largest reference count.
Most frequently Used (MFU) algorithm (count based)
MFU replacement algorithm is based on the argument that the page with the
smallest count was probably just brought in and has yet to be used most.
Solution to the LFU problem.
MFU and LFU are the most expensive algorithms