Linux Space Division & MMU

Source: Internet
Author: User

Linux Kernel address space partitioning
Typically, the 32-bit Linux kernel address space is partitioned 0~3g to user space and 3~4g to kernel space. Note that this is a 32-bit kernel address space partition, and the 64-bit kernel address space partition is different. 32-bit Linux system from 0x00000000 to 0xFFFFFFFF of entire 4GB virtual storage space.
Kernel space: The kernel space represents code or data running at the highest processor level in Superuser mode (supervisor mode), which occupies a 1GB linear address space from 0xc0000000 to 0xFFFFFFFF, and the kernel linear address space is shared by all processes. However, only processes running in the kernel state can access the kernel space through system calls to the kernel State, and the address generated by the process running in the kernel state is the kernel space.
User space: User space takes up from 0x00000000 to 0xBFFFFFFF a total of 3GB of linear address space, each process has a separate 3GB user space, so the user space is unique to each process, but the kernel thread does not have user space, because it does not produce a user space address. In addition, the child process share (inherit) the user space of the parent process is simply a mapping with the same user-linear address to the physical memory address as the parent process, rather than the shared parent process user space. User space can be accessed by processes running in both the user state and the kernel state.
Such a user program can independently use their own 0~3g space, while the system can be called through the use of kernel space 1G space, so that each application is equivalent to have 4G of space can be used.
Linux operating systems and drivers run in kernel space, applications run in user space, both cannot simply use pointers to pass data, because the virtual memory mechanism used by Linux, user-space data may be swapped out, and when kernel space uses user-space pointers, the corresponding data may not be in memory.
Kernel space is generally divided into one partition, for example, divided into Zone_dma, Zone_normal, zone_highmem three blocks, the above analysis can be concluded that ZONE_DMA and zone_normal can use a simple mapping relationship to the physical memory, Because this part of the space is consistent for the kernel for each application, the mapping is relatively cumbersome because of the fact that the user space is 0~3g for each application's independent space (this is a hassle for the user to write the application in great convenience). Zone_normal mapping is generally implemented directly with an offset, such as the actual memory address where the start is 0x0, then only need to add an offset 0xc0000000 (3G). But if this 1G space is mapped in this way, the kernel space can only access the actual physical memory of 1G space, so there is high-end memory to solve this problem. High-end memory is generally 896~1024m this section of the 128M space, when the kernel wants to access higher than 896MB Physical address memory, from the 0xf8000000 ~ 0xFFFFFFFF address space range to find a corresponding size of the free logical address space, borrowed for a while. Using this logical address space, create a map to the physical memory that you want to access (that is, populate the Kernel Pte page table), temporarily for a while, and then return when you're done. This allows others to use the address space to access other physical memory, allowing access to all physical memory using a limited address space.
For the mapping of s3c2440 's user-space address, a page table is used, and it is important to note that the page table is a dynamic concept, which means that the page table is likely to be modified as the program runs. The MMU provides two basic functions:
>>> responsible for converting between virtual and physical addresses
The feature is that each application mentioned above has its own independent 0~3g user space, and each application sees its own data in this 0~3g space. The page table mentioned above is used to convert virtual and physical addresses when the MMU is working.

>>> provides hardware-mechanism memory access authorization
In an ARM processor, the MMU divides the entire storage space into up to 16 domains, which are recorded as D0~D15, and each domain corresponds to a certain storage area that has the same access control properties. In an ARM processor, the access rights for each domain in the MMU are set by the two bits in the C3 register of the CP15, and the C3 register is able to set the access rights to 16 domains, respectively.

The swap partition of Linux is best set to twice times the memory capacity: when the system is fully loaded, there will be a part of the program occupied by the memory will be written to the swap partition, when your system suddenly down, you can ensure that your swap is large enough to put down the memory of the things to use as a later query.

Linux Space Division & MMU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.