0

所以这不是一个家庭作业问题。这是我的教授在之前的考试中发布的一个问题,作为帮助我们为期中学习的资源。但是,有两个答案(对我来说)似乎是正确的答案。

A.) 页面错误意味着要替换的物理页面必须保存到硬盘上。B.) 请求的虚拟不在物理内存中。

现在,我的理解是页面错误是指存储在物理内存页面中的数据不是您需要的数据,因此,您需要访问硬盘驱动器并加载正确的数据。此外,如果脏标志为1,则表示物理内存中的先前数据已被修改,因此您需要将其重新保存到磁盘。

因此,在我看来,A 和 B 都是正确的,但我想知道是否有人可以告诉我他们认为更好的选择是什么。

如果我被迫选择,我会说A。

旁注 我已经通过电子邮件向教授发送了答案,但他的回复真的很糟糕,还没有给我发电子邮件。

4

1 回答 1

1

Neither of these is correct.

A.) A page fault means the physical page to be replaced must be saved to the hard disk.

This is not correct because it could also mean the page needs to be read from the hard disk.

B.) The requested virtual is not in the physical memory.

This is not correct because in a soft page fault, the page is resident in physical memory. For example, the operation may just be the first write to a resident, unshared page, so the page has to be marked dirty. Or the page may be shared and need to be unshared. In these cases, the requested virtual page is resident in physical memory, it just needs some massaging by the memory management system.

A page fault means some help from the kernel is needed in order to permit the access to that page of virtual memory. The help needed could vary from reading the page in to disk to just marking the page accessed so the kernel knows not to evict it.

Of those two, B is probably closer to correct because A is almost never right. The "classic" page fault would be if the page had to be read in from hard disk, which B would apply to but not A.

Now, it is my understanding that a page fault is when the data stored in the physical memory page is not the data you need, therefore, you need to access the hard drive and load the correct data. Also, if the dirty flag is 1, then that means the previous data in physical memory has been modified, therefore you need to re-save that to the disk.

How could the page both be dirty and not hold the data you need? If it's dirty, that means you dirtied it. Which means it's holding the data you're working with.

于 2012-11-09T19:27:44.290 回答