Information storage sharing method and device, equipment and medium
By managing the available buffers and reference counting modules in shared memory, the problem of multiple consumers sharing data under one BufferQueue is solved, efficient resource utilization and synchronous consumption of data are achieved, and resource occupation and data copying are avoided.
Patent Information
- Application Number
- CN202411614294.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2024-12-13
AI Technical Summary
In the Android system, a producer process can only correspond to one consumer process, resulting in that if a producer process wants to correspond to multiple consumer processes, multiple BufferQueues must be created, resulting in an increase in system memory and CPU resources, which cannot be achieved Multiple consumers share data under one BufferQueue.
By managing available shared buffers in shared memory and using the reference count module to track the number of consumers, marking the buffer as idle when the reference count is zero, multiple consumers can share data under one BufferQueue, avoiding data replication and resource usage.
It realizes that a producer can correspond to multiple consumers and synchronize consumption data, avoiding more resource and memory usage, and no data copying is required, which improves distribution efficiency.
Smart Images

Figure CN119127536A_ABST
Abstract
Description
Technical Field
[0001] The present application is applicable to the field of display technology, and in particular, relates to an information storage sharing method, device, equipment and medium. Background Art
[0002] BufferQueue is an implementation of the producer-consumer model. The producer fills data into the BufferQueue, and the consumer obtains data from the BufferQueue. The producer-consumer model allows producers and consumers to operate asynchronously, which improves the efficiency of the system. In the Android system, BufferQueue is the core component for managing graphics buffers, but a producer process can only correspond to one consumer process. For example, Android's BufferQueue is a mechanism for transferring image buffers between graphics producers and consumers, where the producer requests a free buffer to draw an image, and BufferQueue returns an available buffer to the producer. The producer draws the image in the buffer, and the producer submits the filled buffer to the BufferQueue. The BufferQueue notifies the consumer that a new image is available, and the consumer requests a filled buffer from the BufferQueue to read the image in the buffer and display it.
[0003] If a producer process is to correspond to multiple consumer processes, multiple BufferQueues must be created, the data must be copied multiple times, and distributed through multiple BufferQueues, which will lead to the occupation of system memory and CPU resources.
[0004] Therefore, how to improve the information sharing process to enable multiple consumers to read shared data under one BufferQueue and reduce resource usage has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, the embodiments of the present application provide an information storage sharing method, apparatus, device and medium to solve the problem of how to improve the information sharing process to enable multiple consumers to read shared data under a BufferQueue and reduce resource usage.
[0006] In a first aspect, an embodiment of the present application provides an information storage sharing method, wherein the information storage sharing method is applied to a buffer manager in a producer consumer model, wherein the producer consumer model further includes a producer and at least two consumers, including: When it is detected that the producer applies for a shared cache, an available shared buffer is determined from the shared memory, and the available shared buffer is returned to the producer, and the producer is used to fill the production data after obtaining the available shared buffer; After detecting that the available shared buffer is filled, obtaining the number of all consumers as a reference count, and storing the reference count in a count management memory; For any consumer, after obtaining a data request of the consumer, the available shared buffer is returned to the consumer, and the consumer is used to read the production data in the available shared buffer after obtaining the available shared buffer; The reference count is reduced by one in the count management memory, and all consumers are traversed until the reference count reaches zero and the available shared buffer is marked as free.
[0007] In a second aspect, an embodiment of the present application provides an information storage sharing method, which is applied to any consumer in a producer consumer model, wherein the producer consumer model also includes a buffer manager and a producer, including: Sending a data request to the buffer manager, wherein the buffer manager is used to implement the information storage sharing method as described in the first aspect above; The available shared buffer is obtained from the buffer manager, and the production data in the available shared buffer is read.
[0008] In a third aspect, an embodiment of the present application provides an information storage sharing device, which is applied to a buffer manager in a producer consumer model, wherein the producer consumer model further includes a producer and at least two consumers, including: An available buffer feedback module is used to determine an available shared buffer from a shared memory when detecting that the producer applies for a shared cache, and return the available shared buffer to the producer, and the producer is used to fill the production data after obtaining the available shared buffer; A reference counting module, used for obtaining the number of all consumers as a reference count after detecting that the available shared buffer is filled, and storing the reference count in a count management memory; A data sending module, for any consumer, after obtaining a data request of the consumer, returns the available shared buffer to the consumer, and the consumer is used to read the production data in the available shared buffer after obtaining the available shared buffer; The sharing management module is used to reduce the reference count by one in the counting management memory, and traverse all consumers until the reference count reaches zero and the available shared buffer is marked as free.
[0009] In a fourth aspect, an embodiment of the present application provides an information storage sharing device, which is applied to any consumer in a producer consumer model, wherein the producer consumer model further includes a buffer manager and a producer, including: A data request module, used to send a data request to the buffer manager, and the buffer manager is used to implement the information storage sharing method as described in the first aspect above; The data reading module is used to obtain the available shared buffer returned by the buffer manager, and read the production data in the available shared buffer.
[0010] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the information storage sharing method described in the first aspect or the information storage sharing method described in the second aspect is implemented.
[0011] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the information storage sharing method described in the first aspect or the information storage sharing method described in the second aspect is implemented.
[0012] Compared with the prior art, the embodiments of the present application have the following beneficial effects: when the present application detects that the producer applies for a shared cache, the present application determines the available shared buffer from the shared memory, returns the available shared buffer to the producer, and after detecting that the available shared buffer is filled by the producer, obtains the number of all consumers as a reference count, stores the reference count in the count management memory, and after obtaining the data request of any consumer, returns the available shared buffer to the consumer to read the production data, reduces the reference count by one in the count management memory, and traverses all consumers until the available shared buffer is marked as free when the reference count is zero. The present application implements a producer that can correspond to multiple consumers, and a production can correspond to multiple consumers for synchronous consumption, avoiding the use of more resources and memory, and does not require data copying, and the distribution efficiency is more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0014] Figure 1This is a schematic diagram of an application environment of an information storage sharing method provided in Example 1 of the present application; Figure 2 It is a flowchart of an information storage sharing method provided in Embodiment 2 of the present application; Figure 3 This is a timing diagram of an information storage sharing method provided in Embodiment 3 of the present application; Figure 4 It is a flowchart of an information storage sharing method provided in Embodiment 3 of the present application; Figure 5 It is a structural diagram of an information storage sharing device provided in Embodiment 4 of the present application; Figure 6 It is a structural diagram of an information storage sharing device provided in Embodiment 5 of the present application; Figure 7 It is a structural diagram of a computer device provided in Example 6 of the present application. DETAILED DESCRIPTION
[0015] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0016] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0017] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0018] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0019] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0020] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0021] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0022] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0023] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0024] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0025] The information storage sharing method provided in the first embodiment of the present application can be applied in the following aspects: Figure 1In the application environment, the producer-consumer model includes a producer, at least two consumers and a buffer manager. The producer is connected to the buffer manager to apply for a buffer and fill corresponding data, such as image data. The consumer is connected to the buffer manager to obtain the data in the buffer. The entire producer-consumer model runs on a computer system of a computer device. The computer device may include but is not limited to a handheld computer, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cloud computer device, a personal digital assistant (PDA), etc.
[0026] See also Figure 2 , is a flow chart of an information storage sharing method provided in Embodiment 2 of the present application, wherein the information storage sharing method is applied to Figure 1 The buffer manager in . Figure 2 As shown, the information storage sharing method may include the following steps: Step S201, when it is detected that the producer applies for a shared cache, an available shared buffer is determined from the shared memory, and the available shared buffer is returned to the producer.
[0027] Among them, the buffer manager is BufferQueue, which has a shared cache (i.e. shared buffer). The shared buffer will apply for two shared memories, one large shared memory, which is used to write the data generated by the producer process into the shared memory area, i.e. data memory, and the other small shared memory is used to implement reference count management, i.e. count management memory.
[0028] The data memory stores the data information produced by the producer process, and the count management memory stores two POSIX semaphore objects, one semaphore is used for synchronized access between multiple processes, and the other semaphore is used to implement reference count management of shared buffers.
[0029] The producer is used to fill the production data after obtaining the available shared buffer. For example, in the Android system, the producer consumer model can be used for image delivery, the producer process fills the image in the applied available shared buffer, and then the consumer can obtain the image through BufferQueue.
[0030] Step S202: after detecting that the available shared buffer is filled, obtaining the number of all consumers as a reference count, and storing the reference count in a count management memory.
[0031] The detection that the available shared buffer is filled can be determined by a feedback signal sent by the producer, which is limited to the producer giving a feedback signal to the BufferQueue after the filling is completed, and then the BufferQueue knows that the available shared buffer is filled after receiving the feedback signal, and can allow the consumer to obtain it, and then the consumer can generate a data request to pull the data.
[0032] Step S203: for any consumer, after obtaining the data request of the consumer, returning the available shared buffer to the consumer.
[0033] Among them, the BufferQueue returns the available shared buffer to the corresponding consumer according to the data request sent by the consumer, so that the consumer can read, copy the data therein, and perform other processing. That is, the consumer is used to read the production data in the available shared buffer after obtaining the available shared buffer.
[0034] Step S204, reducing the reference count in the count management memory by one, traversing all consumers until the reference count reaches zero and marking the available shared buffer as free.
[0035] Among them, the producer process gets an idle shared buffer from BufferQueue. If there are multiple consumer processes that need to consume the data at this time; each time the producer process distributes the shared buffer to the consumer process, the reference count of the shared buffer is increased by 1. Every time a consumer process consumes the data, the reference count of the shared buffer is reduced by one. When all consumers have completed the consumption of the shared buffer data, BufferQueue will recycle the shared buffer to the producer, that is, mark the available shared buffer as idle, which can be used for the next data production.
[0036] Optionally, the number of all consumers is obtained as a reference count, including: For any consumer, detecting whether the consumer meets a preset condition; If the consumer meets the preset condition, the reference count is increased by one, and all consumers are traversed to obtain the number of all consumers as the reference count. When counting the reference count, the number of consumers and the size of the corresponding reference count are calculated. Only consumers that meet the preset condition can be the object of the manager's service. Therefore, by determining the number of consumers that meet the preset condition, the final reference count is obtained, which can improve the counting efficiency.
[0037] Optionally, the detecting whether the consumer meets a preset condition includes: Get the registration information of all consumers; If the registration information of the consumer is detected, it is determined that the consumer meets the preset conditions.
[0038] Among them, the consumer needs to register with the BufferQueue so that the BufferQueue knows that the corresponding consumer meets the preset conditions. This application can be used for multiple consumers to read data without establishing multiple BufferQueues.
[0039] Optionally, after detecting that the available shared buffer is filled, the method further includes: Mark the available shared buffer as filled.
[0040] Among them, marking the available shared buffer as filled can prevent others from using it. At the same time, it can also form a notification to the BufferQueue to trigger the BufferQueue to count.
[0041] like Figure 3 FIG. 1 is a timing diagram of an information storage sharing method provided in Embodiment 2 of the present application, and the specific process is as follows: a) The producer process applies for an idle shared buffer; b) BufferQueue returns an available buffer to the producer; c) The producer process fills the produced data in the shared buffer’s data memory; d) BufferQueue marks the buffer as filled, determines the reference count based on the number of registered consumers, and increases the reference count of the shared buffer's count management memory storage by 1; e) A consumer process requests a filled buffer from the BufferQueue; f) BufferQueue returns a filled buffer to the consumer process; g) The consumer process reads the data in the shared buffer and after consumption, it synchronously modifies the reference count in the count management memory by decrementing it by 1; h) When multiple consumer processes complete the data consumption of the shared buffer according to step eg, the reference count of the shared buffer will be changed to 0; i) BufferQueue marks the shared buffer as free so that the producer can use it again.
[0042] When the embodiment of the present application detects that the producer applies for a shared cache, the available shared buffer is determined from the shared memory, and the available shared buffer is returned to the producer. After detecting that the available shared buffer is filled by the producer, the number of all consumers is obtained as a reference count, and the reference count is stored in the count management memory. After obtaining the data request of any consumer, the available shared buffer is returned to the consumer to read the production data, and the reference count is reduced by one in the count management memory. All consumers are traversed until the reference count is zero and the available shared buffer is marked as free. The present application implements a producer that can correspond to multiple consumers, and one production can correspond to multiple consumers for synchronous consumption, avoiding the occupation of more resources and memory, and no data copy is required, and the distribution efficiency is more efficient.
[0043] See also Figure 4 , is a flow chart of an information storage sharing method provided in Example 3 of the present application, wherein the information storage sharing method is applied to Figure 1 Consumers in Figure 4 As shown, the information storage sharing method may include the following steps: Step S401: Send a data request to the buffer manager.
[0044] The buffer manager is used to implement the information storage sharing method described in the second embodiment.
[0045] Step S402: Obtain the available shared buffer returned by the buffer manager, and read the production data in the available shared buffer.
[0046] In this embodiment, the consumer needs to send a data request to the manager, and then read the production data from the returned available shared buffer.
[0047] Optionally, the information storage sharing method further includes: The registration information is sent to the buffer manager, and the buffer manager is used to determine whether the consumer meets the preset condition according to the registration information.
[0048] Among them, consumers can register with the buffer manager in unlimited numbers, that is, they only need to send registration information. Registered consumers can send data requests to the buffer manager, otherwise they cannot obtain production data.
[0049] When the embodiment of the present application detects that the producer applies for a shared cache, the available shared buffer is determined from the shared memory, and the available shared buffer is returned to the producer. After detecting that the available shared buffer is filled by the producer, the number of all consumers is obtained as a reference count, and the reference count is stored in the count management memory. After obtaining the data request of any consumer, the available shared buffer is returned to the consumer to read the production data, and the reference count is reduced by one in the count management memory. All consumers are traversed until the reference count is zero and the available shared buffer is marked as free. The present application implements a producer that can correspond to multiple consumers, and one production can correspond to multiple consumers for synchronous consumption, avoiding the occupation of more resources and memory, and no data copy is required, and the distribution efficiency is more efficient.
[0050] Corresponding to the information storage sharing method of the above embodiment, Figure 5 The structure diagram of the information storage sharing device provided in the fifth embodiment of the present application is shown. The information storage sharing device is applied to Figure 1 For ease of description, only the parts related to the embodiment of the present application are shown.
[0051] See also Figure 5 , the information storage sharing device comprises: An available buffer feedback module 51 is used to determine an available shared buffer from a shared memory when detecting that the producer applies for a shared cache, and return the available shared buffer to the producer, and the producer is used to fill the production data after obtaining the available shared buffer; A reference counting module 52, configured to obtain the number of all consumers as a reference count after detecting that the available shared buffer is filled, and store the reference count in a count management memory; The data sending module 53 is used for returning the available shared buffer to any consumer after obtaining the data request of the consumer, and the consumer is used for reading the production data in the available shared buffer after obtaining the available shared buffer; The sharing management module 54 is used to reduce the reference count by one in the count management memory, traverse all consumers, and mark the available shared buffer as free when the reference count is zero.
[0052] Optionally, the reference counting module 52 includes: A detection unit, used for detecting, for any consumer, whether the consumer meets a preset condition; The reference counting unit is used to increase the reference count by one if the consumer meets the preset condition, traverse all consumers, and obtain the number of all consumers as the reference count.
[0053] Optionally, the detection unit includes: A registration information acquisition subunit is used to acquire the registration information of all consumers; The detection and determination subunit is used to determine whether the consumer meets a preset condition if the registration information of the consumer is detected.
[0054] Optionally, the information storage sharing device further includes: The buffer marking module is used to mark the available shared buffer as filled after detecting that the available shared buffer is filled.
[0055] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0056] Corresponding to the information storage sharing method of the above embodiment, Figure 6 The structure diagram of the information storage sharing device provided in the fifth embodiment of the present application is shown. The information storage sharing device is applied to Figure 1 For ease of description, only the parts related to the embodiment of the present application are shown.
[0057] See also Figure 6 , the information storage sharing device comprises: A data request module 61, used to send a data request to the buffer manager, and the buffer manager is used to implement the information storage sharing method in the above-mentioned embodiment 2; The data reading module 62 is used to obtain the available shared buffer returned by the buffer manager, and read the production data in the available shared buffer.
[0058] Optionally, the information storage sharing device further includes: The registration module is used to send registration information to the buffer manager, and the buffer manager is used to determine whether the consumer meets the preset conditions according to the registration information.
[0059] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0060] Figure 7 This is a schematic diagram of the structure of a computer device provided in Example 6 of the present application. Figure 7 As shown, the computer device of this embodiment includes: at least one processor ( Figure 7Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on a processor, and when at least one processor executes the computer program, the steps in any of the above-mentioned information storage sharing method embodiments are implemented.
[0061] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 7 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0062] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0063] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments, it may also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0064] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0065] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.
[0066] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0067] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0068] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0069] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0070] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An information storage sharing method, characterized in that: The information storage sharing method is applied to a buffer manager in a producer-consumer model, wherein the producer-consumer model further includes a producer and at least two consumers, including: When it is detected that the producer applies for a shared cache, an available shared buffer is determined from the shared memory, and the available shared buffer is returned to the producer, and the producer is used to fill the production data after obtaining the available shared buffer; After detecting that the available shared buffer is filled, obtaining the number of all consumers as a reference count, and storing the reference count in a count management memory; For any consumer, after obtaining a data request of the consumer, the available shared buffer is returned to the consumer, and the consumer is used to read the production data in the available shared buffer after obtaining the available shared buffer; The reference count is reduced by one in the count management memory, and all consumers are traversed until the reference count reaches zero, and the available shared buffer is marked as free.
2. The information storage sharing method according to claim 1, characterized in that: The number of all consumers is obtained as a reference count, including: For any consumer, detecting whether the consumer meets a preset condition; If the consumer meets the preset condition, the reference count is increased by one, and all consumers are traversed to obtain the number of all consumers as the reference count.
3. The information storage sharing method according to claim 2, characterized in that: The detecting whether the consumer meets the preset condition includes: Get the registration information of all consumers; If the registration information of the consumer is detected, it is determined that the consumer meets the preset conditions.
4. The information storage sharing method according to claim 1, characterized in that: After detecting that the available shared buffer is filled, the method further includes: Mark the available shared buffer as filled.
5. An information storage sharing method, characterized in that: The information storage sharing method is applied to any consumer in a producer-consumer model, wherein the producer-consumer model also includes a buffer manager and a producer, including: Sending a data request to the buffer manager, the buffer manager being used to implement the information storage sharing method according to any one of claims 1 to 4; The available shared buffer is obtained from the buffer manager, and the production data in the available shared buffer is read.
6. The information storage sharing method according to claim 5, characterized in that: The information storage sharing method further includes: The registration information is sent to the buffer manager, and the buffer manager is used to determine whether the consumer meets the preset condition according to the registration information.
7. An information storage sharing device, characterized in that: The information storage sharing device is applied to a buffer manager in a producer-consumer model, wherein the producer-consumer model further includes a producer and at least two consumers, including: An available buffer feedback module is used to determine an available shared buffer from a shared memory when detecting that the producer applies for a shared cache, and return the available shared buffer to the producer, and the producer is used to fill the production data after obtaining the available shared buffer; A reference counting module, used for obtaining the number of all consumers as a reference count after detecting that the available shared buffer is filled, and storing the reference count in a count management memory; A data sending module, for any consumer, after obtaining a data request of the consumer, returns the available shared buffer to the consumer, and the consumer is used to read the production data in the available shared buffer after obtaining the available shared buffer; The sharing management module is used to reduce the reference count by one in the counting management memory, and traverse all consumers until the reference count reaches zero and the available shared buffer is marked as free.
8. An information storage sharing device, characterized in that: The information storage sharing device is applied to any consumer in a producer-consumer model, wherein the producer-consumer model also includes a buffer manager and a producer, including: A data request module, used to send a data request to the buffer manager, the buffer manager is used to implement the information storage sharing method according to any one of claims 1 to 4; The data reading module is used to obtain the available shared buffer returned by the buffer manager, and read the production data in the available shared buffer.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the information storage sharing method as described in any one of claims 1 to 4 or the information storage sharing method as described in any one of claims 5 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the information storage sharing method according to any one of claims 1 to 4 or the information storage sharing method according to any one of claims 5 to 6 is implemented.
Citation Information
Patent Citations
Interthread memory sharing method and device, equipment and storage medium
CN117194072A
Image distortion removal method and device, intelligent equipment and vehicle
CN117670744A
Database query performance optimization method and device, electronic equipment and storage medium
CN118210825A
Cited By
Engineering machinery camera monitoring storage and multi-process image multiplexing system and method
CN120711277A
