Virtual memory in Operating system examples 2022


Virtual memory in Operating system examples

Virtual Memory

Virtual memory is a technique of using secondary memory as a part of primary memory. It is used when a process does not fit into the secondary memory or the size of the main memory is too short and we want to run a larger process. It allows us to execute large programs than the size of the main memory.

Example

 Let us suppose we have a primary device of Size 8 GB and we want to execute a process that is about 12 GB. In this condition, some parts of the process load into the memory which we need to implement first, and the remaining part of the process will be loaded into the secondary storage which is served as virtual memory.

Why use Virtual Memory

Virtual memory is used when the size of the main memory is limited than the size of the processor when the space is not available into the main memory that a process is required for its execution.

How Virtual Memory Works

Let us suppose the size of the available main memory is 1 GB and I want to run a process whose size is 4 GB.  In This case, the process is divided into the pieces 1 GB is loaded into the main memory and the remaining part that is 3 GB will be loaded into the secondary storage that is served as virtual memory.  The part of remaining part of the process that is loaded into the secondary storage will be swapped in when it is required or when the space is available into the main memory.

When a part of the process is required to execute and it is not into the main memory Operating system search this part into the secondary memory that is served as virtual memory and load it into the main memory. If the space is not available into the main memory Operating system to Deallocate (swap out) space first that is occupied by the process that completed their execution and then this space is allocated (swap in) to the process that is coming from the main memory. It helps us to execute more processes simultaneously.
Virtual memory in Operating system examples 2022

What should be the size of Virtual memory

By default, windows use boot partition as virtual memory it is recommended to set the size of paging file 1.5 times than the size of RAM (Main Memory).

Corrections are welcomed

Please comment on your suggestion in the comment box 

Post a Comment (0)
Previous Post Next Post