Discussion on Linux memory management __linux

Source: Internet
Author: User

A preliminary discussion on Linux memory management Author: Changuo memory Management (Memory Management, ' mm ' for short) is the technology of allocating and using the computer's memory resources when the software is running, in the Linux operating system The source code is located under the MM folder is the operating system's important Components (Linux kernel consists of 5 modules: Process scheduling module, memory management module, file system module, interprocess communication module, network interface module). First, why do you have to manage memory? Memory is one of the hardware components of a computer and it is a bridge to communicate with the CPU. All the programs in the computer are in memory, which shows the importance of memory. The function of memory is to temporarily store the operation data of CPU and the data exchanged with external memory such as hard disk. As long as the computer in operation, the CPU will need to operate the data into the memory of the operation, when the operation is completed after the CPU will be sent out the results, the memory of the operation of the computer to determine the stable operation. As a result, the importance of memory management can be reflected. In addition, memory management is one of the most basic areas of computer programming. In many scripting languages, you don't have to worry about how memory is managed, but that doesn't make memory management a little bit less important. In most system languages, C and C + +, you must manage memory. In the Intel80x86 CPU program during addressing, the program uses the address of the segment and offset values in the addressing process. This address is not directly used to address physical memory, so it is called a virtual address. In order to address physical memory, it is necessary to map or transform a virtual address into physical memory, which is one of the main functions of memory management (another function of memory management is the memory addressing protection mechanism). The virtual address is first transformed into a linear address (also known as a virtual address) of the middle address form--cpu32 bit through the segment management mechanism, and then uses the paging management mechanism to map the linear address to the physical address. From the above elaboration, we can get a conclusion: The 80x86 uses two kinds of mechanism of segment and paging in the transformation from logical address to physical address. Staging mechanism: The responsibility to convert the logical address of a program to an address in the memory space addressable by the processor. At the same time, it provides a mechanism for isolating individual code, data, and stack areas, so that multiple programs can run on the same processor without interfering with each other. Paging mechanism: is responsible for the conversion of linear address to physical address, but also for the virtual memory system to provide the implementation mechanism. Memory in the early development of the operating system has generated a continuous allocation of memory, which can be divided into a single continuous allocation (only for Single-user, single task operating system, divided into user and system areas, the system area is located in the address, the rest of the user area), fixed pointsDistrict Allocation (The simplest one can run multi-channel program storage management, the memory user zoning into a number of fixed size areas), dynamic partition allocation (to achieve variable partition allocation, involving data structure, partition allocation algorithm and partition allocation and recycling operations such as three problems). There are deficiencies in both fixed and dynamic partition allocations. Fixed partition allocations limit the number of active processes, and memory space utilization is low when the process size does not match the partition size. The dynamic partitioning method is complex, and the partition merging is necessary for the recovery of partition, and the system overhead is large. The partner system approach is a compromise between the two memory modes. The partner system stipulates that, regardless of the allocated partition or the idle partition, its size is 2 k power, K is an integer, 1<<k<<m, where: 2 of the 1 power to the minimum partition size, 2 m power is the maximum partition size, usually the entire allocation partition size. Paging Storage Management (the basic unit of memory discrete allocation is a page) is to solve the problem of fragmentation by continuous allocation. The logical space of a process is divided into pieces of equal size, called pages or pages, and numbered, and the corresponding memory space is divided into several storage blocks of the same page size, called blocks or page frames. Segmented storage Management (the basic unit of memory discrete allocation is a segment) is mainly to meet the programmer programming and use of the multiple requirements: convenient programming, information sharing, information protection, dynamic growth, dynamic connection. The previous chapters pave the road for Linux memory management. The Linux operating system uses virtual memory management technology, so that each process has its own process address space that is not interfering with each other. The space is a block size 4G (4G process space is artificially divided into two parts-user space and kernel space) of the linear virtual space, the user can see and contact is the virtual address, unable to see the actual physical address. This virtual address not only protects the operating system (the user cannot access physical memory directly), but more importantly, the user program can use a larger address space than the actual physical memory. The implementation of Linux virtual memory needs 6 kinds of mechanism support: address mapping mechanism, memory allocation and recovery mechanism, caching and refreshing mechanism, request paging mechanism, exchange mechanism and memory sharing mechanism. Bibliography: http://www.ibm.com/developerworks/cn/linux/l-memory/http://baike.baidu.com/view/4541016.htm http:// Baike.baidu.com/view/1082.htm http://blog.csdn.net/kanghua/archive/2007/10/22/1837872.aspx Http://articles.e-works.net.cn/411/article171

Related Article

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.