虚拟内存(Virtual Memory)

本文介绍了计算机内存管理系统中从虚拟地址到物理地址的映射原理。涵盖了虚拟地址空间与物理地址空间的基本参数、虚拟地址各组成部分(如虚拟页号、虚拟页偏移等)及物理地址组成部分(如物理页号、物理页偏移等)。此外,还探讨了用于加速地址转换的翻译后备缓冲区(TLB)的工作机制,并提到了两层分页方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自http://www.cnblogs.com/shuaiwhu/archive/2012/11/22/2749043.html

Each process has its own virtual address space, so the virtual address 0xdead0000 in one process's address space will represent a different physical page than the page represented by 0xdead0000 in another process. Each process has it's own mapping from virtual addresses to physical addresses, virtual addresses are often reused between processes.

Basic Paramaters
SymbolDescription
N = 2nNumber of addresses in virtual address space
M = 2mNumber of addresses in physical address space
P = 2pPage size (bytes)
Components of a virtual address (VA)
SymbolDescription
VPOVirtual page offset (bytes)
VPNVirtual page number
TLBITLB index
TLBTTLB tag
Components of a physical address (PA)
SymbolDescription
PPOPhysical page offset(bytes)
PPNPhysical page number
COByte offset within cache block
CICache index
CTCache tag

As we have seen, every time the CPU generates a virtual address, the MMU must refer to a PTE in order to translate the virtual address into a physical address. In the worst case, this requires an additional fetch from memory, at a cost of tens to hundreds of cycles. If the PTE happens to be cached in L1, then the cost goes down to one or two cycles. However, many systems try to eliminate even this cost by including a small cache of PTEs in the MMU called a translation lookaside buffer (TLB).

A TLB is a small, virtually addressed cache where each line holds a block consisting of a single PTE. A TLB usually has a high degree of associativity. As shown below, the index and tag fields that are used for set selection and line matching are extracted from the virtual page number in the virtual address. If the TLB has T = 2t sets, then the TLB index (TLBI) consists of the t least significant bits of the VPN, and the TLB tag (TLBT) consists of the remaining bits in the VPN.

Two-level paging scheme

---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值