LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How does processor know about a process's address space (https://www.linuxquestions.org/questions/linux-kernel-70/how-does-processor-know-about-a-processs-address-space-818840/)

nitinarora 07-09-2010 01:38 AM

How does processor know about a process's address space
 
Dear all,

I was studying the linux virtual memory system.
Because I am reading it for the first time I have many confusions.

Linux maintains VMA and page table data structures corresponding to virtual address space of processes on the system. Through page tables it maintains the mappings from process virtual address space to physical address space.

It means that every process has an address range and if it tries to accss beyond it segmentation fault will occur.

okay so far its fine...

I had a doubt that when a process being executed by the processor then how will processor keep track of its virtual address space. Every time a process tries to access some particular address, for example process writes some data as mentioned by the following pseudo code:
STORE <value> <address>
1.
Now how will processor verify that this address comes under its virtual address space or not?
After thinking a bit I made an understanding, Because processor accesses its own (hardware) page tables every time an address is accessed. In case no entry is found corresponding to any virtual address, processor will jump to the page fault exception handler of the kernel.

2.
But after making this understanding I again had a doubt that does it mean that every time a process is scheduled for execution by the kernel , kernel also populates processor's page tables?

3.
If yes, then does it mean that architectures which do not support paging hardware cannot run linux kernel? Or is it possible to run linux without VM on those architectures.

Please comment on it, if you feel that I making any wrong understanding about the kernel operation then please correct me.I would appreciate if you answer my questions point wise and at the same time apart from answering questions please write a descriptive text also.

Thanks

zirias 07-09-2010 01:48 AM

Quote:

Originally Posted by nitinarora (Post 4028009)
2.
But after making this understanding I again had a doubt that does it mean that every time a process is scheduled for execution by the kernel , kernel also populates processor's page tables?

This is absolutely correct and is one main reason, the "context switch" (from one AS to another) is very expensive. For a lot of theory on that (not linux-related), I could recommend the great work of the L4 team at university of karlsruhe:
http://i30www.ira.uka.de/teaching/co...eid=182&lid=en

Quote:

3.
If yes, then does it mean that architectures which do not support paging hardware cannot run linux kernel? Or is it possible to run linux without VM on those architectures.
No idea, sorry -- but at least, it seems difficult without hardware support for virtual memory.

Mara 07-09-2010 04:23 PM

Quote:

Originally Posted by nitinarora (Post 4028009)
1.
Now how will processor verify that this address comes under its virtual address space or not?
After thinking a bit I made an understanding, Because processor accesses its own (hardware) page tables every time an address is accessed. In case no entry is found corresponding to any virtual address, processor will jump to the page fault exception handler of the kernel.

There's a hardware unit, MMU, which does exactly what you describe. The complexity of this unit varies between architectures, but the general idea is that if it doesn't find an entry, it makes an exception.

Quote:

2.
But after making this understanding I again had a doubt that does it mean that every time a process is scheduled for execution by the kernel , kernel also populates processor's page tables?
Generally yes.

Quote:

3.
If yes, then does it mean that architectures which do not support paging hardware cannot run linux kernel? Or is it possible to run linux without VM on those architectures.
An architecture without an MMU doesn't have virtual memory, but can run Linux. There's an option for no-MMU systems (often called uCLinux, but it's in mainline).


All times are GMT -5. The time now is 12:10 AM.