Virtual and physical addresses are the two types of addresses that define the memory’s unique locations. The user can see the virtual address but he cannot directly see the physical address. The virtual address is used as a reference to access the physical address in the operating system’s memory. There are some common differences between virtual or logical addresses and physical addresses.
One of the primary differences between these two addresses is that the CPU generates the virtual address when executing a program. And the Physical address is nothing but a location in the memory unit. Let’s understand the common differences between virtual and physical addresses.
In computing, the virtual address is nothing but a binary number stored in Virtual memory that differs from a physical address. It enables a process that helps to use a preferred location in the computer’s main memory. It requires more space than exists in primary memory, so for that purpose, it relegates some contents to an internal flash drive and hard disk.
According to Techopedia, “A virtual address in memory is a pointer or marker for a memory space that an operating system allows a process to use. The virtual address points to a location in primary storage that a process can use independently of other processes.”
A virtual and physical address is different in the devices with memory management. The Memory Management Unit helps translate virtual addresses into physical addresses in such hardware. A memory management system and virtual address can assign a large amount of memory to a particular process. With virtual addresses, new systems can change the physical memory drive locations with the virtual memory addresses, and the device is divided into different storage types.
The physical address present in the memory unit is nothing but the physical location of the information stored. The user can not directly see the physical location and require the logical address or virtual address for that purpose.
The user program generates the virtual address, but it cannot run it; instead, it needs physical memory for the execution of the program. Therefore, it is essential to map logical or virtual addresses to the physical address with the help of MMU (Memory management unit). Physical address space is used for all the physical addresses, and logical or virtual address space is used for virtual addresses.
MMU (Memory Management Unit) sets up the physical addresses for the particular virtual addresses in the system. The user can not directly access the physical address. Instead, he requires the corresponding virtual address to access the physical location of the memory.
The memory management unit or MMU is responsible for the run time mapping between logical and physical addresses. The operating system handles the process of mapping and moves it between memory and disk. MMU updates the available and used memory space and combines two different registers, the base register and the limit register. The base register contains the process’s starting physical address, and the limit register mentions the limit relative to the base addresses.
The addresses (Virtual and Physical) show the particular location in the memory unit whose actual code is placed in the OS. There are some common differences between virtual and physical addresses. Here we will discuss all of them with a comparison.
Memory consists of a large number of addresses. The central processing unit (CPU) is responsible for collecting instruction addresses from program files, and it may cause loading to a particular memory address. The address binding is nothing but the mapping process from one address space to another address space. Hence, there are three different methods to complete the address binding: compile time, load time, and execution time.
If you know the compile time at which the process resides in the memory, then it will help you to generate the absolute address. The physical address generates at the time of compilation during the program’s execution.
If the compile time does not show where the process will reside, then relocated address will generate. Hence, the loader will translate this relocated address to an absolute address. Therefore, a loader will add the base address of the process to the virtual address to develop an absolute address.
The central processing unit already has the instructions, and it will process them on time. During this process, the additional memory can allocate or relocate. Mapping addresses helps if the process can transfer from one memory to another.
In conclusion, the virtual address is used as a reference to access the physical address. The user can access the physical address in the memory unit by using a logical or virtual address. The set of all physical addresses and logical addresses is known as physical address space and logical address space. Compile and load time address binding methods generate identical virtual and physical addresses.