Storage space management method and device, electronic equipment, storage medium and program product

By introducing virtual internal nodes into the binary tree of the buddy algorithm, the problems of storage space fragmentation and deadlock in multi-process environments are solved, and more efficient storage space management and utilization are achieved.

CN120371720BActive Publication Date: 2026-01-27MOORE THREADS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510440143.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2026-01-27
Estimated Expiration
2045-04-09

AI Technical Summary

Technical Problem

In a multi-process environment, the buddy algorithm causes storage fragmentation and deadlock problems, making it impossible to effectively utilize contiguous space.

Method used

Introducing virtual internal nodes into the binary tree structure allows for the use of contiguous space across actual internal nodes. By marking the target node and its related nodes as occupied, storage space allocation and reclamation are optimized.

Benefits of technology

It improves storage space utilization, reduces fragmentation and deadlock, and achieves more efficient cache space management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371720B_ABST
    Figure CN120371720B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a storage space management method and device, electronic equipment, storage medium and program product. A binary tree corresponding to a storage space includes a root node, at least one level of actual internal nodes and leaf nodes, and a virtual internal node is arranged between two adjacent actual internal nodes at the same level. The method comprises: in response to receiving a storage space allocation request from a first process, determining a target node in the binary tree for allocation to the first process according to a first quantity of the requested storage space, wherein the target node is a lowest level free node with a space quantity greater than or equal to the first quantity, and the target node allows virtual internal nodes; marking the target node as occupied, and marking at least part of the related nodes of the target node as occupied. The present disclosure can use the remaining continuous space across the actual internal nodes, and can improve the space utilization rate under the buddy algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a storage space management method, storage space management device, electronic device, computer-readable storage medium, and computer program product. Background Technology

[0002] The buddy algorithm is a memory management algorithm primarily used in operating systems for memory allocation and reclamation. The core idea of ​​the buddy algorithm is to divide memory into blocks of size powers of two, such as 2 bytes, 4 bytes, 8 bytes, 16 bytes, and so on. The buddy algorithm gets its name from the fact that each memory block has a "buddy," which is another block of the same size and located adjacent to it.

[0003] Although the buddy algorithm reduces fragmentation by merging adjacent free blocks, in a multi-process environment, space allocation and reclamation are often unordered, which can lead to fragmentation of contiguous space, making it impossible to allocate even if there is enough remaining space. Summary of the Invention

[0004] This disclosure provides a storage space management technology solution.

[0005] According to one aspect of this disclosure, a storage space management method is provided. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are respectively set between two adjacent actual internal nodes of the same level, wherein the left child of any virtual internal node is the right child of the actual internal node to the left of the virtual internal node, and the right child of the virtual internal node is the left child of the actual internal node to the right of the virtual internal node. The actual internal nodes and virtual internal nodes of the same level correspond to the same amount of space. The method includes:

[0006] In response to receiving a storage space allocation request from a first process, a target node in the binary tree is determined for allocation to the first process based on a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node.

[0007] The target node is marked as occupied, and at least some of the related nodes of the target node are also marked as occupied.

[0008] In one possible implementation, determining the target node in the binary tree for allocation to the first process based on a first quantity of storage space requested by the storage space allocation request includes:

[0009] The leftmost node among the lowest-level free nodes with a space quantity greater than or equal to the first quantity is determined as the target node.

[0010] In one possible implementation, marking at least some of the related nodes of the target node as occupied includes:

[0011] In response to the target node being an actual internal node, each ancestor node of the target node is marked as occupied.

[0012] In response to the number of spaces corresponding to the target node being greater than the first number, some descendant nodes of the target node are marked as occupied based on the first number; or, in response to the number of spaces corresponding to the target node being equal to the first number, each descendant node of the target node is marked as occupied.

[0013] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0014] In one possible implementation, marking a portion of the target node's descendant nodes as occupied based on the first quantity includes:

[0015] For any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes marked as occupied among other descendant nodes at the same level as the target node has not reached the first number, the descendant node is marked as occupied.

[0016] or,

[0017] For any descendant node of the target node, in response to the total number of spaces corresponding to nodes marked as occupied among other descendant nodes of the same level as the target node having reached the first number, the descendant node is kept in an idle state, and the marking of the remaining descendant nodes of the same level is stopped.

[0018] In one possible implementation, marking at least some of the related nodes of the target node as occupied includes:

[0019] In response to the target node being a virtual internal node and the space corresponding to the target node being greater than the first quantity, some descendant nodes of the target node are marked as occupied based on the first quantity; or, in response to the target node being a virtual internal node and the space corresponding to the target node being equal to the first quantity, each descendant node of the target node is marked as occupied.

[0020] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0021] In one possible implementation, marking at least some of the related nodes of the target node as occupied includes:

[0022] In response to the target node being a leaf node, each ancestor node of the target node is marked as occupied.

[0023] In one possible implementation, the method further includes:

[0024] The space allocation record table records the correspondence between the first process and the target node, and records the first quantity.

[0025] In one possible implementation, the method further includes:

[0026] In the node enable table, the usage status of the nodes in the binary tree is recorded by the enable bits that correspond one-to-one with the nodes in the binary tree. The enable bit corresponding to any node is a first preset value, which indicates that the node is in an idle state. The enable bit corresponding to any node is a second preset value, which indicates that the node is in an occupied state.

[0027] In one possible implementation, the method further includes:

[0028] In response to a storage space release request from the first process, and the storage space release request is used to request the release of the target node, the target node is marked as idle according to the first quantity, and at least some of the related nodes of the target node are marked as idle.

[0029] In one possible implementation, the method further includes:

[0030] For any node that is in an occupied state, in response to all descendant nodes of that node updating their usage status to an idle state, the usage status of that node is updated to an idle state.

[0031] According to one aspect of this disclosure, a storage space management device is provided. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are respectively set between two adjacent actual internal nodes of the same level, wherein the left child node of any virtual internal node is the right child node of the actual internal node to the left of the virtual internal node, and the right child node of the virtual internal node is the left child node of the actual internal node to the right of the virtual internal node. The actual internal nodes and virtual internal nodes of the same level correspond to the same number of spaces. The device includes:

[0032] The determination module is configured to respond to receiving a storage space allocation request from a first process, and determine a target node in the binary tree for allocation to the first process based on a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node.

[0033] A marking module is used to mark the target node as occupied and to mark at least some of the related nodes of the target node as occupied.

[0034] In one possible implementation, the determining module is used to:

[0035] The leftmost node among the lowest-level free nodes with a space quantity greater than or equal to the first quantity is determined as the target node.

[0036] In one possible implementation, the tagging module is used for:

[0037] In response to the target node being an actual internal node, each ancestor node of the target node is marked as occupied.

[0038] In response to the number of spaces corresponding to the target node being greater than the first number, some descendant nodes of the target node are marked as occupied based on the first number; or, in response to the number of spaces corresponding to the target node being equal to the first number, each descendant node of the target node is marked as occupied.

[0039] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0040] In one possible implementation, the tagging module is used for:

[0041] For any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes marked as occupied among other descendant nodes at the same level as the target node has not reached the first number, the descendant node is marked as occupied.

[0042] or,

[0043] For any descendant node of the target node, in response to the total number of spaces corresponding to nodes marked as occupied among other descendant nodes of the same level as the target node having reached the first number, the descendant node is kept in an idle state, and the marking of the remaining descendant nodes of the same level is stopped.

[0044] In one possible implementation, the tagging module is used for:

[0045] In response to the target node being a virtual internal node and the space corresponding to the target node being greater than the first quantity, some descendant nodes of the target node are marked as occupied based on the first quantity; or, in response to the target node being a virtual internal node and the space corresponding to the target node being equal to the first quantity, each descendant node of the target node is marked as occupied.

[0046] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0047] In one possible implementation, the tagging module is used for:

[0048] In response to the target node being a leaf node, each ancestor node of the target node is marked as occupied.

[0049] In one possible implementation, the device further includes:

[0050] The first recording module is used to record the correspondence between the first process and the target node in the space allocation record table, and to record the first quantity.

[0051] In one possible implementation, the device further includes:

[0052] The second recording module is used to record the usage status of nodes in the binary tree in the node enable table by using enable bits that correspond one-to-one with the nodes in the binary tree. Here, if the enable bit corresponding to any node is a first preset value, it means that the node is in an idle state, and if the enable bit corresponding to any node is a second preset value, it means that the node is in an occupied state.

[0053] In one possible implementation, the tagging module is further configured to:

[0054] In response to a storage space release request from the first process, and the storage space release request is used to request the release of the target node, the target node is marked as idle according to the first quantity, and at least some of the related nodes of the target node are marked as idle.

[0055] In one possible implementation, the device further includes:

[0056] The update module is used to update the usage status of any node in an occupied state to an idle state in response to all descendant nodes of the node being updated to an idle state.

[0057] According to one aspect of this disclosure, an electronic device is provided, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to invoke the executable instructions stored in the memory to perform the method described above.

[0058] According to one aspect of this disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the above-described method.

[0059] According to one aspect of this disclosure, a computer program product is provided, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in an electronic device, a processor in the electronic device performs the above-described method.

[0060] In this embodiment, the binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are set between two adjacent actual internal nodes of the same level. The left child of any virtual internal node is the right child of the actual internal node to the left of the virtual internal node, and the right child of the virtual internal node is the left child of the actual internal node to the right of the virtual internal node. The actual internal nodes and virtual internal nodes of the same level correspond to the same number of spaces. In response to receiving a storage space allocation request from a first process, a target node in the binary tree is determined based on the first number of storage spaces requested in the storage space allocation request. The target node is the lowest-level free node with a space quantity greater than or equal to the first number, and the target node can be a virtual internal node. The target node is marked as occupied, and at least some of its related nodes are also marked as occupied. Thus, by utilizing virtual internal nodes, the remaining contiguous space can be used across actual internal nodes, improving space utilization under the buddy system algorithm and solving the problems of space fragmentation and deadlock. This disclosure utilizes a binary tree to allocate and merge space in a more efficient manner while minimizing fragmentation, thereby maximizing the use of limited cache space. This allows processes to use space more efficiently according to their operational needs, which is beneficial for efficient and intensive management of cache space in a multi-process environment.

[0061] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure.

[0062] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description

[0063] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.

[0064] Figure 1 A schematic diagram of the binary tree structure shown in the buddy algorithm is presented.

[0065] Figure 2 A schematic diagram of the storage space is shown.

[0066] Figure 3 A flowchart illustrating the storage space management method provided in an embodiment of this disclosure is shown.

[0067] Figure 4 This diagram illustrates a binary tree structure in the storage space management method provided in an embodiment of the present disclosure.

[0068] Figure 5 This diagram illustrates the array corresponding to the binary tree in the storage space management method provided in this embodiment of the present disclosure.

[0069] Figure 6 This diagram illustrates how, in the storage space management method provided in this embodiment of the present disclosure, virtual internal nodes are used to allocate contiguous space to processes across actual internal nodes.

[0070] Figure 7 This diagram illustrates how, in the storage space management method provided in this embodiment, the leftmost node among the lowest-level free nodes with a space quantity greater than or equal to a first quantity is determined as the target node.

[0071] Figure 8 This diagram illustrates a method for managing storage space provided in this embodiment of the present disclosure, in which at least some related nodes of a target node are marked as occupied.

[0072] Figure 9 This diagram illustrates an entry in the node enable table of the storage space management method provided in this embodiment of the present disclosure.

[0073] Figure 10 This diagram illustrates a space allocation record table in the storage space management method provided in an embodiment of the present disclosure.

[0074] Figure 11 A block diagram of a storage space management apparatus provided in an embodiment of this disclosure is shown.

[0075] Figure 12 A block diagram of an electronic device 1900 provided in an embodiment of this disclosure is shown. Detailed Implementation

[0076] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.

[0077] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.

[0078] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0079] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.

[0080] The buddy algorithm is a widely used memory management technique in operating systems, especially in Linux. Its core advantage lies in its efficient memory allocation and reclamation mechanism, achieved by dividing memory into blocks of power-of-two sizes. These memory blocks are logically represented by a binary tree structure, where each non-leaf node represents a memory block that can be further subdivided, while leaf nodes represent the actual memory blocks. Leaf nodes can refer to the lowest-level nodes in the binary tree structure.

[0081] The buddy algorithm can allocate a size of 2 n A memory block of bytes, where n is an integer not less than 12 (i.e., the smallest allocation unit is 4KB). Figure 1 A schematic diagram of the binary tree structure for the buddy algorithm is shown. Figure 1 As shown, in the buddy system algorithm, the relationships between memory blocks can be represented by a binary tree, where each node, except for leaf nodes, can be split into two child nodes for allocation. When two adjacent free blocks are reclaimed, they can be merged into their parent node to form a larger free block, which helps reduce memory fragmentation.

[0082] In the buddy search algorithm, each memory block has a strict one-to-one correspondence with its address space. This correspondence ensures that the positions of adjacent nodes are definite and unique, and the positions of their parent nodes are also definite and unique. For example, for a memory block of size 512MB, its addresses could be 0, 512MB, 1024MB, and 1536MB. Among these addresses, 0 and 512MB are adjacent nodes, and their parent node address is 0. This correspondence simplifies memory management, making the search and merging of adjacent free blocks more efficient.

[0083] When using the buddy system algorithm for memory management, a two-part structure can be used to store allocation and deallocation information; both parts are memory structures. For example... Figure 1 As shown, a binary tree can represent the occupancy and adjacency relationships of all nodes. The binary tree structure facilitates quickly finding the occupancy status of adjacent nodes when a free block is reclaimed. When a free block is reclaimed, adjacent free nodes can be recursively merged upwards to create a larger free block, i.e., the parent node. This process helps optimize memory usage and reduce fragmentation.

[0084] While the buddy system performs well in memory management, in a multi-process environment, space allocation and reclamation are often unordered. This can lead to fragmentation of contiguous memory, making efficient allocation impossible even when there is sufficient free space. Furthermore, since memory block sizes are fixed powers of 2, this can result in underutilization of space in certain situations, leading to wasted space and, in extreme cases, deadlock.

[0085] Figure 2 A schematic diagram of the storage space is shown. Figure 2 In the example shown, there are four leaf nodes, with each of the two processes occupying one. When the system attempts to request contiguous space for two more leaf nodes, because the leaf nodes of the binary tree are not interconnected, even if there are enough remaining contiguous spaces, they cannot be allocated, resulting in underutilization of space. Therefore, in related technologies, even with sufficient contiguous free space, the lack of interconnectivity between the leaf nodes of the binary tree prevents the allocation of the required contiguous space. Furthermore, related technologies using the buddy system algorithm to manage storage space cannot effectively utilize contiguous space across internal nodes.

[0086] To address technical problems similar to those described above, this disclosure provides a storage space management method. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are set between two adjacent actual internal nodes of the same level. The left child of any virtual internal node is the right child of the actual internal node to its left, and the right child of any virtual internal node is the left child of the actual internal node to its right. The actual internal nodes and virtual internal nodes of the same level correspond to the same number of spaces. In response to receiving a storage space allocation request from a first process, a target node in the binary tree is determined based on the first number of storage spaces requested in the allocation request. The target node is the lowest-level free node with a space quantity greater than or equal to the first number, and the target node can be a virtual internal node. The target node is marked as occupied, and at least some of its related nodes are also marked as occupied. By utilizing virtual internal nodes, the remaining contiguous space can be used across actual internal nodes, improving space utilization under the buddy system algorithm and resolving space fragmentation and deadlock issues. This disclosure utilizes a binary tree to allocate and merge space in a more efficient manner while minimizing fragmentation, thereby maximizing the use of limited cache space. This allows processes to use space more efficiently according to their operational needs, which is beneficial for efficient and intensive management of cache space in a multi-process environment.

[0087] The storage space management method provided in the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.

[0088] Figure 3A flowchart illustrating a storage space management method provided in an embodiment of this disclosure is shown. In one possible implementation, the execution entity of the storage space management method can be a storage space management device. For example, the storage space management method can be executed by a terminal device, a server, or other electronic devices. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, or wearable device, etc. In some possible implementations, the storage space management method can be implemented by a processor calling computer-readable instructions stored in memory. In this embodiment, the binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are respectively set between two adjacent actual internal nodes of the same level. The left child node of any virtual internal node is the right child node of the actual internal node to the left of the virtual internal node, and the right child node of the virtual internal node is the left child node of the actual internal node to the right of the virtual internal node. The actual internal nodes and virtual internal nodes of the same level correspond to the same amount of space. Figure 3 As shown, the storage space management method includes steps S11 to S12.

[0089] In step S11, in response to receiving a storage space allocation request from the first process, a target node in the binary tree is determined for allocation to the first process based on the first quantity of storage space requested in the storage space allocation request. The target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node.

[0090] In step S12, the target node is marked as occupied, and at least some of the related nodes of the target node are marked as occupied.

[0091] In this embodiment of the disclosure, the storage space can be represented by a binary tree. The binary tree includes a root node, at least one level of actual internal nodes, at least one level of virtual internal nodes corresponding to the at least one level of actual internal nodes, and leaf nodes.

[0092] In a binary tree, the root node is the topmost node, and the entire tree expands from the root node. In the buddy system algorithm, the root node can represent the largest memory block. Internal nodes are all nodes except the root and leaf nodes. Internal nodes can have two children. Leaf nodes are the bottommost nodes in the binary tree. Leaf nodes have no children. In the buddy system algorithm, leaf nodes can represent the smallest memory block actually allocated to a process and are units that cannot be further split.

[0093] Actual internal nodes can represent real nodes in a binary tree, representing storage blocks that can be further split. In the buddy search algorithm, actual internal nodes can be split to allocate smaller storage requests. When storage space is freed, actual internal nodes can be merged with adjacent free sibling nodes to form larger free blocks.

[0094] Virtual internal nodes were introduced to provide additional flexibility in binary trees; they do not directly correspond to actual physical storage blocks. Virtual internal nodes are inserted between adjacent physical internal nodes to help utilize remaining contiguous space across these nodes. The introduction of virtual internal nodes allows the system to allocate and reclaim storage space more efficiently, especially when handling storage requests of varying sizes.

[0095] In one possible implementation, a given space size can be divided into 2 n Therefore, according to the geometric progression formula, the actual number of nodes S in the binary tree is... n =a1(1-q n ) / (1-q). Where a1 can represent the number of nodes at the bottom level (i.e., the lowest level) of the binary tree, that is, the number of leaf nodes; q can represent the proportion of each node splitting into child nodes.

[0096] As an example of this implementation, a1 equals 2. n q equals 1 / 2, indicating that each node can split into two child nodes; the number of levels (i.e., the number of layers) of the binary tree is n+1. In this example, S n =a1(1-q n ) / (1-q) can be transformed into S n =2 n+1 -1. For example, if n equals 4, then the actual number of nodes in the binary tree is 31, including 1 root node, 14 actual internal nodes, and 16 leaf nodes.

[0097] The number of actual nodes at any level can be a m =2 n-m, where m is greater than or equal to 0 and less than or equal to n. m=0 =2 n-0 This indicates the number of nodes at the lowest level (i.e., leaf nodes). m=n =2 n-n This indicates the number of nodes at the highest level (i.e., the root node).

[0098] For any intermediate level (i.e., any level other than the highest and lowest levels), the number of virtual internal nodes at that level can be equal to the number of actual internal nodes at that level. Therefore, the total number of all nodes in a binary tree, including virtual internal nodes, can be S. n =3×2 n -3.

[0099] Figure 4 This diagram illustrates a binary tree structure in the storage space management method provided in an embodiment of this disclosure. Figure 4 In the example shown, the space is divided into 2 4 =16 parts. The binary tree includes a root node, three levels of internal nodes, and leaf nodes. The root node has 1 node and 16 storage spaces.

[0100] exist Figure 4 In this context, internal nodes include both actual internal nodes and virtual internal nodes. Figure 4 In the diagram, the nodes within the solid lines are the actual nodes in the binary tree, including the root node, actual internal nodes, and leaf nodes. Except for the level 4, level 2, and level 1 head nodes, the nodes within the dashed lines are virtual internal nodes. The level 4 head node represents the first actual internal node with a space requirement of 4, i.e., the leftmost actual internal node with a space requirement of 4; the level 2 head node represents the first actual internal node with a space requirement of 2, i.e., the leftmost actual internal node with a space requirement of 2; and the level 1 head node represents the first leaf node with a space requirement of 1, i.e., the leftmost leaf node.

[0101] exist Figure 4 In the first level, the internal nodes consist of 2 actual internal nodes and 2 virtual internal nodes, with each internal node having 8 spaces; the second level consists of 4 actual internal nodes and 4 virtual internal nodes, with each internal node having 4 spaces; and the third level consists of 8 actual internal nodes and 8 virtual internal nodes, with each internal node having 2 spaces.

[0102] exist Figure 4 In this example, there are 16 leaf nodes, and each leaf node has a space requirement of 1.

[0103] Figure 5This diagram illustrates the array corresponding to the binary tree in the storage space management method provided in this embodiment. Figure 5 As shown, each level of a binary tree can be viewed as a separate array, and each array element can represent a node in the binary tree. Figure 5 In this example, five arrays are used to represent the five levels of the binary tree. The first array represents the lowest level, containing 16 elements corresponding to the 16 leaf nodes, each with a space of 1. The second array contains 16 elements, corresponding to the 8 actual internal nodes and 8 virtual internal nodes, each with a space of 2. The third array contains 8 elements, corresponding to the 4 actual internal nodes and 4 virtual internal nodes, each with a space of 4. The fourth array contains 4 elements, corresponding to the 2 actual internal nodes and 2 virtual internal nodes, each with a space of 8. The fifth array contains 1 element, corresponding to the root node of the binary tree. These five arrays linearize the hierarchical structure of the binary tree, allowing the parent-child and sibling relationships of each node to be determined using array indices.

[0104] In this embodiment of the disclosure, in response to receiving a storage space allocation request from a first process, a target node in the binary tree for allocation to the first process can be determined according to a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node may be a virtual internal node.

[0105] In this context, "first process" can refer to any process requesting storage space, and "first quantity" can refer to the amount of storage space requested by the storage space allocation request issued by the first process. "Target node" can refer to a node in a binary tree used for allocation to the first process. Before allocating the target node to the first process, the target node is in an idle state. That is, before allocating the target node to the first process, the target node is an idle node. The space quantity of the target node is greater than or equal to the first quantity. If the space quantity of the target node is equal to the first quantity, the target node and all its descendant nodes can be allocated to the first process; if the space quantity of the target node is greater than the first quantity, the target node and some of its descendant nodes can be allocated to the first process. The target node is the lowest-level idle node among the idle nodes with a space quantity greater than or equal to the first quantity. That is, the target node is the idle node with the smallest space quantity among the idle nodes with a space quantity greater than or equal to the first quantity. The target node can be an actual internal node, a virtual internal node, or a leaf node.

[0106] Figure 6This diagram illustrates a method for managing storage space according to an embodiment of the present disclosure, in which virtual internal nodes are used to allocate contiguous space to processes across actual internal nodes. Figure 6 In the example shown, there are four leaf nodes. Process 1 occupies the leftmost leaf node, and process 2 occupies the rightmost leaf node. Now, process 3 requests two contiguous leaf nodes. Since the leaf nodes of the two actual internal nodes are connected through a virtual internal node, two contiguous leaf nodes can be allocated to process 3.

[0107] In one possible implementation, in response to receiving a storage space allocation request from a first process, a first quantity of storage space requested by the storage space allocation request can be obtained through a space manager, and a target node in the binary tree for allocation to the first process can be determined through the space manager.

[0108] In one possible implementation, determining the target node in the binary tree for allocation to the first process based on the first quantity of storage space requested by the storage space allocation request includes: determining the leftmost node among the lowest-level free nodes whose space quantity is greater than or equal to the first quantity as the target node.

[0109] In this implementation, the target space quantity level corresponding to the storage space allocation request can be determined based on the first quantity, and the leftmost node among the free nodes at the target space quantity level can be determined as the target node. When the target space quantity level is at the internal node level, the leftmost node may be an actual internal node or a virtual internal node.

[0110] Figure 7 This diagram illustrates how, in the storage space management method provided by this disclosure, the leftmost node among the lowest-level free nodes with a space quantity greater than or equal to a first quantity is determined as the target node. Figure 7 In the example shown, the binary tree includes 8 storage spaces, and the first process requests 3 storage spaces in its storage allocation request. Based on the first quantity of 3, the target space quantity level corresponding to the storage allocation request can be determined to be 4. At this time, since the 3 internal nodes (including 2 actual internal nodes and 1 virtual internal node) of the target space quantity level 4 are all in an idle state, the leftmost actual internal node can be determined as the target node.

[0111] In this implementation, the leftmost node among the lowest-level free nodes with a space quantity greater than or equal to the first quantity is identified as the target node. This simplifies the search process and improves space allocation efficiency by always selecting the leftmost free node that meets the criteria. Furthermore, this implementation helps reduce storage fragmentation, making storage space utilization more compact and efficient.

[0112] In this embodiment of the disclosure, after determining the target node, the target node can be marked as occupied (in... Figure 7 (Used in dark color), and at least some of the related nodes of the target node are marked as occupied.

[0113] In one possible implementation, marking at least some of the related nodes of the target node as occupied includes: in response to the target node being an actual internal node, marking each ancestor node of the target node as occupied; in response to the number of spaces corresponding to the target node being greater than a first number, marking some of the descendant nodes of the target node as occupied according to the first number, or, in response to the number of spaces corresponding to the target node being equal to the first number, marking each descendant node of the target node as occupied; and marking each ancestor node of the descendant nodes marked as occupied as occupied.

[0114] In this implementation, when the target node is an actual internal node, each ancestor node of the target node is marked as occupied. Figure 8 This diagram illustrates a storage space management method provided in an embodiment of the present disclosure, in which at least some related nodes of a target node are marked as occupied. Figure 8 In the example shown, after determining the target node (i.e., the leftmost actual internal node with a space quantity of 4), the ancestor node of the target node (i.e., the root node) is marked as occupied.

[0115] In this implementation, if the space corresponding to the target node is greater than a first quantity, some descendant nodes of the target node are marked as occupied based on the first quantity. For example, in Figure 8 In the first case, the quantity is 3, and the target node is the leftmost actual internal node with a space quantity of 4. Then, mark the target node's 2 child nodes and 3 grandchild nodes as occupied.

[0116] In this implementation, when the space quantity corresponding to the target node is equal to the first quantity, each descendant node of the target node is marked as occupied. For example, if the first quantity is 4, and the target node is the leftmost actual internal node with a space quantity of 4, then the 2 child nodes and 4 grandchild nodes of the target node are marked as occupied.

[0117] In this implementation, each ancestor node of the descendant node marked as occupied is marked as occupied. For example, in Figure 8 In the process, after the second actual internal node with a space quantity of 2 is marked as occupied, its parent node (the virtual internal node with a space quantity of 4) is also marked as occupied. After the second and third leaf nodes are marked as occupied, their parent nodes (the first virtual internal node with a space quantity of 2) are also marked as occupied.

[0118] This implementation improves storage space utilization efficiency, reduces fragmentation, and optimizes storage space management through a fine-grained and flexible storage space allocation strategy, thereby enhancing the overall performance and reliability of the system.

[0119] As an example of this implementation, marking some descendant nodes of the target node as occupied according to the first quantity includes: for any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes already marked as occupied among other descendant nodes of the same level as the target node has not reached the first quantity, marking the descendant node as occupied; or, for any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes already marked as occupied among other descendant nodes of the same level as the target node has reached the first quantity, keeping the descendant node in an idle state and stopping the marking of the remaining descendant nodes of the same level.

[0120] In this example, for nodes at the same level, occupancy markers can be assigned to descendant nodes in a left-to-right order (i.e., from smallest to largest node number). For example, in... Figure 8 In the first case, the quantity is 3, and the target node is the first actual internal node with a spatial quantity of 4.

[0121] refer to Figure 8 In the left and middle subgraphs, for the left child of the target node, since the total space corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 0, which is less than the first number of 3, the left child of the target node is marked as occupied. For the right child of the target node, since the total space corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 2, which is less than the first number of 3, the right child of the target node is marked as occupied.

[0122] refer to Figure 8In the middle and right subgraphs, for the first grandchild node (i.e., the first leaf node) of the target node, since the total space corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 0, which is less than the first number of 3, the first grandchild node (i.e., the first leaf node) of the target node is marked as occupied. For the second grandchild node (i.e., the second leaf node) of the target node, since the total space corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 1, which is less than the first number of 3, the second grandchild node (i.e., the second leaf node) of the target node is marked as occupied. For the third grandchild node (i.e., the third leaf node) of the target node, since the total space corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 2, which is less than the first number of 3, the third grandchild node (i.e., the third leaf node) of the target node is marked as occupied. For the fourth grandchild node (i.e. the fourth leaf node) of the target node, since the total number of spaces corresponding to the nodes marked as occupied among the other descendant nodes of the same level of the target node is 3, which has reached the first number of 3, the fourth grandchild node (i.e. the fourth leaf node) of the target node is kept in an idle state, and the marking of the remaining descendant nodes of the same level is stopped.

[0123] This implementation method ensures that the required amount of storage space (the initial quantity) is precisely calculated and allocated, preventing waste and improving storage utilization. In a multi-process environment, this method can effectively allocate the necessary storage space to each process while ensuring that other processes also obtain the necessary resources, thus supporting the efficient operation of multiple processes.

[0124] In another possible implementation, marking at least some of the related nodes of the target node as occupied includes: in response to the target node being a virtual internal node and the number of spaces corresponding to the target node being greater than a first number, marking some of the descendant nodes of the target node as occupied according to the first number; or, in response to the target node being a virtual internal node and the number of spaces corresponding to the target node being equal to the first number, marking each descendant node of the target node as occupied; and marking each ancestor node of the descendant nodes marked as occupied as occupied.

[0125] In this implementation, if the space corresponding to the target node is greater than a first quantity, only a portion of the target node's descendant nodes can be marked as occupied, based on the first quantity. This means that only the minimum amount of space required by the request is allocated, maintaining flexibility in the remaining space. If the space corresponding to the target node is exactly equal to the first quantity, all descendant nodes of the target node can be marked as occupied. This means that all space under this virtual internal node is fully allocated to the requesting process. In either case, once a descendant node is marked as occupied, all its ancestor nodes will also be marked as occupied accordingly to ensure the continuity and consistency of storage space allocation.

[0126] This implementation provides flexible allocation options by distinguishing the relationship between the target node's space size and the request size. It can allocate space partially or completely to adapt to different process needs. By precisely allocating the amount of space required by the request, it avoids over-allocation and improves the utilization of storage space.

[0127] In another possible implementation, marking at least some of the related nodes of the target node as occupied includes: in response to the target node being a leaf node, marking each ancestor node of the target node as occupied.

[0128] In this implementation, in response to the target node being a leaf node, each ancestor node of the target node is marked as occupied, so that each ancestor node of the target node can no longer be allocated to other processes, thereby ensuring the consistency of storage space allocation.

[0129] In one possible implementation, the method further includes: in a node enable table, recording the usage status of nodes in the binary tree through enable bits that correspond one-to-one with the nodes in the binary tree, wherein an enable bit corresponding to any node being of a first preset value indicates that the node is in an idle state, and an enable bit corresponding to any node being of a second preset value indicates that the node is in an occupied state.

[0130] In this implementation, the node enable table can be a data structure used to record the usage status of each node in the binary tree. The node enable table can include a series of enable bits (or flag bits), each enabling bit corresponding one-to-one with a node in the binary tree. The value of each enable bit indicates the usage status of the corresponding node. When the enable bit is at the first preset value, it indicates that the corresponding node is idle and not occupied by any process. When the enable bit is at the second preset value, it indicates that the corresponding node has been occupied by a process.

[0131] In one example, the first preset value can be 0, and the second preset value can be 1.

[0132] Figure 9This diagram illustrates an entry in the node enable table of the storage space management method provided in this embodiment of the present disclosure. For example... Figure 9 As shown, the node number of each node can be recorded in the node enable table, and the usage status of the node can be recorded through the enable bit.

[0133] In this implementation, whenever a node is allocated or released, the corresponding enable bit is updated to a preset value to reflect the node's latest state. By checking the enable bits in the node enable table, it is possible to quickly determine whether any given node is available, thereby speeding up allocation and reclamation operations.

[0134] This implementation provides a clear and systematic approach to tracking the allocation status of each node, simplifying state management. Determining node status by quickly checking enable bits reduces the time required to find and allocate storage space.

[0135] In one possible implementation, for any node in the binary tree, the spatial quantity level of that node can also be recorded. For example, in Figure 4 In the binary tree shown, the space quantity of the root node is 16, the space quantity of each actual internal node and virtual internal node in the first level internal node is 8, the space quantity of each actual internal node and virtual internal node in the second level internal node is 4, the space quantity of each actual internal node and virtual internal node in the third level internal node is 2, and the space quantity of each leaf node is 1.

[0136] In one possible implementation, for any node in the binary tree, the node's number can also be recorded. For example, in Figure 4 In the binary tree shown, the nodes are numbered from 1 to 45 in a top-to-bottom, left-to-right order. The numbers of higher-level nodes are lower than those of lower-level nodes.

[0137] In one possible implementation, for any node in the binary tree, the parent-child relationship and sibling relationship between the node and other nodes in the binary tree can also be recorded.

[0138] In one possible implementation, the method further includes: recording the correspondence between the first process and the target node in a space allocation record table, and recording the first quantity.

[0139] For example, the identification information of the first process (such as the process number of the first process) and the number of the target node, as well as the first quantity, can be recorded in the space allocation record table.

[0140] As an example of this implementation, the correspondence between the first process and the target node can be recorded in a space allocation record table through a storage unit, and the first quantity can also be recorded.

[0141] Figure 10 This diagram illustrates a space allocation record table in a storage space management method provided in an embodiment of the present disclosure. Figure 10 As shown, the process ID, node ID, and space usage can be recorded in the space allocation record table.

[0142] As an example of this implementation, the corresponding record can be deleted from the space allocation record table in response to the process releasing the node.

[0143] In this implementation, the node corresponding to a process can be queried based on the space allocation record table, thereby revealing the physical location of the process's storage space. When it is necessary to track the storage space used by a specific process, the space allocation record table provides a direct reference, allowing for quick location of the relevant node. Furthermore, this implementation method occupies a small amount of space and is fast.

[0144] In one possible implementation, the method further includes: in response to a storage space release request from the first process, wherein the storage space release request is for requesting the release of the target node, marking the target node as idle based on the first quantity, and marking at least some of the related nodes of the target node as idle.

[0145] As an example of this implementation, each descendant node of the target node can be marked as idle in response to the number of spaces corresponding to the target node being equal to the first number.

[0146] As an example of this implementation, in response to the target node having a space quantity greater than the first quantity, some of the target node's descendant nodes can be marked as idle.

[0147] In this example, for any descendant node of the target node, release can be performed sequentially from left to right (i.e., in ascending order of node number). For any descendant node of the target node, if the total space corresponding to the released nodes among other descendant nodes of the same level as the target node has not reached the first number, the descendant node is marked as idle; or, for any descendant node of the target node, if the total space corresponding to the released nodes among other descendant nodes of the same level as the target node has reached the first number, the release of the remaining descendant nodes of the same level is stopped.

[0148] As an example of this implementation, the record corresponding to the target node can be deleted from the space allocation record table.

[0149] This implementation allows the system to promptly reclaim storage space when processes release it, making it available for use by other processes or reallocated. By determining which nodes need to be marked as idle based on a first quantity (i.e., the amount of space requested by a process), the system can accurately update the storage space status, avoiding resource waste.

[0150] In one possible implementation, the method further includes: for any node in an occupied state, updating the usage state of the node to an idle state in response to all descendant nodes of the node being updated to an idle state.

[0151] In this implementation, when all descendant nodes (child nodes, grandchild nodes, etc.) of a node become idle, that node is also updated to an idle state. This process proceeds upwards, starting from the leaf nodes and continuing up to the root node. Once all child nodes are marked as idle, their parent node will also be marked as idle.

[0152] In this implementation, a data structure (such as a node enable table) can be maintained to record the usage status of each node. When a process releases a node, it can be marked as idle. Next, the parent nodes of these idle nodes can be checked; if all child nodes of the parent node are idle, then the parent node is also updated to an idle state. This process can continue until no more parent nodes can be updated to an idle state.

[0153] This implementation helps reduce storage fragmentation by updating the usage status of any node in an occupied state to idle in response to all its descendant nodes being updated to idle. Furthermore, it allows the system to utilize freed space more efficiently because large contiguous blocks of space can be quickly reintegrated into the available space pool. When storage space needs to be allocated again, the system can find sufficiently large contiguous spaces more quickly because large blocks of space have already been maintained as idle.

[0154] The storage space management method provided in this disclosure can be applied to the technical fields of processors, space management, buddy systems, address allocation, etc., and is not limited thereto.

[0155] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0156] In addition, this disclosure also provides storage space management devices, electronic devices, computer-readable storage media, and computer program products, all of which can be used to implement any of the storage space management methods provided in this disclosure. The corresponding technical solutions and effects can be found in the relevant descriptions in the method section, and will not be repeated here.

[0157] Figure 11 This diagram illustrates a block diagram of a storage space management device provided in an embodiment of this disclosure. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are respectively set between two adjacent actual internal nodes of the same level. The left child node of any virtual internal node is the right child node of the actual internal node to its left, and the right child node of any virtual internal node is the left child node of the actual internal node to its right. The actual internal nodes and virtual internal nodes of the same level correspond to the same number of spaces. Figure 11 As shown, the storage space management device includes:

[0158] The determining module 21 is configured to respond to receiving a storage space allocation request from the first process, and determine a target node in the binary tree for allocation to the first process based on a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node.

[0159] The marking module 22 is used to mark the target node as occupied and to mark at least some of the related nodes of the target node as occupied.

[0160] In one possible implementation, the determining module 21 is used to:

[0161] The leftmost node among the lowest-level free nodes with a space quantity greater than or equal to the first quantity is determined as the target node.

[0162] In one possible implementation, the marking module 22 is used for:

[0163] In response to the target node being an actual internal node, each ancestor node of the target node is marked as occupied.

[0164] In response to the number of spaces corresponding to the target node being greater than the first number, some descendant nodes of the target node are marked as occupied based on the first number; or, in response to the number of spaces corresponding to the target node being equal to the first number, each descendant node of the target node is marked as occupied.

[0165] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0166] In one possible implementation, the marking module 22 is used for:

[0167] For any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes marked as occupied among other descendant nodes at the same level as the target node has not reached the first number, the descendant node is marked as occupied.

[0168] or,

[0169] For any descendant node of the target node, in response to the total number of spaces corresponding to nodes marked as occupied among other descendant nodes of the same level as the target node having reached the first number, the descendant node is kept in an idle state, and the marking of the remaining descendant nodes of the same level is stopped.

[0170] In one possible implementation, the marking module 22 is used for:

[0171] In response to the target node being a virtual internal node and the space corresponding to the target node being greater than the first quantity, some descendant nodes of the target node are marked as occupied based on the first quantity; or, in response to the target node being a virtual internal node and the space corresponding to the target node being equal to the first quantity, each descendant node of the target node is marked as occupied.

[0172] Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

[0173] In one possible implementation, the marking module 22 is used for:

[0174] In response to the target node being a leaf node, each ancestor node of the target node is marked as occupied.

[0175] In one possible implementation, the device further includes:

[0176] The first recording module is used to record the correspondence between the first process and the target node in the space allocation record table, and to record the first quantity.

[0177] In one possible implementation, the device further includes:

[0178] The second recording module is used to record the usage status of nodes in the binary tree in the node enable table by using enable bits that correspond one-to-one with the nodes in the binary tree. Here, if the enable bit corresponding to any node is a first preset value, it means that the node is in an idle state, and if the enable bit corresponding to any node is a second preset value, it means that the node is in an occupied state.

[0179] In one possible implementation, the marking module 22 is further configured to:

[0180] In response to a storage space release request from the first process, and the storage space release request is used to request the release of the target node, the target node is marked as idle according to the first quantity, and at least some of the related nodes of the target node are marked as idle.

[0181] In one possible implementation, the device further includes:

[0182] The update module is used to update the usage status of any node in an occupied state to an idle state in response to all descendant nodes of the node being updated to an idle state.

[0183] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation and technical effects can be referred to the description of the above method embodiments. For the sake of brevity, they will not be repeated here.

[0184] This disclosure also provides a computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the above-described method. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.

[0185] This disclosure also proposes a computer program including computer-readable code, wherein when the computer-readable code is run in an electronic device, a processor in the electronic device executes the above-described method.

[0186] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in an electronic device, the processor in the electronic device executes the above-described method.

[0187] This disclosure also provides an electronic device, including: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to invoke the executable instructions stored in the memory to perform the above-described method.

[0188] Electronic devices can be provided as terminals, servers, or other forms of devices.

[0189] Figure 12 A block diagram of an electronic device 1900 provided according to an embodiment of this disclosure is shown. For example, the electronic device 1900 may be provided as a terminal or a server. (Refer to...) Figure 12 The electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.

[0190] Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). Electronic device 1900 can operate on an operating system stored in memory 1932, such as Microsoft Server operating system (Windows Server). TM Apple's graphical user interface-based operating system (MacOS X) TM ), a multi-user, multi-process computer operating system (Unix) TM Linux is a free and open-source Unix-like operating system. TM ), the open-source Unix-like operating system (FreeBSD) TM (or similar.)

[0191] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions that can be executed by a processing component 1922 of an electronic device 1900 to perform the above-described method.

[0192] This disclosure can be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of this disclosure.

[0193] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0194] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0195] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0196] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0197] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0198] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0199] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0200] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0201] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0202] If the technical solution of this disclosure involves personal information, the product applying the technical solution of this disclosure has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this disclosure involves sensitive personal information, the product applying the technical solution of this disclosure has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to indicate that the user has entered the scope of personal information collection and that personal information will be collected. If the user voluntarily enters the collection scope, it is deemed to have consented to the collection of their personal information; or on the personal information processing device, with clear signs / information informing the user of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.

[0203] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A storage space management method, characterized in that, The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are set between two adjacent actual internal nodes of the same level. The left child of any virtual internal node is the right child of the actual internal node to its left, and the right child of any virtual internal node is the left child of the actual internal node to its right. The number of spaces corresponding to actual internal nodes and virtual internal nodes of the same level is the same. For any intermediate level other than the highest and lowest levels, the number of virtual internal nodes at the same intermediate level is equal to the number of actual internal nodes. The method includes: In response to receiving a storage space allocation request from a first process, a target node in the binary tree is determined for allocation to the first process based on a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node. The target node is marked as occupied, and at least some of the related nodes of the target node are also marked as occupied.

2. The method according to claim 1, characterized in that, The step of determining the target node in the binary tree for allocation to the first process based on the first quantity of storage space requested in the storage space allocation request includes: The leftmost node among the lowest-level free nodes with a space quantity greater than or equal to the first quantity is determined as the target node.

3. The method according to claim 1 or 2, characterized in that, The step of marking at least some of the related nodes of the target node as occupied includes: In response to the target node being an actual internal node, each ancestor node of the target node is marked as occupied. In response to the number of spaces corresponding to the target node being greater than the first number, some descendant nodes of the target node are marked as occupied based on the first number; or, in response to the number of spaces corresponding to the target node being equal to the first number, each descendant node of the target node is marked as occupied. Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

4. The method according to claim 3, characterized in that, The step of marking a portion of the target node's descendant nodes as occupied based on the first quantity includes: For any descendant node of the target node, in response to the fact that the total number of spaces corresponding to nodes marked as occupied among other descendant nodes at the same level as the target node has not reached the first number, the descendant node is marked as occupied. or, For any descendant node of the target node, in response to the total number of spaces corresponding to nodes marked as occupied among other descendant nodes of the same level as the target node having reached the first number, the descendant node is kept in an idle state, and the marking of the remaining descendant nodes of the same level is stopped.

5. The method according to claim 1 or 2, characterized in that, The step of marking at least some of the related nodes of the target node as occupied includes: In response to the target node being a virtual internal node and the space corresponding to the target node being greater than the first quantity, some descendant nodes of the target node are marked as occupied based on the first quantity; or, in response to the target node being a virtual internal node and the space corresponding to the target node being equal to the first quantity, each descendant node of the target node is marked as occupied. Each ancestor node of the descendant node that is marked as occupied is marked as occupied.

6. The method according to claim 1 or 2, characterized in that, The step of marking at least some of the related nodes of the target node as occupied includes: In response to the target node being a leaf node, each ancestor node of the target node is marked as occupied.

7. The method according to claim 1 or 2, characterized in that, The method further includes: The space allocation record table records the correspondence between the first process and the target node, and records the first quantity.

8. The method according to claim 1 or 2, characterized in that, The method further includes: In the node enable table, the usage status of the nodes in the binary tree is recorded by the enable bits that correspond one-to-one with the nodes in the binary tree. The enable bit corresponding to any node is a first preset value, which indicates that the node is in an idle state. The enable bit corresponding to any node is a second preset value, which indicates that the node is in an occupied state.

9. The method according to claim 1 or 2, characterized in that, The method further includes: In response to a storage space release request from the first process, and the storage space release request is used to request the release of the target node, the target node is marked as idle according to the first quantity, and at least some of the related nodes of the target node are marked as idle.

10. The method according to claim 9, characterized in that, The method further includes: For any node that is in an occupied state, in response to all descendant nodes of that node updating their usage status to an idle state, the usage status of that node is updated to an idle state.

11. A storage space management device, characterized in that, The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. Virtual internal nodes are set between two adjacent actual internal nodes of the same level. The left child of any virtual internal node is the right child of the actual internal node to its left, and the right child of any virtual internal node is the left child of the actual internal node to its right. The number of spaces corresponding to actual internal nodes and virtual internal nodes of the same level is the same. For any intermediate level other than the highest and lowest levels, the number of virtual internal nodes at the same intermediate level is equal to the number of actual internal nodes. The device includes: The determination module is configured to respond to receiving a storage space allocation request from a first process, and determine a target node in the binary tree for allocation to the first process based on a first quantity of storage space requested in the storage space allocation request, wherein the target node is the lowest-level free node with a space quantity greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node. A marking module is used to mark the target node as occupied and to mark at least some of the related nodes of the target node as occupied.

12. An electronic device, characterized in that, include: One or more processors; Memory used to store executable instructions; The one or more processors are configured to invoke executable instructions stored in the memory to perform the method according to any one of claims 1 to 10.

13. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 10.

14. A computer program product comprising computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, characterized in that, When the computer-readable code is run in an electronic device, the processor in the electronic device performs the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • File system metadata separation storage method and device and storage medium

    CN115599704A

  • Data processing method, computer equipment and storage medium

    CN118643041A