页面 table: 页面错误

Page table: Page fault

我有几个关于页面 table 的问题,尤其是发生页面错误时。

我知道当 CPU 需要一个页面时会发生页面错误,但它不在 RAM 中,必须从交换区 space 中获取。页面table使用虚拟地址的高位进行索引,还包含一个无效位,表示该页面是否在内存中。

这是我不明白的地方。页面 table 是否包含那些设置了无效位的页面的物理地址?我的意思是,它们不存在于物理内存中。所以,我的理解是那些设置了无效位的页,对应的物理地址应该是空白的。我错过了什么吗?

另一个问题是为什么我们不能只为那些存在于内存中的页面创建条目。这样,页面的大小table可以变小

还有一个问题是,当操作系统在页面错误后将页面换入RAM时,页面分配到的帧的物理地址是否转换为虚拟地址以更新页面table?

有没有人能解开这些疑惑?谢谢!

I understand that a page fault occurs when the CPU demands a page, but it is not present in the RAM, and has to be fetched from the swap space.

页面错误的触发通常是一个或两个步骤的过程。该故障由页面table.

的状态触发

The page table uses the higher order bits of the virtual address for indexing, and also contains an invalid bit that indicates if the page is in the memory.

位的位置和用法完全取决于系统。有两个级别的无效。 (1) 页面可能没有映射到逻辑地址space; (2) 页面可能被映射但没有对应的映射到物理页面框架(页面调出)。这两项检查可以在页面 table 中指示或与操作系统维护的映射数据一起指示。

Does the page table contain the physical addresses for those pages also for whom the invalid bit is set?

如果页面 table 条目指示存在逻辑页面到物理页框的有效映射,则页面 table 条目包含该映射。

I mean, they are not present in the physical memory. So, my understanding is that those pages for whom the invalid bit is set, the corresponding physical addresses should be blank.

通常情况并非如此。如果页 table 条目通过其控制位指示没有到物理页框的映射,处理器通常会忽略实际的映射位。这允许操作系统使用这些位来识别页面在磁盘上的存储位置。

Another question is why can't we have entries only for those pages that are present in the memory. This way, the size of the page table can be made smaller.

您描述的是颠倒的页面 TABLE。一些系统以这种方式实现页面 tables。但是,大多数系统不会这样做,它们会给操作系统带来额外的开销。

Yet another question is that when the operating system swaps-in a page after a page fault into the RAM, is the physical address of the frame to which the page is assigned converted to virtual address for updating the page table?

页错误处理程序需要(1)分配一个物理页框; (2)将二级故事的数据加载到页面框架中; (3)更新pagetable表示逻辑页到物理页框的映射; (4) 重新启动导致错误的指令。