Resource allocation structure, memory management method, and memory management system

By managing the operations of each node through an independent node management module in the resource allocation structure, the problem of low CPU efficiency and memory waste caused by the scattered memory space management of the malloc function is solved, achieving efficient memory access and saving.

CN116340000BActive Publication Date: 2026-05-29SHENZHEN CITY TECHWIN SEMICONDUCTOR COMPANY LIMITED

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN CITY TECHWIN SEMICONDUCTOR COMPANY LIMITED
Filing Date
2023-03-27
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, the memory space managed by the malloc function is physically scattered and has low access efficiency, resulting in low CPU efficiency and inflexible memory release, causing resource waste.

Method used

It adopts a resource allocation structure, including a node management module, a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module. Each node's operation is managed through an independent node management module, enabling synchronous and independent operation execution, improving CPU access efficiency and saving memory space.

Benefits of technology

By managing the operations of each node independently, the efficiency of CPU access to memory is improved, memory space waste is reduced, and the efficiency and flexibility of memory management are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116340000B_ABST
    Figure CN116340000B_ABST
Patent Text Reader

Abstract

The application provides a resource allocation structure, a memory management method and a memory management system. The resource allocation structure comprises at least one node management module, and a linked list node allocation module, a residual space calculation module, a linked list number management module and a physical address calculation module connected with the node management module respectively. The node management modules are independent of each other. In this way, the behaviors of each node are managed by the node management modules in the resource allocation structure, so that all the nodes can synchronously judge the operation to be performed, thereby improving the efficiency of CPU accessing memory and saving memory space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory management technology, and in particular to a resource allocation structure, a memory management method, and a memory management system. Background Technology

[0002] In current technology, the malloc function (memory allocation, dynamic memory allocation function) is commonly used to manage memory. The pointer returned by malloc is a virtual address, which requires multiple address decoding steps to become the actual physical address. With repeated allocation and deallocation, memory becomes many small fragments, making the allocated space physically dispersed. Accessing this space requires a linked list-like approach, searching node by node from the beginning until the target location is found, which is time-consuming and reduces CPU (Central Processing Unit) efficiency. Furthermore, memory allocated using malloc can only be freed once, resulting in the consumption of large amounts of memory. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a resource allocation structure, a memory management method, and a memory management system that can improve the efficiency of CPU access to memory while saving memory space.

[0004] In a first aspect, embodiments of the present invention provide a resource allocation structure, comprising: at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, each connected to the node management module; the node management modules are independent of each other; the linked list node allocation module is used to determine whether the node number of any node is in use, and when a new linked list is generated, it provides unused node numbers for the new linked list to use; the remaining space calculation module is used to determine whether the current linked list meets the requirements of the new linked list; the linked list number management module is used to determine whether the linked list number of any linked list is in use, and when a new linked list is generated, it provides unused linked list numbers for the new linked list to use; the physical address calculation module is used to receive a feedback signal sent by the node management module when an address query or node query request is received, and convert the feedback signal from one-hot encoding to physical address; the node management modules are used to synchronously determine the operation to be performed when node operations are performed, and independently perform the corresponding operation; the node operations include creating a new linked list, querying a node, releasing a linked list, and releasing a node.

[0005] Furthermore, the node management module includes a node state value trigger, a linked list number trigger, and a node position trigger. The node state value trigger is used to record the state value of the current node to determine whether the current node management module corresponding to the current node is used by the linked list. The linked list number trigger is used to record the linked list number of the current linked list to which the current node management module belongs. The node position trigger is used to record the node position of the current node management module in the current linked list.

[0006] Secondly, embodiments of the present invention provide a memory management method applied to the above-mentioned resource allocation structure; the method includes: obtaining operation information of the current linked list; wherein the operation information includes at least one of linked list allocation, node query, linked list release and node release; sending the operation information to each node management module of the resource allocation structure, so that each node management module synchronously determines the operation to be performed and independently performs the corresponding operation.

[0007] Furthermore, the operation information is a linked list request; the operation information is sent to each node management module of the resource allocation structure so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, including: obtaining the memory space size of the linked list to be created; determining the first number of node management modules corresponding to the linked list to be created based on the memory space size; obtaining the second number of unused node management modules, and if the first number is less than or equal to the second number, determining the unused linked list number as the first linked list number of the linked list to be created; based on the linked list node allocation module, obtaining the current node status value and node number of each node management module, determining the node management module whose current node status value is 1 and whose node number meets the preset requirements as the node management module to be created corresponding to the linked list to be created; determining the current linked list number of the node management module to be created as the first linked list number; wherein, the linked list node allocation module is set on the resource allocation structure.

[0008] Furthermore, the step of obtaining a second number of unused node management modules, and determining the unused linked list number as the first linked list number of the linked list to be created if the first number is less than or equal to the second number, includes: obtaining the current node status value of each node management module based on the remaining space calculation module, and determining the sum of all current node status values ​​as the second number; if the first number is less than or equal to the second number, obtaining the current trigger parameter corresponding to each linked list number in the resource allocation structure based on the linked list number management module; determining the linked list number with a current trigger parameter of 0 as the unused linked list number; determining the unused linked list number that meets the preset rules as the first linked list number; and sending the first linked list number to the first linked list so that the linked list number of the first linked list is the first linked list number; wherein, the remaining space calculation module and the linked list number management module are respectively set on the resource allocation structure.

[0009] Furthermore, when querying a node, the operation information is sent to each node management module so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps. This also includes: obtaining the second linked list number and the first target node number of the target node; sending the second linked list number and the first target node number to each node management module respectively, so that the node management module can determine whether its current parameters meet a first preset condition; if the node management module meets the first preset condition, determining the node management module that meets the first preset condition as the target node, and sending the one-hot encoding output by the target node to the physical address calculation module, so that the physical address calculation module converts the one-hot encoding into the target node's physical address and outputs the physical address; wherein, the physical address calculation module is set on the resource allocation structure; the first preset condition is that the current state value of the node management module is 0, and the current linked list number and the current node number of the node management module are the same as the second linked list number and the first target node number, respectively.

[0010] Furthermore, the operation information is a linked list release; the operation information is sent to each node management module so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, which also includes: obtaining the third linked list number of the linked list to be released; sending the third linked list number to each node management module so that the node management module can determine whether the current parameters of the node management module meet the second preset condition; when the current parameters meet the second preset condition, the node management module is determined as the first node to be released, and the current node status value corresponding to the first node to be released is modified to 1; wherein, the second preset condition is that the current node status value of the node management module is 0, and the current linked list number is the third linked list number.

[0011] Furthermore, the operation information is node release; the operation information is sent to each node management module so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, which also includes: obtaining the fourth linked list number and the second target node number of the node to be released; sending the fourth linked list number and the second target node number to each node management module so that the node management module can determine whether the current parameters of the node management module meet the third preset condition; when the current parameters meet the third preset condition, the node management module is determined to be the second node to be released, and the current node status value corresponding to the second node to be released is modified to 1; wherein, the third preset condition is that the current node status value of the node management module is 0, and the current linked list number and the current node number are the same as the fourth linked list number and the second target node number, respectively.

[0012] Thirdly, embodiments of the present invention provide a memory management system applied to the above-mentioned resource allocation structure; the system includes: an operation acquisition module, used to acquire operation information of the current linked list; wherein, the operation information includes at least one of linked list allocation, node query, linked list release, and node release; and an operation execution module, used to send the operation information to each node management module of the resource allocation structure, so that each node management module synchronously determines the operation to be executed and independently executes the corresponding operation.

[0013] Fourthly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the above-described memory management method.

[0014] This invention provides a resource allocation structure, a memory management method, and a memory management system. The resource allocation structure includes: at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, all connected to the node management module. The node management modules are independent of each other. The linked list node allocation module is used to determine whether the node number of any node is in use, and when a new linked list is generated, it provides unused node numbers for the new linked list to use. The remaining space calculation module is used to determine whether the current linked list meets the requirements of the new linked list. The system comprises several modules: a linked list number management module, a physical address calculation module, and a node management module. The node management module receives feedback signals from the node management module and converts these signals into physical addresses using one-hot encoding. Each node management module synchronously determines the required operation and executes it independently during node operations, including creating new linked lists, querying nodes, releasing linked lists, and releasing nodes. This approach manages the behavior of each node through its own node management module within the resource allocation structure, enabling all nodes to synchronously determine their required operations, thereby improving CPU memory access efficiency and saving memory space.

[0015] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0016] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0017] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of the resource allocation structure provided in Embodiment 1 of the present invention;

[0019] Figure 2 This is a schematic diagram of the structure of a single node management module provided in Embodiment 1 of the present invention;

[0020] Figure 3 This is a flowchart of a memory management method provided in Embodiment 2 of the present invention;

[0021] Figure 4 The operational information provided for Embodiment 2 of the present invention is a flowchart of the operation execution when applying for a linked list;

[0022] Figure 5 The operation information provided in Embodiment 2 of the present invention is an operation execution flowchart for address query;

[0023] Figure 6 The operation information provided in Embodiment 2 of the present invention is a flowchart of the operation execution when the linked list is released;

[0024] Figure 7 The operation information provided in Embodiment 2 of the present invention is a flowchart of the operation execution when a node is released;

[0025] Figure 8 This is a schematic diagram of a memory management system provided in Embodiment 3 of the present invention.

[0026] Icons: 1 - Operation acquisition module; 2 - Operation execution module. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0028] To facilitate understanding of this embodiment, the embodiments of the present invention will be described in detail below.

[0029] Example 1:

[0030] Figure 1 This is a schematic diagram of the resource allocation structure provided in Embodiment 1 of the present invention.

[0031] Reference Figure 1 The Resource Allocation Module (RAM) includes at least one node management module (node_ctrl), and linked list node allocation module (list_req_node_alloc), residual space calculation module (residue_node_cal), linked list number management module (list_no_manager), and physical address calculation module (phy_addr_cal), all connected to the node management module (node_ctrl). The node management modules (node_ctrl) are independent of each other.

[0032] Here, the Resource Classification Structure (RAM) is a hardware module. The chip area consumed by the RAM is determined by the following parameters based on requirements: 1) The size of the managed space, i.e., the total memory size managed by the RAM; 2) The number of nodes into which the managed memory is divided, i.e., how many nodes of equal size the total space managed by the RAM is divided into. The size of each node is obtained by dividing the managed space size by the number of nodes. The number of nodes equals the number required by the node management module `node_ctrl`; 3) The number of concurrently requested spaces, i.e., the number of spaces the RAM can maintain simultaneously, also called the maximum number of linked lists (lists). Each time the CPU requests a space from the RAM, it is considered one space. The total number of spaces requested by the CPU minus the number of spaces released gives the current number of spaces being maintained; 4) The maximum size of a single requested space, which can be converted into the maximum number of nodes a single space can contain.

[0033] A contiguous memory space is allocated within the CPU and managed by a Resource Allocation Structure (RAM). The RAM virtualizes this memory space into multiple nodes of equal size. Each node corresponds to a node management module (node_ctrl) within the RAM, which is responsible for maintaining the state of its corresponding node. For example, if the total size managed by the RAM is 1MB, and each node management module (node_ctrl) is 4KB, there are a total of 256 node management modules (node_ctrl). The number of node management modules is N, and each node management module is labeled node_ctrl_n, where 0 ≤ n ≤ N-1, and n is an integer.

[0034] When the CPU needs to store a batch of data, it requests a linked list (the length of which depends on the data size) from the Resource Allocation Structure (RAM). The RAM then searches its managed memory space for sufficient free memory to create the linked list and provides it to the CPU. The CPU can use the linked list to query the RAM for the actual physical address of any node and store the data in the memory space corresponding to those addresses. Alternatively, the CPU can delegate the linked list information to other hardware modules, which can then query the RAM for physical addresses. When the allocated space is no longer needed, individual nodes or the entire linked list can be released.

[0035] The node management module node_ctrl is used to determine the operations to be performed synchronously by each node management module when node operations are performed, and to execute the corresponding operations independently. Node operations include creating new linked lists, querying nodes, releasing linked lists, and releasing nodes.

[0036] Here, each node management module (node_ctrl) has a completely identical structure, and the specific number of node management modules (node_ctrl) matches the maximum number of nodes. Each node management module (node_ctrl) maps to an independent memory space. When allocating and releasing the linked list (list), each node management module (node_ctrl) synchronously and independently changes its state. When querying a node, it independently determines whether it is the target node being queried.

[0037] Figure 2 This is a schematic diagram of the structure of a single node management module provided in Embodiment 1 of the present invention.

[0038] In one embodiment, reference is made to Figure 2 The node management module node_ctrl includes: node status value trigger idle_tiger, list number trigger list_no, and node position trigger list_node_no.

[0039] Here, refer to Figure 2 The node state value trigger idle_tiger, the list number trigger list_no, and the node position trigger list_node_no each receive the rising edge signal clk.

[0040] The node management module `node_ctrl` also includes two comparators (comp1 and comp2), a two-input AND gate `gate1`, and a three-input AND gate `gate2`. The comparators output 1 when the two input signals are equal, and 0 otherwise. Specifically, the inputs of `comp1` are connected to the signal inputs of the list number trigger `list_no` and the list number `target_list_no` of the target query, respectively. The outputs of `comp1` are connected to the two-input AND gate `gate1` and the three-input AND gate `gate2`. The inputs of `comp2` are connected to the signal inputs of the node position trigger `list_node_no` and the list position `target_list_node_no` of the target query, respectively. The output of `comp2` is connected to the three-input AND gate `gate2`. The output of the node status value trigger `idle_tiger` is connected to the two-input AND gate `gate1`, the three-input AND gate `gate2`, and the status value signal output. The output of the two-input AND gate `gate1` is used to output a signal indicating whether the list numbers `target_list_flag` are the same. The three-input AND gate `gate2` outputs a signal indicating whether the node is the target node (`target_node_flag`). If `target_node_flag` = 1, the node is the target node; if `target_node_flag` = 0, the node is not the target node.

[0041] The node management module node_ctrl also includes a multiplexer. The multiplexer controls the output of a specific input signal through a strobe signal (0 or 1).

[0042] Multiplexers m1 and m2 are connected to the node status value trigger idle_tiger. The lower pin of multiplexer m1 receives the node connection signal node_link; when the node management module node_ctrl allocates space to a new linked list, node_link = 1. Its first input is connected to the Q terminal of the idle_tiger to obtain the status value signal idle. Its second input receives the status value signal idle = 0. Its output is connected to the first input of multiplexer m2. The lower pin of multiplexer m2 receives the initialization signal rst or the node release signal node_rls; rst = 1 when the node management module node_ctrl is initialized, and node_rls = 1 when the node management module node_ctrl needs to release space. Its second input receives the status value signal idle = 1. Its output is connected to the D terminal of the idle_tiger.

[0043] Multiplexer m3 is connected to list_no, a linked list numbering flip-flop. The lower pin of multiplexer m3 is used to receive the node connection signal node_link. The first input is connected to the Q terminal of list_no. The second input is used to receive the new linked list number list_no_new. The output is connected to the D terminal of list_no.

[0044] Multiplexer m4 is connected to node position trigger list_node_no. The lower pin of multiplexer m4 is used to receive the node connection signal node_link. The first input is connected to the Q terminal of node position trigger list_node_no. The second input is used to receive the new node position list_node_no_new. The output is connected to the D terminal of node position trigger list_node_no.

[0045] The node state value trigger `idle_tiger` is used to record the current node's state value `idle` to determine whether the current node's corresponding current node management module is being used by the linked list.

[0046] Here, when idle = 0, the current node management module node_ctrl is used by the linked list. When idle = 1, the current node management module node_ctrl is not used by the linked list.

[0047] The list number trigger `list_no` is used to record the list number of the current linked list to which the current node management module belongs.

[0048] Here, if the current node management module node_ctrl is used by a linked list, the linked list number trigger list_no is used to record the number of the linked list using the module.

[0049] The node position trigger `list_node_no` is used to record the node position of the current node management module in the current linked list.

[0050] Here, each node_ctrl corresponds to a node in the linked list. The number of node_ctrls needed is equal to the number of nodes in the linked list. For example, if a linked list is numbered 5 and has 10 nodes, then 10 node_ctrls are needed. These 10 node_ctrls have idle=1, list_no is recorded as "5", and list_node_no values ​​range from 0 to 9.

[0051] Specifically, the actual application scenarios of the node management module node_ctrl are as follows.

[0052] 1) Power-on initialization. When rst=1, node_ctrl is power-on initialized, and idle is assigned a value of 1 to indicate that the node corresponding to node_ctrl is in an idle state.

[0053] 2) Linked list allocation (space allocation). When a node_ctrl is allocated to a new list, node_link = 1, the idle value is updated to 0 (not idle, currently in use), the list_no value is updated to the current list_no_new, and the list_node_no value is updated to the list_node_no_new in the current linked list.

[0054] 3) Node Lookup. When querying a specific node in a linked list, the linked list number `target_list_no` and its position in the list `target_list_node_no` are provided. At this point, the comparator `comp` inside each `node_ctrl` compares its stored `list_no` and `list_node_no` with `target_list_no` and `target_list_node_no`, respectively. If a `node_ctrl` finds all the values ​​to be equal and `idle = 0`, it outputs `target_node_flag = 1`, indicating that this `node_ctrl` is the target node being searched for.

[0055] 4) Linked List Release (Space Release). When it's necessary to release previously allocated space, the linked list number corresponding to the space to be released, `target_list_no`, needs to be provided. At this point, each `node_ctrl` module compares its stored `list_no` with `target_list_no`. If they are equal and `idle` = 0, the `node_ctrl` module outputs `target_list_flag` = 1. The `node_rls` signal is then input to all `node_ctrl` modules with `target_list_flag` = 1, causing their `idle` to become 1, indicating that the corresponding space release is complete.

[0056] 5) Node release (releasing a portion of the allocated space): This process provides the linked list number `target_list_no` and its position in the linked list `target_list_node_no`. First, a node lookup operation is performed. Each `node_ctrl`'s internal comparator compares its stored `list_no` and `list_node_no` with `target_list_no` and `target_list_node_no`, respectively. If a `node_ctrl` is found to be equal and its `idle` is 0, it outputs `target_node_flag` = 1, indicating that this `node_ctrl` is the target node to be released. At this point, inputting `node_rls` to this module will change its `idle` to 1, thus completing the release of a single node.

[0057] The linked list node allocation module `list_req_node_alloc` is used to determine whether the node number of the current node is in use. When a new linked list is created, it provides unused node numbers for the new linked list to use.

[0058] Here, when the CPU requests memory space from the resource allocation structure RAM, the linked list node allocation module list_req_node_alloc analyzes the usage of each node management module node_ctrl to find enough free nodes to allocate to the new linked list list. Once the nodes are determined, the actual memory space for the data to be processed is also determined.

[0059] Specifically, the idle state value of all node management modules (node_ctrl) is input into this module. When a new linked list (list) is requested, the linked list allocation module (list_req_node_alloc) allocates a corresponding number of node management modules (node_ctrl) with idle=1 to the new linked list (list). The order of these node management modules (node_ctrl) in the linked list is consistent with their own numbering order. For example, node management modules (node_ctrl) with smaller numbers are located earlier in the linked list (list). When the total number of node management modules (node_ctrl) is large, they can be allocated in groups. For example, allocation can be performed every 32 node management modules (node_ctrl), that is, first allocate the idle nodes (node) in node management modules (node_ctrl) numbered 0 to 31 to the new linked list (list), then allocate node management modules (node_ctrl) numbered 32 to 64, and so on. During the allocation in each group, the state of the allocated node management modules (node_ctrl) is updated.

[0060] The residual_node_cal module is used to determine whether any linked list meets the requirements of a new linked list.

[0061] Here, each node management module node_ctrl contains a 1-bit trigger to indicate whether it is in use. The remaining space size is obtained by counting the number of unused node management modules node_ctrl.

[0062] The method for counting the number of unused node management modules (node_ctrl) is as follows: input the idle values ​​of all node management modules (node_ctrl) into the residual space calculation module (residue_node_cal), and perform an addition operation on all idle values ​​to obtain the total number of free nodes. If the total number of node management modules (node_ctrl) is too large, the addition operation can be performed independently in multiple groups, and the results can be added together.

[0063] The list_no_manager module is used to determine whether the list number of any linked list is in use. When a new linked list is created, it provides unused list numbers for the new linked list to use.

[0064] Here, each space requested by the CPU from the resource allocation structure RAM has a unique linked list number, and the linked list numbers existing at the same time are all different. For example, if the entire resource allocation structure RAM supports a maximum of 32 linked lists, then the linked list numbers will be from 0 to 31. The linked list number management module list_no_manager is responsible for managing whether these numbers are used. When a new linked list is created, it provides unused numbers for the new linked list to use.

[0065] There are several ways to implement this; one feasible method is provided below. When the maximum number of linked lists to be managed is X, an X-bit trigger is used, with each bit representing a linked list number. When a number is used, the corresponding bit is set to 1. When a new number is needed, a bit with a value of 0 is directly found, and that bit's number is used as the new list number.

[0066] The physical address calculation module phy_addr_cal is used to receive feedback signals sent by the node management module when an address query or node query request is received, and to convert the feedback signals into physical addresses by one-hot encoding and decoding.

[0067] Here, when querying a physical address based on a list, the resource allocation structure RAM finds the node_no corresponding to the target address based on the status information recorded by the node management module node_ctrl, and then converts the number into a physical address through the physical address calculation module phy_addr_cal.

[0068] The physical address calculation module phy_addr_cal receives the target node signal target_node_flag from all node_ctrls. Because each time the physical address of a node in the space is queried, only one node_ctrl's target_node_flag signal is 1. The one-hot encoded result is converted into a natural number form. For example, if there are 256 target_node_flag signals input, and the target_node_flag signal of node_ctrl numbered N is 1, the conversion result is the natural number N.

[0069] RAM manages a contiguous memory space with a starting physical address str_phy_addr. Each node has a fixed and identical size node_size. Therefore, the physical address of the final query result is: target_phy_addr = str_phy_addr + node_size × N.

[0070] This invention provides a resource allocation structure, comprising: at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, all connected to the node management module. The node management modules are independent of each other. The linked list node allocation module determines whether the node number of any node is in use, and provides unused node numbers for use when a new linked list is created. The remaining space calculation module determines whether the current linked list meets the requirements of the new linked list. The linked list number management module determines whether the linked list number of any linked list is in use, and provides unused linked list numbers for use when a new linked list is created. The physical address calculation module receives feedback signals from the node management module when an address query or node query request is received, and converts the feedback signals from one-hot encoding to physical addresses. When node operations are performed, each node management module synchronously determines the operation to be performed and independently executes the corresponding operation. Node operations include creating a new linked list, querying a node, releasing a linked list, and releasing a node. In this approach, the node management module in the resource allocation structure manages the behavior of each node, enabling all nodes to synchronously determine the operations they need to perform, thereby improving the efficiency of CPU access to memory and saving memory space.

[0071] Example 2:

[0072] Figure 3 This is a flowchart of a memory management method provided in Embodiment 2 of the present invention.

[0073] Reference Figure 3The memory management methods applied to the above resource allocation structure include:

[0074] Step S101: Obtain the operation information of the current linked list; wherein, the operation information includes at least one of linked list allocation, node query, linked list release, and node release.

[0075] Specifically, a resource allocation structure RAM is provided, supporting up to 256 nodes and up to 32 list operations, with a maximum length of 256 nodes for a single linked list. This resource allocation structure includes 256 node management module pairs (node_ctrl). Each node management module pair (node_ctrl) contains a 1-bit state value (idle), a 5-bit linked list number trigger (list_no), and an 8-bit node position trigger (list_node_no).

[0076] Referring to Table 1, during power-on initialization, the idle state value is assigned to 1, and the values ​​of the list number trigger list_no and the node position trigger list_node_no are both reset to 0. Each row in the table represents the internal state of a node management module node_ctrl, and 256 node management modules node_ctrl correspond to 256 rows.

[0077] Table 1 Resource Allocation Structure Initialization Table

[0078]

[0079]

[0080] Referring to Table 2, if there is already a linked list with number 5 and length 10 in the current resource allocation structure RAM, and node_ctrl with numbers 0-5 and 10-13 is used, then the status of each node_ctrl module is as follows.

[0081] Table 2 Resource Allocation Structure Preservation Table

[0082]

[0083]

[0084] Step S102: Send the operation information to each node management module of the resource allocation structure so that each node management module can synchronously determine the operation to be performed and execute the corresponding operation independently.

[0085] Figure 4 The operational information provided for Embodiment 2 of the present invention is a flowchart of the operation execution when applying for a linked list.

[0086] In one embodiment, reference is made to Figure 4The operation information is a linked list request; the operation information is sent to each node management module of the resource allocation structure so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, including:

[0087] Step S201: Obtain the memory space size of the linked list to be created.

[0088] Here, the memory space size is the amount of data that the CPU needs to store.

[0089] Step S202: Determine the first number of node management modules corresponding to the linked list to be created based on the memory space size.

[0090] Here, the first quantity is the quotient obtained by dividing the memory size by the node management module size.

[0091] Step S203: Obtain the second number of unused node management modules. If the first number is less than or equal to the second number, determine the unused linked list number as the first linked list number of the linked list to be created.

[0092] In one embodiment, the step of obtaining a second number of unused node management modules, and determining the unused linked list number as the first linked list number to be created if the first number is less than or equal to the second number, includes:

[0093] Based on the remaining space calculation module, the current node status value of each node management module is obtained, and the sum of all current node status values ​​is determined as the second quantity.

[0094] Here, a status value of idel = 1 indicates that the current node management module is idle. A status value of idel = 0 indicates that the current node management module is in use.

[0095] If the first quantity is less than or equal to the second quantity, the current trigger parameter corresponding to each linked list number in the resource allocation structure is obtained based on the linked list number management module.

[0096] Here, when the memory space required by the CPU is less than or equal to the remaining memory space, the resource allocation structure allocates memory space to the data that needs to be saved.

[0097] The linked list number whose current trigger parameter is 0 is identified as an unused linked list number.

[0098] Here, when the maximum number of linked lists to be managed is X, an X-bit trigger is used, with each bit representing a corresponding linked list number. When a number is used, the corresponding bit is set to 1. When a new number is needed, a bit with a value of 0 is directly found, and that bit's number is used as the new linked list number.

[0099] The unused linked list number that meets the preset rules is determined as the first linked list number.

[0100] Here, the preset rules can be set according to the actual situation. They can be the smallest bit number, the largest bit number, or any bit number.

[0101] Send the first linked list number to the first linked list so that the linked list number of the first linked list is the same as the first linked list number.

[0102] The remaining space calculation module and the linked list number management module are respectively set on the resource allocation structure.

[0103] Step S204: Based on the linked list node allocation module, obtain the current node status value and node number of each node management module, and determine the node management module whose current node status value is 1 and whose node number meets the preset requirements as the node management module to be created corresponding to the linked list to be created.

[0104] Here, the preset requirements can be set according to the actual situation. It can be the minimum node number, the maximum node number, or any node number.

[0105] Step S205: Determine the current linked list number of the node management module to be created as the first linked list number; wherein, the linked list node allocation module is set on the resource allocation structure.

[0106] Specifically, referring to Table 3, if the CPU requests a memory space of size 8 nodes, the resource allocation structure RAM first needs to use the linked list number management module list_no_manager to allocate a linked list number for this space; let's assume the allocated number is 6. Then, using the linked list node allocation module list_req_node_alloc, it analyzes the usage of each node management module node_ctrl to find 8 free nodes; let's assume these 8 nodes are numbered "6, 7, 8, 9, 14, 15, 16, 17".

[0107] Table 3. State table of resource allocation structure after creating a new linked list.

[0108] node_ctrl number idle list_no list_node_no 0 0 5 0 1 0 5 1 2 0 5 2 3 0 5 3 4 0 5 4 5 0 5 5 6 1->0 0->6 0->0 7 1->0 0->6 0->1 8 1->0 0->6 0->2 9 1->0 0->6 0->3 10 0 5 6 11 0 5 7 12 0 5 8 13 0 5 9 14 1->0 0->6 0->4 15 1->0 0->6 0->5 16 1->0 0->6 0->6 17 1->0 0->6 0->7 18 1 0 0 19 1 0 0 …… …… …… …… 246 1 0 0 247 1 0 0 248 1 0 0 249 1 0 0 250 1 0 0 251 1 0 0 252 1 0 0 253 1 0 0 254 1 0 0 255 1 0 0

[0109] Figure 5 The operation information provided in Embodiment 2 of the present invention is an operation execution flowchart for address query.

[0110] In one embodiment, reference is made to Figure 5When the operation information is a node query, the operation information is sent to each node management module so that each node management module can synchronously determine the operation to be performed and independently execute the corresponding operation steps, including:

[0111] Step S401: Obtain the second linked list number and the first target node number of the target node.

[0112] Step S402: Send the second linked list number and the first target node number to each node management module respectively, so that the node management module can determine whether the current parameters of the node management module meet the first preset condition.

[0113] Step S403: If the node management module meets the first preset condition, the node management module that meets the first preset condition is determined as the target node, and the one-hot encoding output by the target node is sent to the physical address calculation module, so that the physical address calculation module converts the one-hot encoding into the physical address of the target node and outputs the physical address. The physical address calculation module is set on the resource allocation structure; the first preset condition is that the current valid value of the node management module is 0, and the current linked list number and the current node number of the node management module are the same as the second linked list number and the first target node number, respectively.

[0114] Specifically, if you want to query the physical address of the 3rd node in the linked list numbered 5, each `node_ctrl` independently determines whether it is the node being queried. If a `node_ctrl` has `idle=0`, `list_no=5`, and `list_node_no=3`, then that node is the target node for the query, as shown in Table 3 where row numbered 3 of `node_ctrl` meets the conditions. For any node query, only one of the 256 `node_ctrl`s will meet the conditions. The result of the one-hot encoding is converted to a natural number, and then converted to a physical address using the `phy_addr_cal` module.

[0115] Figure 6 The operation information provided for Embodiment 2 of the present invention is a flowchart of the operation execution when the linked list is released.

[0116] In one embodiment, reference is made to Figure 6 The operation information is a linked list release; the operation information is sent to each node management module so that each node management module can synchronously determine the operation to be performed and independently execute the corresponding operation steps, which also includes:

[0117] Step S501: Obtain the third linked list number of the linked list to be released.

[0118] Step S502: Send the third linked list number to each node management module so that the node management module can determine whether the current parameters of the node management module meet the second preset condition.

[0119] Step S503: When the current parameters meet the second preset condition, the node management module is determined as the first node to be released, and the current node status value corresponding to the first node to be released is modified to 1. The second preset condition is that the current node status value of the node management module is 0, and the current linked list number is the third linked list number.

[0120] Specifically, referring to Table 4, if the space of linked list number 5 is to be released at this time, each node_ctrl independently checks whether its stored list_no is equal to 5. If it is equal to 5 and idle = 0, then idle is updated to 1, and the release operation is completed.

[0121] Table 4. Status table of the resource allocation structure linked list after release.

[0122] node_ctrl number idle list_no list_node_no 0 0->1 5 0 1 0->1 5 1 2 0->1 5 2 3 0->1 5 3 4 0->1 5 4 5 0->1 5 5 6 0 6 0 7 0 6 1 8 0 6 2 9 0 6 3 10 0->1 5 6 11 0->1 5 7 12 0->1 5 8 13 0->1 5 9 14 0 6 4 15 0 6 5 16 0 6 6 17 0 6 7 18 1 0 0 19 1 0 0 …… …… …… …… 246 1 0 0 247 1 0 0 248 1 0 0 249 1 0 0 250 1 0 0 251 1 0 0 252 1 0 0 253 1 0 0 254 1 0 0 255 1 0 0

[0123] Figure 7 The operation information provided for Embodiment 2 of the present invention is a flowchart of the operation execution when a node is released.

[0124] In one embodiment, reference is made to Figure 7 The operation information is node release; the operation information is sent to each node management module so that each node management module can synchronously determine the operation to be performed and independently execute the corresponding operation steps, which also includes:

[0125] Step S601: Obtain the fourth linked list number of the node to be released and the second target node number.

[0126] Step S602: Send the fourth linked list number and the second target node number to each node management module so that the node management module can determine whether the current parameters of the node management module meet the third preset condition.

[0127] Step S603: When the current parameters meet the third preset condition, the node management module is determined as the second node to be released, and the current node status value corresponding to the second node to be released is modified to 1. The third preset condition is that the current node status value of the node management module is 0, and the current linked list number and the current node number are the same as the fourth linked list number and the second target node number, respectively.

[0128] Specifically, referring to Table 5, if node 5 of linked list 6 is released at this time, each node_ctrl independently checks whether its stored list_no is equal to 6 and list_node_no is equal to 5. If they are equal and idle = 0, then idle is updated to 1.

[0129] Table 5: Status of Resource Allocation Structure Nodes After Release

[0130]

[0131]

[0132] This invention provides a memory management method. The resource allocation structure includes at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, all connected to the node management module. The node management modules are independent of each other. The linked list node allocation module is used to determine whether the node number of any node is in use, and when a new linked list is generated, it provides unused node numbers for the new linked list. The remaining space calculation module is used to determine whether the current linked list meets the requirements of the new linked list. The linked list number management module is used to determine whether the linked list number of any linked list is in use, and when a new linked list is generated, it provides unused linked list numbers for the new linked list. The physical address calculation module is used to receive feedback signals sent by the node management module when an address query or node query request is received, and convert the feedback signals from one-hot encoding to physical addresses. When node operations are performed, each node management module synchronously determines the operation to be performed and independently executes the corresponding operation. Node operations include creating a new linked list, querying a node, releasing a linked list, and releasing a node. In this approach, the node management module in the resource allocation structure manages the behavior of each node, enabling all nodes to synchronously determine the operations they need to perform, thereby improving CPU efficiency and saving memory space.

[0133] Example 3:

[0134] Figure 8 This is a schematic diagram of a memory management system provided in Embodiment 3 of the present invention.

[0135] Reference Figure 8 The memory management systems applied to the above resource allocation structure include:

[0136] Operation acquisition module 1 is used to acquire operation information of the current linked list; wherein, the operation information includes at least one of linked list allocation, node query, linked list release and node release.

[0137] Operation execution module 2 is used to send operation information to each node management module of the resource allocation structure, so that each node management module can synchronously determine the operation to be executed and execute the corresponding operation independently.

[0138] This invention provides a memory management system with a resource allocation structure including: at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, all connected to the node management module. The node management modules are independent of each other. The linked list node allocation module is used to determine whether the node number of any node is in use, and when a new linked list is created, it provides unused node numbers for the new linked list. The remaining space calculation module is used to determine whether the current linked list meets the requirements of the new linked list. The linked list number management module is used to determine whether the linked list number of any linked list is in use, and when a new linked list is created, it provides unused linked list numbers for the new linked list. The physical address calculation module is used to receive feedback signals sent by the node management module when an address query or node query request is received, and convert the feedback signals from one-hot encoding to physical addresses. When node operations are performed, each node management module synchronously determines the operation to be performed and independently executes the corresponding operation. Node operations include creating a new linked list, querying a node, releasing a linked list, and releasing a node. In this approach, the node management module in the resource allocation structure manages the behavior of each node, enabling all nodes to synchronously determine the operations they need to perform, thereby improving the efficiency of CPU access to memory and saving memory space.

[0139] This invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the memory management method provided in the above embodiments.

[0140] The computer program product provided in this embodiment of the invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0141] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0142] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0143] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0144] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0145] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A resource allocation structure, characterized in that, The resource allocation structure includes: at least one node management module, and a linked list node allocation module, a remaining space calculation module, a linked list number management module, and a physical address calculation module, which are respectively connected to the node management module; the node management modules are independent of each other; The linked list node allocation module is used to determine whether the node number of any node is in use, and when a new linked list is generated, it provides unused node numbers for the new linked list to use. The remaining space calculation module is used to determine whether the current linked list meets the requirements of the new linked list; The linked list number management module is used to determine whether the linked list number of any linked list is in use, and when a new linked list is generated, it provides an unused linked list number for the new linked list to use. The physical address calculation module is used to receive a feedback signal sent by the node management module when an address query or node query request is received, and to convert the feedback signal into a physical address by one-hot encoding decoding; wherein, the feedback signal is converted into a node number in natural number form by one-hot encoding decoding; and to calculate the target physical address based on the starting physical address of a contiguous memory space managed by the resource allocation structure, a fixed node size, and the node number; wherein, the target physical address is the sum of the products of the starting physical address, the node size, and the node number; The node management module is used to determine the operation to be performed synchronously and execute the corresponding operation independently when a node operation is performed; the node operation includes creating a new linked list, querying a node, releasing a linked list, and releasing a node; The node management module includes a node status value trigger, a linked list number trigger, and a node position trigger. The node state value trigger is used to record the state value of the current node in order to determine whether the current node management module corresponding to the current node is used by the linked list. The linked list number trigger is used to record the linked list number of the current linked list to which the current node management module belongs; The node position trigger is used to record the node position of the current node management module in the current linked list.

2. A memory management method, characterized in that, Applied to the resource allocation structure of claim 1; the method includes: Obtain the operation information of the current linked list; wherein, the operation information includes at least one of linked list allocation, node query, linked list release, and node release; The operation information is sent to each node management module of the resource allocation structure so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation; The operation information is the linked list application; The operation information is sent to each node management module of the resource allocation structure, so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, including: Get the memory size of the linked list to be created; The first number of node management modules corresponding to the linked list to be created is determined based on the memory space size. Obtain the second number of unused node management modules. If the first number is less than or equal to the second number, determine the unused linked list number as the first linked list number of the linked list to be created. Based on the linked list node allocation module, the current node status value and node number of each node management module are obtained, and the node management module whose current node status value is 1 and whose node number meets the preset requirements is determined to be the node management module to be created corresponding to the linked list to be created. The current linked list number of the node management module to be created is determined as the first linked list number; wherein, the linked list node allocation module is set on the resource allocation structure; The step of obtaining a second number of unused node management modules, and determining the unused linked list number as the first linked list number of the linked list to be created if the first number is less than or equal to the second number, includes: Based on the remaining space calculation module, the current node status value of each node management module is obtained, and the sum of all the current node status values ​​is determined to be the second quantity; If the first quantity is less than or equal to the second quantity, the current trigger parameter corresponding to each linked list number in the resource allocation structure is obtained based on the linked list number management module. The linked list number whose current trigger parameter is 0 is determined as the unused linked list number; The unused linked list number that meets the preset rules is determined as the first linked list number; Send the first linked list number to the first linked list so that the linked list number of the first linked list is the first linked list number; The remaining space calculation module and the linked list number management module are respectively set on the resource allocation structure.

3. The memory management method according to claim 2, characterized in that, The operation information refers to the node query; Sending the operation information to each node management module, so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, further includes: Obtain the second linked list number and the first target node number of the target node; The second linked list number and the first target node number are sent to each of the node management modules, so that the node management modules can determine whether the current parameters of the node management modules meet the first preset condition. If the node management module meets the first preset condition, the node management module that meets the first preset condition is determined as the target node, and the one-hot code output by the target node is sent to the physical address calculation module, so that the physical address calculation module converts the one-hot code into the node physical address of the target node and outputs the node physical address. The physical address calculation module is located on the resource allocation structure; the first preset condition is that the current state value of the node management module is 0, and the current linked list number and the current node number of the node management module are the same as the second linked list number and the first target node number, respectively.

4. The memory management method according to claim 2, characterized in that, The operation information refers to the release of the linked list; Sending the operation information to each node management module, so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, further includes: Get the third linked list number of the linked list to be released; The third linked list number is sent to each node management module so that the node management module can determine whether the current parameters of the node management module meet the second preset condition. When the current parameter meets the second preset condition, the node management module is determined to be the first node to be released, and the current node status value corresponding to the first node to be released is modified to 1. The second preset condition is that the current node status value of the node management module is 0, and the current linked list number is the number of the third linked list.

5. The memory management method according to claim 2, characterized in that, The operation information is that the node is released; Sending the operation information to each node management module, so that each node management module synchronously determines the operation to be performed and independently executes the corresponding operation steps, further includes: Get the fourth linked list number of the node to be released and the second target node number; The fourth linked list number and the second target node number are sent to each of the node management modules so that the node management modules can determine whether the current parameters of the node management modules meet the third preset condition. When the current parameter satisfies the third preset condition, the node management module is determined to be the second node to be released, and the current node status value corresponding to the second node to be released is modified to 1. The third preset condition is that the current node status value of the node management module is 0, and the current linked list number and the current node number are the same as the fourth linked list number and the second target node number, respectively.

6. A memory management system, characterized in that, The system is applied to the resource allocation structure described in claim 1; the system includes: An operation acquisition module is used to acquire operation information of the current linked list; wherein, the operation information includes at least one of linked list allocation, node query, linked list release, and node release; The operation execution module is used to send the operation information to each node management module of the resource allocation structure, so that each node management module synchronously determines the operation to be executed and independently executes the corresponding operation.

7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the method described in any one of claims 2-5.