A method and device for updating data in a storage area and a computer-readable storage medium
By dividing the to-processed data into the first and second bit areas, and modifying and computing the data bits based on the flag bits, the problems of low update density and long storage time in the BIOS ROM data storage method are solved, and more efficient data storage and update are achieved.
Patent Information
- Application Number
- CN202111161476.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-09-30
AI Technical Summary
In the prior art, the data storage method of BIOS ROM has a low data update density, and it takes a long time to store data, and increases the probability of data loss.
By dividing the to-processed data into a first bit area and a second bit area, the flag bit is determined based on the processing request, and the data bits corresponding to the flag bit in the second bit area are sequentially changed, and the target data is obtained by performing operations on the data of the flag bit and the data bit.
This increases the density of data updates, shortens the time required to store data, and reduces the probability of data loss.
Smart Images

Figure CN113849134B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to information verification technology in the computer field, and in particular to a data updating method and device for a storage area and a computer-readable storage medium. Background Art
[0002] At present, the Basic Input Output System (BIOS) system stores Unified Extensible Firmware Interface (UEFI) data; and UEFI data is generally stored in a designated area of the BIOS memory Read-Only Memory (ROM). Due to the inherent characteristics of the BIOS ROM, data cannot be stored in situ, but is stored using a chain data structure. In addition to storing the data that must be updated, additional storage is required to indicate the identifier and name of the data; and there is also an erase and write action during the storage process; therefore, this storage method in the related art will reduce the effective density of data updates, increase the probability of BIOS ROM data loss, and require a longer time to store data. Summary of the invention
[0003] The embodiments of the present application are intended to provide a method, device and computer-readable storage medium for updating data in a storage area, which solve the problems in the data storage method in the related art that the data update density is low and the time required to store data is long, and reduce the probability of data loss.
[0004] The technical solution of this application is implemented as follows:
[0005] A method for updating data in a storage area, applied to a memory, the method comprising:
[0006] Get the data to be processed in the storage area;
[0007] Dividing the data to be processed into data in a first bit area and data in a second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area;
[0008] determining a flag bit in the first bit region based on a processing request for processing the data to be processed;
[0009] The data bits corresponding to the flag bits in the second bit area are changed in sequence, and the target data are obtained by operating the data of the flag bits and the data of the data bits.
[0010] In the above solution, the step of dividing the data to be processed into data in the first bit area and data in the second bit area includes:
[0011] According to a target counting mechanism, the data to be processed is divided into data in the first bit area and data in the second bit area; wherein, when the target counting mechanism represents that the values of the data on the bits in the data to be processed are all first values, the initial value of the data to be processed is the first value; when the values of the data on the bits in the data to be processed include the first value and the second value, the initial value of the data to be processed is the second value.
[0012] In the above solution, the determining the flag bit in the first bit area based on the processing request for processing the data to be processed includes:
[0013] Determine, based on the processing request, a value of each bit in the data of the first bit region;
[0014] The flag bit is determined from the first bit region based on a value of each bit in the data of the first bit region.
[0015] In the above scheme, sequentially changing the data bits corresponding to the flag bits in the second bit area and obtaining the target data by operating the data of the flag bits and the data bits includes:
[0016] Based on the flag bit data, sequentially determining data bits in the second bit region;
[0017] The value of the data of the data bit in the second bit area is changed, and the target data is obtained by operating the data of the flag bit and the data of the data bit.
[0018] In the above scheme, the step of changing the value of the data bit in the second bit area and obtaining the target data by performing a target operation on the data of the flag bit and the data bit includes:
[0019] Based on the target data, changing the value of the data of the data bit in the second bit area;
[0020] A target operation is performed on the data of the flag bit and the data of the data bit to obtain the target data.
[0021] In the above scheme, the step of changing the value of the data bit in the second bit area and obtaining the target data by performing a target operation on the data of the flag bit and the data bit includes:
[0022] In the case where the to-be-processed data is modified from a first value to a second value of the target data, based on the data of the flag bit and the data of the data bit, the value of the data of the data bit is modified to the second value;
[0023] A target operation is performed on the data of the flag bit and the updated data of the data bit to modify the data to be processed from a first value to a second value of the target data.
[0024] In the above scheme, the step of changing the value of the data bit in the second bit area and obtaining the target data by performing a target operation on the data of the flag bit and the data bit includes:
[0025] In the case where the data to be processed is modified from the second value to the first value of the target data, based on the data of the flag bit and the data of the data bit, the value of the data of the flag bit is modified to the second value, and the data of the first bit area is updated;
[0026] Determine the data of the updated flag bit from the updated data of the first bit area, and based on the updated data of the flag bit, change the data of the data bit corresponding to the flag bit in the data of the second bit area to obtain the data of the updated data bit;
[0027] A target operation is performed on the data of the updated flag bit and the data of the updated data bit to modify the data to be processed from the second value to the first value of the target data.
[0028] In the above solution, the storage area may be a storage area of a memory in a target system of the electronic device; wherein the target system includes a system whose corresponding memory has the property of being difficult to erase but easy to write.
[0029] An electronic device, comprising: a processor, a memory and a communication bus;
[0030] The communication bus is used to realize the communication connection between the processor and the memory;
[0031] The processor is used to execute a data update program of a storage area in the memory to implement the following steps:
[0032] Get the data to be processed in the storage area;
[0033] Dividing the data to be processed into data in a first bit area and data in a second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area;
[0034] determining a flag bit in the first bit region based on a processing request for processing the data to be processed;
[0035] The data bits corresponding to the flag bits in the second bit area are changed in sequence, and the target data are obtained by operating the data of the flag bits and the data of the data bits.
[0036] A computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the data updating method of the storage area described above.
[0037] The data updating method, device and computer-readable storage medium of the storage area provided in the embodiments of the present application obtain the data to be processed in the storage area, divide the data to be processed into data in the first bit area and data in the second bit area, each bit in the first bit area has a one-to-one correspondence with the bit in the second bit area, determine the flag bit in the first bit area based on the processing request for processing the data to be processed, change the data bits corresponding to the flag bit in the second bit area in sequence, and obtain the target data by operating the data of the flag bit and the data of the data bit. In this way, by dividing the data to be processed into data in the first bit area and the second bit area, and modifying the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area, the data of the two bits can be operated to realize the processing of the data to be processed, without the need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of a flow chart of a method for updating data in a storage area provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a flow chart of another method for updating data in a storage area provided in an embodiment of the present application;
[0040] Figure 3 A schematic flow chart of another method for updating data in a storage area provided in an embodiment of the present application;
[0041] Figures 4a to 4c A schematic diagram of a data structure of first bit area data, second bit area data and target data in a data updating method for a storage area provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of a comparison of data structures for data modification provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of a data structure for data modification in a method for updating data in a storage area provided in an embodiment of the present application;
[0044] Figure 7A schematic diagram of a data structure for data modification in another method for updating data in a storage area provided by an embodiment of the present application;
[0045] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0046] Fig. 9 A schematic diagram of the structure of a data updating device for a storage area provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0048] It should be understood that the "embodiments of the present application" or "the aforementioned embodiments" mentioned throughout the specification mean that specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, "in the embodiments of the present application" or "in the aforementioned embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0049] Unless otherwise specified, the electronic device performs any step in the embodiments of the present application, and the processor of the electronic device may perform the step. It is also worth noting that the embodiments of the present application do not limit the order in which the electronic device performs the following steps. In addition, the methods used to process data in different embodiments may be the same method or different methods. It should also be noted that any step in the embodiments of the present application can be independently executed by the electronic device, that is, when the electronic device executes any step in the following embodiments, it may not rely on the execution of other steps.
[0050] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] The embodiment of the present application provides a method for updating data in a storage area, the method is applied to a memory, referring to Figure 1 As shown, the method comprises the following steps:
[0052] Step 101: Obtain the data to be processed in the storage area.
[0053] The data to be processed may be data with a target even number of bits or data with an odd number of bits.
[0054] In the embodiment of the present application, the storage area may be a certain area of the memory of the target system whose corresponding memory of the electronic device has the characteristics of being difficult to erase but easy to write; the data to be processed may be data in the target system. In a feasible implementation, the data to be processed may be stored in the storage area of the electronic device according to a target counting mechanism with an even number of bits.
[0055] Step 102: Divide the data to be processed into data in the first bit area and data in the second bit area.
[0056] Among them, each bit in the first bit area has a one-to-one correspondence with the bit in the second bit area. It should be noted that if the number of bits included in the data to be processed is an even number of bits, then each bit in the first bit area corresponds to each bit in the second bit area one-to-one; if the number of bits included in the data to be processed is an odd number of bits, then when dividing the data to be processed, the number of bits in the second bit area is one more than the number of bits in the first bit area, and when the data to be processed is subsequently processed, the highest bit in the second bit area can be discarded, then each bit in the first bit area corresponds to each remaining bit in the second bit area one-to-one.
[0057] In an embodiment of the present application, when the data to be processed is divided, it can be divided according to the principle of equal distribution; and the data in the first bit area and the data in the second bit area are respectively continuous in the data to be processed, and each bit in the first bit area has a corresponding correlation relationship with each bit in the second bit area.
[0058] Step 103: Determine a flag bit in the first bit area based on a processing request for processing the data to be processed.
[0059] The flag bit is used to indicate which bit in the second bit area is used to modify the data to be processed and determine the value of the target data finally obtained. That is, after receiving a processing request for processing the data to be processed, the first bit area of the data to be processed can be analyzed in response to the processing request to determine the flag bit in the first bit area. It should be noted that the processing request can be a request for modifying the data to be processed.
[0060] Step 104: sequentially change the data bits corresponding to the flag bits in the second bit area, and obtain target data by operating the data of the flag bits and the data bits.
[0061] In an embodiment of the present application, the data bit is a bit in the second bit area corresponding to the bit where the flag bit is located; when obtaining the target data, the data of the data bit in the second bit area can be modified starting from the data bit in bit order, and then the data of the modified data bit and the data of the flag bit are operated to obtain the target data; it should be noted that operating on the data of the flag bit and the data bit can refer to performing an AND operation or an OR operation on the data of the flag bit and the data bit.
[0062] The data updating method of the storage area provided in the embodiment of the present application divides the data to be processed into data in the first bit area and the second bit area, and modifies the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area. After the two bits of data are operated, the processing of the data to be processed can be realized, and there is no need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss.
[0063] The embodiment of the present application provides a method for updating data in a storage area. Figure 2 As shown, the method may include the following steps:
[0064] Step 201: The electronic device obtains data to be processed in a storage area.
[0065] In an embodiment of the present application, the storage area may be a storage area of a memory in a target system of the electronic device; wherein the target system includes a system in which the corresponding memory has the property of being difficult to erase but easy to write.
[0066] In a feasible implementation, the target system may refer to a BIOS system, the data to be processed may refer to UEFI data in the BIOS system, and the storage area may refer to a storage area in a BIOS ROM.
[0067] Step 202: The electronic device divides the data to be processed into data in the first bit area and data in the second bit area according to the target counting mechanism.
[0068] Among them, the number of bits included in the data in the first bit area and the data in the second bit area is the same; each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area; when the target counting mechanism represents that the values of the data on the bits in the data to be processed are all first values, the initial value of the data to be processed is the first value; when the values of the data on the bits in the data to be processed include the first value and the second value, the initial value of the data to be processed is the second value.
[0069] In the embodiment of the present application, if the data to be processed has 16 bits, the first bit area can be the upper 8 bits and the second bit area can be the lower 8 bits; if the data to be processed has 32 bits, the first bit area can be the upper 16 bits and the second bit area can be the lower 16 bits. The target counting mechanism can refer to that if the value of the data on all bits of the data to be processed is a certain value, then the initial value of the data represented by the data to be processed is a certain value.
[0070] Step 203: The electronic device determines the value of each bit in the data of the first bit area based on the processing request.
[0071] The electronic device may respond to the processing request, analyze the data in the first bit area of the data to be processed, and obtain the value of the data on each bit in the first bit area.
[0072] Step 204: The electronic device determines a flag bit from the first bit area based on the value of each bit in the data of the first bit area.
[0073] In an embodiment of the present application, the value of each bit of data in the first bit area can be analyzed to determine the flag bit; in a feasible implementation method, starting from the lowest bit of data in the first bit area, the bit whose corresponding bit data in the first bit area is 1 can be determined as the flag bit.
[0074] Step 205: The electronic device determines the data bits in the second bit area in order based on the flag bit data.
[0075] In an embodiment of the present application, if the value of the data of the flag bit is 1 and the flag bit is located at the lowest bit, then the corresponding lowest bit in the second bit area is determined to be the data bit; of course, if the value of the data of the flag bit is 1 and the flag bit is located at the second to last lowest bit, then the corresponding second to last lowest bit in the second bit area is determined to be the data bit.
[0076] Step 206: The electronic device changes the value of the data bit in the second bit area, and obtains the target data by performing operations on the data of the flag bit and the data bit.
[0077] In the embodiment of the present application, the data of the flag bit cannot be modified, and the data of the first bit area cannot be modified; however, the position of the flag bit in the first bit area can be changed according to the different data to be processed. When modifying the data to be processed, the value of the data bit in the second bit area can be changed, and then the value of the modified data bit and the value of the flag bit are AND / ORed to obtain the target data.
[0078] Wherein, step 206 can be implemented in the following manner:
[0079] Step 206a: The electronic device changes the value of the data bit in the second bit area based on the target data.
[0080] In the embodiment of the present application, the value of the data bit in the second bit area may be changed according to the change between the value of the target data and the value of the data to be processed.
[0081] Step 206b: The electronic device performs a target operation on the data of the flag bit and the data of the data bit to obtain target data.
[0082] In the embodiment of the present application, when modifying the value of the data bit, the value of the data can only be modified from 0 to 0, but the value of the data cannot be modified from 1 to 0.
[0083] In the embodiment of the present application, a specific description is given by taking the case where the data to be processed includes an even number of bits as an example.
[0084] It should be noted that the explanation and description of the same or corresponding steps in the embodiments of the present application can refer to the description in other embodiments and will not be repeated here.
[0085] The data updating method of the storage area provided in the embodiment of the present application divides the data to be processed into data in the first bit area and the second bit area, and modifies the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area. After the two bits of data are operated, the processing of the data to be processed can be realized without the need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss.
[0086] Based on the above embodiments, the embodiments of the present application provide a method for updating data in a storage area. Figure 3 As shown, the method comprises the following steps:
[0087] Step 301: The electronic device obtains data to be processed in a storage area.
[0088] Step 302: The electronic device divides the data to be processed into data in the first bit area and data in the second bit area according to the target counting mechanism.
[0089] The data in the first bit area and the data in the second bit area include the same number of bits; each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area.
[0090] In a feasible implementation, the data to be processed has 61 bits as an example: when the value of the data to be processed is 1, it can be as follows Figure 4aAs shown in , the value of each bit in the data to be processed is 1; the first bit area may be the upper 8 bits of the data to be processed, and the second bit area may be the lower 8 bits of the data to be processed.
[0091] Step 303: The electronic device determines the value of each bit in the data in the first bit area based on the processing request.
[0092] Step 304: The electronic device determines a flag bit from the first bit area based on the value of each bit in the data of the first bit area.
[0093] Step 305: The electronic device determines the data bits in the second bit area in order based on the flag bit data.
[0094] In the embodiments of the present application, Figure 4a As shown in the figure, the flag bit determined can be the first data bit with a value of 1 from the lowest bit in the first bit area, that is, the lowest bit in the first bit area is the flag bit; in this case, the data bit determined is the lowest bit in the second bit area. And if no modification is made to the data to be processed, the value of the target data obtained after the target operation is still 1
[0095] It should be noted that after step 305, steps 306 to 307 or steps 308 to 310 may be executed;
[0096] Step 306: When the electronic device modifies the to-be-processed data from the first value to the second value of the target data, based on the data of the flag bit and the data of the data bit, the value of the data bit is modified to the second value.
[0097] It should be noted that the first value may refer to 1, and the second value may refer to 0; then, the value of the data bit may be modified from the first value to the second value, that is, from 1 to 0; Figure 4b As shown in , the value of the last bit of data in the second bit area can be modified from the initial 1 to 0.
[0098] Step 307: The electronic device performs a target operation on the data of the flag bit and the data of the updated data bit to modify the data to be processed from the first value to the second value of the target data.
[0099] In the embodiment of the present application, the data of the flag bit and the data of the updated data bit can be AND / ORed to obtain the target data; wherein the value obtained after the AND / ORed operation of the data of the flag bit and the data of the updated data bit is the value of the target data. In a feasible implementation, if Figure 4bAs shown, the target operation refers to an AND operation, so after the data of the flag bit and the data of the updated data bit are ANDed, the value obtained is 0, and the value of the target data is also 0; that is, the data to be processed is successfully modified from 1 to 0.
[0100] Step 308: When the electronic device modifies the data to be processed from the second value to the first value of the target data, based on the data of the flag bit and the data of the data bit, the value of the flag bit data is modified to the second value, and the data of the first bit area is updated.
[0101] It should be noted that the first value may refer to 1, and the second value may refer to 0; then, the value of the data bit may be modified from the second value to the first value, that is, from 0 to 1; Figure 4c As shown in , the first 15 bits of the initial value of the data to be processed are all 1, and the lowest bit is 0; at this time, the value of the original flag bit data in the first bit area can be modified from the initial 1 to 0.
[0102] Step 309: The electronic device determines the updated flag bit data from the updated data in the first bit area, and based on the updated flag bit data, changes the data bit corresponding to the flag bit in the second bit area to obtain the updated data bit data.
[0103] In the embodiment of the present application, after the data in the first bit area is modified, an updated flag bit can be determined from the first bit area based on the value of the modified data in the first bit area, and an updated data bit in the second bit area can be determined based on the updated flag bit, and then the updated data bit can be modified. In a feasible implementation, as Figure 4c As shown, the second to last bit in the first bit area (that is, the bit with a data value of 1 from the lowest) can be determined as the updated flag bit; then the second to last bit in the second bit area can be determined as the updated data bit; because the data to be processed needs to be modified from 0 to 1, and the data bit of the updated flag bit is 1, then the value of the updated data bit needs to be modified to 1.
[0104] Step 310: The electronic device performs a target operation on the data of the updated flag bit and the data of the updated data bit to modify the data to be processed from the second value to the first value of the target data.
[0105] In the embodiment of the present application, the data of the updated flag bit and the data of the updated data bit can be AND / ORed to modify the data to be processed from the second value to the first value; wherein the value obtained after the AND / ORed operation of the data of the updated flag bit and the data of the updated data bit is the value of the target data. In a feasible implementation, if Figure 4cAs shown, the target operation refers to an AND operation, so after the updated flag bit data and the updated data bit data are ANDed, the value obtained is 1, and the value of the target data is 0; that is, the data to be processed is successfully modified from 0 to 1.
[0106] In the embodiment of the present application, Figure 5 When modifying the data of DATA0 shown in Figure 6 As shown in FIG. 1 , a chain data structure needs to be stored; and after adopting the data updating method of the storage area provided in the embodiment of the present application, the following can be done: Figure 5 The corresponding processing of the data can be achieved directly as indicated in the figure; obviously, Figure 6 In the example, three fields need to be copied repeatedly to update DATA0 to DATA1 and DATA2 accordingly; however, Figure 7 As shown in , in the embodiment of the present application, the entire field where DATA1 and DATA2 are located is a redundant field, and the entire field where these two fields are located is no longer needed. Only the field where DATA0 is located can be used to update the data from DATA0 to DATA1 and DATA2, thereby avoiding unnecessary waste of the storage area, and also avoiding the loss of user settings, and not increasing the startup time.
[0107] In the embodiment of the present application, a specific description is given by taking the case where the data to be processed includes an even number of bits as an example.
[0108] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.
[0109] The data updating method of the storage area provided in the embodiment of the present application divides the data to be processed into data in the first bit area and the second bit area, and modifies the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area. After the two bits of data are operated, the processing of the data to be processed can be realized without the need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss.
[0110] Based on the above embodiments, the embodiments of the present application provide an electronic device, which can be applied to Figures 1 to 3 In the data updating method of the storage area provided in the corresponding embodiment, refer to Figure 8 As shown, a processor 41, a memory 42 and a communication bus 43;
[0111] The communication bus 43 is used to realize the communication connection between the processor 41 and the memory 42;
[0112] The processor 41 is used to execute the data update program of the storage area in the memory 42 to implement the following steps:
[0113] Get the data to be processed in the storage area;
[0114] Dividing the data to be processed into data in the first bit area and data in the second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area;
[0115] determining a flag bit in the first bit area based on a processing request for processing the data to be processed;
[0116] The data bits corresponding to the flag bits in the second bit area are changed in sequence, and the target data are obtained by operating the data of the flag bits and the data of the data bits.
[0117] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 to divide the data to be processed into data in the first bit area and data in the second bit area, so as to implement the following steps:
[0118] According to a target counting mechanism, the data to be processed is divided into data in a first bit area and data in a second bit area; wherein, when the target counting mechanism represents that the values of the data on the bits in the data to be processed are all first values, the initial value of the data to be processed is the first value; when the values of the data on the bits in the data to be processed include the first value and the second value, the initial value of the data to be processed is the second value.
[0119] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 based on the processing request for processing the data to be processed, and determine the flag bit in the first bit area to implement the following steps:
[0120] Determine, based on the processing request, a value of each bit in the data of the first bit area;
[0121] Based on the value of each bit in the data of the first bit area, a flag bit is determined from the first bit area.
[0122] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 to sequentially change the data bits corresponding to the flag bits in the second bit area, and obtain the target data by operating the data of the flag bit and the data bit, so as to implement the following steps:
[0123] Based on the flag bit data, sequentially determining the data bits in the second bit region;
[0124] The value of the data bit in the second bit area is changed, and the target data is obtained by operating the data of the flag bit and the data bit.
[0125] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 to change the value of the data bit in the second bit area, and obtain the target data by operating the data of the flag bit and the data bit, so as to implement the following steps:
[0126] Based on the target data, changing the value of the data of the data bit in the second bit region;
[0127] A target operation is performed on the data of the flag bit and the data of the data bit to obtain the target data.
[0128] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 to change the value of the data bit in the second bit area, and obtain the target data by operating the data of the flag bit and the data bit, so as to implement the following steps:
[0129] In the case of modifying the data to be processed from the first value to the second value of the target data, based on the data of the flag bit and the data of the data bit, modifying the value of the data of the data bit to the second value;
[0130] A target operation is performed on the data of the flag bit and the data of the updated data bit to modify the data to be processed from a first value to a second value of the target data.
[0131] In other embodiments of the present application, the processor 41 is used to execute the data update program of the storage area in the memory 42 to change the value of the data bit in the second bit area, and obtain the target data by operating the data of the flag bit and the data bit, so as to implement the following steps:
[0132] In the case of modifying the data to be processed from the second value to the first value of the target data, based on the data of the flag bit and the data of the data bit, modifying the value of the data of the flag bit to the second value, and updating the data of the first bit area;
[0133] Determine the data of the updated flag bit from the data of the updated first bit area, and based on the data of the updated flag bit, change the data of the data bit corresponding to the flag bit in the data of the second bit area to obtain the data of the updated data bit;
[0134] A target operation is performed on the data of the updated flag bit and the data of the updated data bit to modify the data to be processed from the second value to the first value of the target data.
[0135] In other embodiments of the present application, the storage area may be a storage area of a memory in a target system of the electronic device; wherein the target system includes a system in which the corresponding memory has the property of being difficult to erase but easy to write.
[0136] It should be noted that the specific implementation process of the steps executed by the processor in this embodiment can refer to Figures 1 to 3 The implementation process of the data updating method of the storage area provided in the corresponding embodiment will not be repeated here.
[0137] The electronic device provided by the embodiment of the present application divides the data to be processed into data in the first bit area and the second bit area, and modifies the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area. After the two bits of data are operated, the processing of the data to be processed can be realized without the need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss.
[0138] Based on the above embodiments, the embodiments of the present application provide a data updating device for a storage area, which can be applied to Figures 1 to 3 The corresponding embodiment provides a method for updating data in a storage area, referring to Fig. 9 As shown, the device may include: an acquisition unit 51, a division unit 52, a determination unit 53 and a processing unit 54, wherein:
[0139] An acquisition unit 51 is used to acquire the data to be processed in the storage area;
[0140] A division unit 52, used for dividing the data to be processed into data in the first bit area and data in the second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area;
[0141] A determining unit 53, configured to determine a flag bit in the first bit area based on a processing request for processing the data to be processed;
[0142] The processing unit 54 is used to sequentially change the data bits corresponding to the flag bits in the second bit area, and obtain the target data by operating the data of the flag bits and the data bits.
[0143] In other embodiments of the present application, the division unit 52 is also used to divide the data to be processed into data in the first bit area and data in the second bit area according to a target counting mechanism; wherein the target counting mechanism represents that when the values of the data on the bits in the processed data are all first values, the initial value of the data to be processed is the first value; when the values of the data on the bits in the data to be processed include the first value and the second value, the initial value of the data to be processed is the second value.
[0144] In other embodiments of the present application, the determining unit 53 is further configured to perform the following steps:
[0145] Determine, based on the processing request, a value of each bit in the data of the first bit area;
[0146] Based on the value of each bit in the data of the first bit area, a flag bit is determined from the first bit area.
[0147] In other embodiments of the present application, the processing unit 54 is further configured to perform the following steps:
[0148] Based on the flag bit data, sequentially determining the data bits in the second bit region;
[0149] The value of the data bit in the second bit area is changed, and the target data is obtained by operating the data of the flag bit and the data bit.
[0150] In other embodiments of the present application, the processing unit 54 is further configured to perform the following steps:
[0151] Based on the target data, changing the value of the data of the data bit in the second bit region;
[0152] A target operation is performed on the data of the flag bit and the data of the data bit to obtain the target data.
[0153] In other embodiments of the present application, the processing unit 54 is further configured to perform the following steps:
[0154] In the case of modifying the data to be processed from the first value to the second value of the target data, based on the data of the flag bit and the data of the data bit, modifying the value of the data of the data bit to the second value;
[0155] A target operation is performed on the data of the flag bit and the data of the updated data bit to modify the data to be processed from a first value to a second value of the target data.
[0156] In other embodiments of the present application, the processing unit 54 is further configured to perform the following steps:
[0157] In the case of modifying the data to be processed from the second value to the first value of the target data, based on the data of the flag bit and the data of the data bit, modifying the value of the data of the flag bit to the second value, and updating the data of the first bit area;
[0158] Determine the data of the updated flag bit from the data of the updated first bit area, and based on the data of the updated flag bit, change the data of the data bit corresponding to the flag bit in the data of the second bit area to obtain the data of the updated data bit;
[0159] A target operation is performed on the data of the updated flag bit and the data of the updated data bit to modify the data to be processed from the second value to the first value of the target data.
[0160] In other embodiments of the present application, the storage area may be a storage area of a memory in a target system of the electronic device; wherein the target system includes a system in which the corresponding memory has the property of being difficult to erase but easy to write.
[0161] It should be noted that the specific implementation process of the steps performed by each unit in this embodiment can refer to Figures 1 to 3 The implementation process of the data updating method of the storage area provided in the corresponding embodiment will not be repeated here.
[0162] The data updating device of the storage area provided in the embodiment of the present application divides the data to be processed into data in the first bit area and the second bit area, and modifies the data in the second bit area corresponding to the flag bit in sequence based on the flag bit determined in the first bit area. After the two bits of data are operated, the processing of the data to be processed can be realized without the need for chain data structure storage, thereby solving the problems of low data update density and long time required for data storage in the data storage method in the related art, and reducing the probability of data loss.
[0163] Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the following. Figures 1 to 3 The corresponding embodiment provides steps of a method for updating data in a storage area.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for updating data in a storage area, applied to a memory, the method comprising: Get the data to be processed in the storage area; Dividing the data to be processed into data in a first bit area and data in a second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area; determining a flag bit in the first bit region based on a processing request for processing the data to be processed; The data bits in the second bit area corresponding to the flag bit are changed in sequence, and the target data is obtained by operating the data of the flag bit and the data of the data bit.
2. The method according to claim 1, wherein dividing the data to be processed into data in the first bit area and data in the second bit area comprises: According to a target counting mechanism, the data to be processed is divided into data in the first bit area and data in the second bit area; wherein, when the target counting mechanism represents that the values of the data on the bits in the data to be processed are all first values, the initial value of the data to be processed is the first value; when the values of the data on the bits in the data to be processed include the first value and the second value, the initial value of the data to be processed is the second value.
3. The method according to claim 1, wherein determining the flag bit in the first bit area based on the processing request for processing the data to be processed comprises: Determine, based on the processing request, a value of each bit in the data of the first bit region; The flag bit is determined from the first bit region based on a value of each bit in the data of the first bit region.
4. The method according to claim 1, wherein the step of sequentially changing the data bits in the second bit area corresponding to the flag bit and obtaining the target data by operating the data of the flag bit and the data of the data bit comprises: Based on the flag bit data, sequentially determining data bits in the second bit region; The value of the data of the data bit in the second bit area is changed, and the target data is obtained by operating the data of the flag bit and the data of the data bit.
5. The method according to claim 4, wherein the step of changing the value of the data bit in the second bit area and obtaining the target data by performing a target operation on the data of the flag bit and the data bit comprises: In the case where the to-be-processed data is modified from a first value to a second value of the target data, based on the data of the flag bit and the data of the data bit, the value of the data of the data bit is modified to the second value; A target operation is performed on the data of the flag bit and the updated data of the data bit to modify the data to be processed from a first value to a second value of the target data.
6. The method according to claim 4, wherein the step of changing the value of the data bit in the second bit area and obtaining the target data by performing a target operation on the data of the flag bit and the data bit comprises: In the case where the data to be processed is modified from the second value to the first value of the target data, based on the data of the flag bit and the data of the data bit, the value of the data of the flag bit is modified to the second value, and the data of the first bit area is updated; Determine the data of the updated flag bit from the updated data of the first bit area, and based on the updated data of the flag bit, change the data of the data bit corresponding to the flag bit in the data of the second bit area to obtain the data of the updated data bit; A target operation is performed on the data of the updated flag bit and the data of the updated data bit to modify the data to be processed from the second value to the first value of the target data.
7. The method according to claim 1, wherein the storage area may be a storage area of a memory in a target system of an electronic device; wherein The target system includes a system whose corresponding memory has the property of being difficult to erase but easy to write.
8. An electronic device, comprising: processor, memory, and communications bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute a data update program of a storage area in the memory to implement the following steps: Get the data to be processed in the storage area; Dividing the data to be processed into data in a first bit area and data in a second bit area; wherein each bit in the first bit area has a one-to-one correspondence with each bit in the second bit area; determining a flag bit in the first bit region based on a processing request for processing the data to be processed; The data bits in the second bit area corresponding to the flag bit are changed in sequence, and the target data is obtained by operating the data of the flag bit and the data of the data bit.
9. A computer-readable storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the steps of the storage area data update method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Program, encoding device, and encoding method
CN105594129A
Data storage system and data read-write method based on same
CN105653208A