A data anti-trampling design method based on double buffer
By establishing an information interaction logic unit between the computing unit and the display unit, exchanging the read and write status information of the buffer, and allowing read and write operations to the same buffer, the bandwidth waste problem caused by double buffer locking in the prior art is solved, and the efficiency and bandwidth utilization of the system are improved.
Patent Information
- Application Number
- CN202510431951.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2045-04-08
AI Technical Summary
In the process of graphic image display, data trampling is prevented by double buffer locking. Although image tear is avoided, bandwidth waste is caused.
An information interaction logic unit is established between the computing unit and the display unit, and the read and write status information of the buffer is exchanged, allowing two units to read and write operations on the same buffer, and ensuring that the data is not covered by adjustments to the read and write speed.
The utilization efficiency of double buffers is improved, the overall bandwidth is improved, the efficiency of the system is improved, and bandwidth waste is avoided.
Smart Images

Figure CN119941488B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing, and particularly relates to a data anti-stampede design method based on a double buffer (buffer). Background Art
[0002] During the process of graphic image display, the computer retrieves data from the display buffer and then displays it. In many cases, the speeds of the computing unit and the display unit are inconsistent, and it is very easy for the data in the buffer to be overwritten by the newly written data from the computing unit before it is read. The consequence of this is that for a continuously displayed graphic, the seen effect may be torn. By using a double buffer, the continuous results generated by the computing unit can be stored in different buffers. After one buffer stores a complete graphic, then switch to the other buffer to store data, and the display unit also alternately reads the graphic data. At the same time, the read and write times of the two buffers need to be adjusted to ensure the normal read and write order, and this adjustment process is called locking. The display refresh is horizontal scanning from left to right and vertical scanning from top to bottom. When the vertical scanning is completed, the entire screen is refreshed, and this is the time to tell the outside world that the next frame can be drawn. A signal is sent here to notify the computing unit to transfer new data to the buffer. After completion, the screen can start to be refreshed. This signal forces the frame rate to be synchronized with the display refresh frequency. If the current frame is not drawn completely, even if the next frame is ready, the next frame is prohibited from being used until the display unit finishes drawing the current frame, and the next frame will be used when the next refresh occurs.
[0003] As Figure 1 shown, currently, the vast majority of solutions use the method of double buffer plus locking to ensure that the displayed graphic will not be torn, and this method adopts the following process:
[0004] Establish a double buffer mechanism;
[0005] Lock the two buffers;
[0006] Switch the read and write buffers according to the locking situation.
[0007] However, restricting the read and write access to the same buffer by locking makes the computing unit and the display unit not operate on the same buffer simultaneously. Although it avoids the tearing of the image, it will cause serious waste of bandwidth. Summary of the Invention
[0008] The purpose of the present invention is to provide a data anti-stampede design method based on a double buffer (buffer), which can be achieved through the following technical solutions:
[0009] The embodiments of the present application provide a data anti-stampede design method based on a double buffer (buffer), including the following steps:
[0010] Establish an information interaction logic unit between the computing unit and the display unit;
[0011] The display unit performs information interaction with the computing unit through the information interaction logic unit to obtain the buffer being written by the computing unit and the quantity information of the writing;
[0012] The computing unit performs information interaction with the display unit through the information interaction logic unit to obtain the buffer being read by the display unit and the quantity information of the reading;
[0013] When the computing unit is writing to the first buffer, the display unit selects to read the data of the second buffer;
[0014] When the computing unit is writing to the second buffer, the display unit selects to read the data of the first buffer.
[0015] Preferably, the information interaction logic unit supports the computing unit and the display unit to perform read and write operations on the same buffer.
[0016] Preferably, when the computing unit and the display unit perform read and write operations on the same buffer, the two units exchange the quantity information of the read and write operations on the buffer with each other.
[0017] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of the read and write operations on the buffer with each other, including:
[0018] When the computing unit writes to the first buffer, record the quantity of data written by the computing unit to the first buffer;
[0019] The display unit learns through information interaction the quantity of data written by the computing unit to the first buffer, and by adjusting the quantity of data read by the display unit, makes the speed of reading data always slower than the speed of the computing unit writing data.
[0020] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of the read and write operations on the buffer with each other, including:
[0021] When the computing unit writes to the first buffer, record the quantity of data written by the computing unit to the first buffer;
[0022] Or, the computing unit learns through information interaction the quantity of data read by the display unit from the first buffer, and by adjusting the writing speed of the computing unit, makes the speed of writing data always faster than the speed of the display unit reading data.
[0023] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and further include:
[0024] When the computing unit writes to the second buffer, record the quantity of data written by the computing unit to the second buffer;
[0025] The display unit learns, through information interaction, the quantity of data written by the computing unit to the second buffer, and by adjusting the quantity of data read by the display unit, makes the data reading speed always slower than the data writing speed of the computing unit.
[0026] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and further include:
[0027] When the computing unit writes to the second buffer, record the quantity of data written by the computing unit to the second buffer;
[0028] Or, the computing unit learns, through information interaction, the quantity of data read by the display unit from the second buffer, and by adjusting the writing speed of the computing unit, makes the data writing speed always faster than the data reading speed of the display unit.
[0029] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and further include:
[0030] If in the first buffer, the data reading position of the display unit is before the data writing position of the computing unit, then the computing unit learns, through information interaction, the quantity information of data read by the display unit, and by adjusting the writing speed of the computing unit, makes the newly written data not overwrite the unread data.
[0031] Preferably, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and further include:
[0032] If in the second buffer, the data reading position of the display unit is before the data writing position of the computing unit, then the computing unit learns, through information interaction, the quantity information of data read by the display unit, and by adjusting the writing speed of the computing unit, makes the newly written data not overwrite the unread data.
[0033] The beneficial effects of the present invention are as follows: By establishing an information interaction logic unit, the present invention can establish information interaction between the computing unit and the display unit, enabling the two units to exchange various required information, more quickly perceive the working status of the other unit and the usage of the buffer, thereby improving the utilization efficiency of the two buffers, improving the overall bandwidth, and enhancing the efficiency of the entire system. Brief Description of the Drawings
[0034] For better understanding and implementation, the technical solutions of the present application will be described in detail below with reference to the accompanying drawings.
[0035] Figure 1 A schematic structural diagram of the double buffer and locking mechanism provided by the prior art;
[0036] Figure 2 A flowchart of the steps of a data anti-trampling design method based on a double buffer provided by an embodiment of the present application;
[0037] Figure 3 A schematic structural diagram of a data anti-trampling design method based on a double buffer provided by an embodiment of the present application. Detailed Embodiment
[0038] To further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the exemplary embodiments will be described in detail herein, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of methods and systems consistent with some aspects of the present application as detailed in the appended claims.
[0039] The terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms of "a", "the", and "said" used in the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to any or all possible combinations of one or more of the associated listed items.
[0040] The following will describe in detail the specific embodiments, features, and their effects of the present invention in combination with the accompanying drawings and preferred embodiments.
[0041] Please refer to Figure 2 , an embodiment of the present application provides a data anti-trampling design method based on a double buffer, including the following steps:
[0042] Establish an information interaction logic unit between the computing unit and the display unit;
[0043] The display unit performs information interaction with the computing unit through the information interaction logic unit to obtain the buffer that the computing unit is writing to and the quantity information being written;
[0044] The computing unit performs information interaction with the display unit through the information interaction logic unit to obtain the buffer that the display unit is reading and the quantity information being read;
[0045] When the computing unit is writing to the first buffer, the display unit selects to read the data in the second buffer;
[0046] When the computing unit is writing to the second buffer, the display unit selects to read the data in the first buffer.
[0047] Specifically, in the prior art, by locking to restrict access to the same buffer for reading and writing, the computing unit and the display unit do not operate on the same buffer simultaneously. Although image tearing is avoided, it causes serious waste of bandwidth. Therefore, to solve this problem, this application adds an information interaction channel between the computing unit and the display unit. The computing unit can know which buffer the display unit is reading and information such as the reading status; the display unit can also know which buffer the computing unit is writing to and information such as the writing status, thereby avoiding the display tearing problem of the display unit. The above method specifically includes the following content: First, establish an information interaction logic unit between the computing unit and the display unit; then the display unit performs information interaction with the computing unit through the information interaction logic unit to obtain the buffer that the computing unit is writing to and the quantity information being written; then the computing unit performs information interaction with the display unit through the information interaction logic unit to obtain the buffer that the display unit is reading and the quantity information being read; when the computing unit is writing to the first buffer, the display unit selects to read the data in the second buffer; when the computing unit is writing to the second buffer, the display unit selects to read the data in the first buffer.
[0048] It should be noted that in this application, the above first buffer is denoted as buffer0 and the second buffer is denoted as buffer1.
[0049] As Figure 3 shown, compared with Figure 1Different from the prior art shown, the present application adds an information interaction logic unit for information interaction between the computing unit and the display unit. The computing unit writes data into buffer0 and buffer1, and the display unit reads data from buffer0 and buffer1; and the computing unit and the display unit perform information interaction with each other.
[0050] In an embodiment provided by the present application, the information interaction logic unit supports the computing unit and the display unit to perform read and write operations on the same buffer.
[0051] In an embodiment provided by the present application, when the computing unit and the display unit perform read and write operations on the same buffer, the two units exchange the quantity information of the read and write operations on the buffer with each other.
[0052] Specifically, in order to increase the available bandwidth, the present application allows the computing unit and the display unit to operate on the same buffer, that is, the same buffer can be read and written simultaneously. In information interaction, the computing unit can obtain the quantity of data read by the display unit, and the display unit can also obtain the quantity of data that the computing unit has written. Generally, the computing unit can know the buffer that the display unit is reading, so as to select another buffer to write; and the display unit can also know the buffer that the computing unit is writing, so as to select another buffer to read; in this way, data overwrite between the computing unit and the display unit can be avoided. When the computing unit and the display unit operate on the same buffer, the two units need to exchange the operation quantity of the buffer with each other, so as to avoid the operations of the two units on the buffer.
[0053] In an embodiment provided by the present application, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of the read and write operations on the buffer with each other, including:
[0054] When the computing unit writes to the first buffer, record the quantity written by the computing unit to the first buffer;
[0055] The display unit obtains, through information interaction, the quantity of data written by the computing unit to the first buffer, and by adjusting the quantity of data read by the display unit, makes the data reading speed always slower than the data writing speed of the computing unit;
[0056] Or, the computing unit obtains, through information interaction, the quantity of data read by the display unit from the first buffer, and by adjusting the writing speed of the computing unit, makes the data writing speed always faster than the data reading speed of the display unit.
[0057] In an embodiment provided by the present application, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and it further includes:
[0058] When the computing unit writes to the second buffer, record the quantity written by the computing unit to the second buffer;
[0059] The display unit learns, through information interaction, the quantity of data written by the computing unit to the second buffer, and by adjusting the quantity of data read by the display unit, makes the reading speed always slower than the writing speed of the computing unit;
[0060] Or, the computing unit learns, through information interaction, the quantity of data read by the display unit from the second buffer, and by adjusting the writing speed of the computing unit, makes the writing speed always faster than the reading speed of the display unit.
[0061] Specifically, through the information interaction established between the two units, the two units can learn about each other's states. When the computing unit and the display unit operate on the same buffer, when the computing unit writes to the buffer, record the quantity written by the computing unit to the buffer; and at this time, the display unit can learn, through information interaction, how much data the computing unit writes to the buffer, and then adjust its own state so that the reading speed is always slower than the writing speed of the computing unit, thereby avoiding the reading speed exceeding the writing speed and reading the previous data, resulting in the image data being overwritten; while the display unit is reading, the computing unit can also learn, through information interaction, information such as the quantity read by the display unit, so as to ensure that the data writing speed is always faster than the reading speed of the display unit.
[0062] In an embodiment provided by the present application, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and it further includes:
[0063] If in the first buffer, the position where the display unit reads data is before the position where the computing unit writes data, then the computing unit learns, through information interaction, the quantity information of the data read by the display unit, and by adjusting the writing speed of the computing unit, makes the newly written data not overwrite the unread data.
[0064] In an embodiment provided by the present application, when the computing unit and the display unit operate on the same buffer, the two units exchange the quantity information of read and write operations on the buffer with each other, and it further includes:
[0065] If, in the second buffer, the position where the display unit reads data is before the position where the computing unit writes data, the computing unit learns the quantity information of the data read by the display unit through information interaction, and adjusts the writing speed of the computing unit so that the newly written data does not overwrite the unread data.
[0066] Specifically, if, in the same buffer, the display unit's reading position is before the computing unit's writing position, the computing unit learns information such as the quantity read by the display unit through information interaction, and thus adjusts its own writing speed so that the newly written data does not overwrite the data that has not yet been read.
[0067] In summary, through the above mechanism, the present application can establish information interaction between the computing unit and the display unit, enabling the two parts to exchange various required information, more quickly perceive the working status of the other part and the usage of the buffer, thereby improving the utilization efficiency of the two buffers, improving the overall bandwidth, and enhancing the efficiency of the entire system.
[0068] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0069] The above are only preferred embodiments of the present invention and do not impose any form of limitation on the present invention. Although the present invention has been disclosed above in preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or equivalent changes and modifications within the scope of the technical solution of the present invention by using the disclosed technical content. However, as long as it does not depart from the technical solution content of the present invention, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention still fall within the scope of the technical solution of the present invention.
Claims
1. A data anti-trampling design method based on double buffer, characterized by: The steps include: Establishing an information interaction logic unit between the computing unit and the display unit; The display unit exchanges information with the computing unit through the information interaction logic unit to obtain the buffer being written by the computing unit and the written quantity information; The computing unit performs information interaction with the display unit through the information interaction logic unit to obtain the buffer being read by the display unit and the read quantity information; When the computing unit is writing into the first buffer, the display unit selects to read data from the second buffer; When the computing unit is writing into the second buffer, the display unit selects to read data from the first buffer; Wherein, when the calculation unit and the display unit perform read and write operations on the same buffer, the two units exchange information on the number of read and write operations on the buffer; When the computing unit writes to the first or second buffer, recording the amount of data written by the computing unit to the first or second buffer; The display unit learns the amount of data written to the first or second buffer by the computing unit through information exchange, and adjusts the amount of data read by the display unit so that the speed of reading data is always slower than the speed of writing data by the computing unit; When the computing unit writes to the first or second buffer, recording the amount of data written by the computing unit to the first or second buffer; Alternatively, the computing unit learns the amount of data read from the first or second buffer by the display unit through information interaction, and adjusts the writing speed of the computing unit so that the speed of writing data is always faster than the speed of reading data by the display unit.
2. The data anti-trampling design method based on double buffer according to claim 1, characterized in that: When the computing unit and the display unit operate the same buffer, the two units exchange information on the number of read and write operations on the buffer, further comprising: If in the first buffer, the position where the display unit reads data is before the position where the computing unit writes data, the computing unit obtains information about the amount of data read by the display unit through information interaction, and adjusts the writing speed of the computing unit so that the newly written data does not overwrite the unread data.
3. The data anti-trampling design method based on double buffer according to claim 1, characterized in that: When the computing unit and the display unit operate the same buffer, the two units exchange information on the number of read and write operations on the buffer, further comprising: If in the second buffer, the position where the display unit reads data is before the position where the computing unit writes data, the computing unit obtains information about the amount of data read by the display unit through information interaction, and adjusts the writing speed of the computing unit so that the newly written data does not overwrite the unread data.
Citation Information
Patent Citations
Apparatus and method for controlling image data to write into and read from buffer unit
CN101303845A
Data processing method and device, data reading method and device and data processing equipment
CN118550445A