Memory management reading notes

xiaoxiao2021-03-06  38

I continue my task! Today's information may have no life help to the paper, but there may be a summary role in the future. Because I believe that myOS (51) can grow up, it is sure to need a memory management mechanism. [SIZE = 5] Memory Management [/ size] Knowing the capacity of the memory management system can assist the application design and help to avoid traps. If you use a dynamic process, you need to assign a certain resource for a certain process, including memory resources. There are also other moments, some system supports dynamic establishment of data nodes or any other dynamic variables. It is necessary to face a few questions, which is the assignment how to recover? What should I do if I have a debris when I allocate? How to combine the neighboring two pieces when recycling? How to handle the nesting and the superior is recycled, and the lower level is forgotten, it is useless and not dead? Dynamic memory allocation is performed using the remaining memory, which is called a heap (HEAP). Here is an object-control block to introduce a data dictionary to maintain internal information of the memory area stack. Information includes: actually address, size, allocation table. A valid memory manager must quickly perform the following scattered work. * Determine whether the idle memory has been met the requirements. * Change internal management information. * Determines whether the block just released can be combined into a large piece with adjacent free blocks. The object involved has an allocation array to achieve allocation mapping. Find the most suitable spatial location for allocation, used to do heap sort.

Book mentioned two operations, assigns Malloc and release free. [Color = Red] Malloc [/ color] When the dispensing block, the area idle or used is recorded by allocating an array. Indicates that the first unit of the idle area is filled in the number of idle areas with the last unit. If the block is assigned, the value is assigned a negative number in the first allocation unit, and the last unit assigns 0 to represent the boundary. In order to find the most suitable air block area, use build a pile to record the size and position of all idle blocks. Whether it is allocated or released in memory, it is necessary to register here. [Color = Red] free [/ color] When the release block is released, in addition to the value of the first tail unit of the released block. It is also necessary to determine if the adjacent units can be merged. If you can merge, you should add the total number of idle blocks of the two units to assign the first tail unit of this idle block. Then add a new node on the heap and remove the merged node. Built again!

Let's talk about the problem of fragmentation. The fragmentation is divided into internal fragments and external scales. In order to facilitate the management of large-area memory, the heap is assigned to a piece of ascendum in one byte. The allocated block is not possible to complete, the storage space belongs to the block is referred to as [Color = Red] internal fragment [/ color]. The other is due to the constant allocation and release of a zero-scattered block that is too small and unable to dispensed between the occupied blocks. These spaces have become [Color = Red] External Debris [/ color].

[size = 4] Fixed size memory management in embedded systems [/ size]

In those applications that have a predictable environment, when the start angle knows the number of running tasks and initializes the required memory size, it is more suitable for [Color = Red] memory pool [/ color]. Its structure is a one-way linked list. The nodes on the linked list are the same size. In order to handle applications of different sizes, multiple linked lists are used. So this is only suitable for a predictable environment, and the user operates a fixed or small system. It is generally used in embedded network programming, such as embedded protocol stacks.

Last continued

转载请注明原文地址:https://www.9cbs.com/read-75857.html

New Post(0)