Two identical line addresses of two different processes?

Hello to all,

I am new to Linux-Kernel and I am now referring to the Understanding Linux Kernel book. I read about memory management where it is all well and good about paging and segmentation, but my question hasn't been answered yet. If two different processes have the same linear address, then they may be different locations in the physical addresses. Because each processor has only one global page directory, which maps to physical addresses again, watching the 32-bit linear address. But how can two processes eat up to 4GB memory. Please explain.

+3


source to share


1 answer


Yes, two different processes can use the same linear pointer, but it can be dereferenced at two different locations in physical memory. This is because each process has its own page tables, and when moving from one process to another, the CPU page table register also switches to point to the page tables of the new process.

Have you already cloned your local copy of the Linux source code? If not, go ahead and do it now. You will need to refer to it when you read the book.



Now cloned? Good. Change to your cloned working directory and open arch/x86/include/asm/mm_context.h

. Go to line 51, you will find static inline void switch_mm

. It is a function that switches the processor from one process's virtual memory space to another. (I am assuming that you are most interested in x86.) Look down at the line 64: load_cr3(next->pgd)

. This is where the magic happens: the page tables are switched and now the CPU will interpret all pointers using the page tables of the new process.

+3


source







All Articles