Home » Operating Systems

Concept of physical and virtual memory in Operating System

In this article, we will learn about the concept of physical and virtual memory and the introduction of physical address and logical address in operating system.
Submitted by Prerana Jain, on January 03, 2019

1) Physical memory

Physical memory is referred to the RAM (Random Access Memory) of the system which is attached to the motherboard. Primary memory is the only storage type which is directly addressable to the CPU. Primary memory holds the instructions of the program to execute. When the computer requires memory usage for loading an application program or like opening a document so RAM is the first memory which is used. Physical memory is the linear addressable memory and the memory addresses increase in a linear fashion and in this each byte is directly addressable. Physical memory allocates processor information in first in last out process. Physical memory is the main memory of the system. Any user program which is going to be executed should reside in this.

A process should always in the main memory for the execution. In the main memory, a process can be swapped temporarily out of the memory when it is not in use and brought back into the memory for continue execution. The main memory is allocated for both the operating system and for the user program. So we allocate main memory in the most efficient way possible. The main memory is mainly divided into two partitions one for the operating system and for user processes. The user area of memory may be contiguous or non-contiguous in nature. In the contiguous memory allocation, each process should remain in the single section of main memory. In the main memory, the efficient approach is to divide it into the fixed size block and each block may contain only one memory.

2) Virtual memory

When there is a layer of abstraction over the physical memory this is called virtual memory. Using secondary memory as physical memory is virtual memory. The concept of virtual memory is based on the non-contiguous memory allocation of memory. It offers many benefits like the ability to use physical memory as a large cache and the ability to maintain separate address spaces. It makes the physical memory appear limitless from the programmer's view. When the RAM(main memory) is filled the virtual memory is used. Virtual memory is comparatively slower than the physical memory and it can decrease the performance of the CPU. Virtual memory uses the concept of paging in which the process is divided into the equal size of pages and these pages are loaded into the main memory for the execution. When we want to increase the CPU utilization we use the concept of virtual memory. In this system, the operating system gives an illusion to the user. The user thinks that they can write a very big program and its entire process is in the RAM and all the space allocated to the user is contiguous. But the reality is only a small portion of the user program is in the main memory which may or may not be contiguous while the remaining program is in secondary storage.

Virtual memory provides benefits to the system and the degree of multiprogramming is maintained. Virtual memory is a type of technology that allows the execution of the process that may not be completely in memory. All the decision like which section to bring in, where to place them, when to bring them is made by the operating system. Virtual memory allows files and memory to be shared by several different processes through page sharing. The details of virtual memory management are generally transparent to programmers. Programmers are practically relieved of the burden of trying to fit a program into limited memory. Moreover, the same program may run without reprogramming or recompilation on a system with significantly different capabilities of installed memory.


Address in system

An address uniquely identifies a location in the memory. There are two types of addresses logical address and physical address.

Logical address

The logical address is the virtual address which can be seen by the user. The user cannot view the physical address directly.

  • The logical address is used as a reference to access the physical memory.
  • The logical address is generated by the CPU for any program and the set of all logical address is called logical address space.
  • The user uses the logical address to access the physical addresses.
  • The identical logical address is generated by the compile-time and load time address binding.
  • The logical and physical address generated while running time address binding method but differ from each other.
  • The user easily views the logical address of a program.
  • The logical address does not exist physically in the memory unit.

Physical address

The physical address is exactly the location that exists in the memory unit. Processes always use the logical address and they do not see the physical address. A translation must be made to a physical address before the memory access can be achieved.

  • The physical address is the location in the memory unit.
  • The set of all physical address mapped to the corresponding logical addresses is referred to as physical address space.
  • The user can not directly access the physical address.
  • The physical address is computed by the memory management unit.
  • The physical address is a location in the memory unit that can be accessed physically.
  • The user can access the physical address is in the memory unit using this logical address.
  • The compile time and load time address binding method generate the same logical and physical address.





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL








Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.