How does the OS know disk address of an absent page?
Asked Answered
P

1

8

Paging acts as indirection layer between virtual address space and physical address space. Given an address, the Operating System(OS)/Memory Management Unit(MMU) translates it to a primary memory location.

My questions are:

In the scenario that the page is absent in primary memory

  1. How does the OS know where to find the page on disk?
  2. Where does it store information for 1?(It is not stored in the page table entry). Links to code examples would be great!
Photodisintegration answered 29/9, 2015 at 14:21 Comment(1)
1) it asks the file system driver; 2) see (1). Other than that, this is extremely generic, because of the vast variety of possible file system types, storage types, etc. You can download the kernel code and look into it yourself...Ploughshare
K
6

You can find the detailed explanation of the process here

  1. How does the OS know where to find the page on disk?

  2. Where does it store information for 1?(It is not stored in the page table entry). Links to code examples would be great!

Everything kernel needs to know is actually stored in PTE (it stores index to swap_info and offset within the swap_map).

swap_info_struct is there for every swap area (file or the partition), so using the first index kernel knows in what area to look. Now every area has a swap_map which is an array with elements that are one page each. Using offset stored in PTE, it can access the particular page.

Kampala answered 29/9, 2015 at 17:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.