
In computer systems, address translation is a process by which the logical address (or virtual address) generated by the CPU is mapped to a physical address in...
In computer systems, address translation is a process by which the logical address (or virtual address) generated by the CPU is mapped to a physical address in memory. This is a key concept in systems that use virtual memory, as it allows programs to use a larger address space than the physical memory available.
The physical address refers to the actual location in the main memory (RAM), while the logical address (or virtual address) is the address seen by the program or the CPU. The Memory Management Unit (MMU) is responsible for handling the mapping between logical and physical addresses.
Let’s break down how physical address calculation works, especially in the context of paging, which is one of the most common memory management techniques.
In a system with virtual memory, the logical address generated by the CPU is divided into two parts:
The physical address is then determined using these components, and this involves looking up a table that stores the mapping between virtual and physical addresses. The translation process can be broken down into several steps:
In a system that uses paging, the virtual address is divided into two parts:
For example:
Each entry in the page table corresponds to a virtual page and contains the physical page number (PFN - Physical Frame Number) where the data for that virtual page is stored in physical memory. The offset remains the same, since it represents a location within the page.
The physical address is calculated by combining the physical frame number (obtained from the page table) and the offset.
This means that the physical address is formed by concatenating the physical frame number (from the page table) with the offset within the page.
Let’s consider a system with the following parameters:
Now, let's say we have a virtual address: 0x00401A7F.
Break the Virtual Address into Components:
So, the virtual address 0x00401A7F can be broken down as:
Translate the VPN to a Physical Frame Number (PFN):
Combine the PFN with the Offset:
The offset remains unchanged because it is the position within the page.
Therefore, the physical address is formed by combining the PFN (0x000F) with the offset (0xA7F):
Physical Address = (PFN << 12) + Offset
So, the physical address calculation would be:
Physical Address = (0x000F << 12) + 0xA7F = 0x000F000 + 0xA7F = 0x000F07F
Final Physical Address:
Given:
The physical address is calculated as:
Where:
In more advanced systems, multilevel page tables are used to manage larger address spaces. Instead of having a single page table that maps virtual pages directly to physical frames, the virtual address is divided into multiple levels:
In this case, the calculation would involve looking up multiple page tables (each corresponding to different parts of the virtual address) before combining the results to generate the physical address.
For example, in a system with 32-bit virtual addresses and a 2-level page table:
The calculation of a physical address involves:
In systems that use paging, this mapping allows the operating system to manage memory efficiently, enabling processes to have their own address spaces and supporting virtual memory, even when the system has limited physical memory.
Open this section to view and download past papers
Click on Show Past Papers to load available exam papers.