0% found this document useful (0 votes)
2 views

Virtual Memory

Virtual Memory is a technique that allows programs to execute using pages stored in secondary memory, providing the illusion of a larger main memory than physically available. It utilizes demand paging to load only necessary pages into main memory, while less-used pages are swapped out to free up space. The need for virtual memory arises when a system requires more memory than is physically installed, allowing for efficient process management and execution.

Uploaded by

santar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Virtual Memory

Virtual Memory is a technique that allows programs to execute using pages stored in secondary memory, providing the illusion of a larger main memory than physically available. It utilizes demand paging to load only necessary pages into main memory, while less-used pages are swapped out to free up space. The need for virtual memory arises when a system requires more memory than is physically installed, allowing for efficient process management and execution.

Uploaded by

santar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Virtual Memory

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 a large virtual memory is
provided for user programs when a very small physical
memory is there. T
• Virtual memory is a technique that allows the execution
of processes that are not in the physical memory
completely.
• Virtual Memory mainly gives the illusion of more
physical memory than there really is with the help of
Demand Paging.
• In an Operating system, the memory is usually stored in
the form of units that are known as pages.
Virtual Memory

• 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.
• In this scheme, User can load the bigger size
processes than the available main memory by
having the illusion that the memory is available to
load the process.
• Instead of loading one big process in the main
memory, the Operating System loads the different
parts of more than one process in the main
memory.
How Virtual Memory Works?
• In modern word, virtual memory has become
quite common these days.
• In this scheme, whenever some pages needs to be
loaded in the main memory for the execution and
the memory is not available for those many pages,
then in that case, instead of stopping the pages
from entering in the main memory,
• the OS search for the RAM area that are least
used in the recent times or that are not referenced
and copy that into the secondary memory to make
the space for the new pages in the main memory.
• Since all this procedure happens automatically,
therefore it makes the computer feel like it is
having the unlimited RAM.
Need of Virtual Memory

• Following are the reasons due to which there is a


need for Virtual Memory:
• In case, if a computer running the Windows
operating system needs more memory or RAM
than the memory installed in the system then it
uses a small portion of the hard drive for this
purpose.
• Suppose there is a situation when your computer
does not have space in the physical memory, then
it writes things that it needs to remember into the
hard disk in a swap file and that as virtual
memory.
Demand Paging
• The basic idea behind demand paging is that
when a process is swapped in, its pages are not
swapped in all at once.
• Rather they are swapped in only when the
process needs them(On-demand).
• Initially, only those pages are loaded which will
be required by the process immediately.
• The pages that are not moved into the memory,
are marked as invalid in the page table.
• For an invalid entry, the rest of the table is empty.
In the case of pages that are loaded in the
memory, they are marked as valid along with the
information about where to find the swapped out
page.
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
Demand paging:
Page Replacement
• As studied in Demand Paging, only certain pages of a
process are loaded initially into the memory.
• This allows us to get more number of processes into
memory at the same time.
• but what happens when a process requests for more
pages and no free memory is available to bring them in.
• Following steps can be taken to deal with this problem :
• Put the process in the wait queue, until any other
process finishes its execution thereby freeing frames.
• Or, remove some other process completely from the
memory to free frames.
• Or, find some pages that are not being used right now,
move them to the disk to get free frames.
• This technique is called Page replacement and is most
commonly used. We have some great algorithms to
carry on page replacement efficiently.
Thrashing
• A process that is spending more time paging
than executing is said to be thrashing.
• In other words, it means, that the process
doesn't have enough frames to hold all the
pages for its execution, so it is swapping pages
in and out very frequently to keep executing.
• Sometimes, the pages which will be required
in the near future have to be swapped out.
Page Replacement Algorithms
Virtual memory in Windows XP

You might also like