Memory resource management method and memory resource management equipment

By acquiring multiple memory requests in the computer system, determining the request set, and allocating memory resources from preset resource blocks, the memory fragmentation problem is solved and memory usage is improved.

CN119883583APending Publication Date: 2025-04-25SHANGHAI HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311378363.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-23
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In computer systems, memory fragments generated when tasks apply for and release memory resources, resulting in low memory resource utilization.

Method used

By obtaining multiple memory requests, determining the request set, and allocating corresponding memory resources from the preset resource blocks, ensuring that the memory resource size of each request is relatively balanced, reducing the generation of memory fragmentation.

Benefits of technology

It effectively reduces the probability of memory fragmentation, increases the utilization rate of memory resources, and ensures that the tasks can run normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883583A_ABST
    Figure CN119883583A_ABST
Patent Text Reader

Abstract

The invention discloses a memory resource management method and memory resource management equipment, relates to the technical field of computers, and can improve the utilization rate of memory resources. The specific scheme comprises: obtaining a plurality of first memory requests; then, according to the resource size requested by each first memory request, at least one request set is determined, and the request set comprises at least one first memory request; then, for each group of request sets, according to a target resource demand of the request set, determining a target resource block corresponding to the request set from a plurality of preset resource blocks, the target resource blocks being unoccupied preset resource blocks, and the sizes of memory resources of the preset resource blocks being the same; the target resource demand is the sum of the sizes of the memory resources required by the request set. And then, allocating memory resources of the corresponding target resource blocks to the to-be-processed tasks corresponding to the first set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a memory resource management method and a memory resource management device. Background Art

[0002] With the development of science and technology, more and more tasks are processed in computer systems. Computer systems need to frequently allocate memory resources for different tasks (or threads) to ensure that the tasks can run normally. In addition, when a task is completed, the computer system will release the memory resources used by the task so that other tasks can continue to use the memory resources.

[0003] At present, when a task applies for memory resources, the computer system can allocate free memory resources with continuous addresses to the task in the order of small to large address sizes according to the memory resource requirements. However, after the computer system allocates memory resources to the task from the free memory resources with continuous addresses, there may still be a small portion of remaining free resources. If the remaining free resources are small, the remaining free resources will become memory fragments and cannot be used by other tasks. In this way, when there are more memory fragments in the computer system, the utilization rate of memory resources will be low. Summary of the invention

[0004] The present application provides a memory resource management method and a memory resource management device, which can reduce the probability of memory fragmentation and thus improve the utilization rate of memory resources.

[0005] In a first aspect, the present application provides a memory resource management method, in which a plurality of first memory requests can be obtained, wherein the first memory request is used to request memory resources, and one first memory request corresponds to one task to be processed. Afterwards, at least one set of request sets can be determined based on the resource size requested by each first memory request, wherein the request set includes at least one first memory request. Then, for each set of request sets, based on the target resource requirements of the request set, an unoccupied target resource block corresponding to the request set is determined from a plurality of preset resource blocks, the size of the memory resources of each preset resource block is the same, and the target resource requirement is the sum of the sizes of the memory resources required by the request set. Then, the memory resources of the corresponding target resource block can be allocated to the task to be processed corresponding to the first set.

[0006] Based on the above technical solution, after the management device of the memory resource (which can be referred to as the management device) obtains multiple first memory requests, it can determine at least one set of request sets according to the resource size requested by each first memory request. Then, the management device can allocate preset resource blocks to the request set with the request set and the preset resource block as the granularity. In this way, it can be ensured that the preset resource blocks allocated to the request set correspond to the memory requirements of the request set. Moreover, the size of the memory resources corresponding to each preset resource block is the same, which can ensure that the size of the total memory requirements of each request set is relatively similar, thereby reducing the fluctuation of the memory size applied. In summary, the management device allocates memory resources with the request set and the preset resource block as the granularity, which can ensure that the size of the memory resources applied for each time is relatively balanced, thereby reducing the probability of memory fragmentation. Then, the management device allocates the memory resources of the corresponding target resource block to the pending tasks corresponding to the first set, so that each pending task obtains the required memory resources, thereby ensuring the normal operation of the task.

[0007] In combination with the first aspect, in a possible design method, the above-mentioned method of "determining at least one group of request sets based on the resource size requested by each first memory request" includes: if the request set is a first set, then the target resource block corresponding to the first set can be determined from multiple preset resource blocks, the first set is a request set whose target resource demand is less than or equal to a first preset value, and the first preset value is the size of the memory resource of the preset resource block.

[0008] In this way, it can be ensured that the preset resource blocks allocated to the request set can meet the memory requirements of the request set, thereby ensuring that the task can run normally.

[0009] In combination with the first aspect, in a possible design, multiple preset resource blocks are arranged consecutively in the memory according to a first preset order.

[0010] It is understandable that the plurality of preset resource blocks are arranged continuously in the memory according to the first preset order, so that there is no idle memory resource between the resource blocks, thus reducing the possibility of memory fragmentation and improving the utilization rate of memory resources.

[0011] In combination with the first aspect, in another possible design, the method may further include: if the request set is a second set, the first memory resource corresponding to each first memory request in the second set may be determined from the memory in a second preset order, the second set is a request set whose target resource demand is greater than the first preset value, and the second preset order is an order opposite to the first preset order. Then, the first memory resource may be allocated to the to-be-processed task corresponding to each first memory request in the second set.

[0012] It can be understood that if the request set is a second set whose target resource demand is greater than the first preset value, the management device determines the first memory resource corresponding to each first memory request in the second set from the memory according to the second preset order. In this way, the problem that the preset resource block cannot meet the resource demand of the task to be processed can be avoided, and the normal operation of the task to be processed can be guaranteed. In addition, the second preset order is an order opposite to the first preset order, so that the management device can allocate memory resources to the tasks corresponding to the second set from the memory in the opposite direction to the direction where the preset resource block is located. In this way, when the management device allocates resources to the tasks corresponding to the second set, it will not occupy the memory resources in the preset resource block, but will give priority to occupying the memory resources in the opposite direction to the direction where the preset resource block is located, which can ensure the efficient use of the preset resource block, thereby reducing the probability of memory fragmentation.

[0013] In combination with the first aspect, in another possible design method, the first set is specifically a request set in which the target resource demand is less than or equal to a first preset value and the target resource demand is greater than a second preset value, and the second preset value is less than the first preset value.

[0014] It is understandable that the first set may be a request set in which the target resource demand is less than or equal to the first preset value, and the target resource demand is greater than the second preset value, which means that the target resource demand is not only within the size range of the preset resource block, but also requires more memory resources, which will not cause more resources to remain in the preset resource block. In this way, more resources of the preset resource block can be occupied to improve resource utilization.

[0015] In combination with the first aspect, in another possible design, the method may further include: if the request set is a third set, the second memory resource corresponding to each first memory request in the third set may be determined from the memory according to a second preset order, the third set is a request set whose target resource demand is less than a second preset value, the second preset value is less than the first preset value, and the second preset order is an order opposite to the first preset order. Afterwards, the second memory resource may be allocated to the pending task corresponding to each first memory request in the third set.

[0016] It is understandable that if the request set is a third set whose target resource demand is less than the second preset value, the management device can determine the second memory resource corresponding to each first memory request in the third set from the memory according to the second preset order. In this way, it is possible to avoid the request set with less demand occupying the preset resource block, ensure the efficient use of the preset resource block, and thus reduce the probability of memory fragmentation.

[0017] In combination with the first aspect, in another possible design manner, there is no idle memory resource between the memory resources corresponding to any two tasks to be processed in the target resource block.

[0018] This avoids internal fragmentation when managing device memory allocations.

[0019] In combination with the first aspect, in another possible design, the method may further include: releasing memory resources of the target resource block.

[0020] It is understandable that the management device releases the memory resources of the target resource block, that is, releases the resources at the granularity of the preset resource block. In this way, the occupied preset resource block becomes an idle preset resource block, and the management device can continue to use the released preset resource block to provide memory resources for other request sets. In this way, allocating and releasing memory resources at the granularity of the preset resource block can reduce the probability of memory fragmentation and improve the utilization rate of memory resources.

[0021] In combination with the first aspect, in another possible design method, "releasing the memory resources of the target resource block" may include: when all the pending tasks corresponding to the first set are completed, the memory resources of the target resource block corresponding to the first set can be released.

[0022] It is understandable that when all pending tasks corresponding to the first set are completed, the management device releases the memory resources of the target resource block corresponding to the first set. In this way, it is possible to avoid releasing resources at the granularity of tasks, which may cause the preset resource block to be occupied by a separate memory request, thereby ensuring that the management device releases resources at the granularity of preset resource blocks, reducing the probability of memory fragmentation and improving the utilization rate of memory resources.

[0023] In combination with the first aspect, in another possible design, all to-be-processed tasks corresponding to the first memory request message in a set of requests are tasks corresponding to the same event.

[0024] It can be understood that the pending tasks corresponding to the first memory request message in a set of request sets are all tasks corresponding to the same event, which can ensure that the preset resource block provides memory resources for the pending tasks in the same event. In this way, when the running time (or life cycle) of the pending tasks in the same event is relatively close, it can avoid that some tasks occupy the preset resource block for a long time, thereby improving the resource utilization rate of the preset resource block.

[0025] In combination with the first aspect, in another possible design, the method may further include: obtaining at least one memory request message, the memory request message is used to request memory resources, and one memory request message corresponds to one task to be processed; the memory request message includes: memory type information, the memory type information is first type information or second type information, the first type information is used to indicate that the task to be processed uses the memory resources alone, and the second type information is used to indicate that the task to be processed uses the memory resources together with other tasks. Afterwards, for each memory request message, if the memory type information of the memory request message is the first type information, it can be determined that the memory request message is a first memory request, so as to obtain multiple first memory requests, and the first memory request is a memory request message whose memory type information is the first type information.

[0026] It is understandable that after the management device obtains at least one memory request message, it can determine the first memory request according to the memory type information, and the first memory request is a memory request message whose memory type information is the first type of information, and the first type of information is used to indicate that the pending task uses memory resources alone. In other words, the pending task that uses memory resources alone can occupy the preset resource block. Since the running time of a pending task is controllable, it can be ensured that the time for the task using a preset resource block to run is close to the completion time, which avoids some tasks occupying the preset resource block for a long time, thereby improving the resource utilization of the preset resource block.

[0027] In combination with the first aspect, in another possible design, the method may further include: if the memory type information of the memory request message is the second type information, a third memory resource may be determined from the memory in a second preset order according to the resource requirement information in the second memory request, and the second memory request is a memory request message whose memory type information is the second type information. Afterwards, the third memory resource may be allocated to the to-be-processed task corresponding to the second memory request.

[0028] It is understandable that if the memory type information of the memory request message is the second type information, the management device determines the third memory resource from the memory according to the second preset order based on the resource requirement information in the second memory request, and allocates the third memory resource to the pending task corresponding to the second memory request. That is, in the case where the task is a task that shares memory resources, the management device can allocate memory resources to the task from the memory in the opposite direction to the direction where the preset resource block is located. Since the release time is uncontrollable when the memory resources are shared, when the management device allocates resources to the task, it avoids occupying the memory resources in the preset resource block, but instead gives priority to occupying the memory resources in the opposite direction to the direction where the preset resource block is located, which can ensure the efficient use of the preset resource block, thereby reducing the probability of memory fragmentation.

[0029] In combination with the first aspect, in another possible design method, the first preset order is the order of memory addresses from large to small, and the second preset order is the order of memory addresses from small to large; or, the first preset order is the order of memory addresses from small to large, and the second preset order is the order of memory addresses from large to small.

[0030] In combination with the first aspect, in another possible design, the method may be applied to a memory resource management device, the memory resource management device comprising: an application layer and a middleware layer. The above-mentioned "obtaining multiple first memory requests" may include: sending each first memory request to the middleware layer respectively through the application layer. Afterwards, receiving each first memory request from the application layer through the middleware layer.

[0031] In combination with the first aspect, in another possible design, the method may also include: for each first memory request, after the first memory request is received through the middleware layer, a memory response message can be sent to the application layer through the middleware layer, and the memory response message is used to indicate that the first memory request has been received.

[0032] It is understandable that the middleware layer sends a memory response message to the application layer each time it receives a first memory request, so that the application layer can determine that the middleware layer has received the memory request message, thereby avoiding the task from repeatedly applying for memory without receiving a response from the middleware layer for a long time.

[0033] In combination with the first aspect, in another possible design, the first memory request also includes: an identifier of the target event, and the method may also include: when all pending tasks corresponding to the target event have applied for memory resources, sending a first message to the middleware layer through the application layer, the first message being used to indicate that a preset resource block is allocated for the pending tasks corresponding to the target event. Afterwards, the first message from the application layer may be received through the middleware layer, and target address information may be sent to the application layer through the middleware layer, the target address information including: at least one sub-address information, one sub-address information corresponding to one pending task corresponding to the first set.

[0034] It is understandable that, when all pending tasks corresponding to the target event have applied for memory resources, sending the first message to the middleware layer can enable the middleware to send the target address information to the application layer, thereby ensuring that the preset resource block provides memory resources for the pending tasks in the same event. In this way, when the running time (or life cycle) of the pending tasks in the same event is relatively close, it can avoid that some tasks occupy the preset resource block for a long time, thereby improving the resource utilization rate of the preset resource block.

[0035] In a second aspect, the present application provides a memory resource management device, which includes: an acquisition unit and a processing unit.

[0036] An acquisition unit is used to acquire multiple first memory requests, where the first memory requests are used to request memory resources; one first memory request corresponds to one task to be processed. A processing unit is used to obtain the resource size requested by each first memory request, and determine at least one set of request sets, where the request set includes at least one first memory request. The processing unit is also used to determine, for each set of request sets, a target resource block corresponding to the request set from multiple preset resource blocks according to the target resource requirement of the request set, where the target resource block is an unoccupied preset resource block, the size of the memory resource of each preset resource block is the same, and the target resource requirement is the sum of the sizes of the memory resources required by the request set. The processing unit is also used to allocate the memory resources of the corresponding target resource block to the task to be processed corresponding to the request set.

[0037] In combination with the first aspect, in a possible design method, the processing unit is specifically used to determine, if the request set is a first set, a target resource block corresponding to the first set from multiple preset resource blocks, the first set is a request set in which the target resource demand is less than or equal to a first preset value, and the first preset value is the size of the memory resource of the preset resource block.

[0038] In combination with the first aspect, in another possible design, multiple preset resource blocks are arranged consecutively in the memory according to a first preset order.

[0039] In combination with the first aspect, in another possible design, the processing unit is further used to determine the first memory resource corresponding to each first memory request in the second set from the memory in a second preset order if the request set is a second set, the second set is a request set whose target resource demand is greater than the first preset value, and the second preset order is an order opposite to the first preset order. The processing unit is also used to allocate the first memory resource to the to-be-processed task corresponding to each first memory request in the second set.

[0040] In combination with the first aspect, in another possible design method, the first set is specifically a request set in which the target resource demand is less than or equal to a first preset value and the target resource demand is greater than a second preset value, and the second preset value is less than the first preset value.

[0041] In combination with the first aspect, in another possible design, the processing unit is further used to determine the second memory resource corresponding to each first memory request in the third set from the memory according to the second preset order if the request set is a third set, the third set is a request set whose target resource demand is less than the second preset value, the second preset value is less than the first preset value, and the second preset order is the opposite order of the first preset order. The processing unit is also used to allocate the second memory resource to the to-be-processed task corresponding to each first memory request in the third set.

[0042] In combination with the first aspect, in another possible design, the acquisition unit is further used to acquire at least one memory request message, the memory request message is used to request memory resources, and one memory request message corresponds to one pending task; the memory request message includes: memory type information, the memory type information is first type information or second type information, the first type information is used to indicate that the pending task uses the memory resources alone, and the second type information is used to indicate that the pending task uses the memory resources together with other tasks. The acquisition unit is specifically used to, for each memory request message, if the memory type information of the memory request message is the first type information, determine that the memory request message is a first memory request, so as to acquire multiple first memory requests, wherein the first memory request is a memory request message whose memory type information is the first type information.

[0043] In combination with the first aspect, in another possible design, the processing unit is further configured to determine a third memory resource from the memory in a second preset order according to resource requirement information in the second memory request if the memory type information of the memory request message is the second type information, and the second memory request is a memory request message whose memory type information is the second type information. The processing unit is further configured to allocate the third memory resource to the to-be-processed task corresponding to the second memory request.

[0044] In a third aspect, the present application provides a memory resource management method, in which at least one memory request message can be obtained, the memory request message is used to request memory resources, and one memory request message corresponds to one task to be processed; the memory request message includes: memory type information, the memory type information is the first type information or the second type information, the first type information is used to indicate that the task to be processed uses the memory resources alone, and the second type information is used to indicate that the task to be processed uses the memory resources together with other tasks. For each memory request message, if the memory type information of the memory request message is the first type information, multiple first memory requests are obtained, and the multiple first memory requests are divided into at least one set of request sets, and the first memory request is a memory request message whose memory type information is the first type information. Afterwards, according to the target resource requirement of the request set, the target resource block corresponding to the request set is determined from multiple preset resource blocks, the target resource block is an unoccupied preset resource block, the size of the memory resource of each preset resource block is the same, and the target resource requirement is the sum of the sizes of the memory resources required by the request set. Then, the memory resources of the corresponding target resource block are allocated to the task to be processed corresponding to the request set. If the memory type information of the memory request message is the second type information, the third memory resource is determined from the memory in a second preset order according to the resource requirement information in the second memory request, and the second memory request is a memory request message whose memory type information is the second type information. The third memory resource is allocated to the to-be-processed task corresponding to the second memory request.

[0045] Based on the above technical solution, after the management device obtains at least one memory request message, the memory request message can be divided into a first memory request and a second memory request. Since the running time of a pending task is controllable, the pending task that uses memory resources alone can occupy a preset resource block. In this way, it can be ensured that the time for the tasks using a preset resource block to run and complete is close, avoiding some tasks from occupying the preset resource block for a long time, and improving the resource utilization rate of the preset resource block. In the case where the task is a task that shares memory resources, the management device can allocate memory resources to the task from the memory in the opposite direction of the preset resource block. Since the release time is uncontrollable when the memory resources are shared, when the management device allocates resources to the task, it avoids occupying the memory resources in the preset resource block, but gives priority to occupying the memory resources in the opposite direction of the preset resource block, which can ensure the efficient use of the preset resource block, thereby reducing the probability of memory fragmentation.

[0046] In a fourth aspect, the present application provides a memory resource management device, which includes: a memory and one or more processors, wherein the memory is coupled to the processors; the memory is used to store computer program code, and the computer program code includes computer instructions; when the computer instructions are executed by the one or more processors, the memory resource management device executes the method described in the first aspect, the third aspect, and any possible design method in the first aspect and the third aspect.

[0047] In a fifth aspect, the present application provides a chip system, which is applied to a memory resource management device. The chip system includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by a line. The interface circuit is used to receive a signal from a memory of the memory resource management device and send the signal to the processor, and the signal includes a computer instruction stored in the memory. When the processor executes the computer instruction, the memory resource management device executes the method described in the first aspect, the third aspect, and any possible design method in the first aspect and the third aspect.

[0048] In a sixth aspect, the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a memory resource management device, the memory resource management device executes the method described in the first aspect, the third aspect, and any possible design method in the first aspect and the third aspect.

[0049] In a seventh aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect, the third aspect, and any possible design of the first aspect and the third aspect.

[0050] It can be understood that the beneficial effects that can be achieved by the memory resource management device described in the second aspect and any possible design method provided above, the memory resource management equipment described in the fourth aspect and any possible design method provided above, the chip system described in the fifth aspect, the computer-readable storage medium described in the sixth aspect, and the computer program product described in the seventh aspect can be referred to as the beneficial effects in the first aspect, the third aspect, and any possible design method of the first aspect and the third aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1A A schematic diagram of an example of memory fragmentation provided in an embodiment of the present application;

[0052] Figure 1B A schematic diagram of an example of memory allocation provided in an embodiment of the present application;

[0053] Figure 2 A system architecture diagram of a memory resource management device provided in an embodiment of the present application;

[0054] Figure 3 A flow chart of a memory resource management method provided in an embodiment of the present application;

[0055] Figure 4 A schematic diagram of an example of a preset resource block provided in an embodiment of the present application;

[0056] Figure 5 A schematic diagram of another example of a preset resource block provided in an embodiment of the present application;

[0057] Figure 6 A flowchart of another memory resource management method provided in an embodiment of the present application;

[0058] Figure 7 A flowchart of another memory resource management method provided in an embodiment of the present application;

[0059] Figure 8 A flowchart of another memory resource management method provided in an embodiment of the present application;

[0060] Fig. 9 A flowchart of another memory resource management method provided in an embodiment of the present application;

[0061] Fig.10 A schematic diagram of a memory resource management example provided in an embodiment of the present application;

[0062] Fig.11 A schematic diagram of the structural composition of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0064] In this application, the character " / " generally indicates that the objects before and after are in an "or" relationship. For example, A / B can be understood as A or B.

[0065] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0066] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not limited to the listed steps or modules, but may optionally include other steps or modules that are not listed, or may optionally include other steps or modules that are inherent to these processes, methods, products or devices.

[0067] In addition, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present concepts in a specific way.

[0068] In order to facilitate understanding of the technical solution of the present application, before introducing the memory resource management method of the embodiment of the present application in detail, the professional terms mentioned in the embodiment of the present application are first introduced.

[0069] Shared memory can refer to memory shared by multiple tasks (or processes). Taking multiple processes as an example, the multiple processes share the same memory through the following specific implementation: when multiple processes are started, they map the shared memory to their own memory. In this way, multiple processes own the shared memory at the same time and perform read and write operations on the shared memory. For example, when two processes sharing the memory need to transmit data, the sending process writes the data to the shared memory, and the receiving process reads the data from the shared memory, thereby avoiding the copying of data during the transmission process.

[0070] After introducing the professional terms mentioned in the embodiments of the present application, conventional technologies are introduced below.

[0071] As described in the background technology, in the process of applying for memory resources and releasing memory resources for tasks in a computer system, since the sizes of memory resources required by different tasks are different, and the computer system needs to allocate free memory resources with continuous addresses to tasks in the order of address size from small to large, it may cause memory fragmentation in the computer system (i.e., the free memory resources are small and cannot be used by other tasks). Among them, memory fragmentation includes internal fragmentation and external fragmentation. In this way, when there are more memory fragments in the computer system, the utilization rate of memory resources will be low, and even the problem of memory application failure will occur.

[0072] It should be noted that internal fragmentation refers to the free memory in the allocated memory. The reason for internal fragmentation is that when allocating memory, the computer system will limit the minimum amount of allocated memory resources. For example, the computer system will allocate at least a first value of memory resources. The first value of memory resources can be called the minimum allocation unit or allocation unit. Even if the size of the memory resources requested by the task is less than an integer multiple of the first value, the computer system will allocate an integer multiple of the first value of memory resources to the task. In this way, some memory resources will be wasted. At this time, the allocated memory resources except the memory resources requested by the task can be called internal fragmentation. For example, Figure 1A As shown, the computer system allocates a first value of memory 1 to task a. Memory 1 includes memory 1a and memory 1b. Memory 1a is the memory required by task a, and memory 1b is an idle memory resource (ie, internal fragmentation).

[0073] External fragmentation refers to the free memory between two already allocated memories. The reason for external fragmentation is that since the size of memory required by each task is different, frequent allocation, recovery, and reallocation will cause part of the memory to be mixed in the middle of the allocated memory, and this memory is small and cannot be allocated again. This memory can be called external fragmentation. For example, suppose there are 100 units of continuous free memory space (such as 0-99). If task 1 applies for 10 units of memory, the memory applied for is 0-9. Afterwards, task 2 applies for 5 units of memory, and the memory applied for is 10-14. The computer system then releases memory 0-9, and then applies for a memory block larger than 10 units (such as 20 units). Because the memory block that has just been released cannot meet the new request, only 20 units of memory can be allocated starting from 15, that is, 15-34. In addition, part of the memory from 35 to 99 is also occupied. For example Figure 1BAs shown in the figure, the status of the entire memory space is now 0-9 is free, 10-14 is occupied, 15-34 is occupied, 35-50 is occupied, 51-55 is free, 56-70 is occupied, 71-80, 81-90, 91-99 are free. Among them, 0-9 is a memory fragment. If 10-14 is always occupied, and the memory space requested in the future is larger than 10 units, then 0-9 will never be used. For example, Figure 1A As shown, the computer system allocates memory 2 for task b. There is memory 3 between memory 2 and memory 1. The size of memory 3 is small and cannot meet the needs of other tasks.

[0074] At present, in order to reduce the amount of memory fragmentation, the computer system can merge the memory required by multiple tasks and allocate fixed memory resources to multiple tasks each time. For example, the memory required by task a, task b and task c for the first time is 30 units of memory, and the computer system allocates memory 1-30 to task a, task b and task c. The next time task a, task b and task c need memory resources again, the computer system directly allocates memory 1-30 to task a, task b and task c. However, the resources required by the task may be different each time. If they are allocated according to fixed memory resources, it may still lead to a waste of memory resources, and the flexibility of the above scheme is also low.

[0075] To this end, an embodiment of the present application provides a memory resource management method. In the method, a memory resource management device (which may be referred to as a management device) may obtain memory requests for multiple tasks to be processed, and group multiple memory requirements to obtain different request sets. Afterwards, the management device may determine the corresponding resource block for the request set from multiple preset resource blocks according to the amount of resources required for each request set, and allocate memory resources in the resource block to the tasks to be processed. In this way, the management device may allocate memory resources in preset resource blocks to multiple tasks to be processed in the memory with preset resource blocks as the granularity. Moreover, the size of the memory resources corresponding to each preset resource block is the same, which can ensure that the size of the total memory resources required by the tasks occupying the preset resource blocks each time is relatively similar, thereby reducing the fluctuation of the memory size applied. In this way, the management device can allocate memory resources according to the size of the preset resource blocks, which can ensure that the size of the memory resources applied for each time is relatively balanced, thereby reducing the probability of memory fragmentation.

[0076] It should be noted that the execution subject of the memory resource management method provided by the present application can be a memory resource management device, and the memory resource management device can be an electronic device or a network device, etc. At the same time, the memory resource management device can also be a central processing unit (CPU) of the electronic device, or a management module for managing memory resources in the electronic device, or a computer system deployed in the electronic device. In the embodiment of the present application, the memory resource management method provided by the embodiment of the present application is described by taking the memory resource management device executing the memory resource management method as an example.

[0077] Exemplarily, the electronic device in the embodiments of the present application may be a tablet computer, a mobile phone, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR)\virtual reality (VR) device, a vehicle-mounted device, or the electronic device may be a server, and the embodiments of the present application do not impose any special restrictions on the specific form of the electronic device. Alternatively, the network device may include various forms of base stations, such as: macro base stations, micro base stations (also called small stations), relay stations, access points, etc.

[0078] It should be noted that the embodiments of the present application do not limit the computer system deployed on the management device. In addition, the system architecture of the computer system can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. For example, the computer system can be an embedded system, System, etc.

[0079] Please refer to Figure 2 , this application takes the computer system as an embedded system as an example to introduce the computer system provided by this application.

[0080] Figure 2 2 is a system architecture diagram of the embedded system 200 of the embodiment of the present application. Figure 2 As shown, the embedded system 200 can be divided into four layers, which are, from top to bottom, an application layer (also called a business layer), a middleware layer (also called a platform layer), a driver layer, and a hardware layer.

[0081] The application layer contains various functions and features required by users to support various businesses (or events). One event corresponds to multiple pending tasks. Events are the parent class of pending tasks, and pending tasks are the subclasses of events. The application layer and the underlying hardware interact and transmit data through middleware.

[0082] For example, if the event is a base station sending and receiving signals, the tasks to be processed in the event may include: tasks for receiving signals, tasks for processing events, and tasks for sending signals. For another example, if the event is a mobile phone displaying a video, the tasks to be processed in the event may include: display tasks, rendering tasks, etc.

[0083] The middleware layer is located in the middle of the embedded system and is responsible for providing various general services and interfaces to facilitate the interaction between the application layer and the underlying hardware. Among them, the middleware layer may include: an operating system, which is the most important component of the middleware layer. The operating system may include multiple system software, which can manage system resources and provide computer services. For example, the operating system may include memory resource management software, which, when executed, can apply for memory from the hardware layer. At the same time, the operating system is also the interface between the application layer and the hardware. The middleware layer may also include: drivers, network protocol stacks, databases, remote procedure calls (not shown in some figures), etc.

[0084] The driver layer is used to directly control the hardware and provide services to the upper layer. The driver layer is responsible for driving various hardware devices, such as sensors, computing chips, displays, etc. The driver and application layer use different communication protocols. For example, the serial port can connect the smart meter and the terminal, and the communication between the two is based on the Modbus protocol.

[0085] The hardware layer includes various hardware devices, such as microprocessors, memories, registers, I / O interfaces, radio frequency communication modules (some are not shown in the figure), etc. The hardware layer is responsible for completing tasks such as digital signal conversion, data storage and processing, providing hardware resources, and communication.

[0086] The methods in the following embodiments can all be implemented in a memory resource management device having the above system architecture.

[0087] In an embodiment of the present application, the management device may obtain multiple first memory requests. Afterwards, the management device may determine at least one set of request sets based on the resource size requested by each first memory request, and the request set includes at least one first memory request. For each set of request sets, the management device may determine the unoccupied target resource block corresponding to the request set from multiple preset resource blocks based on the sum of the resource requirements of the request set, the target resource block being an unoccupied preset resource block, and the size of the memory resources of each preset resource block is the same. Then, the management device may allocate the memory resources of the corresponding target resource block to the pending task corresponding to the request set.

[0088] The present application embodiment provides a memory resource management method, such as Figure 3 As shown, the memory resource management method may include S301-S305.

[0089] S301: A management device obtains multiple first memory requests.

[0090] Among them, the first memory request can be used to request memory resources. The first memory request includes: resource requirement information, and the resource requirement information is used to indicate the size of the requested memory resources. It should be understood that in the present application, the memory resources requested by the memory request can also be referred to as the resources required by the memory request, and the size of the memory resources requested by the memory request can also be referred to as the resource size required by the memory request or the resource size required by the memory request. For example, the memory resources requested by the first memory request can be referred to as the memory resources required by the first memory request, and the size of the memory resources requested by the first memory request can be referred to as the resource size required by the first memory request.

[0091] In the embodiment of the present application, one first memory request corresponds to one task to be processed.

[0092] For example, if the event is a base station sending and receiving signals, the tasks to be processed may include: tasks for receiving signals, tasks for processing events, and tasks for sending signals. For another example, if the event is a mobile phone displaying a video, the tasks to be processed may include: display tasks, rendering tasks, etc.

[0093] That is, the resource requirement information is used to indicate the size of the memory resources required by the task to be processed.

[0094] Exemplarily, memory request a corresponds to task a, memory request b corresponds to task b, and memory request c corresponds to task c. The resource requirement information in memory request a is 10 megabytes, the resource requirement information in memory request b is 5 megabytes, and the resource requirement information in memory request c is 8 megabytes, which means that task a requires 10 megabytes of memory, task b requires 15 megabytes of memory, and task c requires 8 megabytes of memory.

[0095] S302: The management device determines at least one request set according to the resource size required by each first memory request.

[0096] A set of request sets includes at least one first memory request.

[0097] It should be noted that the embodiment of the present application does not limit the number of first memory requests in each request set. For example, a request set may include 1 first memory request. For another example, a request set may include 5 first memory requests. For another example, a request set may include 10 first memory requests.

[0098] In a possible implementation manner, the management device may adopt a greedy algorithm to group the multiple first memory requests according to the resource requirement information of each first memory request to determine at least one request set.

[0099] It should be noted that, in the embodiment of the present application, the greedy strategy is used to indicate that the difference between the memory resource size required by the request set and the memory resource size of the preset resource block is less than a preset threshold, for example, the memory resource size required by the request set is close to the size of the memory resource of the preset resource block. It should be understood that the sum of the memory resource sizes required by the request set may refer to the sum of the memory resource sizes requested by all memory requests included in the request set.

[0100] In an embodiment of the present application, the management device may traverse at least one first memory request through a greedy strategy, and sort the at least one first memory request in descending order according to resource requirement information. Then, for each first memory request, the management device may combine the first memory request with other first memory requests from front to back until the difference in the size of memory resources required by the first memory request and the target memory request in the other first memory requests is less than a preset threshold, and the first memory request and the target memory request are divided into a request set.

[0101] For example, if the size of the memory resource of the preset resource block is 100 megabytes. The resource requirement information of memory request a is 50 megabytes, the resource requirement information of memory request b is 40 megabytes, the resource requirement information of memory request c is 80 megabytes, the resource requirement information of memory request d is 20 megabytes, the resource requirement information of memory request e is 75 megabytes, and the resource requirement information of memory request f is 30 megabytes. The management device can sort memory request a-memory request f from large to small according to the size of the resource requirement information, and obtain memory request c-memory request e-memory request a-memory request b-memory request f-memory request d. Afterwards, the management device traverses the above memory requests through a greedy strategy to group them, and groups memory request c and memory request d into one group (request set a), memory request e and memory request f into one group (request set b), and memory request a and memory request b into one group (request set c).

[0102] S303: The management device determines whether the requested set is the first set.

[0103] In some embodiments, the first set is a request set whose target resource requirement is less than or equal to a first preset value, and the first preset value is the size of the memory resource of the preset resource block. The target resource requirement is the sum of the sizes of the memory resources required by the request set.

[0104] In an embodiment of the present application, the management device may determine the target resource requirement of the request set based on the resource requirement information of each first memory request in the request set.

[0105] Exemplarily, request set a includes memory request c and memory request d, request set b includes memory request e and memory request f, and request set c includes memory request a and memory request b in one group. Among them, the resource requirement information of memory request a is 50 megabytes, the resource requirement information of memory request b is 40 megabytes, the resource requirement information of memory request c is 80 megabytes, the resource requirement information of memory request d is 20 megabytes, the resource requirement information of memory request e is 75 megabytes, and the resource requirement information of memory request f is 30 megabytes. Then the target resource requirement of request set a is 100 megabytes, the target resource requirement of request set b is 105 megabytes, and the target resource requirement of request set c is 90 megabytes.

[0106] It should be noted that the first preset value is not limited in the embodiment of the present application. For example, the first preset value may be 50 megabytes. For another example, the first preset value may be 80 megabytes. For another example, the first preset value may be 100 megabytes.

[0107] In an embodiment of the present application, the memory in the management device includes multiple preset resource blocks, and the size of the memory resources of each preset resource block is the same.

[0108] For example, Figure 4 As shown, if there are 50 units of continuous memory space (such as 10-59) in the memory, the size of the memory resource of each preset resource block is 10 units. Among them, resource block 401 includes 50-59 units of memory space, resource block 402 includes 40-49 units of memory space, resource block 403 includes 30-39 units of memory space, resource block 404 includes 20-29 units of memory space, and resource block 405 includes 10-19 units of memory space.

[0109] In a possible implementation manner, a plurality of preset resource blocks may be arranged continuously in a memory according to a first preset order.

[0110] In the embodiment of the present application, there is no memory resource between two adjacent preset resource blocks. Figure 4 It can be seen that there is no memory space between resource block 401 and resource block 402 , there is no memory space between resource block 402 and resource block 403 , and there is no memory space between resource block 403 and resource block 404 .

[0111] In the embodiment of the present application, the first preset order is determined according to the size of the memory address. The first preset order can be the order of the memory address from large to small, or the order of the memory address from small to large.

[0112] In a possible design, the first preset order may be an order of memory addresses from large to small.

[0113] For example, if resource block a includes: memory resources at memory address 0×99-memory address 0×90, resource block b includes: memory resources at memory address 0×89-memory address 0×80, and resource block c includes: memory resources at memory address 0×79-memory address 0×70.

[0114] In another possible design, the first preset order may be an order of memory addresses from small to large.

[0115] Exemplarily, if resource block a includes: memory resources at memory address 0×00 and memory address 0×09, resource block b includes: memory resources at memory address 0×10 and memory address 0×19, resource block c includes: memory resources at memory address 0×20 and memory address 0×29.

[0116] It is understandable that the plurality of preset resource blocks are arranged continuously in the memory according to the first preset order, so that there is no idle memory resource between the resource blocks, thus reducing the possibility of memory fragmentation and improving the utilization rate of memory resources.

[0117] In another possible implementation, the plurality of preset resource blocks are not arranged continuously in the memory. There are memory resources between two preset resource blocks, and the memory resources in two adjacent resource blocks are not adjacent memory resources in the memory.

[0118] Optionally, there is a memory resource of a preset size between two adjacent preset resource blocks, and the preset size is smaller than a preset threshold.

[0119] It should be noted that the embodiments of the present application do not limit the preset threshold. For example, the preset threshold may be 2 bytes, or 10 bytes, or 40 bytes.

[0120] For example, Figure 5 As shown, if the memory includes resource blocks 501-503, resource block 501 includes: memory resources at memory address 0×99-memory address 0×90, resource block 502 includes: memory resources at memory address 0×87-memory address 0×78, and resource block 503 includes: memory resources at memory address 0×76-memory address 0×67.

[0121] That is to say, there are memory resources at memory addresses 0×89 to 0×88 between resource block 501 and resource block 502 , and there are memory resources at memory address 0×77 between resource block 502 and resource block 503 .

[0122] It is understandable that the multiple preset resource blocks are not arranged continuously in the memory, so that there are idle memory resources between the resource blocks. In this way, when the resources used by the task exceed the applied memory resources, resources can still be provided for the task to ensure that the task can run normally.

[0123] In the embodiment of the present application, the management device may compare the target resource requirement of the request set with a first preset value. If the target resource requirement is less than or equal to the first preset value, the management device determines that the request set is the first set.

[0124] For example, if request set a includes: memory request a (requesting 40 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b) and memory request c (requesting 20 megabytes of memory resources for task c), the target resource requirement of request set a is 90 megabytes. If the first preset value is 100 megabytes, then request set a is the first set.

[0125] It should be noted that in an embodiment of the present application, for each request set, the management device can compare the target resource requirement of the request set with a first preset value to determine whether the request set is the first set (i.e., execute S303 for each request set).

[0126] In some other embodiments, the first set may be a set of requests whose target resource requirement is less than or equal to a first preset value and whose target resource requirement is greater than a second preset value. The second preset value is less than the first preset value.

[0127] It should be noted that the second preset value is not limited in the embodiment of the present application. For example, the second preset value may be 30 megabytes. For another example, the second preset value may be 60 megabytes. For another example, the second preset value may be 80 megabytes.

[0128] For example, if request set a includes: memory request a (requesting 40 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b) and memory request c (requesting 20 megabytes of memory resources for task c), the target resource requirement of request set a is 90 megabytes. If the first preset value is 100 megabytes and the second preset value is 80 megabytes, then request set a is the first set.

[0129] It is understandable that the first set may be a request set in which the target resource demand is less than or equal to the first preset value, and the target resource demand is greater than the second preset value, which means that the target resource demand is not only within the size range of the preset resource block, but also requires more memory resources, which will not cause more resources to remain in the preset resource block. In this way, more resources of the preset resource block can be occupied to improve resource utilization.

[0130] In some embodiments, for each request set, if the request set is the first set, the management device executes S304.

[0131] S304. The management device determines a target resource block corresponding to the first set from a plurality of preset resource blocks.

[0132] In the embodiment of the present application, if the request set is the first set, the management device determines the target resource block corresponding to the first set from the plurality of preset resource blocks, wherein the target resource block is an unoccupied preset resource block.

[0133] In a possible implementation, the management device stores first information, the first information being used to indicate whether a preset resource block is occupied. The management device may determine a target resource block corresponding to the first set according to the first information of each preset resource block.

[0134] In one possible design, the first information may be a first identifier or a second identifier, the first identifier being used to indicate that the preset resource block has been occupied, and the second identifier being used to indicate that the preset resource block has not been occupied.

[0135] It should be noted that the embodiment of the present application does not limit the form of expression of the first information. For example, the first information can be represented by a number (such as "1" for occupied and "0" for unoccupied). For another example, the first information can be represented by a letter (such as "a" for occupied and "b" for unoccupied).

[0136] It should be noted that, in the embodiment of the present application, the preset resource block has been occupied, which means that all memory addresses or part of the memory addresses in the preset resource block have been allocated. The preset resource block is not occupied, which means that all memory addresses in the preset resource block are not allocated. In other words, if there are allocated addresses among all memory addresses in the preset resource block, it means that the preset resource block has been occupied, and if all memory addresses in the preset resource block are not allocated addresses, it means that the preset resource block has been occupied.

[0137] Exemplarily, as shown in Table 1, it shows the first information of the preset resource block.

[0138] Table 1

[0139] Preset Resource Blocks Memory resources First Information Resource Block a Address 0×99 - Address 0×90 Occupied Resource block b Address 0×89 - Address 0×80 Not occupied Resource Block c Address 0×79 - Address 0×70 Not occupied Resource Block d Address 0×69 - Address 0×60 Occupied

[0140] That is to say, the memory resources in resource block a are currently being used by tasks, the memory resources in resource block b are not being used by tasks, the memory resources in resource block c are not being used by tasks, and the memory resources in resource block d are currently being used by tasks. Among them, the addresses 0×99 to 0×90 in resource block a have been allocated, and the addresses 0×69 to 0×60 in resource block d have been allocated.

[0141] Exemplarily, in combination with Table 1, the management device determines according to the first information that resource block a and resource block d are occupied, and then resource block b or resource block c can be used as the target resource block of the first set.

[0142] In another possible implementation, the management device may traverse the plurality of preset resource blocks in sequence according to a first preset order, and determine whether each preset resource block is occupied, until a target resource block corresponding to the first set is determined from the plurality of preset resource blocks.

[0143] Exemplarily, if the first preset order is the order of memory addresses from large to small. In combination with Table 1, the management device first traverses resource block a to determine that the memory addresses in resource block a have been allocated. Afterwards, the management device can traverse resource block b to determine that none of the memory addresses in resource block b have been allocated. Then, resource block b can be used as the target resource block of the first set.

[0144] S305. The management device allocates memory resources of corresponding target resource blocks to the tasks to be processed corresponding to the first set.

[0145] The pending tasks corresponding to the first set are pending tasks corresponding to each first memory request in the first set.

[0146] In a possible implementation, for each first memory request in the first set, the management device may determine the memory resource corresponding to the first memory request from the target resource block in a first preset order according to the resource requirement information of the first memory request. Afterwards, the management device may allocate the memory resource corresponding to the first memory request to the to-be-processed task corresponding to the first memory request.

[0147] Exemplarily, if the first preset order is the order of memory addresses from large to small, the first set includes: memory request a (requesting 40 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b) and memory request c (requesting 20 megabytes of memory resources for task c), and the target resource block includes: memory resources at memory address 0×87-memory address 0×78, then the management device can allocate memory resources at memory address 0×87-memory address 0×84 to task a, allocate memory resources at memory address 0×83-memory address 0×81 to task b, and allocate memory resources at memory address 0×80-memory address 0×79 to task c.

[0148] Optionally, the management device may determine the memory resource corresponding to the first memory request from the target resource block according to a second preset order.

[0149] Exemplarily, if the first preset order is the order of memory addresses from small to large, the first set includes: memory request a (requesting 40 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b) and memory request c (requesting 20 megabytes of memory resources for task c), and the target resource block includes: memory resources from memory address 0×87 to memory address 0×78, then the management device can allocate memory resources from memory address 0×78 to memory address 0×81 to task a, allocate memory resources from memory address 0×82 to memory address 0×84 to task b, and allocate memory resources from memory address 0×85 to memory address 0×86 to task c.

[0150] Optionally, there is no free memory resource between the memory resources corresponding to any two tasks to be processed in the target resource block.

[0151] In an exemplary embodiment, the size of the memory resource allocated by the management device for the task to be processed is the same as the size of the memory resource required by the task to be processed. The memory resource corresponding to the first memory request is greater than 0, and the memory resource corresponding to the first memory request is less than or equal to a first preset value.

[0152] That is to say, in the embodiment of the present application, the management device allocates memory with the preset resource block as the granularity, and limits the maximum number of allocated memory resources by the resource size of the preset resource block, and does not limit the minimum number of allocated memory resources. That is, the occupied memory resources in the preset resource block are adjacent to each other. In this way, it can be avoided that the management device limits the minimum number of allocated memory resources when allocating memory, which leads to internal fragmentation.

[0153] Based on the above technical solution, when the management device allocates preset resource blocks to the request set with the request set and the preset resource block as the granularity, it can ensure that the preset resource blocks allocated to the request set can meet the memory requirements of the request set. In addition, the size of the memory resources corresponding to each preset resource block is the same, which can ensure that the size of the total memory requirements of each request set is relatively similar, thereby reducing the fluctuation of the requested memory size. In summary, the management device allocates memory resources with the request set and the preset resource block as the granularity, which can ensure that the size of the memory resources requested each time is relatively balanced, thereby reducing the probability of memory fragmentation. Then, the management device allocates the memory resources of the corresponding target resource block to the pending tasks corresponding to the first set, so that each pending task obtains the required memory resources, thereby ensuring the normal operation of the task.

[0154] In some embodiments, the management device may allocate a target resource block for a request set whose required resource size is less than a first preset value. For a request set whose resource requirements exceed the resource amount of the preset resource block, the management device may allocate memory resources from the memory for each task to be processed according to the resource requirements of each task to be processed.

[0155] like Figure 6 As shown, an embodiment of the present application provides a memory resource management method. After S303, the memory resource management method may include S601-S602.

[0156] S601. A management device determines, from a memory according to a second preset order, a first memory resource corresponding to each first memory request in a second set.

[0157] The second set is a set of requests whose target resource demand is greater than the first preset value.

[0158] For example, if request set a includes: memory request a (requesting 50 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b) and memory request c (requesting 30 megabytes of memory resources for task c), the target resource requirement of request set a is 110 megabytes. If the first preset value is 100 megabytes, then request set a is the second set.

[0159] In the embodiment of the present application, the second preset order is an order opposite to the first preset order.

[0160] Exemplarily, if the first preset order is the order of memory addresses from small to large, then the second preset order is the order of memory addresses from large to small. If the first preset order is the order of memory addresses from large to small, then the second preset order is the order of memory addresses from small to large. The following takes the second preset order as the order of memory addresses from small to large as an example to introduce the present application.

[0161] In an embodiment of the present application, if the request set is the second set, the management device determines the first memory resource corresponding to each first memory request in the second set from the memory according to a second preset order.

[0162] That is, after the management device executes S303, if the requested set is the second set, the management device may execute S601.

[0163] In one possible implementation, for each first memory request in the second set, the management device may traverse the memory addresses of the memory in sequence according to the resource requirement information of the first memory request and in a second preset order to determine whether each memory address is occupied until the first memory resource corresponding to the first memory request is determined from the memory.

[0164] For example, if the second set includes: memory request a (requesting 50 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b), and memory request c (requesting 30 megabytes of memory resources for task c), there are 50 units of continuous memory space (such as 0-49) in the memory, and the memory space of units 0-3, 9-16, 19-22, and 40-45 is occupied. The management device can determine the memory space of units 4-8 as the memory resource of task a, the memory space of units 23-25 ​​as the memory resource of task b, and the memory space of units 26-28 as the memory resource of task c.

[0165] S602: The management device allocates a first memory resource to a to-be-processed task corresponding to each first memory request in the second set.

[0166] For example, if the second set includes: memory request a (requesting 50 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b), and memory request c (requesting 30 megabytes of memory resources for task c), there are 50 units of continuous memory space (such as 0-49) in the memory, and 0-3, 9-16, 19-22, and 40-45 units of memory space are occupied. The management device can allocate 4-8 units of memory space to task a, 23-25 ​​units of memory space to task b, and 26-28 units of memory space to task c.

[0167] It can be understood that if the request set is a second set whose target resource demand is greater than the first preset value, the management device determines the first memory resource corresponding to each first memory request in the second set from the memory according to the second preset order. In this way, the problem that the preset resource block cannot meet the resource demand of the task to be processed can be avoided, and the normal operation of the task to be processed can be guaranteed. In addition, the second preset order is an order opposite to the first preset order, so that the management device can allocate memory resources to the tasks corresponding to the second set from the memory in the opposite direction to the direction where the preset resource block is located. In this way, when the management device allocates resources to the tasks corresponding to the second set, it will not occupy the memory resources in the preset resource block, but will give priority to occupying the memory resources in the opposite direction to the direction where the preset resource block is located, which can ensure the efficient use of the preset resource block, thereby reducing the probability of memory fragmentation.

[0168] In some embodiments, for a request set whose resource requirements exceed the resource amount of a preset resource block, the management device may allocate memory resources from the memory to each task to be processed according to the resource requirements of each task to be processed. For a request set whose resource requirements are much less than the resource amount of a preset resource block, the management device may also allocate memory resources from the memory to each task to be processed according to the resource requirements of each task to be processed.

[0169] like Figure 7 As shown, an embodiment of the present application provides a memory resource management method. After S303, the memory resource management method may include S701-S702.

[0170] S701. A management device determines, from a memory according to a second preset order, a second memory resource corresponding to each first memory request in a third set.

[0171] Among them, the third set is a request set whose target resource demand is less than or equal to a second preset value, the second preset value is less than the first preset value, and the second preset order is the opposite order of the first preset order.

[0172] For example, if request set a includes: memory request a (requesting 30 megabytes of memory resources for task a), memory request b (requesting 20 megabytes of memory resources for task b) and memory request c (requesting 5 megabytes of memory resources for task c), the target resource requirement of request set a is 55 megabytes. If the second preset value is 80 megabytes, then request set a is the third set.

[0173] In the embodiment of the present application, if the request set is the third set, the management device determines the second memory resource corresponding to each first memory request in the third set from the memory according to the second preset order.

[0174] That is, after the management device executes S303, if the requested set is the third set, the management device may execute S701.

[0175] In one possible implementation, for each first memory request in the third set, the management device can traverse the memory addresses of the memory in sequence according to the resource requirement information of the first memory request in a second preset order to determine whether each memory address is occupied until the first memory resource corresponding to the first memory request is determined from the memory.

[0176] For example, if the third set includes: memory request a (requesting 30 megabytes of memory resources for task a), memory request b (requesting 20 megabytes of memory resources for task b), and memory request c (requesting 5 megabytes of memory resources for task c), there are 50 units of continuous memory space (such as 0-49) in the memory, and 0-3, 9-16, 19-22, and 40-45 units of memory space are occupied. The management device can determine 4-6 units of memory space as memory resources for task a, 23-25 ​​units of memory space as memory resources for task b, and 26 units of memory space as memory resources for task c.

[0177] S702: The management device allocates second memory resources to the to-be-processed task corresponding to each first memory request in the third set.

[0178] It is understandable that if the request set is a third set whose target resource demand is less than the second preset value, the management device can determine the second memory resource corresponding to each first memory request in the third set from the memory according to the second preset order. In this way, it is possible to avoid the request set with less demand occupying the preset resource block, ensure the efficient use of the preset resource block, and thus reduce the probability of memory fragmentation.

[0179] It should be noted that, when the pending tasks occupying the preset resource blocks are completed, if the preset resource blocks are still occupied, it will lead to a waste of memory resources.

[0180] In some embodiments, after the management device allocates the memory resources of the target resource block corresponding to the to-be-processed tasks corresponding to the first set, the management device may release the memory resources of the target resource block.

[0181] In some examples, the management device releasing the memory resources of the target resource block means that all memory resources in the target resource block are released.

[0182] In a possible implementation, for each pending task corresponding to the first set, when the pending task is completed, the management device releases the memory resources occupied by the pending task until all memory resources of the target resource block are released.

[0183] That is to say, each time the management device completes a pending task, it releases the memory resources of the pending task.

[0184] For example, if the first set includes: memory request a (requesting 40 megabytes of memory resources for task a), memory request b (requesting 30 megabytes of memory resources for task b), and memory request c (requesting 20 megabytes of memory resources for task c), the target resource block includes: memory resources at memory address 0×87-memory address 0×78, task a occupies memory resources at memory address 0×87-memory address 0×84, task b occupies memory resources at memory address 0×83-memory address 0×81, and task c occupies memory resources at memory address 0×80-memory address 0×79. After task b is completed, the management device can release the memory resources at memory address 0×83-memory address 0×81. After task a is completed, the management device can release the memory resources at 0×87-memory address 0×84. After task c is completed, the management device can release the memory resources at memory address 0×80-memory address 0×79.

[0185] It is understandable that the management device releases the memory resources of the target resource block, that is, releases the resources at the granularity of the preset resource block. In this way, the occupied preset resource block becomes an idle preset resource block, and the management device can continue to use the released preset resource block to provide memory resources for other request sets. In this way, allocating and releasing memory resources at the granularity of the preset resource block can reduce the probability of memory fragmentation and improve the utilization rate of memory resources.

[0186] In another possible implementation manner, when all pending tasks corresponding to the first set are completed, the management device may release the memory resources of the target resource block corresponding to the first set.

[0187] That is to say, the management device does not release the memory resources of each pending task after completing the execution of the pending task, but waits until all pending tasks occupying the target resource block are completed before releasing the memory resources of the target resource block.

[0188] Exemplarily, if the first set includes: memory request a (requesting memory resources for task a), memory request b (requesting memory resources for task b) and memory request c (requesting memory resources for task c), tasks a-task c occupy the memory resources at memory address 0×87-memory address 0×79 in resource block a. After task a is completed, the management device does not release the memory resources. After task b is completed, the management device does not release the memory resources either. Until task c is also completed (that is, all tasks occupying the resource block are completed), the management device releases the memory resources at memory address 0×87-memory address 0×79 in resource block a.

[0189] It is understandable that when all pending tasks corresponding to the first set are completed, the management device releases the memory resources of the target resource block corresponding to the first set. In this way, it is possible to avoid releasing resources at the granularity of tasks, which may cause the preset resource block to be occupied by a separate memory request, thereby ensuring that the management device releases resources at the granularity of preset resource blocks, reducing the probability of memory fragmentation and improving the utilization rate of memory resources.

[0190] In some embodiments, after the management device releases the memory resources of the target resource block, the management device may update the first information of the target resource block.

[0191] In one possible design, after the management device releases the memory resources of the target resource block, the management device may update the first information of the target resource block to a second identifier.

[0192] Exemplarily, if the first information is "1" when resource block a is occupied, after the management device releases the memory resources of resource block a, the first information of resource block a is updated to "0".

[0193] In this way, the management device updates the first information of the target resource block and can timely update the unoccupied status of the target resource block, so that the management device can allocate the memory resources of the target resource block to the pending tasks corresponding to other request sets to improve the utilization efficiency of memory resources.

[0194] It should be noted that programs that implement various functions and features are deployed in the management device to support various businesses (or events). One event corresponds to multiple pending tasks, and the operation of the event is completed by the multiple pending tasks corresponding to the event. When the management device runs multiple events, the management device can obtain pending tasks for different events. If the management device adds the memory requests corresponding to the pending tasks of different events to the same request set, a preset resource block will provide memory resources for the pending tasks of different events. Since the task running time of different events may be different, some tasks will still be running after some tasks are completed, so that the preset resource block is still in an occupied state, reducing the resource utilization of the preset resource block.

[0195] In some embodiments, the to-be-processed tasks corresponding to the first memory request messages in a set of requests are all tasks corresponding to the same event.

[0196] For example, if request set a includes: memory request a (requesting memory resources for signal receiving task), memory request b (requesting memory resources for signal processing task) and memory request c (requesting memory resources for signal sending task), the signal receiving task, signal processing task and signal sending task all correspond to events of base station receiving and sending signals.

[0197] It can be understood that the pending tasks corresponding to the first memory request message in a set of request sets are all tasks corresponding to the same event, which can ensure that the preset resource block provides memory resources for the pending tasks in the same event. In this way, when the running time (or life cycle) of the pending tasks in the same event is relatively close, it can avoid that some tasks occupy the preset resource block for a long time, thereby improving the resource utilization rate of the preset resource block.

[0198] It should be noted that the above embodiment determines the way to allocate memory resources to each pending task based on the resource demand and the resource amount of the preset resource block. However, the memory request message can have different types. In some embodiments, the management device can determine the way to allocate memory resources based on the type of the memory request message.

[0199] like Figure 8 As shown, an embodiment of the present application provides a memory resource management method. Before S301, the memory resource management method may also include S801-S802.

[0200] S801. A management device obtains at least one memory request message.

[0201] The memory request message is used to request memory resources, and one memory request message corresponds to one task to be processed.

[0202] In an embodiment of the present application, the memory request message may include: memory type information. The memory type information may be first type information or second type information, the first type information is used to indicate that the task to be processed uses memory resources alone, and the second type information is used to indicate that the task to be processed uses memory resources together with other tasks.

[0203] In some examples, the to-be-processed task using the memory resource alone means that the memory resource can only be used by one task. The to-be-processed task and other tasks using the memory resource together (ie, shared memory) means that the memory resource can be shared by multiple tasks.

[0204] Exemplarily, taking the base station signal receiving and sending events as an example, the base station signal receiving and sending events may include: signal receiving tasks, filtering tasks, demodulation tasks, signal sending tasks, etc. The signal receiving tasks and signal sending tasks are tasks that use memory resources separately. When the same signal is received in different cells, each cell needs to process the signal (such as filtering, demodulation, etc.), then the filtering tasks and demodulation tasks of different cells can share memory resources.

[0205] It should be noted that the embodiments of the present application do not limit the form of expression of the memory type information. For example, the memory type information can be represented by numbers (such as "1" represents the first type of information, and "0" represents the second type of information). For another example, the memory type information can be represented by letters (such as "a" represents the first type of information, and "b" represents the second type of information).

[0206] S802: The management device determines whether the memory type information of the memory request message is first type information.

[0207] In an embodiment of the present application, for each memory request message in at least one memory request message, the management device may execute S802 to determine whether the memory request message is a first memory request or a second memory request. The first memory request is a memory request message whose memory type information is first type information, and the second memory request is a memory request message whose memory type information is second type information.

[0208] In some embodiments, for each memory request message, if the memory type information of the memory request message is first type information, the management device determines that the memory request message is a first memory request to obtain multiple first memory requests (ie, S301).

[0209] It is understandable that after the management device obtains at least one memory request message, it can determine the first memory request according to the memory type information, and the first memory request is a memory request message whose memory type information is the first type of information, and the first type of information is used to indicate that the pending task uses memory resources alone. In other words, the pending task that uses memory resources alone can occupy the preset resource block. Since the running time of a pending task is controllable, it can be ensured that the time for the task using a preset resource block to run is close to the completion time, which avoids some tasks occupying the preset resource block for a long time, thereby improving the resource utilization of the preset resource block.

[0210] In some other embodiments, if the memory type information of the memory request message is the second type information, the management device determines that the memory request message is the second memory request. Afterwards, the management device may execute S803.

[0211] S803: The management device determines a third memory resource from the memory according to a second preset order based on the resource requirement information in the second memory request.

[0212] In one possible implementation, for the second memory request, the management device can traverse the memory addresses of the memory in sequence according to the resource requirement information of the second memory request in a second preset order to determine whether each memory address is occupied until the third memory resource corresponding to the second memory request is determined from the memory.

[0213] S804: The management device allocates a third memory resource to the to-be-processed task corresponding to the second memory request.

[0214] It is understandable that if the memory type information of the memory request message is the second type information, the management device determines the third memory resource from the memory according to the second preset order based on the resource requirement information in the second memory request, and allocates the third memory resource to the pending task corresponding to the second memory request. That is, in the case where the task is a task that shares memory resources, the management device can allocate memory resources to the task from the memory in the opposite direction to the direction where the preset resource block is located. Since the release time is uncontrollable when the memory resources are shared, when the management device allocates resources to the task, it avoids occupying the memory resources in the preset resource block, but instead gives priority to occupying the memory resources in the opposite direction to the direction where the preset resource block is located, which can ensure the efficient use of the preset resource block, thereby reducing the probability of memory fragmentation.

[0215] Combine the following Figure 2 The computer system shown is used to introduce the embodiments of the present application.

[0216] like Fig. 9 As shown, an embodiment of the present application provides a memory resource management method, which may include S901-S911.

[0217] S901. The application layer sends each memory request message to the middleware layer.

[0218] The memory request message may be a first memory request or a second memory request.

[0219] In a possible implementation, in response to the task triggering instruction, the application layer generates a memory request message, and then sends the memory request message to the middleware layer.

[0220] In another possible implementation, when the memory request is the first memory request, the application layer may send a request set to the middleware layer.

[0221] That is, the application layer can determine multiple first memory requests according to the memory type information of the memory request message. Afterwards, the application layer can determine at least one set of request sets (ie, S302) according to the resource requirement information of each first memory request, and send the request set to the middleware layer.

[0222] S902: The middleware layer receives each memory request message from the application layer.

[0223] In a possible implementation, after the application layer sends the memory request message to the middleware layer, the middleware layer may receive the memory request message from the application layer.

[0224] That is to say, the application layer uses the memory request message as the granularity, and each time a memory request message is generated, the application layer can send a memory request message to the middleware layer. Moreover, the memory request received by the middleware layer is also the memory request message as the granularity.

[0225] For example, when the memory request message is a first memory request, the middleware layer may receive the first memory request from the application layer. When the memory request message is a second memory request, the middleware layer may receive the second memory request from the application layer.

[0226] In another possible implementation, after the application layer sends the request set to the middleware layer, the middleware layer may receive the request set from the application layer.

[0227] That is to say, the application layer sends a memory request message to the middleware layer with the request set as the granularity, and the memory request received by the middleware layer is also with the request set as the granularity.

[0228] In some embodiments, the middleware layer may determine whether the memory request message is the first memory request. If the memory request message is the first memory request, the middleware layer may execute S903-S908.

[0229] In some embodiments, if the memory request message is a second memory request, the middleware layer may execute S909 - S911 .

[0230] S903: For each first memory request, the middleware layer sends a memory response message to the application layer.

[0231] The memory response message is used to indicate that the first memory request has been received.

[0232] In an embodiment of the present application, for each first memory request, after the middleware layer receives the first memory request, the middleware layer may send a memory response message to the application layer.

[0233] Optionally, the memory response message may include: an identifier of a memory address corresponding to the first memory request.

[0234] Exemplarily, the identifier of the memory address may be the address of the memory address (ie, memory pre-allocation), or the identifier of the memory address may be a secondary pointer of the memory address.

[0235] It is understandable that the middleware layer sends a memory response message to the application layer each time it receives a first memory request, so that the application layer can determine that the middleware layer has received the memory request message, thereby avoiding the task from repeatedly applying for memory without receiving a response from the middleware layer for a long time.

[0236] S904: When all pending tasks corresponding to the target event have applied for memory resources, the application layer sends a first message to the middleware layer.

[0237] The first message is used to indicate that a preset resource block is allocated to a task to be processed corresponding to a target event.

[0238] That is, after the application layer sends all memory request messages corresponding to the target event to the middleware layer, the application layer may send the first message to the middleware layer.

[0239] In a possible implementation, the application layer may detect whether all pending tasks corresponding to the target event have applied for memory resources. If all pending tasks corresponding to the target event have applied for memory resources, the application layer may send a first message to the middleware layer.

[0240] Optionally, the first message includes: an identifier of a target event. The first memory request corresponding to the target event refers to the first memory request corresponding to the to-be-processed task corresponding to the target event.

[0241] S905: The middleware layer receives a first message from the application layer.

[0242] S906: The middleware layer sends a second message to the hardware layer.

[0243] The second message is used to request memory resources for the request set.

[0244] In a possible design, the first memory request also includes: an identifier of the target event. After receiving the first message, the middleware layer can determine all memory requests corresponding to the target event based on the identifier of the first memory request corresponding to the target event, and divide all memory requests corresponding to the target event into at least one request set. Afterwards, for each request set, the middleware layer sends a second message of the request set to the hardware layer. Among them, the memory request corresponding to the target event refers to the memory request message corresponding to the task to be processed corresponding to the target event.

[0245] Correspondingly, the hardware layer receives the second message from the middleware layer and determines the target resource block.

[0246] It should be noted that, for the process of determining the target resource block at the hardware layer, reference may be made to the introduction of determining the target resource block in the above embodiment (such as S304), which will not be described in detail here.

[0247] S907: The hardware layer sends the target address information to the middleware layer.

[0248] The target address information includes: at least one sub-address information, and one sub-address information corresponds to a to-be-processed task corresponding to the first set.

[0249] Exemplarily, if the first set includes: memory request a (requesting memory resources for task a), memory request b (requesting memory resources for task b) and memory request c (requesting memory resources for task c), then the target address information includes: sub-address information a corresponding to task a, sub-address information b corresponding to task b, and sub-address information c corresponding to task c.

[0250] Correspondingly, the middleware layer receives the target address information from the hardware layer.

[0251] S908. The middleware layer sends the target address information to the application layer.

[0252] Correspondingly, the application layer receives the target address information from the middleware layer.

[0253] In the embodiment of the present application, after the application layer receives the target address information from the middleware layer, it can allocate sub-address information to each to-be-processed task corresponding to the first set.

[0254] It is understandable that, when all pending tasks corresponding to the target event have applied for memory resources, sending the first message to the middleware layer can enable the middleware to send the target address information to the application layer, thereby ensuring that the preset resource block provides memory resources for the pending tasks in the same event. In this way, when the running time (or life cycle) of the pending tasks in the same event is relatively close, it can avoid that some tasks occupy the preset resource block for a long time, thereby improving the resource utilization rate of the preset resource block.

[0255] S909: For the second memory request, the middleware layer sends a third message to the hardware layer.

[0256] The third message is used to instruct to allocate a third memory resource to the pending task (which may be referred to as a shared memory task) corresponding to the second memory request.

[0257] Correspondingly, the hardware layer receives the third message from the middleware layer, and determines the third memory resource corresponding to the shared memory task.

[0258] It should be noted that, for the process of the hardware layer determining the third memory resource corresponding to the task to be processed, reference may be made to the introduction of determining the third memory resource in the above embodiment (such as S803), which will not be described in detail here.

[0259] S910. The hardware layer sends a memory address corresponding to the shared memory task to the middleware layer.

[0260] Correspondingly, the middleware layer receives the memory address corresponding to the shared memory task from the hardware layer.

[0261] S911. The middleware layer sends the memory address corresponding to the shared memory task to the application layer.

[0262] In an embodiment of the present application, after the application layer receives the memory address corresponding to the shared memory task from the middleware layer, the memory address allocated to the shared memory task can be allocated.

[0263] After introducing the process of requesting memory resources, the process of releasing memory resources is introduced below.

[0264] In some embodiments, when the pending task is completed, the application layer may send a memory release request to the middleware layer. After the middleware layer receives all memory release requests corresponding to the same preset resource block, the middleware layer may send a fourth message to the hardware layer, the fourth message being used to instruct the release of all memory resources in the preset resource block. In response to the fourth message, the hardware layer may release all memory resources in the preset resource block.

[0265] In other implementations, when the pending task is completed, the application layer may send a memory release request to the middleware layer. Afterwards, the middleware layer may send a fifth message to the hardware layer, the fifth message being used to instruct the release of the memory resources corresponding to the pending task. In response to the fifth message, the hardware layer may release the memory resources corresponding to the pending task in the preset resource block. Then, each time a pending task is completed, the hardware layer may release the memory resources corresponding to a pending task in the preset resource block until the hardware layer releases the last occupied memory resources in the preset resource block.

[0266] The present application is introduced below with reference to specific examples. Fig.10As shown, the first preset order is the order of memory addresses from large to small (also called from back to front), and the second preset order is the order of memory addresses from small to large (also called from front to back) as an example. The management device can allocate resource 1001 to shared memory task (i.e., the pending task corresponding to the second memory request) a, shared memory task b, and shared memory task c in a search manner from front to back in the memory. Among them, resource 1002 and resource 1003 are all occupied, and the sizes of resource 1001, resource 1002, and resource 1003 are different. In addition, the management device can allocate preset resource block 1004 (i.e., multiple unique memories are applied for by LCL) from back to front in the memory for multiple unique memory tasks (i.e., the pending tasks corresponding to the first memory request) in request set a (such as unique memory task 1, unique memory task 2, unique memory task 3, unique memory task 4,). Among them, the sizes of memory resources in preset resource block 1004, preset resource block 1005, and preset resource block 1006 are the same. That is, memory resources may be bidirectionally allocated by searching from front to back and requesting resource blocks from back to front at the same time (which may be referred to as a delayed aggregation algorithm (DDA)).

[0267] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the management device. It is understandable that, in order to realize the above functions, the management device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the steps of a memory resource management method of each example described in the embodiment disclosed in this application, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or management device software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0268] The embodiment of the present application can divide the memory resource management device into functional modules or functional units according to the above method example. For example, each functional module or functional unit can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules or functional units. Among them, the division of modules or units in the embodiment of the present application is schematic, which is only a logical function division. There may be other division methods in actual implementation.

[0269] Some other embodiments of the present application provide a management device. The management device may include: a memory and one or more processors. The memory and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the management device may perform various functions or steps performed by the management device in the above method embodiment.

[0270] The present application also provides a chip system, such as Fig.11 As shown, the chip system includes at least one processor 1101 and at least one interface circuit 1102. The processor 1101 and the interface circuit 1102 can be interconnected via lines. For example, the interface circuit 1102 can be used to receive signals from other devices (such as the memory of the management device). For another example, the interface circuit 1102 can be used to send signals to other devices (such as the processor 1101). Exemplarily, the interface circuit 1102 can read the instructions stored in the memory and send the instructions to the processor 1101. When the instructions are executed by the processor 1101, the management device can execute the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0271] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned management device, the management device executes each function or step executed by the management device in the above-mentioned method embodiment.

[0272] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the management device in the above method embodiment.

[0273] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0274] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0275] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0276] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0277] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0278] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A memory resource management method, characterized in that: The method comprises: Acquire multiple first memory requests, where the first memory requests are used to request memory resources; one first memory request corresponds to one task to be processed; Determine at least one set of requests according to the resource size requested by each of the first memory requests, the set of requests including at least one of the first memory requests; For each group of the request sets, according to the target resource requirement of the request set, determining the target resource block corresponding to the request set from multiple preset resource blocks, the target resource block is an unoccupied preset resource block, the size of the memory resource of each preset resource block is the same, and the target resource requirement is the sum of the sizes of the memory resources required by the request set; Allocate memory resources of the target resource block corresponding to the to-be-processed task corresponding to the request set.

2. The method according to claim 1, characterized in that The step of determining, for each group of the request sets, a target resource block corresponding to the request set from a plurality of preset resource blocks according to a target resource requirement of the request set, comprises: If the request set is the first set, the target resource block corresponding to the first set is determined from multiple preset resource blocks, the first set is a request set whose target resource demand is less than or equal to a first preset value, and the first preset value is the size of the memory resource of the preset resource block.

3. The method according to claim 2, characterized in that The plurality of preset resource blocks are arranged continuously in the memory according to a first preset order.

4. The method according to claim 3, characterized in that The method further comprises: If the request set is a second set, determining the first memory resource corresponding to each of the first memory requests in the second set from the memory in a second preset order, the second set being a request set whose target resource demand is greater than the first preset value, and the second preset order being an order opposite to the first preset order; Allocate the first memory resource to each pending task corresponding to the first memory request in the second set.

5. The method according to claim 3 or 4, characterized in that: The first set is specifically a request set in which the target resource demand is less than or equal to the first preset value, and the target resource demand is greater than a second preset value, and the second preset value is less than the first preset value.

6. The method according to any one of claims 3 to 5, characterized in that: The method further comprises: If the request set is a third set, determining the second memory resource corresponding to each of the first memory requests in the third set from the memory according to a second preset order, the third set is a request set whose target resource demand is less than a second preset value, the second preset value is less than the first preset value, and the second preset order is an order opposite to the first preset order; The second memory resource is allocated to each pending task corresponding to the first memory request in the third set.

7. The method according to any one of claims 1 to 6, characterized in that There is no idle memory resource between the memory resources corresponding to any two tasks to be processed in the target resource block.

8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: Release the memory resources of the target resource block.

9. The method according to claim 8, characterized in that The releasing the memory resources of the target resource block comprises: When all the to-be-processed tasks corresponding to the first set are completed, the memory resources of the target resource block corresponding to the first set are released.

10. The method according to any one of claims 1 to 9, characterized in that: The tasks to be processed corresponding to the first memory request messages in a group of the request sets are all tasks corresponding to the same event.

11. The method according to any one of claims 1 to 10, characterized in that: Before obtaining the plurality of first memory requests, the method further includes: Acquire at least one memory request message, where the memory request message is used to request memory resources, and one memory request message corresponds to one task to be processed; the memory request message includes: memory type information, where the memory type information is first type information or second type information, where the first type information is used to indicate that the task to be processed uses the memory resources alone, and the second type information is used to indicate that the task to be processed uses the memory resources together with other tasks; The obtaining of multiple first memory requests includes: For each of the memory request messages, if the memory type information of the memory request message is the first type information, the memory request message is determined to be the first memory request to obtain the multiple first memory requests, and the first memory request is a memory request message whose memory type information is the first type information.

12. The method according to claim 11, characterized in that The method further comprises: If the memory type information of the memory request message is the second type information, determining a third memory resource from the memory in accordance with a second preset order according to the resource size requested by the second memory request, the second memory request being a memory request message whose memory type information is the second type information; The third memory resource is allocated to the task to be processed corresponding to the second memory request.

13. The method according to any one of claims 3 to 12, characterized in that: The first preset order is the order of memory addresses from large to small, and the second preset order is the order of memory addresses from small to large; or, the first preset order is the order of memory addresses from small to large, and the second preset order is the order of memory addresses from large to small.

14. The method according to any one of claims 1 to 13, characterized in that The method is applied to a memory resource management device, the memory resource management device comprising: an application layer and a middleware layer; The obtaining of multiple first memory requests includes: Sending each of the first memory requests to the middleware layer respectively through the application layer; Each of the first memory requests from the application layer is received through the middleware layer.

15. The method according to claim 14, characterized in that The method further comprises: For each of the first memory requests, after the first memory request is received by the middleware layer, a memory response message is sent to the application layer by the middleware layer, where the memory response message is used to indicate that the first memory request has been received.

16. The method according to claim 14 or 15, characterized in that The first memory request further includes: an identifier of a target event. Before determining the target resource block corresponding to the first set from the plurality of preset resource blocks, the method further includes: In a case where all pending tasks corresponding to the target event have applied for memory resources, sending a first message to the middleware layer through the application layer, wherein the first message is used to indicate allocation of a preset resource block for the pending tasks corresponding to the target event; receiving the first message from the application layer through the middleware layer; The allocating the memory resources of the target resource block corresponding to the to-be-processed tasks corresponding to the first set includes: The target address information is sent to the application layer through the middleware layer, wherein the target address information includes: at least one sub-address information, and one sub-address information corresponds to one of the to-be-processed tasks corresponding to the first set.

17. A memory resource management device, characterized in that: The device comprises: An acquiring unit, configured to acquire a plurality of first memory requests, wherein the first memory requests are used to request memory resources; one first memory request corresponds to one task to be processed; a processing unit, configured to obtain a resource size requested according to each of the first memory requests, and determine at least one set of requests, wherein the set of requests includes at least one of the first memory requests; The processing unit is further configured to determine, for each group of the request sets, a target resource block corresponding to the request set from a plurality of preset resource blocks according to a target resource requirement of the request set, wherein the target resource block is an unoccupied preset resource block, the size of the memory resource of each preset resource block is the same, and the target resource requirement is the sum of the sizes of the memory resources required by the request set; The processing unit is further used to allocate the memory resources of the corresponding target resource block to the to-be-processed tasks corresponding to the request set.

18. The device according to claim 17, characterized in that The processing unit is specifically used to determine, if the request set is a first set, a target resource block corresponding to the first set from a plurality of preset resource blocks, the first set being a request set whose target resource demand is less than or equal to a first preset value, and the first preset value being the size of the memory resource of the preset resource block.

19. The device according to claim 18, characterized in that The plurality of preset resource blocks are arranged continuously in the memory according to a first preset order.

20. The device according to claim 19, characterized in that The processing unit is further configured to determine, from the memory, a first memory resource corresponding to each of the first memory requests in the second set according to a second preset order if the request set is a second set, the second set being a request set whose target resource demand is greater than the first preset value, and the second preset order being an order opposite to the first preset order; The processing unit is further used to allocate the first memory resource to a to-be-processed task corresponding to each of the first memory requests in the second set.

21. The device according to claim 19 or 20, characterized in that The first set is specifically a request set in which the target resource demand is less than or equal to the first preset value, and the target resource demand is greater than a second preset value, and the second preset value is less than the first preset value.

22. The device according to any one of claims 19 to 21, characterized in that The processing unit is further configured to, if the request set is a third set, determine from the memory a second memory resource corresponding to each of the first memory requests in the third set in a second preset order, the third set being a request set whose target resource demand is less than a second preset value, the second preset value being less than the first preset value, and the second preset order being an order opposite to the first preset order; The processing unit is further used to allocate the second memory resource to the to-be-processed task corresponding to each first memory request in the third set.

23. The device according to any one of claims 17 to 22, characterized in that The acquisition unit is further used to acquire at least one memory request message, where the memory request message is used to request memory resources, and one memory request message corresponds to one task to be processed; The memory request message includes: memory type information, where the memory type information is first type information or second type information, where the first type information is used to indicate that the task to be processed uses memory resources alone, and the second type information is used to indicate that the task to be processed uses memory resources together with other tasks; The acquisition unit is specifically used to, for each of the memory request messages, determine that the memory request message is the first memory request if the memory type information of the memory request message is the first type information, so as to acquire the multiple first memory requests, wherein the first memory request is a memory request message whose memory type information is the first type information.

24. The device according to claim 23, characterized in that The processing unit is further configured to determine, if the memory type information of the memory request message is the second type information, a third memory resource from the memory in accordance with a second preset order according to a resource size requested by the second memory request, the second memory request being a memory request message whose memory type information is the second type information; The processing unit is further configured to allocate the third memory resource to the task to be processed corresponding to the second memory request.

25. A memory resource management device, characterized in that: The memory resource management device includes: a memory and one or more processors; the memory is coupled to the processor, the memory is used to store computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the one or more processors, the memory resource management device executes the method described in any one of claims 1-16.

26. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on a memory resource management device, cause the memory resource management device to execute the method according to any one of claims 1 to 16.

Citation Information

Cited By

  • Memory control method, computing device, storage medium and program product

    CN121501518A