Question

When there is a process switch, and the page tables and page directory of the new process has to be used, from where does the kernel come to know about the location of the page directory for the new process ?

I know that the page directory of the new process is stored in physical memory. But how does the kernel know where to find it ?

Was it helpful?

Solution

Generally a kernel keeps a structure of state describing each process on the system. Somewhere in that structure there will be the address of the process's 'root' page table. On x86 machines this needs to be stored in the CR3 register to switch to a new page table. Sometimes this register is implicitly saved and restored as a side-effect of a larger operation that saves/restores a bunch of CPU state, or sometimes this value is explicitly managed by the kernel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top