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

By introducing virtual internal nodes into the binary tree, the problem of storage space fragmentation and deadlock of partner algorithms in multi-process environments is solved, and more efficient storage space management is achieved.

CN120371720AActive Publication Date: 2025-07-25MOORE THREADS TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In a multi-process environment, partner algorithms lead to continuous space fragmentation and deadlock of storage space, and cannot effectively utilize the remaining space.

Method used

The virtual internal node is introduced into the binary tree, allowing continuous space to be used across actual internal nodes, and the storage space allocation request is met by marking the target node and its related nodes into the occupied state.

Benefits of technology

Improve the utilization rate of storage space, reduce fragmentation and deadlock, and achieve more efficient storage space management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371720A_ABST
    Figure CN120371720A_ABST
Patent Text Reader

Abstract

The invention relates to a storage space management method and device, electronic equipment, a storage medium and a program product. A binary tree corresponding to a storage space comprises a root node, at least one level of actual internal nodes and leaf nodes, and a virtual internal node is arranged between every two adjacent actual internal nodes of the same level, and the method comprises the following steps: responding to a received storage space allocation request from a first process, target nodes used for being distributed to the first process in the binary tree are determined according to the first number of the requested storage spaces, the target nodes are idle nodes of the lowest level with the space number larger than or equal to the first number, and the target nodes are allowed to be virtual internal nodes; and marking the target node as an occupied state, and marking at least part of related nodes of the target node as an occupied state. According to the invention, the residual continuous space can be used across actual internal nodes, and the space utilization rate under the partner algorithm can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a storage space management method, a storage space management device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] The Buddy algorithm is a memory management algorithm mainly used for the allocation and recycling of memory space in an operating system. The core idea of the Buddy algorithm is to divide the memory into blocks with sizes that are powers of 2, such as 2 bytes, 4 bytes, 8 bytes, 16 bytes, and so on. The name of the Buddy algorithm comes from the fact that each memory block has a "buddy", that is, another block with the same size and adjacent address.

[0003] Although the Buddy algorithm reduces fragmentation by merging adjacent free blocks, in a multi-process environment, the allocation and recycling of space are usually disordered, which may lead to fragmentation of continuous space, making it impossible to allocate even if there is enough remaining space. Summary of the Invention

[0004] The present disclosure provides a technical solution for storage space management.

[0005] According to one aspect of the present disclosure, there is provided 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. And virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Wherein, the left child node of any virtual internal node is the right child node of the actual internal node on the left side of the virtual internal node, the right child node of the virtual internal node is the left child node of the actual internal node on the right side of the virtual internal node, and the space quantities corresponding to the actual internal nodes and the virtual internal nodes at the same level are the same. The method includes:

[0006] In response to receiving a storage space allocation request from a first process, determine a target node in the binary tree for allocating to the first process according to a first quantity of the storage space requested by the storage space allocation request, where the target node is the lowest-level free node whose space quantity is greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node;

[0007] Mark the target node as an occupied state, and mark at least some related nodes of the target node as an occupied state.

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

[0009] Determine the leftmost node among the lowest-level free nodes with the number of spaces greater than or equal to the first number as the target node.

[0010] In a 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, mark each ancestor node of the target node as occupied respectively;

[0012] In response to the number of spaces corresponding to the target node being greater than the first number, mark 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, mark each descendant node of the target node as occupied respectively;

[0013] Mark each ancestor node of the marked descendant nodes as occupied respectively.

[0014] In a possible implementation, marking some of the descendant nodes of the target node as occupied according to the first number includes:

[0015] For any descendant node of the target node, in response to the total number of spaces corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node not reaching the first number, mark the descendant node as occupied;

[0016] Or,

[0017] For any descendant node of the target node, in response to the total number of spaces corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node having reached the first number, keep the descendant node in the free state and stop marking the remaining descendant nodes at the same level.

[0018] In a 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 number of spaces corresponding to the target node being greater than the first number, mark 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, mark each descendant node of the target node as occupied respectively;

[0020] Mark each ancestor node of the marked descendant nodes as occupied respectively.

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

[0022] In response to the target node being a leaf node, marking each ancestor node of the target node as an occupied state respectively.

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

[0024] In the space allocation record table, record the corresponding relationship between the first process and the target node, and record the first quantity.

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

[0026] In the node enable table, record the usage status of the nodes in the binary tree through enable bits corresponding one by one to the nodes in the binary tree, where an enable bit corresponding to any node being the first preset value indicates that the node is in an idle state, and an enable bit corresponding to any node being the second preset value indicates that the node is in an occupied state.

[0027] In a 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 being used to request the release of the target node, mark the target node as an idle state according to the first quantity, and mark at least some of the related nodes of the target node as idle states.

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

[0030] For any node in an occupied state, in response to the usage status of all descendant nodes of the node being updated to an idle state, update the usage status of the node to an idle state.

[0031] According to an aspect of the present disclosure, there is provided a storage space management device. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes and leaf nodes, and virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Wherein, the left child node of any virtual internal node is the right child node of the actual internal node on the left side of the virtual internal node, the right child node of the virtual internal node is the left child node of the actual internal node on the right side of the virtual internal node, and the space quantities corresponding to the actual internal nodes and virtual internal nodes at the same level are the same. The device includes:

[0032] A determination module, configured to, in response to receiving a storage space allocation request from a first process, determine a target node in the binary tree for allocating to the first process according to a first quantity of the storage space requested by the storage space allocation request, where 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 allows being a virtual internal node;

[0033] A marking module, configured to mark the target node as an occupied state, and mark at least some related nodes of the target node as occupied states.

[0034] In a possible implementation manner, the determination module is configured to:

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

[0036] In a possible implementation manner, the marking module is configured to:

[0037] In response to the target node being an actual internal node, mark each ancestor node of the target node as an occupied state respectively;

[0038] In response to the space quantity corresponding to the target node being greater than the first quantity, mark some descendant nodes of the target node as occupied states according to the first quantity; or, in response to the space quantity corresponding to the target node being equal to the first quantity, mark each descendant node of the target node as an occupied state respectively;

[0039] Mark each ancestor node of the marked descendant nodes as an occupied state respectively.

[0040] In a possible implementation manner, the marking module is configured to:

[0041] For any descendant node of the target node, in response to the total space quantity corresponding to the nodes marked as occupied states among the other descendant nodes at the same level of the target node not reaching the first quantity, mark the descendant node as an occupied state;

[0042] Or,

[0043] For any descendant node of the target node, in response to the total space quantity corresponding to the nodes marked as occupied states among the other descendant nodes at the same level of the target node having reached the first quantity, keep the descendant node in an idle state, and stop marking the remaining descendant nodes at the same level.

[0044] In a possible implementation manner, the marking module is configured to:

[0045] In response to the target node being a virtual internal node and the number of spaces corresponding to the target node being greater than the first number, mark some 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, mark each descendant node of the target node as occupied respectively;

[0046] Mark each ancestor node of the descendant node marked as occupied as occupied respectively.

[0047] In a possible implementation, the marking module is configured to:

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

[0049] In a possible implementation, the apparatus further includes:

[0050] A first recording module, configured to record the corresponding relationship between the first process and the target node in a space allocation record table, and record the first number.

[0051] In a possible implementation, the apparatus further includes:

[0052] A second recording module, configured to record the usage status of the nodes in the binary tree through enable bits corresponding one by one to the nodes in the binary tree in a node enable table, where an enable bit corresponding to any node being a first preset value indicates that the node is in an idle state, and an enable bit corresponding to any node being a second preset value indicates that the node is in an occupied state.

[0053] In a possible implementation, the marking 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, mark the target node as idle according to the first number, and mark at least some related nodes of the target node as idle.

[0055] In a possible implementation, the apparatus further includes:

[0056] An update module, configured to, for any node in an occupied state, in response to the usage status of all descendant nodes of the node being updated to idle, update the usage status of the node to idle.

[0057] According to one aspect of the present disclosure, there is provided an electronic device, including: one or more processors; a memory for storing executable instructions; wherein, the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.

[0058] According to one aspect of the present disclosure, there is provided a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the above method is implemented.

[0059] According to one aspect of the present disclosure, there is provided a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, the processor in the electronic device executes the above method.

[0060] In an embodiment of the present disclosure, the binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. And, virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Wherein, the left child node of any virtual internal node is the right child node of the actual internal node on the left side 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 on the right side of the virtual internal node. The number of spaces corresponding to the actual internal nodes and virtual internal nodes at the same level is the same. By responding to a storage space allocation request received from a first process, according to a first quantity of the storage space requested by the storage space allocation request, a target node in the binary tree to be allocated to the first process is determined. Wherein, the target node is the lowest-level free node whose number of spaces is 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 an occupied state, and at least some related nodes of the target node are marked as an occupied state. Thus, by using virtual internal nodes, the remaining continuous space can be used across actual internal nodes, the space utilization rate under the buddy algorithm can be improved, and the problems of space fragmentation and deadlock can be solved. The embodiment of the present disclosure uses a binary tree to allocate and merge spaces in a better way while minimizing fragmentation as much as possible, so as to maximize the use of limited cache space, enabling a process to use space more intensively according to running needs, which is beneficial to the efficient 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 merely exemplary and explanatory, and do not limit the present disclosure.

[0062] According to the following detailed description of exemplary embodiments with reference to the accompanying drawings, other features and aspects of the present disclosure will become clear. Description of the Drawings

[0063] The accompanying drawings here are incorporated into the specification and form a part of this specification. These drawings show embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure.

[0064] Figure 1 Schematic diagram showing the binary tree structure of the buddy algorithm.

[0065] Figure 2 Schematic diagram showing a storage space.

[0066] Figure 3 Flowchart showing the storage space management method provided by the embodiments of the present disclosure.

[0067] Figure 4 Schematic diagram showing the binary tree structure in the storage space management method provided by the embodiments of the present disclosure.

[0068] Figure 5 Schematic diagram showing the array corresponding to the binary tree in the storage space management method provided by the embodiments of the present disclosure.

[0069] Figure 6 Schematic diagram showing that in the storage space management method provided by the embodiments of the present disclosure, continuous space is allocated to a process across actual internal nodes by using virtual internal nodes.

[0070] Figure 7 Schematic diagram showing that in the storage space management method provided by the embodiments of the present disclosure, the leftmost node in the lowest-level free nodes with the number of spaces greater than or equal to the first number is determined as the target node.

[0071] Figure 8 Schematic diagram showing that in the storage space management method provided by the embodiments of the present disclosure, at least some relevant nodes of the target node are marked as occupied.

[0072] Figure 9 Schematic diagram showing an entry in the node enable table in the storage space management method provided by the embodiments of the present disclosure.

[0073] Figure 10 Schematic diagram showing the space allocation record table in the storage space management method provided by the embodiments of the present disclosure.

[0074] Figure 11 Block diagram showing the storage space management device provided by the embodiments of the present disclosure.

[0075] Figure 12 Block diagram showing the electronic device 1900 provided by the embodiments of the present disclosure. Detailed implementation manners

[0076] Various exemplary embodiments, features, and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the drawings denote elements having the same or similar functions. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0077] As used herein, the term "exemplary" means "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior to or better than other embodiments.

[0078] As used herein, the term "and / or" merely describes an association relationship between associated objects and represents three relationships that may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" as used herein means any one or any combination of at least two of a plurality. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0079] In addition, for a better illustration of the present disclosure, numerous specific details are given in the following specific implementation manners. Those skilled in the art should understand that the present disclosure can also be implemented without certain specific details. In some instances, methods, means, elements, and circuits well-known to those skilled in the art are not described in detail so as to highlight the gist of the present disclosure.

[0080] The Buddy algorithm is a memory management technique widely used in operating systems, especially in the Linux system. The core advantage of the Buddy algorithm lies in its efficient memory space allocation and recycling mechanism, which is achieved by splitting the memory into blocks of size 2 to the power of n. These memory blocks are logically represented by a binary tree structure, where each non-leaf node represents a memory block that can be further split, and the leaf nodes represent the actual memory blocks. Among them, the leaf nodes can refer to the lowest-level nodes in the binary tree structure.

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

[0082] In the buddy 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 determined and unique, and at the same time, the positions of their parent nodes are also determined and unique. For example, for a memory block of 512 MB, its addresses may be 0, 512 MB, 1024 MB, and 1536 MB. Among these addresses, 0 and 512 MB are adjacent nodes, and the address of their parent node is 0. This correspondence simplifies memory management and makes it more efficient to find and merge adjacent free blocks.

[0083] When using the buddy algorithm for memory space management, a two-part structure can be adopted to store allocation information and recycling information, and both of these two parts are memory structures. As Figure 1 shown, a binary tree can represent the occupancy relationship and adjacency relationship of all nodes. The binary tree structure facilitates quickly finding the occupancy situation of adjacent nodes of a recycled free block. When a free block is recycled, adjacent free nodes can be recursively merged upward to generate a larger free block, that is, the parent node. This process helps to optimize memory usage and reduce fragmentation.

[0084] Although the buddy algorithm performs well in memory management, in a multi-process environment, the allocation and recycling of space are often disordered, which may lead to fragmentation of continuous space, making it impossible to perform effective allocation even when there is enough remaining space. In addition, since the memory block size is fixed as a power of 2, this may result in the space not being fully utilized in some cases, causing space waste, and even leading to deadlocks in some extreme cases.

[0085] Figure 2 A schematic diagram showing the storage space is presented. In Figure 2 the shown example, there are a total of 4 leaf nodes, and two processes each occupy 1 leaf node. When the system tries to apply for continuous space of 2 leaf nodes again, since the leaf nodes of the binary tree are not interconnected, even if the remaining 2 continuous spaces are sufficient, they cannot be allocated, resulting in the space not being fully utilized. It can be seen from this that in the related technology, even if there is enough continuous free space, due to the non-interconnection of the leaf nodes of the binary tree, the required continuous space cannot be allocated. When the related technology uses the buddy algorithm to manage the storage space, it cannot effectively utilize the continuous space across internal nodes.

[0086] To solve the technical problems similar to those described above, an embodiment of the present 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. Moreover, virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Among them, the left child node of any virtual internal node is the right child node of the actual internal node on the left side 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 on the right side of the virtual internal node. The number of spaces corresponding to the actual internal nodes and virtual internal nodes at the same level is the same. By responding to a storage space allocation request received from a first process, according to a first quantity of the storage space requested by the storage space allocation request, a target node in the binary tree for allocating to the first process is determined. Among them, the target node is the lowest-level free node whose number of spaces is 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 an occupied state, and at least some of the related nodes of the target node are marked as an occupied state. Thus, by using virtual internal nodes, the remaining continuous space can be used across actual internal nodes, the space utilization rate under the buddy algorithm can be improved, and the problems of space fragmentation and deadlock can be solved. An embodiment of the present disclosure uses a binary tree to allocate and merge spaces in a better way while minimizing fragmentation as much as possible, so as to maximize the use of limited cache space, enabling a process to use space more intensively according to its running needs, which is conducive to efficient intensive management of cache space in a multi-process environment.

[0087] The following describes in detail the storage space management method provided by the embodiment of the present disclosure with reference to the accompanying drawings.

[0088] Figure 3The flowchart showing the storage space management method provided by the embodiments of the present disclosure. In a possible implementation manner, the execution subject of the storage space management method may be a storage space management device. For example, the storage space management method may be executed by a terminal device, a server, or other electronic devices. Among them, the terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, or a wearable device, etc. In some possible implementation manners, the storage space management method may be implemented by a processor calling computer-readable instructions stored in a memory. In the embodiments of the present disclosure, the binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. And, virtual internal nodes are respectively arranged 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 on the left side of the virtual internal node, the right child node of the virtual internal node is the left child node of the actual internal node on the right side of the virtual internal node, and the space quantities corresponding to the actual internal nodes and the virtual internal nodes of the same level are the same. As Figure 3 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 a first process, according to the first quantity of the storage space requested by the storage space allocation request, determine a target node in the binary tree for allocating to the first process, where the target node is the lowest-level free node whose space quantity is greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node.

[0090] In step S12, mark the target node as an occupied state, and mark at least some related nodes of the target node as an occupied state.

[0091] In the embodiments of the present disclosure, the storage space may be represented by a binary tree. Wherein, 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] Among them, the root node is the topmost node in a binary tree, and the entire binary tree expands starting from the root node. In the buddy algorithm, the root node can represent the largest memory block. An internal node is a node other than the root node and the leaf nodes. An internal node can have two child nodes. A leaf node is the bottommost node in a binary tree. A leaf node has no child nodes. In the buddy algorithm, a leaf node can represent the smallest memory block actually allocated for a process to use and is a unit that cannot be split any further.

[0093] Actual internal nodes can represent the nodes that actually exist in the binary tree, and they represent storage space blocks that can be further split. In the buddy algorithm, actual internal nodes can be split to allocate to smaller storage space requests. When the storage space is released, actual internal nodes can be merged with adjacent free sibling nodes to form larger free blocks.

[0094] Virtual internal nodes are introduced to provide additional flexibility in the binary tree, and they do not directly correspond to actual physical storage space blocks. Virtual internal nodes are inserted between adjacent actual internal nodes to help utilize the remaining continuous space across actual internal nodes. The introduction of virtual internal nodes allows the system to allocate and recycle storage space more efficiently, especially when dealing with storage requests of different sizes.

[0095] In a possible implementation, a certain space size can be divided into 2 n parts. Then, according to the geometric sequence formula, the number of actual nodes S n in the binary tree = a1(1 - q n ) / (1 - q). Among them, a1 can represent the number of nodes at the bottom layer (i.e., the lowest level) of the binary tree, that is, the number of leaf nodes; q can represent the ratio of each node splitting into child nodes.

[0096] As an example of this implementation, a1 is equal to 2 n ; q is equal to 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 is equal to 4, then the number of actual 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. a m=0 = 2 n-0 represents the number of nodes at the lowest level (i.e., leaf nodes). a m=n = 2 n-n represents 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 this level can be equal to the number of actual internal nodes at this level. Therefore, the number of all nodes including virtual internal nodes in the binary tree can be S n = 3×2 n - 3.

[0099] Figure 4 shows a schematic diagram of the binary tree structure in the storage space management method provided by an embodiment of the present disclosure. In Figure 4 the example shown, the space is divided into 2 4 = 16 parts, and the binary tree includes a root node, internal nodes at 3 levels, and leaf nodes. Among them, the number of root nodes is 1, and the root node includes 16 storage spaces.

[0100] In Figure 4 , the internal nodes include actual internal nodes and virtual internal nodes. In Figure 4 , the nodes in the solid line box are the actual nodes in the binary tree, including the root node, actual internal nodes, and leaf nodes. Except for the 4th-level first node, 2nd-level first node, and 1st-level first node, the nodes in other dashed line boxes are virtual internal nodes. The 4th-level first node represents the first actual internal node with a space quantity of 4, that is, the leftmost actual internal node with a space quantity of 4; the 2nd-level first node represents the first actual internal node with a space quantity of 2, that is, the leftmost actual internal node with a space quantity of 2; the 1st-level first node represents the first leaf node with a space quantity of 1, that is, the leftmost leaf node.

[0101] In Figure 4 , the internal nodes at the first level include 2 actual internal nodes and 2 virtual internal nodes, where the space quantity of each internal node is 8; the internal nodes at the second level include 4 actual internal nodes and 4 virtual internal nodes, where the space quantity of each internal node is 4; the internal nodes at the third level include 8 actual internal nodes and 8 virtual internal nodes, where the space quantity of each internal node is 2.

[0102] In Figure 4 , the number of leaf nodes is 16, and the space quantity of each leaf node is 1.

[0103] Figure 5A schematic diagram showing an array corresponding to a binary tree in the storage space management method provided by an embodiment of the present disclosure. As Figure 5 shown, each level in the binary tree can be regarded as a separate array, and each array element can represent a node in the binary tree. In Figure 5 , five arrays are used to represent five levels in the binary tree. Among them, the first array represents the lowest level in the binary tree, including 16 elements, corresponding to 16 leaf nodes in the binary tree, and the space quantity of each leaf node is 1. The second array includes 16 elements, corresponding to 8 actual internal nodes and 8 virtual internal nodes with a space quantity of 2 in the binary tree. The third array includes 8 elements, corresponding to 4 actual internal nodes and 4 virtual internal nodes with a space quantity of 4 in the binary tree. The fourth array includes 4 elements, corresponding to 2 actual internal nodes and 2 virtual internal nodes with a space quantity of 8 in the binary tree. The fifth array includes 1 element, corresponding to the root node of the binary tree. The five arrays can linearize the hierarchical structure of the binary tree, so that the parent-child relationship and sibling relationship of each node can be determined through array indexes.

[0104] In an embodiment of the present disclosure, in response to receiving a storage space allocation request from a first process, according to a first quantity of the storage space requested by the storage space allocation request, a target node in the binary tree for allocating to the first process is determined, where 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.

[0105] Among them, the first process can represent any process requesting storage space, and the first quantity can represent the quantity of the storage space requested by the storage space allocation request sent by the first process. The target node can represent the node in the binary tree for allocating to the first process. Before determining to allocate the target node to the first process, the target node is in an idle state. That is, before determining to allocate the target node to the first process, the target node is a free node. The space quantity of the target node is greater than or equal to the first quantity. In the case where the space quantity of the target node is equal to the first quantity, the target node and all descendant nodes of the target node can be allocated to the first process; in the case where the space quantity of the target node is greater than the first quantity, the target node and some descendant nodes of the target node can be allocated to the first process. The target node is the lowest-level free node among the free nodes with a space quantity greater than or equal to the first quantity. That is, the target node is the free node with the smallest space quantity among the free 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 6A schematic diagram showing the method for managing storage space provided by an embodiment of the present disclosure, in which continuous space is allocated to a process across actual internal nodes by using virtual internal nodes. In Figure 6 In the example shown, there are a total of 4 leaf nodes. Process 1 occupies the leftmost leaf node, and Process 2 occupies the rightmost leaf node. At this time, Process 3 requests continuous space for 2 leaf nodes. Since the leaf nodes of two actual internal nodes are connected through virtual internal nodes, 2 continuous leaf nodes can be allocated to Process 3.

[0107] In a possible implementation manner, in response to receiving a storage space allocation request from a first process, the space manager may obtain a first quantity of the storage space requested by the storage space allocation request, and determine a target node in the binary tree for allocating to the first process through the space manager.

[0108] In a possible implementation manner, determining the target node in the binary tree for allocating to the first process according to the first quantity of the 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 manner, the target space quantity level corresponding to the storage space allocation request may be determined according to the first quantity, and the leftmost node among the free nodes at the target space quantity level may be determined as the target node. When the target space quantity level is the internal node level, the leftmost node may be an actual internal node or a virtual internal node.

[0110] Figure 7 A schematic diagram showing that the leftmost node among the lowest-level free nodes whose space quantity is greater than or equal to the first quantity is determined as the target node in the method for managing storage space provided by an embodiment of the present disclosure. In Figure 7 In the example shown, the binary tree includes 8 storage spaces, and the first quantity of the storage space requested by the storage space allocation request sent by the first process is 3. According to the first quantity 3, the target space quantity level corresponding to the storage space allocation request can be determined to be 4. At this time, since 3 internal nodes (including 2 actual internal nodes and 1 virtual internal node) at the target space quantity level 4 are all in the idle state, the leftmost actual internal node can be determined as the target node.

[0111] In this implementation manner, by determining the leftmost node among the lowest-level free nodes with the number of spaces greater than or equal to the first number as the target node, the search process is simplified by always selecting the leftmost free node that meets the conditions, improving the efficiency of space allocation. Moreover, this implementation manner helps to reduce the fragmentation of the storage space, making the utilization of the storage space more compact and efficient.

[0112] In the embodiments of the present disclosure, after determining the target node, the target node can be marked as an occupied state (represented by a dark color in Figure 7 ), and at least some of the related nodes of the target node are marked as occupied states.

[0113] In a possible implementation manner, the marking of at least some of the related nodes of the target node as occupied states includes: in response to the target node being an actual internal node, marking each ancestor node of the target node as an occupied state respectively; in response to the number of spaces corresponding to the target node being greater than the first number, according to the first number, marking some descendant nodes of the target node as occupied states, 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 an occupied state respectively; marking each ancestor node of the marked descendant nodes as an occupied state respectively.

[0114] In this implementation manner, when the target node is an actual internal node, each ancestor node of the target node is marked as an occupied state respectively. Figure 8 Shows a schematic diagram of marking at least some of the related nodes of the target node as occupied states in the storage space management method provided by the embodiments of the present disclosure. In Figure 8 the example shown, after determining the target node (i.e., the leftmost actual internal node with the number of spaces being 4), the ancestor node of the target node (i.e., the root node) is marked as an occupied state.

[0115] In this implementation manner, when the number of spaces corresponding to the target node is greater than the first number, according to the first number, some descendant nodes of the target node are marked as occupied states. For example, in Figure 8 it, the first number is 3, and the target node is the leftmost actual internal node with the number of spaces being 4, then 2 child nodes and 3 grandchild nodes of the target node are marked as occupied states.

[0116] In this implementation manner, when the number of spaces corresponding to the target node is equal to the first number, each descendant node of the target node is marked as an occupied state respectively. For example, if the first number is 4 and the target node is the leftmost actual internal node with the number of spaces being 4, then 2 child nodes and 4 grandchild nodes of the target node are marked as occupied states respectively.

[0117] In this implementation, each ancestor node of the descendant node marked as occupied is marked as occupied respectively. For example, in Figure 8 , 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 leaf node and the third leaf node are marked as occupied, their parent node (the first virtual internal node with a space quantity of 2) is also marked as occupied.

[0118] This implementation improves the utilization efficiency of storage space, reduces fragmentation, optimizes the management of storage space, and thus enhances the overall performance and reliability of the system through a refined and flexible storage space allocation strategy.

[0119] As an example of this implementation, the step of 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 space quantity corresponding to the nodes marked as occupied among the other descendant nodes at the same level of 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 space quantity corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node has reached the first quantity, keeping the descendant node in an idle state and stopping marking the remaining descendant nodes at the same level.

[0120] In this example, for the same level, the descendant nodes can be marked as occupied in the order from left to right (i.e., the order of node numbers from small to large). For example, in Figure 8 , the first quantity is 3, and the target node is the first actual internal node with a space quantity of 4.

[0121] Referring to Figure 8 's left sub - figure and middle sub - figure, for the left child node of the target node, since the total space quantity corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 0 at this time and has not reached the first quantity 3, the left child node of the target node is marked as occupied. For the right child node of the target node, since the total space quantity corresponding to the nodes marked as occupied among the other descendant nodes at the same level of the target node is 2 at this time and has not reached the first quantity 3, the right child node of the target node is marked as occupied.

[0122] Referring to Figure 8For the middle sub - graph and the right - hand sub - graph, for the first grand - child node (i.e., the first leaf node) of the target node, since among the other descendant nodes at the same level of the target node, the total space quantity corresponding to the nodes that have been marked as occupied at this time is 0, which is less than the first quantity 3, the first grand - child node (i.e., the first leaf node) of the target node is marked as occupied. For the second grand - child node (i.e., the second leaf node) of the target node, since among the other descendant nodes at the same level of the target node, the total space quantity corresponding to the nodes that have been marked as occupied at this time is 1, which is less than the first quantity 3, the second grand - child node (i.e., the second leaf node) of the target node is marked as occupied. For the third grand - child node (i.e., the third leaf node) of the target node, since among the other descendant nodes at the same level of the target node, the total space quantity corresponding to the nodes that have been marked as occupied at this time is 2, which is less than the first quantity 3, the third grand - child node (i.e., the third leaf node) of the target node is marked as occupied. For the fourth grand - child node (i.e., the fourth leaf node) of the target node, since among the other descendant nodes at the same level of the target node, the total space quantity corresponding to the nodes that have been marked as occupied at this time is 3, which has reached the first quantity 3, the fourth grand - child node (i.e., the fourth leaf node) of the target node is kept in the idle state, and the marking of the remaining descendant nodes at the same level is stopped.

[0123] This implementation method ensures that neither too much nor too little storage space is allocated by accurately calculating and allocating the required amount of storage space (the first quantity), thus avoiding waste of space and improving the utilization rate of storage space. In a multi - process environment, this implementation method can effectively allocate the required storage space for each process while ensuring that other processes can also obtain the necessary resources, thus supporting the efficient operation of multi - processes.

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

[0125] In this implementation, if the number of spaces corresponding to the target node is greater than the first number, then according to the first number, only some of the descendant nodes of the target node can be marked as occupied. This means that only the minimum amount of space required by the request is allocated, keeping the flexibility of the remaining space. If the number of spaces corresponding to the target node is exactly equal to the first number, then all the descendant nodes of the target node can be marked as occupied. This means that all the spaces under this virtual internal node are fully allocated to the requesting process. In either case, once the descendant nodes are marked as occupied, all their ancestor nodes will also be marked as occupied accordingly to ensure the continuity and consistency of the storage space allocation.

[0126] This implementation provides flexible allocation options by distinguishing the relationship between the size of the target node space and the request size. It can be partially allocated or fully allocated to adapt to different process requirements. By accurately allocating the amount of space required by the request, over-allocation is avoided and the utilization rate of the storage space is improved.

[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 respectively.

[0128] In this implementation, by marking each ancestor node of the target node as occupied in response to the target node being a leaf node, each ancestor node of the target node cannot be allocated to other processes anymore, thus ensuring the consistency of the storage space allocation.

[0129] In a possible implementation, the method further includes: in the node enable table, recording the usage status of the nodes in the binary tree through enable bits corresponding one by one to the nodes in the binary tree, where an enable bit corresponding to any node being the first preset value indicates that the node is in an idle state, and an enable bit corresponding to any node being the 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 for recording the usage status of each node in the binary tree. The node enable table can include a series of enable bits (or flag bits), and each enable bit corresponds one by one to a node in the binary tree. The value of each enable bit represents the usage status of the corresponding node. When the enable bit is the first preset value, it indicates that the corresponding node is idle and not occupied by any process. When the enable bit is the second preset value, it indicates that the corresponding node has been occupied by a certain process.

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

[0132] Figure 9Schematic diagram showing an entry in the node enablement table in the storage space management method provided by an embodiment of the present disclosure. As Figure 9 shown, in the node enablement table, the node numbers of each node can be recorded, and the usage status of the node can be recorded through the enable bit.

[0133] In this implementation, whenever a node allocation or release operation is performed, the corresponding enable bit will be updated to a corresponding preset value to reflect the latest status of the node. By checking the enable bit in the node enablement table, it is possible to quickly determine whether any given node is available, thus accelerating the speed of allocation and recycling operations.

[0134] This implementation provides a clear and systematic method to track the allocation status of each node, simplifying status management. By quickly checking the enable bit to determine the node status, the time required to find and allocate storage space is reduced.

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

[0136] In a possible implementation, for any node in the binary tree, the number of the node can also be recorded. For example, in Figure 4 the binary tree shown, in the order from top to bottom and from left to right, the numbers of each node are 1 to 45 respectively. Among them, the numbers of higher-level nodes are less than the numbers of lower-level nodes.

[0137] In a 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 a possible implementation, the method further includes: in the space allocation record table, recording the correspondence between the first process and the target node, and recording the first quantity.

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

[0140] As an example of this implementation manner, the storage unit can record the corresponding relationship between the first process and the target node in the space allocation record table, and record the first quantity.

[0141] Figure 10 The figure shows a schematic diagram of the space allocation record table in the storage space management method provided by the embodiments of the present disclosure. As Figure 10 shown, the process number, node number, and occupied amount of space can be recorded in the space allocation record table.

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

[0143] In this implementation manner, according to the space allocation record table, the node corresponding to the process can be queried, so as to query the physical location of the storage space corresponding to the process. When it is necessary to track the storage space used by a specific process, the space allocation record table provides a direct reference and can quickly locate the relevant node. Moreover, in this implementation manner, the space occupied by the space allocation record table is small and the speed is fast.

[0144] In a possible implementation manner, 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, according to the first quantity, mark the target node as an idle state, and mark at least some of the related nodes of the target node as idle states.

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

[0146] As an example of this implementation manner, in response to the space quantity corresponding to the target node being greater than the first quantity, some descendant nodes of the target node can be marked as idle states.

[0147] In this example, for the descendant nodes of any level of the target node, they can be released in sequence in the order from left to right (i.e., the order of increasing node numbers). For any descendant node of the target node, in response to the fact that the total space quantity corresponding to the released nodes among the other descendant nodes of the same level of the target node has not reached the first quantity, mark the descendant node as an idle state; or, for any descendant node of the target node, in response to the fact that the total space quantity corresponding to the released nodes among the other descendant nodes of the same level of the target node has reached the first quantity, stop releasing the remaining descendant nodes of the same level.

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

[0149] In this implementation manner, when the process releases the storage space, the system can timely recycle these resources so that they can be used by other processes or reallocated. By determining which nodes need to be marked as idle according to the first quantity (i.e., the amount of space requested by the process to be released), the system can accurately update the state of the storage space and avoid waste of resources.

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

[0151] In this implementation manner, when the usage states of all descendant nodes (i.e., child nodes, grandchild nodes, etc.) of a node become idle, the node is also updated to the idle state. This process will proceed level by level, that is, starting from the leaf nodes until the root node. Once all child nodes are marked as idle, their parent nodes will also be marked as idle.

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

[0153] In this implementation manner, by for any node in the occupied state, in response to the usage states of all descendant nodes of the node being updated to the idle state, updating the usage state of the node to the idle state, it helps to reduce the fragmentation of the storage space. And it allows the system to more effectively utilize the released space because large contiguous spaces can be quickly incorporated back into the available space pool. When storage space needs to be allocated again, the system can find a large enough contiguous space faster because the idle state of large spaces has been maintained before.

[0154] The storage space management method provided by the embodiments of the present disclosure can be applied to technical fields such as processors, space management, buddy systems, address allocation, etc., which are not limited herein.

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

[0156] In addition, the present disclosure also provides a storage space management device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any one of the storage space management methods provided by the present disclosure. The corresponding technical solutions and technical effects can be seen in the corresponding records in the method part and will not be elaborated further.

[0157] Figure 11 The block diagram of the storage space management device provided by the embodiment of the present disclosure is shown. The binary tree corresponding to the storage space includes a root node, at least one level of actual internal nodes, and leaf nodes. And, virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Wherein, the left child node of any virtual internal node is the right child node of the left actual internal node of the virtual internal node, and the right child node of the virtual internal node is the left child node of the right actual internal node of the virtual internal node. The space quantities corresponding to the actual internal nodes and virtual internal nodes at the same level are the same. As Figure 11 shown, the storage space management device includes:

[0158] A determination module 21, configured to, in response to receiving a storage space allocation request from a first process, determine a target node in the binary tree for allocating to the first process according to a first quantity of the storage space requested by the storage space allocation request, where the target node is the lowest-level free node whose space quantity is greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node;

[0159] A marking module 22, configured to mark the target node as an occupied state, and mark at least some related nodes of the target node as an occupied state.

[0160] In a possible implementation manner, the determination module 21 is configured to:

[0161] Determine 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.

[0162] In a possible implementation manner, the marking module 22 is configured to:

[0163] In response to the target node being an actual internal node, mark each ancestor node of the target node as an occupied state;

[0164] In response to the number of spaces corresponding to the target node being greater than the first number, mark some 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, mark each descendant node of the target node as occupied respectively;

[0165] Mark each ancestor node of the descendant node marked as occupied as occupied respectively.

[0166] In a possible implementation, the marking module 22 is configured to:

[0167] For any descendant node of the target node, in response to the total number of spaces corresponding to the nodes marked as occupied among the other descendant nodes at the same level as the target node not reaching the first number, mark the descendant node as occupied;

[0168] Or,

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

[0170] In a possible implementation, the marking module 22 is configured to:

[0171] In response to the target node being a virtual internal node and the number of spaces corresponding to the target node being greater than the first number, mark some 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, mark each descendant node of the target node as occupied respectively;

[0172] Mark each ancestor node of the descendant node marked as occupied as occupied respectively.

[0173] In a possible implementation, the marking module 22 is configured to:

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

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

[0176] A first recording module, configured to record the correspondence between the first process and the target node in a space allocation record table, and record the first number.

[0177] In a possible implementation, the apparatus further includes:

[0178] A second recording module, configured to record the usage status of the nodes in the binary tree through the enable bits corresponding one by one to the nodes in the node enable table, where an enable bit corresponding to any node being a first preset value indicates that the node is in an idle state, and an enable bit corresponding to any node being a second preset value indicates that the node is in an occupied state.

[0179] In a 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, mark the target node as an idle state according to the first quantity, and mark at least some of the related nodes of the target node as idle states.

[0181] In a possible implementation, the apparatus further includes:

[0182] An update module, configured to, for any node in an occupied state, in response to the usage status of all descendant nodes of the node being updated to an idle state, update the usage status of the node to an idle state.

[0183] In some embodiments, the functions or modules included in the apparatus provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments. The specific implementation and technical effects can refer to the descriptions of the above method embodiments. For the sake of brevity, they are not described herein again.

[0184] The embodiments of the present disclosure further provide a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above methods are implemented. Wherein, the computer-readable storage medium can be a non-volatile computer-readable storage medium, or can be a volatile computer-readable storage medium.

[0185] The embodiments of the present disclosure further propose a computer program, including computer-readable code, and when the computer-readable code runs in an electronic device, the processor in the electronic device executes the above methods.

[0186] The embodiments of the present disclosure further provide a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code, and when the computer-readable code runs in an electronic device, the processor in the electronic device executes the above methods.

[0187] Embodiments of the present disclosure also provide an electronic device, including: one or more processors; a memory for storing executable instructions; wherein, the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.

[0188] The electronic device may be provided as a terminal, a server or other forms of devices.

[0189] Figure 12 The block diagram of the electronic device 1900 provided by embodiments of the present disclosure is shown. For example, the electronic device 1900 may be provided as a terminal or a server. Referring to Figure 12 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by a memory 1932 for storing instructions executable by the processing component 1922, such as application programs. The application programs stored in the memory 1932 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to execute the above method.

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

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

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

[0193] A computer-readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, -- but is not limited to -- an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punched card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing. The computer-readable storage medium as used herein is not construed as being a transitory signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., an optical pulse through an optical fiber cable), or an electrical signal transmitted through a wire.

[0194] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to respective computing / processing devices, or can be downloaded to an external computer or an external storage device through a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include a copper transmission cable, an optical fiber transmission, a wireless transmission, a router, a firewall, a switch, a gateway computer, and / or an edge server. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing / processing device.

[0195] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine - related instructions, microcode, firmware instructions, state - 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 be executed entirely on the user's computer, partially on the user's computer, executed as a stand - alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through 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 an Internet service provider through the Internet). In some embodiments, by using the state information of the computer - readable program instructions to customize an electronic circuit, such as a programmable logic circuit, a field - programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute the computer - readable program instructions to implement various aspects of the present disclosure.

[0196] Aspects of the present disclosure are described herein with reference to the flowchart and / or block diagram of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowchart and / or block diagram, and the combinations of blocks in the flowchart and / or block diagram, 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 the instructions are executed by the processor of the computer or other programmable data - processing apparatus, a device is created that implements 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, which causes a computer, a programmable data - processing apparatus, and / or other devices to operate in a particular manner, so that the computer - readable medium storing the instructions includes a manufacture, which includes instructions for implementing various 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 devices, causing a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other devices to generate a computer-implemented process, so that the instructions executed on the computer, other programmable data processing apparatus, or other devices implement the functions / actions specified in one or more boxes of the flowchart and / or block diagram.

[0199] The flowcharts and block diagrams in the figures 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 box in the flowchart or block diagram may represent a module, a segment of a program, or a part of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the boxes may occur in a different order than noted in the figures. For example, two consecutive boxes may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and combinations of boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0200] The computer program product may be implemented specifically in the form of hardware, software, or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium. In another alternative embodiment, the computer program product is embodied as a software product, such as a Software Development Kit (SDK), etc.

[0201] The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments. Their similarities or likenesses can be referred to each other. For the sake of brevity, they will not be elaborated herein.

[0202] If the technical solution of the embodiments of the present disclosure involves personal information, before the product applying the technical solution of the embodiments of the present disclosure processes personal information, it has clearly informed the personal information processing rules and obtained the personal's autonomous consent. If the technical solution of the embodiments of the present disclosure involves sensitive personal information, before the product applying the technical solution of the embodiments of the present disclosure processes sensitive personal information, it has obtained the personal's separate consent and at the same time meets the requirements of "express consent". For example, at a personal information collection device such as a camera, a clear and prominent sign is set to inform that the personal information collection scope has been entered and personal information will be collected. If an individual voluntarily enters the collection scope, it is considered consent to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are informed by obvious signs / information, personal authorization is obtained through pop-up messages or by asking the individual to upload their personal information by themselves, etc.; among them, 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 embodiments of the present disclosure have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations are obvious to those of ordinary skill in the art in the technical field without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, the practical application, or the improvement of the technology in the market, or to enable other ordinary skill in the art in the technical field 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. And virtual internal nodes are respectively arranged 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 on the left side 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 on the right side of the virtual internal node. The number of spaces corresponding to the actual internal nodes and virtual internal nodes at the same level is the same. The method includes: In response to receiving a storage space allocation request from a first process, determine a target node in the binary tree for allocating to the first process according to a first quantity of the storage space requested by the storage space allocation request. Wherein, the target node is the lowest-level free node whose space quantity is greater than or equal to the first quantity, and the target node is allowed to be a virtual internal node; Mark the target node as an occupied state, and mark at least some related nodes of the target node as occupied states.

2. The method according to claim 1, wherein The determining the target node in the binary tree for allocating to the first process according to the first quantity of the storage space requested by the storage space allocation request includes: Determine 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.

3. The method according to claim 1 or 2, characterized in that The marking at least some related nodes of the target node as occupied states includes: In response to the target node being an actual internal node, mark each ancestor node of the target node as an occupied state respectively; In response to the space quantity corresponding to the target node being greater than the first quantity, mark some descendant nodes of the target node as occupied states according to the first quantity; or, in response to the space quantity corresponding to the target node being equal to the first quantity, mark each descendant node of the target node as an occupied state respectively; Mark each ancestor node of the marked descendant nodes as an occupied state respectively.

4. The method according to claim 3, characterized in that The marking some descendant nodes of the target node as occupied states according to the first quantity includes: For any descendant node of the target node, in response to the total space quantity corresponding to the nodes marked as occupied states among the other descendant nodes of the same level of the target node not reaching the first quantity, mark the descendant node as an occupied state; Or, For any descendant node of the target node, in response to the total space quantity corresponding to the nodes marked as occupied states among the other descendant nodes of the same level of the target node reaching the first quantity, keep the descendant node in a free state and stop marking the remaining descendant nodes of the same level.

5. The method according to claim 1 or 2, characterized in that, The marking at least some related nodes of the target node as occupied states 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 the first number, mark some 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, mark each descendant node of the target node as occupied respectively; Mark each ancestor node of the descendant nodes marked as occupied as occupied respectively.

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

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

8. The method according to claim 1 or 2, characterized in that, The method further includes: In the node enable table, record the usage status of the nodes in the binary tree through enable bits corresponding one by one to the nodes in the binary tree, where an enable bit corresponding to any node being the first preset value indicates that the node is in the idle state, and an enable bit corresponding to any node being the second preset value indicates that the node is in the 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 being used to request the release of the target node, mark the target node as idle according to the first number, and mark at least some relevant nodes of the target node as idle.

10. The method according to claim 9, wherein The method further includes: For any node in the occupied state, in response to the usage status of all descendant nodes of the node being updated to the idle state, update the usage status of the node to the 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, and virtual internal nodes are respectively arranged between two adjacent actual internal nodes at the same level. Among them, the left child node of any virtual internal node is the right child node of the actual internal node on the left side 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 on the right side of the virtual internal node. The number of spaces corresponding to the actual internal nodes and virtual internal nodes at the same level is the same. The device includes: A determination module, configured to, in response to receiving a storage space allocation request from a first process, determine a target node in the binary tree for allocation to the first process according to a first number of the storage space requested by the storage space allocation request, where the target node is the lowest-level idle node with a number of spaces greater than or equal to the first number, and the target node is allowed to be a virtual internal node; A marking module, configured to mark the target node as occupied, and mark at least some relevant nodes of the target node as occupied.

12. An electronic device, characterized in that, Includes: One or more processors; A memory for storing executable instructions; Wherein, the one or more processors are configured to call executable instructions stored in the memory to execute 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 a processor, the method according to any one of claims 1 to 10 is implemented.

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

Citation Information

Patent Citations

  • Computing platform memory space determination method, device and equipment and storage medium

    CN111857575A

  • Storage space allocation method and device based on double-array dictionary tree and electronic equipment

    CN114780533A

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

    CN115599704A

  • Data processing method, computer equipment and storage medium

    CN118643041A

  • Memory management method for reducing fragmentization and operating system

    CN119621609A