Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!
like image 328
Saimadhav Heblikar Avatar asked Sep 29 '15 14:09

Saimadhav Heblikar


People also ask

How does OS know if a page is in memory?

The memory is kept track by the MMU (memory management unit). The MMU is a piece of hardware that is a part of the CPU. With older hardware, the MMU could be a separate from the CPU. The MMU has what is called a page table.

Where pages are stored in OS?

The page table of the process is held in the kernel space. The kernel may have several page tables in RAM, but only one is the active page table.

What is page in and page out in OS memory management?

When pages are written to disk, the event is called a page-out, and when pages are returned to physical memory, the event is called a page-in. A page fault occurs when the kernel needs a page, finds it doesn't exist in physical memory because it has been paged-out, and re-reads it in from disk.


1 Answers

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.

like image 104
Nemanja Boric Avatar answered Nov 15 '22 03:11

Nemanja Boric