Kernel logical address for multiple processes

As I understand it, the address space “each process” is divided into 3G / 1G for the user / kernel space, and 1G (slightly less) is mapped one to the other with physical addresses called the kernel logical address. "Now, to my question, there is a system several processes, and how can all processes have one to one with physical addresses? For example, when the kernel accesses the logical address of the kernel in the context of process A, and now there is continuity, and what happens when the kernel accesses the logical address in context Process B?

on a similar line, what happens for a PC with only 512 MB of RAM ?. How does a 1G kernel space display once for these PCs?

+4
source share
3 answers

At first, you might think that part of the kernel (let them say 1 GB) of the entire virtual address space is not used. And shared physical memory is not all mapped to kernel space.

In the core of the space, virtual memory cells for the used physical memory will be displayed, as well as any memory-related peripherals that are defined. They are not unloaded.

Each process in user space can have up to 3 GB of virtual memory for its code + data. There are two extremes to physical memory; it can shed light to look at each.

Large physical memory: if the processor supports large physical addressing, for example. 36-bit, maybe 64 GB of physical memory. You can have several processes, each of which has 3 GB of code + data, and they don’t even have to change pages to secondary storage. Each context switch configured an MMU to map the new physical memory of the execution process to user space.

Small physical memory: say 512 MB, and the core uses 128 MB. The remaining 384 MB will contain the code + data for user processes. If the user's user processes require more, pages will be replaced between the secondary storage and RAM as needed.

+2
source

Here is a link that gives a pretty good clarification for my question.

http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory

“On Linux, kernel space is constantly present and displays the same physical memory in all processes. Kernel code and data are always addressable, ready to handle interrupts or system calls at any time. On the contrary, part of the address space area changes whenever a process switch occurs : "

The answer to the first part of the question: the Linux kernel space remains the same in all processes, and switching the context of the process does not matter. The core of the space is mapped onto identical RAM pages in all process contexts.

The answer to the second part of the question: the size of the physical amount of RAM (512 MB or 2 GB) is not related to the address space of the kernel. As with the rule, the kernel has an available 1G kernel address space and any distribution it makes using these addresses. Matching these addresses with available RAM (512 MB or 2 GB) is the job of the MMU. In the case of 1G or more RAM, all 1G will be displayed for the kernel address space, while in the case of 512 MB RAM there will be 512 MB. This does not interfere with user space addresses, since all these are virtual addresses, and they will be replaced by demand, including pages in kernel space.

Note. Here I assume 1G / 3G sharing, and this is not a tough rule.

+2
source

Well, in a traditional multi-core system, all processors have access to the entire RAM. On Linux, each process has its own address space on the 3 GB side, while the 1 GB side remains constant (I think), because the kernel, in a sense, is a process that always exists. Since part of the virtual memory core remains unchanged (and because of this there is one kernel address space), the kernel address space does not change when it crowds out the process.

Simply put, the kernel only displays these 512 MB. The other 512 MB of virtual address space is simply mapped to a draw record that simply tells the CPU that memory should not be accessible at that address and raise a CPU exception whenever it is accessed.

0
source

Source: https://habr.com/ru/post/1441063/


All Articles