Difference Between Virtual and Physical Addresses


Modern computing systems' primary building block is computer memory. It keeps track of the information and commands that the processor is currently executing. An address, which identifies the location of the data in memory, is used by programmes to access memory.

Physical addresses and virtual addresses are two different kinds of memory addresses used in computing. Virtual addresses are mapped to physical addresses by the operating system, whereas physical addresses point to a specific physical location in memory. Virtual addressing shields the memory of one process from being accessed by another and enables the computer to utilise more memory than is physically accessible.

What is Virtual Address?

An address used by a process or programme to refer to a memory region within its address space is known as a virtual address. There is no direct connection between this memory address and a specific physical location in the computer's memory. Instead, it refers to a virtual memory address that the computer's operating system maps to a physical memory address.

Modern computer operating systems must have virtual addressing because it allows numerous processes to function simultaneously without interfering with one another. Each process has a unique virtual address space that is separate from the virtual address spaces of other processes.

By allowing the operating system to store portions of a process' virtual memory in secondary storage devices, like hard drives or solid-state drives, when physical memory is limited, the use of virtual addressing also enables more effective use of physical memory. This process, referred to as virtual memory management, is used to expand the amount of available memory without adding more physical memory to the system.

Advantages of Virtual Address

Here are some of the advantages of using Virtual Addresses −

  • Increased Memory Usage  By putting less often utilised data on secondary storage devices, virtual addressing enables the computer to utilise more memory than is physically accessible.

  • Memory protection  Each process has a separate virtual address space that is secured against access by other processes, prohibiting memory access between processes.

  • Increased Security  By preventing malicious programmes from accessing memory outside of their assigned location, virtual addressing can increase system security.

Disadvantages of Virtual Address

Listed below are some of the disadvantages of using Virtual Addresses −

  • Overhead  The translation of virtual addresses to physical addresses that occurs while using virtual addressing adds additional overhead and can delay performance.

  • Fragmentation  Memory fragmentation can happen from the usage of virtual addressing because different processes may occupy memory blocks of varying sizes, leaving unused memory blocks dispersed throughout the address space.

  • Complexity  The use of virtual addressing makes the operating system more complicated and necessitates additional hardware support, which could raise the cost of the system.

What is Physical Address?

A memory address that directly identifies a physical location in the computer's memory is known as a physical address in memory. It is the precise location of a memory store in the RAM of the computer or in other forms of physical memory, like flash drives or hard discs.

The hardware of the computer, such as the memory management unit (MMU), uses physical addresses to access and modify data held in memory. The MMU converts a physical address used by a software to access a memory location into an electrical signal that indicates the precise position of the data in the memory hardware.

Physical addresses are frequently shown in binary format and are made up of a string of bits that serve to specifically identify a location in memory. The maximum amount of memory that a computer may access depends on the number of bits used to represent a physical address.

Physical addresses and virtual addresses are frequently used together in modern computer systems, allowing the operating system to better manage the system's memory by mapping the virtual addresses to the physical addresses. This process, referred to as virtual memory management, is used to expand the amount of available memory without adding more physical memory to the system.

Advantages of Physical Address

Here are some advantages of using Physical Address −

  • Direct access to memory  Physical addresses give direct access to the memory hardware and make it possible to quickly and effectively access the data that is stored in memory. Direct access to memory.

  • Easy memory administration  Physical addresses and memory locations immediately correspond, making physical memory management easy and simple.

  • No overhead  There is no additional overhead when accessing memory using physical addresses because the address does not need to be translated into another format.

  • Predictable memory usage  Physical addresses offer a predictable method of allocating and using memory, which can ease programme design.

Disadvantages of Physical Address

Listed below are some of the disadvantages of using Physical Address −

  • Restricted memory capacity  The number of address lines made accessible by the hardware architecture determines how much memory may be accessed using physical addresses. The system's ability to use memory may be constrained as a result.

  • Memory fragmentation  Because memory blocks have a set size, it is simple for physical memory to break up, leaving empty memory blocks that cannot be used by programmes.

  • Security concerns  Physical addresses can be used by malicious programmes to access memory outside of their assigned space, which could jeopardise system security because they give direct access to the memory hardware.

Logical Address vs. Physical Address

The following table highlights the major differences between Logical Address and Physical Address −

Terms

Logical Address

Physical Address

Definition

The logical address is created by the CPU while the programme is running.

The memory location corresponds to the physical address.

Location

As the logical address does not physically exist in the memory, it is also referred to as a virtual address.

The memory unit's physical address designates a location.

Access

To access the physical address, the logical address is used as a point of reference.

Direct access to the actual address is not possible.

Address space

The term "logical address space" refers to the collection of all the logical addresses that the CPU has created about a programme.

Physical Address Space, in contrast, refers to all physical addresses that have been translated into logical addresses.

Conclusion

Virtual and physical addresses are crucial ideas in computer memory management, to sum up. Virtual addresses are used by the operating system to map to physical addresses, whereas physical addresses refer to the precise physical location of data in memory. In addition to protecting processes from one another and enabling a system to use more memory than is physically possible, virtual addressing has several other advantages.

The distinctions between virtual and physical addresses, as well as their benefits and drawbacks, have been covered in this tutorial. We have also covered the methods that operating systems employ, such as memory mapping and page tables, to manage memory using virtual addresses.

Updated on: 13-Jul-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements