Data writing control method, system, terminal and medium
By receiving data write requests and determining the request type, data updates are carried out in a targeted manner, and performance and efficiency reduction caused by inability to distinguish between direct write requests and write back requests during data writing in the prior art, achieving more efficient data writing.
Patent Information
- Application Number
- CN202411866792.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-18
AI Technical Summary
The prior art cannot distinguish between direct write requests and write back requests when writing data, resulting in refreshing all data in the cache at one time, reducing the performance and efficiency of data writing.
By receiving data write requests, determine the request terminal and request type (write back request or write direct request), and update data according to the request type to avoid refreshing all data at once.
Improve the performance and efficiency of data writing, and distinguish the request types, and perform targeted data updates to reduce unnecessary data refreshes.
Smart Images

Figure CN119311229B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data writing, and in particular to a data writing control method, system, terminal and medium. Background Art
[0002] Currently, when a request to write data is received from the client, since it cannot distinguish whether the data to be written is the data of a direct write request or a write-back request, all data in the cache will be refreshed at once when the data is written, which will reduce the performance of data writing and also reduce the efficiency of data writing.
[0003] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0004] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a data writing control method, system, terminal and medium are provided, aiming to solve the problem that when writing data, all data in the cache will be refreshed at one time in the prior art, which will reduce the performance of data writing and also reduce the efficiency of data writing.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:
[0006] In a first aspect, the present invention provides a data writing control method, wherein the method comprises:
[0007] receiving a data writing request, and determining a request terminal corresponding to the data writing request;
[0008] Based on the request terminal, determining a request type corresponding to the data write request, the request type including a write-back request or a write-through request;
[0009] The write data corresponding to the data write request is acquired, and data is updated based on the request type and the write data.
[0010] In one implementation, receiving a data write request and determining a request terminal corresponding to the data write request includes:
[0011] Receiving a data writing request, parsing the data writing request, and obtaining device information carried in the data writing request;
[0012] Based on the device information, the requesting terminal is determined.
[0013] In one implementation, before receiving a data write request and determining a request terminal corresponding to the data write request, the method includes:
[0014] Pre-acquire device information of the requesting terminal;
[0015] The data write request is generated based on the device information and the write data.
[0016] In one implementation, determining the request type corresponding to the data write request based on the request terminal includes:
[0017] Acquire tag information corresponding to the requesting terminal, wherein the tag information is used to mark the write data of the data write request;
[0018] Determine a write type of the write data based on the tag information, the write type including write-through write or write-back write;
[0019] Based on the write type, the request type is determined.
[0020] In one implementation, obtaining the write data corresponding to the data write request, and updating the data based on the request type and the write data, includes:
[0021] Obtaining write data in the data write request;
[0022] Acquire first cache data in the buffer memory and second cache data in the preset random access memory;
[0023] When the request type is a write-through request, the first cache data and the second cache data are updated based on the write data;
[0024] When the request type is a write-back request, only the first cache data is updated based on the write data.
[0025] In one implementation, obtaining the write data corresponding to the data write request, and updating the data based on the request type and the write data, further includes:
[0026] When the request type is a write-back request and the updating of the first cache data is completed, obtaining the running status of the data writing process;
[0027] If the running state is idle, the second cache data in the random access memory is updated based on the write data.
[0028] In one implementation, obtaining the write data corresponding to the data write request, and updating the data based on the request type and the write data, further includes:
[0029] If the operating state is non-idle, determining the remaining storage capacity of the random access memory;
[0030] If the remaining storage capacity is greater than or equal to the amount of the written data, determining the data to be output in the second cache data based on the first-in-first-out principle;
[0031] The written data replaces the to-be-out data in the second cache data.
[0032] In a second aspect, an embodiment of the present invention further provides a data writing control system, the system is used to implement the steps of the data writing control method described in the above scheme, the system comprising:
[0033] A request terminal determination module, used for receiving a data writing request and determining a request terminal corresponding to the data writing request;
[0034] A request type determination module, used to determine the request type corresponding to the data write request based on the request terminal, the request type including a write-back request or a write-through request;
[0035] The data update module is used to obtain the write data corresponding to the data write request, and update based on the request type and the write data.
[0036] In a third aspect, an embodiment of the present invention further provides a terminal, wherein the terminal includes a memory, a processor, and a data write control program stored in the memory and executable on the processor, and when the processor executes the data write control program, the steps of the data write control method of any one of the above schemes are implemented.
[0037] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein a data write control program is stored on the computer-readable storage medium, and when the data write control program is executed by a processor, the steps of the data write control method described in any one of the above schemes are implemented.
[0038] Beneficial effect: Compared with the prior art, the present invention provides a data write control method, which first receives a data write request and determines the request terminal corresponding to the data write request. Then, based on the request terminal, the request type corresponding to the data write request is determined, and the request type includes a write-back request or a write-through request. Finally, the write data corresponding to the data write request is obtained, and the data is updated based on the request type and the write data. The present invention can determine whether the request type of the data write request is a write-back request or a write-through request, so that the data can be updated based on the request type, thereby improving the efficiency of data updating. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 The present invention provides a flowchart of a preferred embodiment of the data writing control method.
[0040] Figure 2 A schematic diagram of the architecture of a data writing control system provided by an embodiment of the present invention.
[0041] Figure 3 A functional block diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0043] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations or steps, nor must they be executed in the order described. For example, some operations or steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0044] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0045] It should be understood that, in order to clearly describe the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, words such as "first" and "second" are used to distinguish between identical or similar items with substantially identical functions and effects. For example, the first control information and the second control information are only used to distinguish different control information, and their order is not limited.
[0046] Those skilled in the art can understand that the words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not necessarily limit the differences.
[0047] It should be further understood that the term “and / or” used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] In order to solve the problems of the prior art, the present embodiment provides a data write control method. The method based on the present embodiment can realize the identification of data write requests, determine whether the request type is a write-back request or a write-through request, and then when refreshing the data, targeted refreshes can be performed for different request types, thereby improving the efficiency of data refresh. In specific applications, the present embodiment can first receive a data write request and determine the request terminal corresponding to the data write request. Then, based on the request terminal, determine the request type corresponding to the data write request, and the request type includes a write-back request or a write-through request. Finally, obtain the write data corresponding to the data write request, and update the data based on the request type and the write data.
[0049] The data writing control method of this embodiment can be applied to a terminal, which can be a mobile phone, a computer, a smart TV or other intelligent product terminal. Figure 1 As shown in , the data writing control method comprises the following steps:
[0050] Step S100: receiving a data writing request, and determining a request terminal corresponding to the data writing request.
[0051] When writing or refreshing data, the terminal will receive a data write request, requesting to write data to the terminal. In actual application, this embodiment can analyze the data write request to determine the request terminal corresponding to the data write request, that is, determine which client issued the data write request.
[0052] In one implementation, when determining the requesting terminal, this embodiment includes the following steps:
[0053] Step S101: receiving a data write request, parsing the data write request, and obtaining device information carried in the data write request;
[0054] Step S102: Determine the requesting terminal based on the device information.
[0055] Specifically, this embodiment pre-acquires the device information of the requesting terminal, which can be the model of the requesting terminal or the device name of the requesting terminal, and then generates the data write request based on the device information and the write data, and the write data is the data to be updated on the terminal. The data write request generated at this time will carry the device information. After receiving the data write request, the terminal can parse the data write request, and then obtain the content carried in the data write request, and thus obtain the device information, so the requesting terminal can be determined based on the device information. This embodiment determines that the requesting terminal can facilitate the determination of the request type of the data write request based on the requesting terminal in subsequent steps.
[0056] Step S200: Based on the requesting terminal, determine the request type corresponding to the data write request, where the request type includes a write-back request or a write-through request.
[0057] After the request terminal is determined, this embodiment can determine the request type of the issued data write request based on the request terminal, and the request type includes a write-back request or a write-through request, thereby realizing the identification of the request type and facilitating data refresh based on the request type in subsequent steps.
[0058] In one implementation, when determining the request type of a data write request, this embodiment includes the following steps:
[0059] Step S201: Acquire tag information corresponding to the requesting terminal, wherein the tag information is used to mark the write data of the data write request;
[0060] Step S202: Determine the write type of the write data based on the tag information, where the write type includes write-through write or write-back write;
[0061] Step S203: Determine the request type based on the write type.
[0062] Specifically, the present embodiment divides the request terminal in advance, and divides the request terminal into a first terminal for issuing a direct write request and a second terminal for issuing a write-back request, and also uses different tag information for marking the first terminal and the second terminal, for example, the first tag is used for the first terminal, and the second tag is used for the second terminal. At the same time, when the first terminal or the second terminal generates a data write request, the corresponding tag information can be used to mark the write data in the data write request. After determining the request terminal, the present embodiment can determine the tag information corresponding to the request terminal, for example, if the request terminal is the first terminal, the tag information is the first tag, and if the request terminal is the second terminal, the tag information is the second tag. Since the write data in the data write request has been marked with the corresponding tag information, it can be determined at this time whether the write data corresponds to the first tag or the second tag, and based on this, it can be determined whether the write type of the write data is direct write or write-back write. Correspondingly, if the write data corresponds to the first tag, the write type of the write data is direct write, and if the write data corresponds to the second tag, the write type of the write data is write-back write. Therefore, the request type is determined based on the write type. This embodiment can more conveniently determine the request type by analyzing the tag information of the requesting terminal.
[0063] Step S300: Acquire write data corresponding to the data write request, and update data based on the request type and the write data.
[0064] After determining the request type corresponding to the data write request, this embodiment can obtain the corresponding write data, and then update the data in the terminal based on the request type and the write data. Since different request types have different ways of updating data, this embodiment can update the data in a targeted manner based on the request type, thereby improving the efficiency of data updating.
[0065] In one implementation, this embodiment includes the following steps when updating data:
[0066] Step S301, obtaining the write data in the data write request;
[0067] Step S302, obtaining first cache data in the buffer memory and second cache data in the preset random access memory;
[0068] Step S303: when the request type is a write-through request, the first cache data and the second cache data are updated based on the write data;
[0069] Step S304: When the request type is a write-back request, only the first cache data is updated based on the write data.
[0070] In specific applications, the data targeted by the write-through request and the write-back request are different. In the present embodiment, the write-through request targets all the data cached on the terminal, while the write-back request targets part of the data cached on the terminal. The purpose of determining the request type in the present embodiment is to update the data that needs to be updated in a targeted manner. For example, if the request type is a write-through request, all the data cached in the terminal can be updated. If the request type is a write-back request, only part of the data cached in the terminal can be updated without updating all the data. This can improve the efficiency of data updating.
[0071] In order to better implement the update of data, the present embodiment can distinguish the data cached in the terminal. Specifically, the buffer memory of the terminal stores the first cache data, and the terminal is also provided with a random access memory, in which the second cache data is stored, wherein the first cache data and the second cache data constitute all the data cached on the terminal. In practical applications, when it is determined that the request type is a write-through request, the present embodiment can update the first cache data in the buffer memory and the second cache data in the random access memory based on the write data, that is, to implement an overall update of the data. When it is determined that the request type is a write-back request, the present embodiment can update only the first cache data in the buffer memory based on the write data. Therefore, when the request type is a write-back request, there is no need to update all the data, thereby improving the efficiency of data updating.
[0072] In one implementation, when the request type is a direct write request, since all data needs to be updated based on the written data, it will inevitably take a certain amount of time. In order to increase the data update speed and shorten the data update time, this embodiment can be implemented by eliminating the same and retaining the different when updating all data. Specifically, this embodiment can compare the written data with the first cache data of the terminal's buffer memory and the second cache data of the terminal's random access memory, respectively, to determine whether the written data has some of the same data as the first cache data or the second cache data. If there is some of the same data, the difference data is determined. This embodiment only needs to update this part of the difference data to the terminal to complete the data update. At the same time, in order to find the difference data as quickly as possible, the present embodiment can set a data type tag for the write data, and the first cache data and the second cache data can also set a data type tag. When the write data is compared with the first cache data of the terminal's buffer memory and the second cache data of the terminal's random access memory, it can be determined first whether the data type tags are the same. If the data type tags are different, it means that the write data and the first cache data or the second cache data do not have the same data. At this time, it is necessary to update the write data as a whole to the terminal, that is, the write data is updated as a whole to the first cache data of the buffer memory and the second cache data of the random access memory. If it is determined that the data type tags are the same, it is further determined whether the data content is the same, and then the part with the difference in data content is found to obtain the difference data, and then the terminal data is updated based on the difference data, that is, the difference data is updated to the first cache data of the buffer memory and the second cache data of the random access memory. The update method of eliminating the same and preserving the different based on the present embodiment can effectively improve the data update efficiency when the request type is a direct write request.
[0073] Furthermore, since this embodiment only updates the first cache data in the buffer memory of the terminal when the request type is a write-back request, in order to ensure data consistency, this embodiment can obtain the running status of the data writing process after the request type is a write-back request and the update of the first cache data is completed, and then determine whether the second cache data needs to be updated based on the running status. Specifically, if the running status is idle, it means that the data update thread of the system is available at this time. Therefore, at this time, the second cache data in the random access memory can be updated based on the written data, thereby achieving staggered updates of the first cache data and the second cache data, and improving the efficiency of data update. When the running status is non-idle, the remaining storage capacity of the random access memory is determined. If the remaining storage capacity is greater than or equal to the amount of data of the written data, it means that the capacity of the random access memory at this time is sufficient and there is enough space to accommodate the written data. However, since the running state of the data writing process at this time is non-idle, it means that data is being updated at this time. In order to reduce the occupancy of the data writing process, this embodiment can determine the data to be output in the second cache data based on the first-in-first-out principle. The data to be output can be the data that is first saved in the second cache data. These data may have been saved in the random access memory for a long time. This embodiment can use this part of the data as the data to be output, and then replace the data to be output in the second cache data with the written data. Since the data to be output is only a part of the second cache data, and the amount of data of the determined data to be output is the same as that of the written data, it will not occupy too many data update threads when the data is updated, which is easy to implement. In addition, this embodiment can move the determined data to be output to other memories for easy tracing when needed later. In addition, when the data of the second cache data is updated based on the written data, this embodiment can also be implemented based on the method of eliminating the same and reserving the different in the above scheme to further improve the efficiency of data updating.
[0074] In other implementations, when there are multiple clients sending data write requests at the same time, this embodiment can analyze each data write request separately and determine the request type corresponding to each data write request. When the request types are inconsistent, for example, there is both a write-back request and a direct write request, this implementation can change the data write strategy of the direct write request to ensure the normal operation of the data write process. Specifically, if the direct write request and the write-back request exist at the same time, the data write process will be crowded. In order to reduce the occupation of the data write process, this embodiment can give priority to updating the first cache data of the buffer memory. Therefore, when processing the direct write request, this embodiment also first ensures the update of the first cache data of the buffer memory, and for the update of the second cache data of the random access memory, this embodiment can be implemented in a mapping synchronization manner. Specifically, the write data can be mapped from the buffer memory to the random access memory, so that the write data is updated to the random access memory data. Such a mapping synchronization method can reduce the occupation of the data write process and improve the efficiency of data update. Similarly, the write-back request is also to update only the first cache data of the buffer memory until the data write process is idle, and then determine the appropriate time to consider whether to update the second cache data of the random access memory. In actual application, when processing a write-back request, this embodiment only needs to ensure that the first cache data in the buffer memory is updated, and whether the write-back request updates the second cache data in the random access memory can be selected based on the importance of the written data. Therefore, this embodiment can set an importance tag for the written data in advance, and when it is determined based on the importance tag that the importance of the written data is high, the second cache data in the random access memory can be updated, otherwise it can be selected not to update the second cache data in the random access memory.
[0075] In summary, this embodiment first receives a data write request and determines the request terminal corresponding to the data write request. Then, based on the request terminal, the request type corresponding to the data write request is determined, and the request type includes a write-back request or a write-through request. Finally, the write data corresponding to the data write request is obtained, and the data is updated based on the request type and the write data. This embodiment can determine whether the request type of the data write request is a write-back request or a write-through request, so that the data can be updated based on the request type, thereby improving the efficiency of data updating.
[0076] Based on the above embodiments, the present invention further provides a data writing control system, which can be used to implement the steps of the data writing control method in the above embodiments, such as Figure 2As shown in , the system includes: a request terminal determination module 10, a request type determination module 20 and a data update module 30. Specifically, the request terminal determination module 10 is used to receive a data write request and determine the request terminal corresponding to the data write request. The request type determination module 20 is used to determine the request type corresponding to the data write request based on the request terminal, and the request type includes a write-back request or a write-through request. The data update module 30 is used to obtain the write data corresponding to the data write request and update it based on the request type and the write data.
[0077] In one implementation, the request terminal determination module 10 includes:
[0078] An information determination unit, configured to receive a data write request, parse the data write request, and obtain device information carried in the data write request;
[0079] A terminal determining unit is used to determine the requesting terminal based on the device information.
[0080] In one implementation, the request terminal determination module 10 further includes:
[0081] A device information setting unit, used to pre-acquire device information of the requesting terminal;
[0082] The write request generating unit is used to generate the data write request based on the device information and the write data.
[0083] In one implementation, the request type determination module 20 includes:
[0084] a marking information acquiring unit, configured to acquire marking information corresponding to the requesting terminal, wherein the marking information is used to mark the write data of the data write request;
[0085] A write type determination unit, configured to determine a write type of the write data based on the tag information, wherein the write type includes write-through write or write-back write;
[0086] A request type determining unit is used to determine the request type based on the write type.
[0087] In one implementation, the data updating module 30 includes:
[0088] A write data acquisition unit, used to acquire the write data in the data write request;
[0089] A cache data acquisition unit, used for acquiring first cache data in the buffer memory and second cache data in a preset random access memory;
[0090] a first data updating unit, configured to update the first cache data and the second cache data based on the write data when the request type is a write-through request;
[0091] The second data updating unit is configured to update only the first cache data based on the write data when the request type is a write-back request.
[0092] In one implementation, the data updating module 30 further includes:
[0093] an operation status determining unit, configured to obtain the operation status of the data writing process when the request type is a write-back request and the updating of the first cache data is completed;
[0094] The third data updating unit is used to update the second cache data in the random access memory based on the write data if the running state is idle.
[0095] In one implementation, the data updating module 30 further includes:
[0096] a remaining capacity determination unit, configured to determine the remaining storage capacity of the random access memory if the operating state is non-idle;
[0097] a to-be-out data determining unit, configured to determine the to-be-out data in the second cache data based on a first-in-first-out principle if the remaining storage capacity is greater than or equal to the amount of the written data;
[0098] A data replacement unit is used to replace the to-be-out data in the second cache data with the written data.
[0099] The working principles of each module in the data writing control system of this embodiment are the same as the principles of each step in the above method embodiment, and will not be repeated here.
[0100] Each module in the above data writing control system can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the terminal in the form of hardware, or can be stored in the memory in the terminal in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0101] Based on the above embodiment, the present invention further provides a terminal, the principle block diagram of the terminal can be as follows: Figure 3 The terminal may include one or more processors 100 ( Figure 3Only one is shown in the figure), a memory 101 and a computer program 102 stored in the memory 101 and executable on one or more processors 100, for example, a sleep analysis program based on multi-sensor data. When one or more processors 100 execute the computer program 102, the various steps in the embodiment of the sleep analysis method based on multi-sensor data can be implemented. Alternatively, when one or more processors 100 execute the computer program 102, the functions of various modules / units in the embodiment of the sleep analysis system based on multi-sensor data can be implemented, which is not limited here.
[0102] In one embodiment, the processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (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.
[0103] In one embodiment, the memory 101 may be an internal storage unit of an electronic device, such as a hard disk or memory of the electronic device. The memory 101 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 101 may also include both an internal storage unit of the electronic device and an external storage device. The memory 101 is used to store computer programs and other programs and data required by the terminal. The memory 101 may also be used to temporarily store data that has been output or is to be output.
[0104] Those skilled in the art will understand that Figure 3 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal to which the scheme of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, operating database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double operational data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention 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. However, 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 invention.
Claims
1. A data writing control method, characterized in that: The method comprises: receiving a data writing request, and determining a request terminal corresponding to the data writing request; Based on the requesting terminal, determining a request type corresponding to the data write request, the request type including a write-back request or a write-through request, the write-through request is for all data cached on the terminal, and the write-back request is for part of the data cached on the terminal; Acquire write data corresponding to the data write request, and update data based on the request type and the write data; Acquiring write data corresponding to the data write request, and updating data based on the request type and the write data, including: Obtaining write data in the data write request; Acquire first cache data in the buffer memory and second cache data in the preset random access memory, wherein the first cache data and the second cache data constitute all data cached on the terminal; When the request type is a write-through request, the first cache data and the second cache data are updated based on the write data; When the request type is a write-back request, only the first cache data is updated based on the write data; When the request type is a write-through request, updating the first cache data and the second cache data based on the write data includes: Compare the written data with the first cache data of the buffer memory of the terminal and the second cache data of the random access memory of the terminal, respectively, to determine whether the written data has some identical data with the first cache data or the second cache data, and if so, determine the difference data, and update the difference data to the terminal to complete the data update; When determining the difference data, a data type tag is set for the write data, and a data type tag is also set for the first cache data and the second cache data. When the write data is compared with the first cache data of the buffer memory of the terminal and the second cache data of the random access memory of the terminal, it is first determined whether the data type tags are the same. If the data type tags are different, it means that the write data and the first cache data or the second cache data do not have the same data, and the write data is updated as a whole to the terminal. If it is determined that the data type tags are the same, it is then determined whether the data content is the same, and the part with the difference in data content is found to obtain the difference data; Acquiring write data corresponding to the data write request, and updating data based on the request type and the write data, further comprising: When the request type is a write-back request and the updating of the first cache data is completed, obtaining the running status of the data writing process; If the running state is idle, updating the second cache data in the random access memory based on the written data; Acquiring write data corresponding to the data write request, and updating data based on the request type and the write data, further comprising: If the operating state is non-idle, determining the remaining storage capacity of the random access memory; If the remaining storage capacity is greater than or equal to the amount of the written data, determining the data to be output in the second cache data based on the first-in-first-out principle; Replacing the to-be-out data in the second cache data with the written data; When multiple clients send data write requests at the same time, each data write request is analyzed respectively, and the request type corresponding to each data write request is determined. If a write-through request and a write-back request exist at the same time, the first cache data in the buffer memory is updated first; When processing a direct write request, first ensure that the first cache data in the buffer memory is updated. For the update of the second cache data in the random access memory, a mapping synchronization method is adopted to map the write data from the buffer memory to the random access memory so that the write data is updated to the random access memory data. When processing a write-back request, it is only necessary to ensure that the first cache data in the buffer memory is updated. As for whether the write-back request updates the second cache data in the random access memory, an importance label is set for the write data in advance. When it is determined based on the importance label that the importance of the write data is high, the second cache data in the random access memory is updated. Otherwise, it is chosen not to update the second cache data in the random access memory.
2. The data writing control method according to claim 1, characterized in that: Receiving a data writing request and determining a request terminal corresponding to the data writing request includes: Receiving a data writing request, parsing the data writing request, and obtaining device information carried in the data writing request; Based on the device information, the requesting terminal is determined.
3. The data writing control method according to claim 2, characterized in that: Before receiving a data writing request and determining a request terminal corresponding to the data writing request, the method includes: Pre-acquire device information of the requesting terminal; The data write request is generated based on the device information and the write data.
4. The data writing control method according to claim 3, characterized in that: Determining, based on the request terminal, a request type corresponding to the data write request, including: Acquire tag information corresponding to the requesting terminal, wherein the tag information is used to mark the write data of the data write request; Determine a write type of the write data based on the tag information, the write type including write-through write or write-back write; Based on the write type, the request type is determined.
5. A data writing control system, characterized in that: The system is used to implement the steps of the data writing control method according to any one of claims 1 to 4, and the system comprises: A request terminal determination module, used for receiving a data writing request and determining a request terminal corresponding to the data writing request; A request type determination module, used to determine the request type corresponding to the data write request based on the request terminal, the request type including a write-back request or a write-through request; The data update module is used to obtain the write data corresponding to the data write request, and update based on the request type and the write data.
6. A terminal, characterized in that: The terminal includes a memory, a processor, and a data writing control program stored in the memory and running on the processor. When the processor executes the data writing control program, the steps of the data writing control method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data writing control program, and when the data writing control program is executed by the processor, the steps of the data writing control method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Data synchronization method and device, equipment and storage medium
CN115510161A
Programmable Address-Based Write-Through Cache Control
US20120198164A1
Method and device using a redundant cache for preventing the loss of dirty data
US5895485A