Virtual Memory in Operating System.
Virtual Memory in Operating System.
• The system can move those that are dormant into virtual memory
until needed.
What is Virtual Memory in OS?
• Imagine the physical memory of your computer in the front section of
your wardrobe.
• You keep the clothes that you would like to wear in front so that they are
handy.
• To make it easy to search, you may keep a note of where you have
placed what clothing items.
•
• Such a mapping mechanism is called a page table.
What is Virtual Memory in OS?
• Virtual memory is a part of the system's secondary memory that acts
and gives us a feel as if it is a part of the main memory.
• To mitigate this issue, some data stored in RAM that isn't being
actively used can be temporarily relocated to virtual memory.
What is Virtual Memory in OS?
• This frees up RAM space, which may then be utilized to store data
that the system will need to access.
• The operating system will then allocate 490 MB of virtual memory and
manage it with an application called the Virtual Memory Manager
(VMM).
How Virtual Memory Works?
• As a result, the VMM will generate a 490 MB file on the hard disc to
contain the extra RAM that is necessary.
Paging
• Paging is a virtual memory technique that separates memory into
sections called paging files.
• By moving unused files into its hard drive, the computer frees its RAM
space for other memory tasks and ensures that it doesn't run out of
real memory.
Demand Paging
• Imagine that you are scrolling through an e-commerce platform and like
some clothes.
• However, since you don't have space in your wardrobe, you save it in
your wishlist and decide to buy them only when needed.
• In demand paging, the pages of a process which are least used, get
stored in the secondary memory.
• When a context switch occurs, the operating system does not copy any
of the old program’s pages out to the disk or any of the new program’s
pages into the main memory Instead.
• it just begins executing the new program after loading the first page
and fetches that program’s pages as they are referenced
Demand Paging
• While executing a program, if the program references a page which is not
available in the main memory because it was swapped out a little ago, the
processor treats this invalid memory reference as a page fault and
transfers control from the program to the operating system to demand
the page back into the memory.
Demand Paging
• In the above image, when Program A finishes executing, it swaps out
the memory that was in use.
• As part of this process, the computer uses page tables, which translate
virtual addresses into the physical addresses that the computer's
memory management unit (MMU) uses to process instructions.
• When the user performs a task, the OS searches its RAM for the
processes to conduct the task.
• We may manage many processes inside the same RAM by using swaps.