Main menu

Media Coverage

<div class="small-4 columns">media 1</div>

<div class="small-4 columns">media 2</div>

<div class="small-4 columns">media 3</div>

Reach to Us

Virtual Memory Concept

Virtual Memory | What is virtual memory? | Why virtual memory? | Explanation using neat diagram | Where we use virtual memory? | What is Demand paging? | Advantages and disadvantages of machine learning.

CONTENTS

Topics we cover in this article:

  • What is virtual memory?
  • Why virtual memory?
  • Explanation using neat diagram
  • Where we use virtual memory?
  • What is Demand paging?
  • Advantages and disadvantages of machine learning.
  • Conclusion.

In this article, we will clearly know about virtual memory and how it works and why we are using, and we know the advantages and disadvantages of using virtual memory.

 

 

VIRTUAL MEMORY

What is virtual memory?

In Virtual memory we able to store immense programs within the sort of pages whenever the execution requires pages or processors are loaded into main memory. This method is very useful when user is having very small physical memory then the virtual memory concept comes into the picture.

                          

And we can also understand in a simple way that computer is having large amount of memory than physically that is in the system, and this extra amount of memory is called virtual memory

 

Before going to learn why we use virtual memory we basically must know about memory and it is nothing but storing information temporarily or permanently here temporarily in the sense suppose you are working on a WordPad suddenly power losses and information will miss nothing but volatile.

 

Why virtual memory?

The main reason why we use virtual memory is we can execute our program is larger than physical memory and we can also extend our physical memory using disk along with that it will also protect the memory because each virtual address is translated into physical address.

 

Now we will see how virtual address is translated into physical address:

Now, this translation job will be done by MMU nothing but memory management unit.

 

Most important feature that virtual memory provides is all the programs that you want to execute is no need of loading into main memory and developed for kernel of operating systems. we can load and execute programs simultaneously and it allows each program to execute because it is having infinite memory and it is more cost effective If we buy any additional RAM.

 

Explanation using neat diagram about virtual memory:

 

Here the page table holds the information about page loaded to which frame.

Firstly, all the pages are stored in the logical memory and marked as A-H and all those 8 pages are available in the disk. Suppose I am looking for A that is page no is 0 loaded into Frame no 4 and again if you see C that is loaded into frame no and page no 5 that is F loaded into frame no 9. out of 8 pages only 3 pages are loaded into the computers memory whenever it calls for page which is not in the memory and that page must be brought and load into memory is no issue, but main memory is available for only 3 pages to have the 4th page available then we must go for page replacement concept nothing but page replacement algorithm.

 

By observing the above process, we can easily know that no need of loading all programs into main memory for execution we can load a certain page on to the computers frame whenever it has been asked for so that the effective loading will be minimum. Finally, user feel the smooth execution thinks that he is working in huge space, but the real scenario is working in a very limited amount of space in computers memory because the whole program is not loaded initially that is the reason we call it as virtual memory.

 

Where we use virtual memory?

Earlier we have learnt that virtual memory is for kernel operating system and mainly it will be useful when software allows programs to execute and the physical memory shortages by temporarily transferring data from RAM to disk then the concept of virtual memory is needed.

 

Now we will see where actually virtual memory is located and how it works.

By observing this process, you can easily understand where virtual memory is located and what is the use.

 

Contributor's Info

Created:
0Comment
Virtual Memory | Frame Allocation | Strategies used from Frame Allocation

The concept of virtual memory comes into rescue when the size of the process is very much bigger than the size of the main memory and we are unable to load the entire process into the Main Memory. Therefore, we load a part of the process and run to completion; once that part is over, pull it back and allocate the rest part.

In earlier days, the concept of virtual memory was used only when the size of the process>>the size of the main memory. But later, it is used to take the advantage of the degree of multiprogramming.

  • The Degree of multiprogramming - many processes or a part of many processes possible present in the main memory.

Virtual Memory has introduced many advantages in Operating Systems but not that easy to implement! In simpler words, main memory is divided into several frames and there are many processes to be allocated inside main memory; the main concept behind virtual memory is too see many processes or a part of as many processes possible present in the main memory.

Without the concept of Virtual Memory, several processes cannot share one resource at the same time. For example, several friends sharing food from the same lunchbox. Think “friends” as PROCESSES and “lunchbox” as MAIN MEMORY. Without the advantage of virtual memory, it’s like one person eating from the lunch box alone i.e., the entire process will be present in the main memory which can be run till completion, then move it out and allocate another process and the story goes on...

creenshot (313).png
 

Main Memory is divided into frames; each processes (P1, P2, P3, P4,P5) will be allocated to each frames.

Several processes share same main memory, therefore, it’s important to manage the processes so that each of them gets chance to share. Hence, two algorithms are used to allocate pages into frames accordingly.

 

Both the algorithms have significant impact on the system performance. In order to increase the performance of the system, these algorithms have to be designed and implemented well. Or else it might to lead into problems such as, thrashing.

  • If we allocate no. of frames to a process comparatively less than the no of frames required; this will lead to thrashing which means for every instructions there will be a page fault (desired page not present in main memory). The overall execution time will increase exponentially. Trashing is highly undesirable and avoided as it slows the system performance.

 

1. FRAME ALLOCATION

This algorithm helps us to decide no. of frames to be allocated to any process. There’s always some requirement defined by the process/system architecture.

  • The maximum number of frames required by any process is the size of the process itself.
  • The minimum number of frames required depends on architecture for execution of the instruction

Strategies used from Frame Allocation

1.1. EQUAL ALLOCATION: each number of frames will be equally distributed among processes.  Not very much useful as not every process will require equal number of frames; some process may require extra frames whereas some process may require less number of frames.

                       For example, given no. of frames: 6

                       No. of processes available: 3

                       Therefore, each process will get 2 frames

Main Memory divided into frames in such a way that every processes gets equal no. of frames.

 

1.2 WEIGHTED ALLOCATION: Depending on the size of the processes, number of frames will be allocated accordingly. More number of frames given the process of larger size.

  • It is commonly used as compared to other algorithms.

For example: available processes of size P1: 20 Pages, P2: 30 Pages, P3: 50 Pages

                       Available frames: 10

                      Requirement: P1= 20/100*10=2    (P1+P2+P3:20+30+50=100)

                                              P2= 30/100*10=3

                                              P3=50/100*10=5

Screenshot (318).png

Therefore,P1,P2,P3 will get 2,3,5 no of frames respectively.

 

1.3. PRIORITY ALLOCATION: The processes with higher priority no. gets more frame. If the process with higher priorities wants more frames; then it can forcefully replace processes with lower priorities. Suppose, Process P1 has higher priority than process P2 and requires more frame then P1 pulls out P2 and uses up the frame.

2. PAGE-REPLACEMENT ALGORITHM

Once we allocate the frame to the process, pages are using the main memory. Then when we need a new page which is not available in the main memory, we need to replace any frame already present in the main memory. The page replacement algorithm helps us to decide which page to replace to get lowest page fault rate and this decision has a significant impact on the system performance.

In the main memory ,already pages P1,P2,P3,P4,P5 are allocated. Now a new page P6 has arrived, therefore, we will use page replacement algorithm to decide which page to replace with P6.

 

Strategies used:-

2.1. LOCAL PAGE-REPLACEMENT: Local page replacement strategy works as static allocation. Whenever we need to replace a page from the main memory then we will replace the page only from the frames which are allocated to that particular process without disturbing any other pages of other processes.

2.2. GLOBAL PAGE-REPLACEMENT: This strategy works differently than local page replacement strategy while replacing any page we have to consider everything for replacement, we can consider all the available frames to replace.

Local page-replacement are preferred more than global page-replacement and practically used in most of the operating system.   

Algorithms

There are several algorithms used for page-replacement but the most popular algorithms are:

  • OPTIMAL: It replaces the pages which will not be referred for a very long period of time in future and gives least page faults. It works according to future requirement.
  • LRU (LEAST-RECENTLY USED):- It replaces the page which has been least recently used or has not been referred for a long period of time. It works according to the past.
  • FIFO (FIRST-IN-FIRST-OUT): The name itself says, the first one to be added in the memory will be the first to go.

Contributor's Info

Created:
0Comment
Virtual Memory | Benefits of having Virtual Memory | Disadvantages of having Virtual Memory

Virtual Memory:
1. In the most of the computer system, the physical main memory is not as large as address space of the processor.
2. Suppose user tries to run a program.
3. If the program run by the user does not completely fit into the main memory then the parts of its currently being executed are stored in main memory and remaining portion is stored in secondary storage device such as HDD.
4. When a new part of program is to be brought into main memory for execution and if the memory is full, it must replace another part which is already is in main memory.
5. As this secondary memory is not actually part of system memory, so for CPU, secondary memory is considered as Virtual Memory. 6. Virtual Memory was introduced in the system in order to increase the size the size of memory.
7. Virtual memory is a memory management technique that is implemented using both hardware and software.
8. It maps memory addresses used by a program, called virtual addresses, into physical addresses in computer memory.

Benefits of having Virtual Memory:
1. Large programs can be written, as virtual space available is huge compared to physical memory.
2. Less I/O required, leads to faster and easy swapping of processes.
3. More physical memory available, as programs are stored on virtual memory, so they occupy very less space on actual physical memory.

DISADVANTAGES OF VIRTUAL MEMORY:
1. Applications run slower if the system is using virtual memory.
2. It takes more time to switch between applications.
3. Less hard drive space for your use.
4. It reduces system stability.

Contributor's Info

Created:
0Comment
Advantages & Disadvantages of Virtual Memory

Performance in virtual memory:

Assume that p is the page fault ratio. When value of p is 0 that means there is no page faults and all page references are hit. If the value of p is 1 that means there is no hit and all references are faults. The performance of virtual memory is depends on total number of page faults. The effective access time(EAT) can be found using formula:

 

EAT = (1 - p)*memory access time + (p)*page fault time.

 

Advantages and disadvantages of virtual memory:

The size of program can be more than the size main memory. Memory can be used efficiently because a section of program loaded only when it need in CPU. Virtual memory allows sharing of code and data, unlimited amounts of multiprogramming. We can reduce internal fragmentation using segmented paging and eliminates external fragmentation.

There are some disadvantages of using virtual memory that increased overhead for handling paging interrupts, software complexity and hardware costs.

 

 

Contributor's Info

Created:
0Comment
Virtual Memory Concept

Virtual memory is a technique that provides larger memory to the user by creating virtual memory space. This scheme has main advantage that programs can be larger than physical memory size. We can have more processes executing in memory at a time. It increases degree of multiprogramming. Virtual memory allows memory protection, because virtual address is translated to physical address.

 

There are some benefits of the using virtual memory. These are higher degree of multiprogramming, higher CPU utilization and throughput, a user process can be larger than physical memory, etc.  

 

23 (1).jpg

 

There are three types of virtual memory techniques: overlays, paged virtual memory and segmented virtual memory.

 

Demand Paging

The demand paging is a method in virtual memory that load a page into memory only when it is needed and any usual page in memory will be swapped out to disk. So, this is referred as to as lazy evaluation. There are valid/invalid bit in demand paging. When valid/invalid bit = 0, that means page is available in the memory. When valid/invalid bit = 1, that means page is not available in the memory.

There are some advantages of demand paging. It reduces context switching time and only executing processes are loaded in the memory.  Disadvantages are programs have extra latency when they access a page for the first time and there is possible security risk. Thrashing may occur due to repeated page faults.

 

Contributor's Info

Created:
0Comment