OS 如何知道缺页的磁盘地址?
How does the OS know disk address of an absent page?
分页充当虚拟地址 space 和物理地址 space 之间的间接层。
给定一个地址,操作系统(OS)/内存管理单元(MMU)将其转换为主内存位置。
我的问题是:
主存不存在页面的场景
- OS 如何知道在磁盘上的哪个位置可以找到页面?
- 它在哪里存储 1 的信息?(它不存储在页面 table 条目中)。链接到代码示例会很棒!
你可以找到过程的详细解释here
How does the OS know where to find the page on disk?
Where does it store information for 1?(It is not stored in the page table entry). Links to code examples would be great!
内核需要知道的一切实际上都存储在 PTE 中(它将索引存储到 swap_info 并在 swap_map 内偏移)。
swap_info_struct
用于每个交换区域(文件或分区),因此使用第一个索引内核知道要查找的区域。现在每个区域都有一个 swap_map
,它是一个数组,每个元素为一页。使用 PTE 中存储的偏移量,它可以访问特定的页面。
分页充当虚拟地址 space 和物理地址 space 之间的间接层。 给定一个地址,操作系统(OS)/内存管理单元(MMU)将其转换为主内存位置。
我的问题是:
主存不存在页面的场景
- OS 如何知道在磁盘上的哪个位置可以找到页面?
- 它在哪里存储 1 的信息?(它不存储在页面 table 条目中)。链接到代码示例会很棒!
你可以找到过程的详细解释here
How does the OS know where to find the page on disk?
Where does it store information for 1?(It is not stored in the page table entry). Links to code examples would be great!
内核需要知道的一切实际上都存储在 PTE 中(它将索引存储到 swap_info 并在 swap_map 内偏移)。
swap_info_struct
用于每个交换区域(文件或分区),因此使用第一个索引内核知道要查找的区域。现在每个区域都有一个 swap_map
,它是一个数组,每个元素为一页。使用 PTE 中存储的偏移量,它可以访问特定的页面。