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
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.
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.
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.
You can find the detailed explanation of the process 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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With