Quick memory-based Linux operating technology-general Linux technology-Linux technology and application information. For more information, see the following. We always hope that data can be freely exchanged between the kernel space and the user space. The traditional method is to use the vma mechanism provided by the kernel and implement it through methods such as copy_to/from_user. This is not desirable for high-speed data block transmission. In fact, when kswapd sometimes exchanges data to external storage, the performance is quite poor. In general, your PC master storage is not necessarily used up, and you are concerned about many applications, but it actually consumes your computing resources. At this time, you may think of using real addresses to operate your applications (even with MMU support). In uClinux, when there is no MMU, it's nice to work.
The most convenient and efficient method is to operate physical memory under the real address, which is equivalent to DMA. although the performance of Linux 2.6 kernel in VMA is better than 2.4, the swap mechanism has some limitations. In VxWorks, memory management is meticulous and accurate. If you apply for a large memory operation in Linux, when kswap is triggered to quickly switch back to the primary storage, you will find that your computer has to rest for a few minutes, even though you look free to output? There are already a lot of operations, but at this time the external storage is almost always busy, and the CPU load is quite heavy, you may not do any operation at all.
Is there a way to work under the VMA mechanism and directly process the primary storage data?
The answer is yes. After the kernel is started, the main memory is mapped to/dev/mem. When we apply for a logical interval in VMA, the physical address to be converted is transmitted to the user space, the user space can perform linear operations in this interval. You can directly use mmap to read and write data in the physical primary storage.
Is there a faster way? Do not use mmap rows?
Of course, after VMA transmits the address and size of the physical block to the user space, the user can use the address read/write mode, which is close to machine commands (which can be independent of OS ). This implementation method is very simple. First, you can open/dev/mem and directly locate the address passed to VMA to perform the operation, without mmap. Notify the user space, and use procfs/sysfs.
It is strongly recommended that the boundary control should be accurate and meticulous. It is not recommended for beginners. Once the boundary is exceeded, it may cause "Kernel Panic ". It is more likely to be DOWN. For this implementation method, we recommend that you refer to the mapper (LDD3) program. You can also use mapper to check whether the read and write operations are correct.
In the new IA32, PAGE_SIZE = 4 K MAX_ORDER = 11, the maximum application of the green code is 4 m linear Logical space, and the physical address is obtained by subtracting PAGE_OFFSET. If HIMEM and NUMA are used, see the Kernel memory ing algorithm. When the primary storage reaches 1 GB or exceeds the upper limit, reduce the user space.
With the development of hardware technology, VMA can be considered for correction when the primary storage is quite large, so it is possible to focus on the physical ing mode. There is no need to switch. Otherwise, performance is affected. For 32-bit platforms, if the primary storage is 2 GB, using SWAP will greatly degrade the performance. In the case of large-capacity data transmission, it is impossible to use the SWAP method, and the switch-out is not allowed. It is recommended that Linus add process classification to VMA and allocate different memory blocks for non-classified applications. Small Data PAGE_SIZE = 4 K/big data 4 M/128 M. The address mode is fully converted to 64-bit, compatible with 32-bit. when applied to the Embedded system, the 32-Bit mode is used directly.
For example, different Microsystems, different microkernel, and different applications (different process management, memory management, and file management) can be run, but interfaces can be unified with different indicators.
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