Memory space allocation method and device, equipment and storage medium
By monitoring memory allocation requests and updating linked list node status, automatic allocation of memory space is realized, solving the problem of excessive CPU load, improving inter-process communication efficiency, and realizing efficient communication of large blocks of data between processes.
Patent Information
- Application Number
- CN202410735851.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-27
AI Technical Summary
In technical fields such as the Metaverse, after the data receiving module of the host camera receives multi-channel camera data, the decoded image frame data is directly copied to other processes, resulting in excessive CPU load and large load overhead. How to achieve memory space optimization? Reasonable allocation to reduce CPU load and improve communication efficiency between data processes becomes a problem.
By monitoring the memory allocation request, determining the amount of image data to be processed, managing the free linked list node information stored in the memory area based on the preset shared memory, determining the target node information, and updating the node status of the free and used linked lists to realize the automation of the memory space. Allocation, using circular linked lists to record memory usage status, to achieve efficient communication of large blocks of data between processes.
It realizes the automatic and reasonable allocation of memory space, reduces the CPU load, improves the efficiency of inter-process communication, and achieves efficient communication of large blocks of data between processes with minimal performance consumption.
Smart Images

Figure CN118708336A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a memory space allocation method, device, equipment and storage medium. Background Art
[0002] In the metaverse and other related technical fields, after receiving the multi-channel camera data transmitted by other processors, the data receiving module of the host camera usually needs to distribute the decoded data to other processes. If the decoded image frame data is directly copied to other processes, the load on the CPU (Central Processing Unit) is too large, resulting in a large CPU load overhead. Therefore, how to achieve reasonable automatic allocation of memory space, reduce the CPU load and improve the communication efficiency between data processes has become a problem that needs to be solved urgently. Summary of the invention
[0003] The present invention provides a memory space allocation method, device, equipment and storage medium to achieve reasonable automatic allocation of memory space, reduce CPU load and improve communication efficiency between data processes.
[0004] According to one aspect of the present invention, a memory space allocation method is provided, which is applied to a data producer, and the method comprises:
[0005] Monitor requests from at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request;
[0006] Determining the amount of memory space to be allocated according to the amount of image data to be processed;
[0007] According to the amount of memory space to be allocated, based on the free list node information stored in the management memory area of the preset shared memory, determine the target node information;
[0008] Feeding back the target node information to the data consumer, so that the data consumer processes the image data to be processed based on the target node information;
[0009] The node status of the free linked list and the used linked list in the data memory area of the preset shared memory is updated according to the target node information.
[0010] According to another aspect of the present invention, a memory space allocation method is provided, which is applied to a data consumer, comprising:
[0011] Sending a memory allocation request to a data producer, so that the data producer determines the amount of image data to be processed according to the memory allocation request, determines the amount of memory space to be allocated according to the amount of image data to be processed, and determines and feeds back target node information based on the amount of memory space to be allocated and the free linked list node information stored in the management memory area of the preset shared memory;
[0012] Obtaining target node information fed back by the data producer;
[0013] Based on the target node information, the image data to be processed is processed.
[0014] According to another aspect of the present invention, a memory space allocation device is provided, which is configured on a data production side, and the device comprises:
[0015] A request monitoring module, used to monitor requests from at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request;
[0016] A module for determining memory to be allocated, used for determining the amount of memory space to be allocated according to the amount of image data to be processed;
[0017] A target node information determination module, configured to determine the target node information according to the amount of memory space to be allocated and based on the free linked list node information stored in the management memory area of the preset shared memory;
[0018] A node information feedback module, used to feed back the target node information to the data consumer, so that the data consumer can process the image data to be processed based on the target node information;
[0019] The node status updating module is used to update the node status of the free linked list and the used linked list in the data memory area of the preset shared memory according to the target node information.
[0020] According to another aspect of the present invention, a memory space allocation device is provided, which is configured at a data consumer, and includes:
[0021] A memory allocation request sending module, used to send a memory allocation request to a data producer, so that the data producer can determine the amount of image data to be processed according to the memory allocation request, determine the amount of memory space to be allocated according to the amount of image data to be processed, and determine and feed back target node information according to the amount of memory space to be allocated based on free linked list node information stored in a management memory area of a preset shared memory;
[0022] A node information acquisition module is used to acquire the target node information fed back by the data producer;
[0023] The image data processing module is used to process the image data to be processed based on the target node information.
[0024] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0025] at least one processor; and
[0026] a memory communicatively connected to the at least one processor; wherein,
[0027] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory space allocation method described in any embodiment of the present invention.
[0028] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the memory space allocation method described in any embodiment of the present invention when executed.
[0029] The technical solution of the embodiment of the present invention determines the amount of image data to be processed according to the memory allocation request when a memory allocation request is monitored, determines the amount of memory space to be allocated according to the amount of image data to be processed, determines the target node information based on the free linked list node information stored in the management memory area of the preset shared memory according to the amount of memory space to be allocated, and feeds back the target node information to the data consumer so that the data consumer can process the image data to be processed based on the target node information, updates the node status of the free linked list and the use linked list in the data memory area of the preset shared memory according to the target node information, thereby realizing automatic and reasonable allocation of memory space, enabling the node status to be cyclically transmitted through a circular linked list, and recording the memory usage status in a counting manner, thereby realizing high-efficiency communication of large blocks of data between processes with minimal performance consumption, reducing the CPU load while improving the efficiency of inter-process communication.
[0030] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0032] Figure 1A is a flowchart of a memory space allocation method provided according to Embodiment 1 of the present invention;
[0033] Figure 1B is a schematic diagram of a data structure of a circular linked list between a used linked list and a free linked list according to a first embodiment of the present invention;
[0034] Figure 2 is a flowchart of a memory space allocation method provided according to Embodiment 2 of the present invention;
[0035] Figure 3 is a flowchart of a memory space allocation method provided according to Embodiment 3 of the present invention;
[0036] Figure 4 is a structural schematic diagram of a memory space allocation device provided according to Embodiment 4 of the present invention;
[0037] Figure 5 is a structural schematic diagram of a memory space allocation device provided according to Embodiment 5 of the present invention;
[0038] Figure 6 It is a structural schematic diagram of an electronic device that implements the memory space allocation method of an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0040] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] Embodiment 1
[0042] Figure 1A This is a flowchart of a memory space allocation method provided in Embodiment 1 of the present invention. This embodiment can be applied to the case where memory space is reasonably allocated to one or more data processing processes. The method can be executed by a memory space allocation device. The memory space allocation device can be implemented in the form of hardware and / or software. The memory space allocation device can be configured in an electronic device. Figure 1A As shown, the method can be applied to data producers, including:
[0043] S110: Monitor requests from at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request.
[0044] The data consumer may be a consumer process, and the data producer may be a producer process. The producer process is used to automatically allocate appropriate memory space to the consumer process so that the consumer can process data based on the appropriate memory space.
[0045] For example, the data producer can initialize the shared memory through mmap (memory map) and monitor in real time whether there is a data consumer in the distribution set. If so, it will request the data consumer to join the distribution set; if not, it will wait for the data consumer to join the distribution set. At the same time, it monitors in real time whether there is a new data consumer accessing, and when the access request of the data consumer is monitored, the newly accessed data consumer is added to the distribution set.
[0046] The data producer can initialize the shared memory according to the actual scenario requirements. In the image data processing scenario, the virtual address space of the shared memory can be divided into the management memory area and the data memory area, and the space size of the shared memory is 4K+100M, where the space size of the management memory area is 4K, which is used to record the free memory list and the allocated memory list. The area size of the data memory area is 100M, which can store the decoded image data and slice memory fields of the next frame. During the allocation process, it can be divided into several memory slices. The size of a memory slice can be 3M, which is used to store one frame of image data and slice memory fields.
[0047] It should be noted that in the specific scenario of this embodiment, the size of each frame of the image is basically the same. Therefore, when initializing the shared memory and dividing the management memory area and the data memory area, the division and space allocation can be performed according to the size of the image frame.
[0048] Optionally, the free list in the data memory area is the same as the node memory space of each list node in the used list, and the node memory space of each list node is determined based on the data consumption scenario of the data consumer. For example, the node memory space size of each edge node in the image frame scenario can be 3M, which can store one frame of image data and slice memory fields.
[0049] When the data producer detects that the request from the data consumer is a memory allocation request, the memory allocation request is parsed to obtain the amount of image data to be processed that the data consumer needs to process.
[0050] S120. Determine the amount of memory space to be allocated according to the amount of image data to be processed.
[0051] Exemplarily, the size of the memory space required for processing the image data to be processed can be determined according to the amount of image data to be processed. For example, if the image data to be processed is 10 frames of images, the amount of memory space to be allocated can be 30M.
[0052] S130. Determine target node information according to the amount of memory space to be allocated and based on free linked list node information stored in the management memory area of the preset shared memory.
[0053] The free linked list node information stored in the management memory area may include node position information of the space linked list nodes.
[0054] Exemplarily, the required number of free list nodes can be determined based on the amount of memory space to be allocated, and based on the free list node information stored in the management memory area, nodes corresponding to the required number of free list nodes can be randomly selected as target nodes, and the target node information can include location information of the target node.
[0055] In an optional embodiment, according to the amount of memory space to be allocated, the target node information is determined based on the free list node information stored in the management memory area of the preset shared memory, including: according to the amount of memory space to be allocated, based on the free list node information stored in the management memory area of the preset shared memory, the number of nodes to be allocated is determined; according to the node association position information in the free list node information, based on the number of nodes, the target node information is determined.
[0056] The number of nodes to be allocated can be determined based on the amount of memory space to be allocated and the memory size of each node in the free list node information; the target node information can be determined based on the number of nodes according to the node associated position information in the free list node information. The node associated position information can be the relative position of the node in the free list. For example, each node corresponding to the number of nodes that are adjacent or have a pointer pointing relationship can be determined as the target node. The advantage is that in the subsequent processing process, since the address is continuous or has a node pointing relationship, it is convenient for node deletion, insertion or update operations.
[0057] Optionally, the data structures of the free list and the used list of this embodiment can be circular lists. The head node of the free list stores a first pointer pointing to the head node of the used list, and the head node of the used list stores a second pointer pointing to the head node of the free list. Figure 1B A data structure diagram of a circular linked list between a used linked list and a free linked list is shown.
[0058] There is a two-way transmission between the used linked list and the free linked list. Bidirectional transmission is added on the basis of the circular linked list to facilitate the insertion and deletion of subsequent nodes. Since the head nodes of the used linked list and the free linked list are associated through mmap, the used linked list and the free linked list can access each other. Mmap can also achieve unified management of the used linked list and the free linked list through the head node. Pointers between nodes point to the next node, the previous node or other nodes.
[0059] S140 . Feedback the target node information to the data consumer, so that the data consumer can process the image data to be processed based on the target node information.
[0060] The data producer feeds back the target node information of the target node to the data consumer, and the data consumer processes the image data to be processed based on the memory logical address in the target node information.
[0061] S150: Update the node status of the free linked list and the used linked list in the data memory area of the preset shared memory according to the target node information.
[0062] According to the node information of the target node, the node state of the target node under the free linked list in the data memory area is updated to the used state, and the target node is added to the used linked list, thereby realizing the update of the free linked list and the used linked list.
[0063] In an optional embodiment, free linked list node information and used linked list node information are stored in the management memory area of the preset shared memory; the free linked list node information includes a free node address and a free node flag; the used linked list node information includes a used node address and a used node flag; accordingly, the node status of the free linked list and the used linked list in the data memory area of the preset shared memory is updated according to the target node information, including: determining the target node according to the target node information; updating the free nodes of the free linked list and their corresponding free node addresses and free status flags according to the node address of the target node; and updating the used nodes of the used linked list and their corresponding used node addresses and used status flags according to the node address of the target node.
[0064] The node flag bit can be represented by "0" and "1". When the node flag bit is "0", it can indicate that the node is in an idle state. When the node flag bit is "1", it can indicate that the node is in use.
[0065] The process of updating the address is to insert the idle node selected from the free list into the use list, and in this process, the node address of the inserted node and the node flag of the node need to be updated. Among them, the idle state flag can be set to "0" and the use state flag can be set to "1".
[0066] It should be noted that since the free list nodes and the usage status of the used list nodes, i.e., the node flag, are marked in a circular linked list, each memory chip has the same size and only needs to take out a node from the free list each time. There is no need to calculate the memory usage, nor is there a need to use a separate memory area to manage the memory usage status and memory space size of each node. Since a node can be selected from the free nodes at will, the node closest to the head node can be selected to improve the efficiency of node management, including node insertion, deletion, and other operations.
[0067] Similarly, after deleting a node from the free list node, the node is inserted into the used list node. Since the memory size of each node is the same, it can be inserted at any position of the used list node. You can choose the head node closest to the used list or the tail node closest to the used list. Since there is no need to traverse the entire list in the process of selecting a node, the memory management is fast and efficient, which is suitable for processing video-related data.
[0068] The technical solution of the embodiment of the present invention determines the amount of image data to be processed according to the memory allocation request when a memory allocation request is monitored, determines the amount of memory space to be allocated according to the amount of image data to be processed, determines the target node information based on the free linked list node information stored in the management memory area of the preset shared memory according to the amount of memory space to be allocated, and feeds back the target node information to the data consumer so that the data consumer can process the image data to be processed based on the target node information, updates the node status of the free linked list and the use linked list in the data memory area of the preset shared memory according to the target node information, thereby realizing automatic and reasonable allocation of memory space, enabling the node status to be cyclically transmitted through a circular linked list, and recording the memory usage status in a counting manner, thereby realizing high-efficiency communication of large blocks of data between processes with minimal performance consumption, reducing the CPU load while improving the efficiency of inter-process communication.
[0069] Embodiment 2
[0070] Figure 2 This is a flowchart of a memory space allocation method provided in Embodiment 1 of the present invention. This embodiment can be applied to the case where memory space is reasonably allocated to one or more data processing processes. The method can be executed by a memory space allocation device. The memory space allocation device can be implemented in the form of hardware and / or software. The memory space allocation device can be configured in an electronic device. Figure 2 As shown, the method can be applied to data consumers, including:
[0071] S210. Send a memory allocation request to the data producer, so that the data producer can determine the amount of image data to be processed according to the memory allocation request, determine the amount of memory space to be allocated according to the amount of image data to be processed, and determine and feedback the target node information based on the amount of memory space to be allocated and the free linked list node information stored in the management memory area of the preset shared memory.
[0072] S220: Obtain target node information fed back by the data producer.
[0073] S230: Process the image data to be processed based on the target node information.
[0074] The data consumer may be a consumer process, and the data producer may be a producer process. The producer process is used to automatically allocate appropriate memory space to the consumer process so that the consumer can process data based on the appropriate memory space.
[0075] For example, the data producer can initialize the shared memory through mmap (memory map) and monitor in real time whether there is a data consumer in the distribution set. If so, it will request the data consumer to join the distribution set; if not, it will wait for the data consumer to join the distribution set. At the same time, it monitors in real time whether there is a new data consumer accessing, and when the access request of the data consumer is monitored, the newly accessed data consumer is added to the distribution set.
[0076] The data producer can initialize the shared memory according to the actual scenario requirements. In the image data processing scenario, the virtual address space of the shared memory can be divided into the management memory area and the data memory area, and the space size of the shared memory is 4K+100M, where the space size of the management memory area is 4K, which is used to record the free memory list and the allocated memory list. The area size of the data memory area is 100M, which can store the decoded image data and slice memory fields of the next frame. During the allocation process, it can be divided into several memory slices. The size of a memory slice can be 3M, which is used to store one frame of image data and slice memory fields.
[0077] It should be noted that in the specific scenario of this embodiment, the size of each frame of the image is basically the same. Therefore, when initializing the shared memory and dividing the management memory area and the data memory area, the division and space allocation can be performed according to the size of the image frame.
[0078] Optionally, the free list in the data memory area is the same as the node memory space of each list node in the used list, and the node memory space of each list node is determined based on the data consumption scenario of the data consumer. For example, the node memory space size of each edge node in the image frame scenario can be 3M, which can store one frame of image data and slice memory fields.
[0079] When the data producer detects that the request from the data consumer is a memory allocation request, the memory allocation request is parsed to obtain the amount of image data to be processed that the data consumer needs to process.
[0080] Exemplarily, the size of the memory space required for processing the image data to be processed can be determined according to the amount of image data to be processed. For example, if the image data to be processed is 10 frames of images, the amount of memory space to be allocated can be 30M.
[0081] In an optional embodiment, according to the amount of memory space to be allocated, the target node information is determined based on the free list node information stored in the management memory area of the preset shared memory, including: according to the amount of memory space to be allocated, based on the free list node information stored in the management memory area of the preset shared memory, the number of nodes to be allocated is determined; according to the node association position information in the free list node information, based on the number of nodes, the target node information is determined.
[0082] The number of nodes to be allocated can be determined based on the amount of memory space to be allocated and the memory size of each node in the free list node information; the target node information can be determined based on the number of nodes according to the node associated position information in the free list node information. The node associated position information can be the relative position of the node in the free list. For example, each node corresponding to the number of nodes that are adjacent or have a pointer pointing relationship can be determined as the target node. The advantage is that in the subsequent processing process, since the address is continuous or has a node pointing relationship, it is convenient for node deletion, insertion or update operations.
[0083] Optionally, the data structures of the free linked list and the used linked list of this embodiment can be circular linked lists. The head node of the free linked list stores a first pointer pointing to the head node of the used linked list, and the head node of the used linked list stores a second pointer pointing to the head node of the free linked list.
[0084] The data producer feeds back the target node information of the target node to the data consumer, and the data consumer processes the image data to be processed based on the memory logical address in the target node information.
[0085] According to the node information of the target node, the node state of the target node under the free linked list in the data memory area is updated to the used state, and the target node is added to the used linked list, thereby realizing the update of the free linked list and the used linked list.
[0086] In an optional embodiment, free linked list node information and used linked list node information are stored in the management memory area of the preset shared memory; the free linked list node information includes a free node address and a free node flag; the used linked list node information includes a used node address and a used node flag; accordingly, the node status of the free linked list and the used linked list in the data memory area of the preset shared memory is updated according to the target node information, including: determining the target node according to the target node information; updating the free nodes of the free linked list and their corresponding free node addresses and free status flags according to the node address of the target node; and updating the used nodes of the used linked list and their corresponding used node addresses and used status flags according to the node address of the target node.
[0087] The node flag bit can be represented by "0" and "1". When the node flag bit is "0", it can indicate that the node is in an idle state. When the node flag bit is "1", it can indicate that the node is in use.
[0088] The process of updating the address is to insert the idle node selected from the free list into the use list, and in this process, the node address of the inserted node and the node flag of the node need to be updated. Among them, the idle state flag can be set to "0" and the use state flag can be set to "1".
[0089] It should be noted that since the free list nodes and the usage status of the used list nodes, i.e., the node flag, are marked in a circular linked list, each memory chip has the same size and only needs to take out a node from the free list each time. There is no need to calculate the memory usage, nor is there a need to use a separate memory area to manage the memory usage status and memory space size of each node. Since a node can be selected from the free nodes at will, the node closest to the head node can be selected to improve the efficiency of node management, including node insertion, deletion, and other operations.
[0090] Similarly, after deleting a node from the free list node, the node is inserted into the used list node. Since the memory size of each node is the same, it can be inserted at any position of the used list node. You can choose the head node closest to the used list or the tail node closest to the used list. Since there is no need to traverse the entire list in the process of selecting a node, the memory management is fast and efficient, which is suitable for processing video-related data.
[0091] The technical solution of this embodiment sends a memory allocation request to the data producer, so that the data producer determines the amount of image data to be processed according to the memory allocation request, determines the amount of memory space to be allocated according to the amount of image data to be processed, and determines and feeds back the target node information based on the amount of memory space to be allocated and the free linked list node information stored in the management memory area of the preset shared memory, obtains the target node information fed back by the data producer, processes the image data to be processed based on the target node information, thereby realizing automatic and reasonable allocation of memory space, enabling node status to be cyclically transmitted through a circular linked list, and recording memory usage status in a counting manner, thereby realizing efficient communication of large blocks of data between processes with minimal performance consumption, reducing CPU load while improving the efficiency of communication between processes.
[0092] Embodiment 3
[0093] Figure 3 This is a flowchart of a memory space allocation method provided in Embodiment 3 of the present invention. This embodiment further provides a preferred embodiment based on the above embodiments.
[0094] like Figure 3 Said method comprises:
[0095] S301, the producer process initializes the shared memory according to the data consumer scenario requirements;
[0096] S302, determine whether there is a new consumer process access; if so, execute S303; if not, continue to monitor the consumer process access;
[0097] S303, adding a new consumer process to the dispatch set;
[0098] S304, monitor the memory allocation request of the consumer process in the dispatch set to determine whether there is a consumer process with a memory allocation request; if so, execute S305; if not, continue to monitor the memory allocation request;
[0099] S305, determining a target node from the free list nodes according to the memory allocation request;
[0100] S306, counting the node status bit of the target node is incremented by 1, and the memory logical address of the target node is sent to the consumer process;
[0101] S307, the consumer process performs data processing based on the memory logical address of the target node;
[0102] S308. After the consumer process has processed the data, it decrements the node status bit of the target node by 1 to release the memory.
[0103] Embodiment 4
[0104] Figure 4 A schematic diagram of the structure of a memory space allocation device provided in Embodiment 4 of the present invention. A memory space allocation device provided in an embodiment of the present invention can be applied to reasonably allocate memory space for one or more data processing processes. The memory space allocation device can be implemented in the form of hardware and / or software, such as Figure 4 As shown, the device can be configured on the data production side, and specifically includes: a request monitoring module 401, a to-be-allocated memory determination module 402, a target node information determination module 403, a node information feedback module 404 and a node status update module 405. Among them,
[0105] The request monitoring module 401 is used to monitor the requests of at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request;
[0106] A memory to be allocated determining module 402, used to determine the amount of memory space to be allocated according to the amount of image data to be processed;
[0107] The target node information determination module 403 is used to determine the target node information according to the amount of memory space to be allocated and based on the free list node information stored in the management memory area of the preset shared memory;
[0108] A node information feedback module 404 is used to feed back the target node information to the data consumer, so that the data consumer can process the image data to be processed based on the target node information;
[0109] The node status updating module 405 is used to update the node status of the free linked list and the used linked list in the data memory area of the preset shared memory according to the target node information.
[0110] The technical solution of the embodiment of the present invention determines the amount of image data to be processed according to the memory allocation request when a memory allocation request is monitored, determines the amount of memory space to be allocated according to the amount of image data to be processed, determines the target node information based on the free linked list node information stored in the management memory area of the preset shared memory according to the amount of memory space to be allocated, and feeds back the target node information to the data consumer so that the data consumer can process the image data to be processed based on the target node information, updates the node status of the free linked list and the use linked list in the data memory area of the preset shared memory according to the target node information, thereby realizing automatic and reasonable allocation of memory space, enabling the node status to be cyclically transmitted through a circular linked list, and recording the memory usage status in a counting manner, thereby realizing high-efficiency communication of large blocks of data between processes with minimal performance consumption, reducing the CPU load while improving the efficiency of inter-process communication.
[0111] Optionally, a first pointer pointing to a head node of the used linked list is stored in the head node of the free linked list, and a second pointer pointing to a head node of the used linked list is stored in the head node of the free linked list.
[0112] Optionally, the management memory area of the preset shared memory stores free linked list node information and used linked list node information; the free linked list node information includes a free node address and a free node flag; the used linked list node information includes a used node address and a used node flag;
[0113] Accordingly, the node status updating module 405 includes:
[0114] A target node determining unit, configured to determine a target node according to the target node information;
[0115] A first updating unit is used to update the idle nodes of the idle linked list and their corresponding idle node addresses and idle state flags according to the node address of the target node; and
[0116] The second updating unit is used to update the usage nodes and their corresponding usage node addresses and usage status flags of the usage linked list according to the node address of the target node.
[0117] Optionally, the free linked list in the data memory area is the same as the node memory space of each linked list node in the used linked list, and the node memory space of each linked list node is determined based on the data consumption scenario of the data consumer.
[0118] Optionally, the target node information determination module 403 includes:
[0119] A node quantity determination unit, configured to determine the number of nodes to be allocated according to the amount of memory space to be allocated and based on free list node information stored in a management memory area of a preset shared memory;
[0120] The target node information determining unit is used to determine the target node information based on the node number according to the node associated position information in the free list node information.
[0121] The memory space allocation device provided in the embodiment of the present invention can execute the memory space allocation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0122] Embodiment 5
[0123] Figure 5 A schematic diagram of the structure of a memory space allocation device provided in Embodiment 5 of the present invention. A memory space allocation device provided in an embodiment of the present invention can be applied to reasonably allocate memory space for one or more data processing processes. The memory space allocation device can be implemented in the form of hardware and / or software, such as Figure 5 As shown, the device can be configured on the data consumer side, and specifically includes: a memory allocation request sending module 501, a node information acquisition module 502 and an image data processing module 503. Among them,
[0124] The memory allocation request sending module 501 is used to send a memory allocation request to a data producer, so that the data producer can determine the amount of image data to be processed according to the memory allocation request, determine the amount of memory space to be allocated according to the amount of image data to be processed, and determine and feed back target node information according to the amount of memory space to be allocated based on the free linked list node information stored in the management memory area of the preset shared memory;
[0125] The node information acquisition module 502 is used to acquire the target node information fed back by the data producer;
[0126] The image data processing module 503 is used to process the image data to be processed based on the target node information.
[0127] The technical solution of this embodiment sends a memory allocation request to the data producer, so that the data producer determines the amount of image data to be processed according to the memory allocation request, determines the amount of memory space to be allocated according to the amount of image data to be processed, and determines and feeds back the target node information based on the amount of memory space to be allocated and the free linked list node information stored in the management memory area of the preset shared memory, obtains the target node information fed back by the data producer, processes the image data to be processed based on the target node information, thereby realizing automatic and reasonable allocation of memory space, enabling node status to be cyclically transmitted through a circular linked list, and recording memory usage status in a counting manner, thereby realizing efficient communication of large blocks of data between processes with minimal performance consumption, reducing CPU load while improving the efficiency of communication between processes.
[0128] The memory space allocation device provided in the embodiment of the present invention can execute the memory space allocation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0129] Embodiment 6
[0130] Figure 6 A schematic diagram of the structure of an electronic device 60 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0131] like Figure 6As shown, the electronic device 60 includes at least one processor 61, and a memory connected to the at least one processor 61, such as a read-only memory (ROM) 62, a random access memory (RAM) 63, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 61 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 62 or the computer program loaded from the storage unit 68 to the random access memory (RAM) 63. In the RAM 63, various programs and data required for the operation of the electronic device 60 can also be stored. The processor 61, the ROM 62, and the RAM 63 are connected to each other via a bus 64. An input / output (I / O) interface 65 is also connected to the bus 64.
[0132] A number of components in the electronic device 60 are connected to the I / O interface 65, including: an input unit 66, such as a keyboard, a mouse, etc.; an output unit 67, such as various types of displays, speakers, etc.; a storage unit 68, such as a disk, an optical disk, etc.; and a communication unit 69, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 69 allows the electronic device 60 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0133] The processor 61 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 61 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 61 executes the various methods and processes described above, such as a memory space allocation method.
[0134] In some embodiments, the memory space allocation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 68. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 60 via the ROM 62 and / or the communication unit 69. When the computer program is loaded into the RAM 63 and executed by the processor 61, one or more steps of the memory space allocation method described above may be performed. Alternatively, in other embodiments, the processor 61 may be configured to execute the memory space allocation method in any other appropriate manner (e.g., by means of firmware).
[0135] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0136] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0137] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0138] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0139] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0140] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0141] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0142] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A memory space allocation method, It is characterized in that Applicable to data producers, including: Monitor requests from at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request; Determining the amount of memory space to be allocated according to the amount of image data to be processed; According to the amount of memory space to be allocated, based on the free list node information stored in the management memory area of the preset shared memory, determine the target node information; Feeding back the target node information to the data consumer, so that the data consumer processes the image data to be processed based on the target node information; The node status of the free linked list and the used linked list in the data memory area of the preset shared memory is updated according to the target node information.
2. The method according to claim 1, It is characterized in that The head node of the free linked list stores a first pointer pointing to the head node of the used linked list, and the head node of the used linked list stores a second pointer pointing to the head node of the free linked list.
3. The method according to claim 1, It is characterized in that The management memory area of the preset shared memory stores free list node information and used list node information; the free list node information includes a free node address and a free node flag; the used list node information includes a used node address and a used node flag; Correspondingly, updating the node status of the free linked list and the used linked list in the data memory area of the preset shared memory according to the target node information includes: Determine the target node according to the target node information; According to the node address of the target node, updating the idle nodes of the idle linked list and their corresponding idle node addresses and idle state flags; and, According to the node address of the target node, the use nodes of the use linked list and their corresponding use node addresses and use status flags are updated.
4. The method according to claim 1, It is characterized in that The node memory space of each linked list node in the free linked list in the data memory area is the same as that of each linked list node in the used linked list, and the node memory space of each linked list node is determined based on the data consumption scenario of the data consumer.
5. The method according to claim 1, It is characterized in that The step of determining target node information according to the amount of memory space to be allocated and based on free linked list node information stored in a management memory area of a preset shared memory includes: According to the amount of memory space to be allocated, based on the free list node information stored in the management memory area of the preset shared memory, determine the number of nodes to be allocated; According to the node associated position information in the free list node information and based on the number of nodes, the target node information is determined.
6. A memory space allocation method, It is characterized in that Applied to data consumers, including: Sending a memory allocation request to a data producer, so that the data producer determines the amount of image data to be processed according to the memory allocation request, determines the amount of memory space to be allocated according to the amount of image data to be processed, and determines and feeds back target node information based on the amount of memory space to be allocated and the free linked list node information stored in the management memory area of the preset shared memory; Obtaining target node information fed back by the data producer; Based on the target node information, the image data to be processed is processed.
7. A memory space allocation device, It is characterized in that Configured on the data producer, including: A request monitoring module, used to monitor requests from at least one data consumer, and when a memory allocation request is monitored, determine the amount of image data to be processed according to the memory allocation request; A module for determining memory to be allocated, used for determining the amount of memory space to be allocated according to the amount of image data to be processed; A target node information determination module, configured to determine the target node information according to the amount of memory space to be allocated and based on the free linked list node information stored in the management memory area of the preset shared memory; A node information feedback module, used to feed back the target node information to the data consumer, so that the data consumer can process the image data to be processed based on the target node information; The node status updating module is used to update the node status of the free linked list and the used linked list in the data memory area of the preset shared memory according to the target node information.
8. A memory space allocation device, It is characterized in that Configured on the data consumer, including: A memory allocation request sending module, used to send a memory allocation request to a data producer, so that the data producer can determine the amount of image data to be processed according to the memory allocation request, determine the amount of memory space to be allocated according to the amount of image data to be processed, and determine and feed back target node information according to the amount of memory space to be allocated based on free linked list node information stored in a management memory area of a preset shared memory; A node information acquisition module is used to acquire the target node information fed back by the data producer; The image data processing module is used to process the image data to be processed based on the target node information.
9. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory space allocation method described in any one of claims 1-5 and / or claim 6.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the memory space allocation method described in any one of claims 1-5 and / or claim 6 when executed.
Citation Information
Cited By
Data storage method and device, electronic equipment and computer readable storage medium
CN120066981A
Data storage method and device, electronic equipment and computer readable storage medium
CN120066981B
Micro-control unit virtual heap space allocation method based on external storage space
CN121326784A
Publish-subscribe mechanism for parallel memory system
US20260111353A1
