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 a more efficient graphic image display is achieved.
Patent Information
- Application Number
- CN202510431951.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-04-08
AI Technical Summary
In the process of graphic image display, image tear is avoided through double buffer locking mechanism, but it leads to bandwidth waste.
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 avoid data overwriting by adjusting the read and write speed.
Improve the utilization efficiency of double buffers, improve the overall bandwidth, and improve the efficiency of the entire system.
Smart Images

Figure CN119941488A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of data processing, and in particular relates to a data anti-trampling design method based on double buffers. Background Art
[0002] In the process of graphic image display, the computer takes data from the display buffer and then displays it. The speed of the computing unit and the display unit is often inconsistent. It is easy for the data in the buffer to be overwritten by the newly written data of the computing unit before it is read out. The result of this is that the graphics displayed continuously 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 the complete graphics, it switches to the other buffer to store the data, and the display unit also reads the graphic data alternately. At the same time, the read and write time of the two buffers needs to be adjusted to ensure the normal read and write order. 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 scan is completed, the entire screen is refreshed. 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 refreshing. This signal forces the frame rate to be synchronized with the display refresh frequency. If the current frame is not drawn, even if the next frame is ready, the next frame is prohibited from being used until the display draws the current frame and waits for the next refresh.
[0003] like Figure 1 As shown, currently, most solutions use a double buffer plus a lock to ensure that the displayed graphics will not be torn. This method uses the following process: Establish a double buffer mechanism; Lock the two buffers; Switch the read and write buffers according to the locking situation.
[0004] However, by restricting the access of readers and writers to the same buffer by locking, the computing unit and the display unit will not operate the same buffer at the same time. Although image tearing is avoided, it will cause serious waste of bandwidth. Summary of the invention
[0005] The object of the present invention is to provide a data anti-trampling design method based on double buffer, which can be achieved by the following technical solutions: The embodiment of the present application provides a data anti-trampling design method based on a double buffer, comprising the following steps: 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.
[0006] Preferably, the information interaction logic unit supports the computing unit and the display unit to perform read and write operations on the same buffer.
[0007] Preferably, 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.
[0008] Preferably, when the calculation 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, including: When the computing unit writes to the first buffer, recording the amount of data written by the computing unit to the first buffer; The display unit learns the amount of data written to the first 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.
[0009] Preferably, when the calculation 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, including: When the computing unit writes to the first buffer, recording the amount of data written by the computing unit to the first buffer; Alternatively, the computing unit learns the amount of data read from the first 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.
[0010] Preferably, 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: When the computing unit writes to the second buffer, recording the amount of data written by the computing unit to the second buffer; The display unit learns the amount of data written to the 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.
[0011] Preferably, 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: When the computing unit writes to the second buffer, recording the amount of data written by the computing unit to the second buffer; Alternatively, the computing unit learns the amount of data read from the second buffer by the display unit through information exchange, 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.
[0012] Preferably, 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.
[0013] Preferably, 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.
[0014] 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, so that the two units can exchange various required information, perceive the working status of the other unit and the use of the buffer zone more quickly, thereby improving the utilization efficiency of the two buffer zones, improving the overall bandwidth and improving the efficiency of the entire system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] For better understanding and implementation, the technical solution of the present application is described in detail below with reference to the accompanying drawings.
[0016] Figure 1A schematic diagram of the structure of the double buffer and locking mechanism provided by the prior art; Figure 2 A flowchart of a method for designing data anti-trampling based on double buffers provided in an embodiment of the present application; Figure 3 A structural schematic diagram of a data anti-trampling design method based on a double buffer provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] In order to further explain the technical means and effects taken by the present invention to achieve the predetermined invention purpose, exemplary embodiments will be described in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of methods and systems consistent with some aspects of the present application as detailed in the attached claims.
[0018] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in this article refers to any or all possible combinations of one or more associated listed items.
[0019] The specific implementation methods, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.
[0020] See also Figure 2 The embodiment of the present application provides a data anti-trampling design method based on a double buffer, comprising the following steps: 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.
[0021] Specifically, since the prior art limits the access of reading and writing to the same buffer by locking, the computing unit and the display unit will not operate the same buffer at the same time. Although the tearing of the image is avoided, it will cause serious waste of bandwidth. Therefore, in order to solve this problem, the present application adds an information interaction channel between the computing unit and the display unit, so that the computing unit can know which buffer the display unit is reading, and the reading status and other information; the display unit can also know which buffer the computing unit is writing, and the writing status and other information, thereby avoiding the display tearing problem of the display unit. The above method specifically includes the following contents: first, an information interaction logic unit is established between the computing unit and the display unit; then the display unit interacts with the computing unit through the information interaction logic unit to obtain the buffer the computing unit is writing and the written quantity information; then the computing unit interacts with the display unit through the information interaction logic unit to obtain the buffer the display unit is reading and the read quantity information; when the computing unit is writing the first buffer, the display unit chooses to read the data of the second buffer; when the computing unit is writing the second buffer, the display unit chooses to read the data of the first buffer.
[0022] It should be noted that, in this application, the first buffer is represented as buffer0, and the second buffer is represented as buffer1.
[0023] like Figure 3 As shown, Figure 1 Different 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 interact with each other.
[0024] In an embodiment provided in 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.
[0025] In an embodiment provided in the present application, when the computing 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 performed on the buffer.
[0026] 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 at the same time. In the information exchange, the computing unit can obtain the amount of data read by the display unit, and the display unit can also obtain the amount of data that the computing unit has written. In general, 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; thereby ensuring that data overwriting does not occur between the computing unit and the display unit. When the computing unit and the display unit operate the same buffer, the two units need to exchange the number of operations on the buffer with each other, so as to avoid the operations of the two units on the buffer.
[0027] In an embodiment provided in the present application, 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, including: When the computing unit writes to the first buffer, recording the amount of the first buffer written by the computing unit; The display unit learns the amount of data written to the first 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; Alternatively, the computing unit learns the amount of data read from the first 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.
[0028] In an embodiment provided by the present application, 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: When the computing unit writes to the second buffer, recording the amount of the second buffer written by the computing unit; The display unit learns the amount of data written to the 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; Alternatively, the computing unit learns the amount of data read from the second buffer by the display unit through information exchange, 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.
[0029] Specifically, by establishing information interaction between the two units, the two units can know each other's status. When the computing unit and the display unit operate the same buffer, when the computing unit writes to the buffer, the amount written by the computing unit to the buffer is recorded; at this time, the display unit can know how much data the computing unit has written to the buffer through information interaction, 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, thereby reading the previous data and causing the image data to be overwritten; while the display unit is reading, the computing unit can also know the amount read by the display unit and other information through information interaction, thereby ensuring that the data writing is always faster than the reading speed of the display unit.
[0030] In an embodiment provided by the present application, 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.
[0031] In an embodiment provided by the present application, 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.
[0032] Specifically, if in the same buffer, the display unit reads before the computing unit writes, the computing unit obtains information such as the number of reads by the display unit through information interaction, thereby adjusting its own writing speed so that the newly written data does not overwrite the data that has not been read.
[0033] To summarize, through the above-mentioned mechanism, the present application can establish information interaction between the computing unit and the display unit, so that the two parts can exchange various required information, perceive the working status of the other part and the usage of the buffer more quickly, thereby improving the utilization efficiency of the two buffers, improving the overall bandwidth, and improving the efficiency of the entire system.
[0034] 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.
[0035] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution 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.
2. The data anti-trampling design method based on double buffer according to claim 1, characterized in that: The information interaction logic unit supports the calculation unit and the display unit to perform read and write operations on the same buffer.
3. The data anti-trampling design method based on double buffer according to claim 2 is characterized in that: 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.
4. The data anti-trampling design method based on double buffer according to claim 3 is 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, including: When the computing unit writes to the first buffer, recording the amount of data written by the computing unit to the first buffer; The display unit learns the amount of data written to the first 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.
5. The data anti-trampling design method based on double buffer according to claim 4 is 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, including: When the computing unit writes to the first buffer, recording the amount of data written by the computing unit to the first buffer; Alternatively, the computing unit learns the amount of data read from the first 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.
6. The data anti-trampling design method based on double buffer according to claim 3 is 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: When the computing unit writes to the second buffer, recording the amount of data written by the computing unit to the second buffer; The display unit learns the amount of data written to the 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.
7. The data anti-trampling design method based on double buffer according to claim 6 is 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: When the computing unit writes to the second buffer, recording the amount of data written by the computing unit to the second buffer; Alternatively, the computing unit learns the amount of data read from the second buffer by the display unit through information exchange, 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.
8. The data anti-trampling design method based on double buffer according to claim 3 is 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.
9. The data anti-trampling design method based on double buffer according to claim 3, 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
Screen refreshing method and device
CN102402409A
Data read-write access system and method
CN113204573A
Display control method and related device
CN114153416A
Data processing method and device, data reading method and device and data processing equipment
CN118550445A