关于分页:操作系统中的页面错误。(无效寻址或页面不在主内存中)

page fault in operating system.(invalid addressing or page not in main memory)

我正在阅读有关需求分页中的页面错误的信息。页面错误发生在
1)被访问的内存是非法的
2)页面有效但不在主存中

我通过有效-无效位读取了它,您可以判断内存是否不符合逻辑
地址空间,因为相应的位会被标记为无效。

相同的有效-无效位用于识别上述2个条件。

我的问题是操作系统如何知道正在访问的内存是否非法
或者如果页面有效但不在主内存中,只有一个有效-无效位?
谢谢!


在按需分页中,如果设置了valid-invalid bit(1),则意味着关联的page 是合法的并且在内存中。但是,如果 valid-invalid bit 未设置 (0),则表示如下:

  • page 无效。这意味着该页面不在进程 logical address space 中。或者
  • 对应的 pagedisk 上。
  • 无效页面访问导致页面错误陷阱。我们通过以下方式处理它。引用 Silberschatz、Galvin、Gagne 的操作系统原则

  • We check an internal table(usually kept with the process control block) for this process to determine whether the reference was a valid
    or an invalid memory access.
  • If the reference was invalid, we terminate the process. If it was valid, but we have not yet brought in that page, we now page it in.
  • We find a free frame(by taking one from the free frame list, for example).
  • We schedule a disk operation to read the desired page into the newly allocated frame.
  • When the disk read is complete, we modify the internal table kept with the process and the page table to indicate that the page is now
    in memory.
  • We restart the instruction that was interrupted by the trap. The process can now access the page as though it had always been in
    memory.