WO2022057872A1 - Data processing method and related apparatus - Google Patents

Data processing method and related apparatus Download PDF

Info

Publication number
WO2022057872A1
WO2022057872A1 PCT/CN2021/118918 CN2021118918W WO2022057872A1 WO 2022057872 A1 WO2022057872 A1 WO 2022057872A1 CN 2021118918 W CN2021118918 W CN 2021118918W WO 2022057872 A1 WO2022057872 A1 WO 2022057872A1
Authority
WO
WIPO (PCT)
Prior art keywords
check code
interval
terminal
address
address interval
Prior art date
Application number
PCT/CN2021/118918
Other languages
French (fr)
Chinese (zh)
Inventor
关楠
陈秋林
于洋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022057872A1 publication Critical patent/WO2022057872A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's

Definitions

  • the present application relates to the field of computer technology, and in particular, to a data processing method and related apparatus.
  • the warning voltage threshold is usually set as A higher voltage value is likely to cause the IoT device to stop running when there is more power remaining, which affects the real-time response performance of the IoT device.
  • the present application provides a data processing method and related device.
  • the check code of the address range used by the program segment is calculated, and based on the check code and the entire program
  • the check code of other address ranges in the used address range determines the total check code of the address range used by the program, and there is no need to calculate the check code for the entire address range where the data is stored, thereby reducing the time required to calculate the check code.
  • Energy consumption and time enable the terminal to run continuously and ensure the real-time response performance of the terminal.
  • a first aspect of the present application provides a data processing method, which is applied to a terminal that works intermittently, that is, a terminal that works intermittently in the case of frequent power failures.
  • the method may include: the terminal executes a first program segment, where the first program segment may be one of multiple program segments of an application program. During the execution of the first program segment by the terminal, the terminal needs to use and modify the data in the first address interval. After executing the first program segment, the terminal calculates the first check code corresponding to the first address interval, for example, the first check code is calculated based on a cyclic redundancy check (Cyclic Redundancy Check, CRC) operation.
  • CRC Cyclic Redundancy Check
  • the terminal obtains a second check code corresponding to a second address interval, where the second address interval is an address interval other than the first address interval in the third address interval, and the third address interval is for executing the program to which the first program segment belongs.
  • the address range used when the second check code can be calculated when the terminal finishes executing other program segments. Since the third address interval is composed of the first address interval and the second address interval, the terminal can determine the third check code corresponding to the third address interval according to the first check code and the second check code.
  • the terminal stores the third check code in the non-volatile memory, where the third check code is used to verify the correctness of the data in the volatile memory after the terminal restores power supply, and the third address interval is located in the volatile memory. in memory.
  • the terminal calculates the check code of the address range used by the program segment after executing the program segment, and based on the check code and the check codes of other address ranges in the address range used by the whole program , the total check code of the address range used by the program can be determined.
  • the terminal no longer needs to calculate the check code for the entire address range where the data is stored, thereby reducing the energy consumption and time for calculating the check code, enabling the terminal to run continuously, and ensuring the real-time response performance of the terminal.
  • the volatile memory may further include a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed, that is, the fourth address The interval is used to back up the data in the third address interval.
  • the third address interval is marked as a working interval
  • the fourth address interval is marked as a backup interval
  • the working interval is an interval used when the program is executed
  • the backup interval is used for backing up data in the working interval.
  • the terminal may copy the data in the third address interval to the third address interval, so as to ensure that the data in the third address interval serving as the working interval is the same as the data in the fourth address interval serving as the backup interval.
  • the data in the address range is the same, and the data in the work range is backed up. In this way, if the terminal is powered off during the execution of the first program segment, the terminal can copy the data in the backup section to the working section after restoring the power supply, so as to restore the data in the working section.
  • obtaining the second check code corresponding to the second address interval by the terminal includes: the terminal calculates the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; The check code corresponding to the four address intervals and the fourth check code determine the second check code.
  • the terminal can determine to obtain the fourth address by calculating the check code of the address range corresponding to the first address range in the fourth address range, and based on the zero-padding property of the check operation and the check code of the fourth address range.
  • the check codes of other address ranges in the range that is, the second check codes corresponding to the second address range.
  • the method further includes: the terminal marks the fourth address interval as a working interval, and marks the third address interval as a backup interval; the terminal marks the third address interval as a backup interval; The data is copied to the fourth address range.
  • the method further includes: the terminal stores the first check code and the second check code in a volatile memory, where the first check code and the second check code are used to restore power supply at the terminal Then, it is compared with the third check code to verify the correctness of the data in the volatile memory. That is to say, after the power supply of the terminal is restored, a new check code can be calculated directly based on the first check code and the second check code in the volatile memory, and the new check code and the new check code can be stored in the NVM. The third check code of the volatile memory is compared to verify whether the data in the volatile memory has an error during the power failure.
  • the verification of the correctness of the data in the volatile memory can be realized, which can save the need to recalculate the data in the volatile memory.
  • the process of data check code saves the time for the terminal to verify the correctness of the data and prolongs the effective operation time of the terminal.
  • the terminal can decide whether to perform data verification according to the actual power-off duration, which avoids performing data verification every time the power is restored, and saves the terminal having to perform data verification. time to prolong the effective operation time of the terminal.
  • the method before the terminal executes the first program segment, the method further includes: executing one or more second program segments according to the voltage of the terminal being higher than the threshold voltage.
  • the second program segment may refer to any other program segment in the program to which the first program segment belongs, and the program may include one or more second program segments.
  • the terminal marks the address range used when executing one or more second program segments. According to the current voltage lower than the threshold voltage, the terminal calculates the check code corresponding to the marked address interval.
  • the terminal when the terminal is at a high battery level, the terminal will only mark the modified address range after executing the program segment; when the terminal is at a low battery level, the terminal will uniformly calculate the check code for the marked address range. In order to reduce the number of times of calculating the check code as much as possible.
  • the method further includes: the terminal periodically stores data in the volatile memory to the non-volatile memory, so as to periodically backup the detection point in the non-volatile memory. In this way, after the terminal restores power supply, when it is determined that the data in the volatile memory is verified incorrectly, the detection point stored in the NVM can be restored to the latest detection point, so as to avoid the terminal repeatedly executing the program frequently.
  • a second aspect of the present application provides a terminal, the terminal includes: a processing unit and an obtaining unit; a processing unit configured to execute a first program segment; and a processing unit configured to calculate a first check code corresponding to a first address interval,
  • the first address interval is the address interval used when executing the first program segment;
  • the obtaining unit is used to obtain the second check code corresponding to the second address interval, and the second address interval is the third address interval except the first address interval
  • the third address interval is the address interval used when executing the program to which the first program segment belongs;
  • the processing unit is also used to determine the third check code according to the first check code and the second check code
  • the third check code is the check code corresponding to the third address interval;
  • the processing unit is also used to store the third check code in the non-volatile memory, and the third check code is used after the terminal restores power supply
  • the correctness of the data in the volatile memory is checked, and the third address range is located in the volatile memory.
  • the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed; wherein, the third address interval is It is marked as a working area, the fourth address area is marked as a backup area, the working area is an area used when the program is executed, and the backup area is used for backing up data in the working area.
  • the processing unit is specifically configured to: calculate the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; Check the code to determine the second check code.
  • the processing unit is further configured to: mark the fourth address interval as a working interval, and mark the third address interval as a backup interval; and copy the data of the third address interval to the fourth address interval.
  • the processing unit is further configured to: store the first check code and the second check code in a volatile memory, and the first check code and the second check code are used to restore power at the terminal Then, it is compared with the third check code to verify the correctness of the data in the volatile memory.
  • the processing unit is further configured to: obtain the power-off duration of the terminal after the power supply of the terminal is restored; if the power-off duration is less than the first duration, determine that the data in the volatile memory is correct; if the power-off duration is correct; If the duration is greater than the first duration and less than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified; if the power-off duration is greater than the second duration, it is determined that the data in the volatile memory is incorrect; wherein, The first duration is shorter than the second duration.
  • the processing unit is further configured to: determine a first address interval corresponding to the first program segment; acquire a check code corresponding to the first address interval, and store the check code corresponding to the first address interval in a volatile According to the check code corresponding to the first address interval, it is determined that the data in the first address interval is correct; based on the correctness of the data in the first address interval, it is determined to execute the first program segment.
  • the processing unit is further configured to: periodically store data in the volatile memory to the non-volatile memory.
  • a fifth aspect of the present application provides a computer program product, which, when executed on a computer, causes the computer to execute the method described in any one of the implementation manners of the first aspect.
  • a sixth aspect of the present application provides a chip including one or more processors. Part or all of the processor is used to read and execute the computer program stored in the memory, so as to execute the method in any possible implementation manner of any of the above aspects.
  • the chip includes a memory, and the memory and the processor are connected to the memory through a circuit or a wire.
  • the chip further includes a communication interface, and the processor is connected to the communication interface.
  • the communication interface is used for receiving data and/or information to be processed, the processor obtains the data and/or information from the communication interface, processes the data and/or information, and outputs the processing result through the communication interface.
  • the communication interface may be an input-output interface.
  • the method provided by the present application may be implemented by one chip, or may be implemented by multiple chips cooperatively.
  • FIG. 1 is a schematic diagram of a backup running state of an Internet of Things device according to an embodiment of the present application
  • FIG. 4 is a schematic diagram of the distribution of another address range provided by an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of terminal operation according to an embodiment of the present application.
  • FIG. 11 is a schematic diagram of the operation of a terminal after power supply is restored according to an embodiment of the present application.
  • the IoT device can collect energy from the operating environment to achieve power supply, such as harvesting energy such as light energy, radio frequency, pressure or thermal energy, and converting these energy into electrical energy.
  • energy harvesting to drive IoT devices can make the deployment of IoT devices highly flexible, reduce the limitations of usage scenarios, and have strong robustness.
  • IoT devices In the case of using energy harvesting to drive IoT devices, because the external energy source is unpredictable and unstable, IoT devices may be powered off frequently, making it difficult for programs in IoT devices to supply power in one A complete execution is completed within the cycle. In order to enable the continuous execution of programs during frequent power outages, intermittent computing is proposed and applied in IoT devices.
  • the IoT device In order to ensure that the IoT device can continue to execute the program in the case of frequent power failure, the IoT device needs to frequently backup the running state on the NVM during the operation process, that is, the value of the register and the variables to be used when the program is executed. to the NVM, so that after a power outage is encountered and power is restored, the operation can be resumed based on the backed-up operating state.
  • NVM Due to the slow write speed and write lifetime of NVM, frequently backing up the running state to NVM will quickly reduce the lifetime of NVM and eventually make IoT devices unusable. Therefore, in order to avoid frequent backup of the running state, a volatile memory is used in the related art to save data, so as to realize that the NVM is not used to backup the running state during a brief power failure.
  • Volatile memory such as SRAM
  • SRAM has faster read and write speed, lower power consumption and longer life than NVM, and has data retention characteristics.
  • a certain threshold usually 1.8V
  • the processor will stop working, and the SRAM can still keep the stored data without errors; as the power supply voltage continues to decrease, when the power supply voltage of the SRAM is low After a lower threshold (usually 0.4V), the data on the SRAM will continue to fail.
  • the power outage time is not very long. Therefore, the data retention feature of SRAM can be used, and the state is not backed up to the NVM during a short power failure, thereby reducing the state backup overhead of the system.
  • the length of time that the SRAM keeps data without errors is uncertain, it is necessary to detect whether the data on the SRAM is erroneous after power is restored.
  • the voltage threshold is set to a higher voltage value, which easily causes the IoT device to stop running when there is more power remaining, which affects the real-time response performance of the IoT device.
  • an embodiment of the present application provides a data processing method.
  • the check code of the address range used by the program segment is calculated, and based on the check code As well as the check codes of other address ranges in the address range used by the whole program, determine the total check code of the data in the volatile memory, and do not need to calculate the check code for the entire address range where the data is stored, thus reducing the calculation
  • the energy consumption and time of the check code enable the terminal to run continuously and ensure the real-time response performance of the terminal.
  • Check perform check operation on the target data, such as Cyclic Redundancy Check (CRC) operation, to obtain the check code of the data.
  • CRC Cyclic Redundancy Check
  • Verification The process of performing a check operation on the target data, and comparing the new check code obtained with the check code obtained by performing the check operation on the target data before to determine whether the target data has changed.
  • CRC A channel coding technology that can generate a fixed-digit check code based on data such as network packets or computer files, which is mainly used to detect errors that may occur after data transmission or storage.
  • CRC has mathematical properties such as linear additivity and zero-padding.
  • Equation 1 The linear additivity of CRC can be expressed as Equation 1:
  • a and B are two independent data
  • the linear additivity of CRC refers to the CRC result after A and B perform XOR operation, which is equal to the result of performing CRC operation on A and B respectively and then XOR operation.
  • Equation 2 The zero-padding property of CRC can be shown in Equation 2:
  • A0...0 means adding n zeros after the data A, that is, shifting the data A to the left by n bits.
  • the zero-padding property of CRC means that the CRC result after a left shift of data by n bits can be directly obtained by multiplying it by a certain coefficient, without having to recalculate the CRC of the entire data.
  • FIG. 2 is a schematic flowchart of a data processing method provided by an embodiment of the present application.
  • an embodiment of the present application provides a data processing method. The method is applied to a terminal that works intermittently. The method may include the following steps.
  • Step 201 the terminal executes the first program segment.
  • one or more application programs may be installed in the terminal, and each application program may include multiple program segments.
  • the application has its corresponding application code, and the terminal implements the running of the application by executing the application code.
  • An application code can be divided into multiple non-repetitive sub-code segments, which can also be called program segments or Atomic Execution Block (AEB).
  • the manner of dividing an application code into multiple program segments may include, but is not limited to, the following manners: acquiring multiple detection points in the application code based on the static detection technology, and separating the application code according to the multiple detection points, That is, the code segment between two adjacent detection points is a program segment; or, if the application code is written based on the task model, one application code can correspond to multiple tasks, and each application code in the application code can correspond to multiple tasks.
  • Each program segment is the subcode segment corresponding to each task.
  • Multiple program segments divided by an application code have a fixed execution sequence, and the terminal can execute the multiple program segments in sequence according to the execution sequence of the multiple program segments during operation.
  • the above-mentioned first program segment may be the program segment currently executed by the terminal.
  • Step 202 the terminal calculates a first check code corresponding to a first address interval, where the first address interval is an address interval used when executing the first program segment.
  • the data that the terminal needs to access is usually located in a fixed address range in the memory. By accessing the address range, the terminal can obtain and modify the data in the address range. This address range can be called the terminal execution program segment. address range used.
  • the address range used by the terminal when executing the program segment is fixed, and the terminal can determine the address range used when executing each program segment. For example, when the program developer pre-specifies the address range corresponding to the program segment, or captures the address range corresponding to each program segment based on the analysis tool in the related art, the terminal can be based on the mapping relationship between the program segment and the address range. , to determine the address range used when executing each program segment.
  • the terminal may determine the first address interval used when executing the first program segment, and after the terminal finishes executing the first program segment, calculate the first check code corresponding to the first address interval. For example, the terminal may calculate the check code corresponding to the data in the first address interval through CRC operation, thereby obtaining the first check code. The terminal may also obtain the first check code by calculating the first check code through other check operation methods, as long as the check operation method has the above-mentioned linear additivity and zero-padding properties, and this embodiment does not calculate the check code for the terminal.
  • the code method is specifically limited. For convenience of description, the following embodiments will be described below by taking the manner in which the terminal obtains the check code based on the CRC operation as an example.
  • Step 203 the terminal obtains the second check code corresponding to the second address interval, the second address interval is the address interval other than the first address interval in the third address interval, and the third address interval is the execution of the first program segment.
  • the address range used in the program is the address range used in the program.
  • each program segment in the terminal has a fixed corresponding address range
  • multiple address ranges corresponding to all the program segments in the same program may constitute the address range corresponding to the program.
  • program A includes program segment A1, program segment A2 and program segment A3, and the three program segments correspond to address interval 1, address interval 2 and address interval 3 respectively; then, the address interval 1, address interval 2 and address interval 3
  • the formed address range 4 is the address range corresponding to the program A.
  • address interval 1, address interval 2 and address interval 3 may be three separate address intervals, for example, the range of address interval 1 is 1-10, the range of address interval 2 is 11-15, and the range of address interval 3 is 16-20, the range of address interval 4 is 1-20.
  • Address interval 1, address interval 2 and address interval 3 may also have overlapping address ranges. For example, the range of address interval 1 is 1-10, the range of address interval 2 is 5-15, and the range of address interval 3 is 10-10. 20, the range of address interval 4 is also 1-20.
  • the terminal may determine the address interval (ie, the third address interval) used when executing the program to which the first program segment belongs, and determine the first address interval according to the third address interval and the first address interval.
  • an address interval other than the first address interval ie, the second address interval. Since the second address interval is the address interval used by the terminal when executing other program segments in the program, when the execution of other program segments is completed, the terminal will also calculate the check code of the address interval used by other program segments, so the terminal The second check code corresponding to the second address interval can be obtained.
  • Step 204 the terminal determines a third check code according to the first check code and the second check code, where the third check code is a check code corresponding to the third address interval.
  • the terminal may determine the third check code corresponding to the third address interval according to the first check code and the second check code based on the zero-padding property of the check operation. code verification.
  • FIG. 3 is a schematic diagram of distribution of an address range provided by an embodiment of the present application.
  • the third check code CS3 can be calculated according to the following formula 3:
  • the constant in formula 3 is a given constant value. It can be known from Equation 3 that, based on the check codes corresponding to the two address ranges respectively, the total check codes corresponding to the two address ranges can be calculated.
  • the above formula 3 takes the second check code as a check code corresponding to the second address interval as an example, and describes the process of calculating the third check code based on the first check code and the second check code.
  • the second address interval can also be divided into multiple address intervals, and the multiple address intervals constituting the second address interval have corresponding check codes, so the second check code may also refer to the second check code. Multiple check codes corresponding to multiple address ranges in the address range.
  • FIG. 4 is a schematic diagram of distribution of another address range provided by this embodiment of the present application.
  • the first address interval includes address interval 1
  • the first check code may refer to the check code corresponding to address interval 1, that is, the first check code is CRC (1010)
  • the second address interval includes In address interval 2 and address interval 3
  • the second check code may refer to the check codes corresponding to address interval 2 and address interval 3
  • the second check code may include CRC(1010) and CRC(1010).
  • the second check code refers to multiple check codes corresponding to the second address interval, it can also be calculated from the first check code and the second check code based on the zero-padding property of CRC.
  • the specific calculation process is not repeated in this embodiment.
  • Step 205 Store the third check code in the NVM, the third check code is used to check the correctness of the data in the volatile memory after the terminal restores power supply, and the third address interval is located in the volatile memory.
  • the third check code may be stored in the NVM to ensure the correctness of the third check code after the terminal is powered off. Since the data in the NVM will not be wrong after the terminal is powered off, after the terminal is powered off and the power is restored, the terminal can check the data in the third address range according to the third check code stored in the NVM. data is verified. That is to say, after the power supply is restored, the terminal can recalculate the check code of the third address interval located in the volatile memory, and compare the recalculated check code with the third check code stored in the NVM. Comparison.
  • the terminal can continue to execute the program based on the data in the volatile memory; if the two check codes are different, then It can be considered that the data in the volatile memory has an error during the power failure, and the terminal can no longer execute the program based on the data in the volatile memory.
  • FIG. 5 is a schematic diagram of operation comparison of a terminal according to an embodiment of the present application.
  • the terminal stops executing the program after its voltage reaches the pre-warning voltage, and the processor is actually powered off after a period of time.
  • the terminal is in a standby state, and the program cannot be continuously advanced, resulting in poor real-time responsiveness of the terminal.
  • the terminal can continue to execute the program segment after its voltage reaches the pre-warning voltage, and verify the address range used by the program segment to ensure the correctness of the data after the power supply is restored. In this way, until the processor is actually powered off, the terminal continues to advance the execution of the program until the processor is powered off and stops running. That is to say, in this solution, the terminal can prolong the execution time of the program as much as possible, which ensures the real-time response performance of the terminal.
  • the terminal may periodically store the data in the volatile memory to the NVM. For example, the terminal may copy the data in the volatile memory to the NVM every 5 minutes or 10 minutes, so as to periodically back up the detection point in the NVM. In this way, after the terminal restores power supply, when it is determined that the data in the volatile memory is verified incorrectly, the detection point stored in the NVM can be restored to the latest detection point, so as to avoid the terminal repeatedly executing the program frequently.
  • the terminal may also store the first check code and the second check code in a volatile memory, and store the third check code in the NVM.
  • the terminal can directly calculate a new check code based on the first check code and the second check code in the volatile memory, and store the new check code with the The third check code in the NVM is compared. If the new check code is the same as the third check code, it can be determined that there is no error in the first check code and the second check code in the volatile memory, that is, it can be considered that the data in the volatile memory is broken.
  • the verification of the correctness of the data in the volatile memory can be realized, and the verification of the data in the volatile memory can be omitted.
  • the code process saves the time for the terminal to verify the correctness of the data and prolongs the effective operation time of the terminal.
  • the terminal when the terminal uses the check code stored in the volatile memory and the check code stored in the NVM to verify the correctness of the data in the volatile memory after power off, the terminal Before executing each program segment, the program segment can also be verified based on the check code in the volatile memory to further ensure the correctness of the data.
  • the terminal may determine the first address interval corresponding to the first program segment, and obtain the check code corresponding to the first address interval, and the check code corresponding to the first address interval is stored in an easy-to-use address. in volatile memory. If the terminal determines that the data in the first address interval is correct according to the check code corresponding to the first address interval, it determines that the first program segment can be executed. If the data in the first address interval is incorrect, the terminal can restart the system or restore to the latest detection point stored on the NVM.
  • the volatile memory Since the volatile memory has data retention characteristics, it can be determined that no error has occurred in the volatile memory even if the data in the volatile memory is not verified when the terminal is powered off for a short time. In the case that the terminal is powered off for a long time, even if the data in the volatile memory is not verified, it can be determined that an error has occurred in the volatile memory.
  • the terminal may obtain its own power-off duration after power is restored. If the power-off duration of the terminal is less than the first duration, it is determined that the data in the volatile memory is correct; if the power-off duration of the terminal is greater than the first duration and less than the second duration, it is determined that the data in the volatile memory needs to be verified If the power-off duration of the terminal is longer than the second duration, it is determined that the data in the volatile memory is incorrect; wherein, the first duration is less than the second duration.
  • the designer of the terminal still determines two durations that can guarantee the accuracy, namely the first duration and the third duration. Two hours.
  • the first duration indicates that the power-off time of the terminal is short enough to ensure that the data on the volatile memory will not be wrong. Therefore, when the power-off duration of the terminal is shorter than the first duration, the terminal can skip the step of data verification.
  • the second duration indicates that the power-off time of the terminal is long enough, and the data on the volatile memory must have been wrong. Therefore, when the power-off duration of the terminal is longer than the second duration, the terminal can restart the system or restore to NVM. The most recent detection point stored on it.
  • the terminal can decide whether to perform data verification according to the actual power-off duration, which avoids performing data verification every time the power supply is restored, saves the time for the terminal to perform data verification, and prolongs the time of the terminal. Effective time to run.
  • FIG. 6a is a schematic structural diagram of a circuit for determining a power-off duration provided by an embodiment of the present application.
  • the circuit includes an intermittent power supply circuit shown in the left dashed box and a time keeping circuit shown in the right dashed box.
  • the time keeping circuit is composed of a switch S1, a switch S2, a capacitor C2 and a resistor.
  • the working mode of the time keeping circuit is:
  • the voltage across the capacitor C2 is detected to calculate the magnitude relationship between the power-off duration T off and the first duration T LB and the second duration T UB .
  • FIG. 6b is a schematic diagram of the voltage variation curve of a time keeping circuit provided by the embodiment of the present application.
  • the volatile memory in the terminal may further include a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before executing the first program segment .
  • the third address interval is marked as a working buffer, and the working buffer refers to the interval used when the program is executed, that is, during the execution of the program, the corresponding data is accessed and modified in the working buffer.
  • the fourth address interval is marked as a backup buffer, and the backup buffer is used to back up the data of the working area.
  • the terminal may copy the data in the third address interval to the third address interval, so as to ensure that the data in the third address interval serving as the working interval is the same as the data in the fourth address interval serving as the backup interval.
  • the data in the address range is the same, and the data in the work range is backed up. In this way, if the terminal is powered off during the execution of the first program segment, the terminal can copy the data in the backup section to the working section after restoring the power supply, so as to restore the data in the working section.
  • FIG. 7 is a schematic flowchart of an execution program segment provided by an embodiment of the present application. As shown in FIG. 7 , the flow of the terminal executing the program segment before and after the power failure includes the following steps.
  • step 701 the terminal executes program segment 1.
  • the program segment 1 includes adding operation to the variable x. Therefore, the terminal performs an addition operation on the variable x in the working range, thereby modifying the value of the variable x from 0 to 1.
  • the terminal is powered off, and after a brief power off, the terminal restores the power supply.
  • step 702 after the terminal restores the power supply, the terminal copies the data in the backup section to the working section.
  • the terminal Since the terminal performs an addition operation on the variable x in the working area before the power failure, after the power supply is restored, the value of the variable x in the working area is 1, and the value of the variable x in the backup area is still 0.
  • the terminal may copy the data in the backup section to the working section, so that the value of the variable x in the working section is still 0.
  • step 703 the terminal executes program segment 1 again.
  • the terminal restores the data in the work area, the terminal continues to run, that is, executes the program segment 1 again, and performs an addition operation on the variable x in the work area, thereby changing the value of the variable x from 0 to 1.
  • the backup interval can back up the data in the working area, so as to ensure that after the terminal is powered off and the power supply is restored, the data in the working area can be restored, so that the data in the working area can be restored.
  • the phenomenon of data errors in the terminal is avoided, and the correctness of the data is ensured.
  • the terminal in order to ensure that the backup interval can play an effective role in data backup, the terminal needs to perform data copy after each execution of the program segment, so as to ensure that the data in the backup interval and the working interval are the same.
  • the process of performing data copying by the terminal may include: after the execution of the first program segment is completed, the terminal marks the fourth address interval as a working interval, and marks the third address interval as a backup interval; then, The terminal then copies the data in the third address range to the fourth address range.
  • the terminal after executing the first program segment, the terminal marks the third address range, which was originally a working range, as a backup range by performing an operation of exchanging pointers, and marks the fourth address range, which was originally a backup range, as a work range. range to realize the exchange of the working range and the backup range. Then, the terminal copies the data in the fourth address interval to the third address interval to ensure data consistency.
  • the terminal marks the third address range as the working range with the pointer "0", and marks the fourth address range as the backup range with the pointer "1"; after executing the first program segment, the terminal By exchanging the pointers, the third address range is marked as a backup range by the pointer "1", and the fourth address range is marked as the working range by the pointer "0".
  • the quick interchange between the working area and the backup area is realized by exchanging pointers, which can effectively avoid the phenomenon of data errors due to power failure during the data copying process.
  • the terminal restores power supply, the terminal still needs to copy the data in the backup area (ie the fourth address area) to the working area (ie the third address area).
  • the backup interval since the backup interval has already copied some data in the working interval before the power failure, the data in the backup interval has actually been contaminated and is wrong data. In this way, restoring the data in the backup area to the working area will also cause the data in the working area to be wrong data, thereby affecting the normal operation of the terminal.
  • the terminal when the terminal is provided with a working area and a backup area, the terminal may also acquire the second check code corresponding to the second address interval based on the data in the backup area.
  • the process that the terminal obtains the second check code corresponding to the second address interval may include: the terminal calculates the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; The corresponding check code and the fourth check code determine the second check code.
  • the fourth address interval is a backup interval corresponding to the third address interval
  • the address scope of the fourth address interval and the address scope of the third address interval are the same and fixed.
  • the address range of the third address interval may be 1-100
  • the address range of the fourth address interval may be 101-200.
  • the address range with the address range of 50-60 in the third address range corresponds to the address range with the address range of 150-160 in the fourth address range
  • the address range with the address range of 50-60 and the address range of 150-160 The data on the address range is the same.
  • the terminal can determine to obtain the fourth address by calculating the check code of the address range corresponding to the first address range in the fourth address range, and based on the above-mentioned zero-padding property and the check code of the fourth address range.
  • the check codes of other address ranges in the range that is, the second check codes corresponding to the second address range.
  • FIG. 8 is a schematic diagram of calculating a check code according to an embodiment of the present application.
  • the data in the backup section is the same as that in the working section, and the address section S0 and the address section S1 in the backup section correspond to the address section S0' and the address section S1' in the working section, respectively.
  • the check codes corresponding to the address interval S0 and the address interval S1 are calculated after executing other program segments.
  • the program segment 1 accesses and modifies the address range S2' in the work range, so that the work range is divided into three address ranges: S01', S2', and S11'.
  • the backup interval can also be divided into three corresponding address intervals: S01, S02+S12, and S11.
  • the check code corresponding to the work interval after executing the program segment 1 can actually be calculated based on the check codes corresponding to the address interval S01 ′, the address interval S2 ′ and the address interval S11 ′ respectively.
  • the sub-check code of the address interval S2' can be obtained by directly performing the check code calculation on the data in the address interval S2'.
  • the check codes corresponding to the address interval S01' and the address interval S11' can be obtained by calculating the check codes corresponding to the address interval S01 and the address interval S11 in the backup interval.
  • the second check code corresponding to the second address interval in the working interval By calculating the second check code corresponding to the second address interval in the working interval based on the data in the backup interval, when the first address interval is small, the time and energy consumed by the CRC operation can be effectively reduced, and the terminal can be improved. After the execution of the program segment, the efficiency of the check code is calculated, so that the electric power of the terminal can be saved and the effective operation time of the terminal can be prolonged.
  • the power in the terminal can be maintained at a relatively high level, so as to ensure that the terminal will not be powered off for a long period of time in the future.
  • the terminal does not need to calculate the check code every time after executing the program segment, so as to save the energy consumption of the terminal.
  • the terminal executes one or more second program segments according to whether the voltage of the terminal is higher than the threshold voltage.
  • the second program segment may refer to any other program segment in the program to which the first program segment belongs, and the program may include one or more second program segments.
  • the terminal marks the address range used when executing one or more second program segments. According to the current voltage lower than the threshold voltage, the terminal calculates the check code corresponding to the marked address interval.
  • This threshold voltage is used to indicate that the terminal is at a low battery level, that is, the terminal may face power outage at any time.
  • the value of the threshold voltage may be determined according to the actual energy harvesting capability of the terminal, which is not specifically limited in this embodiment.
  • the terminal can be used to mark the address range used when executing the program segment after each program segment is executed; the terminal can also be used to mark the address range used when executing the multiple program segments after executing the multiple program segments.
  • the address range to use can be used.
  • the current voltage of the terminal may be detected once to determine whether the current voltage is lower than the threshold voltage. In this way, when the terminal determines that the current voltage is lower than the threshold voltage, the terminal uniformly calculates the check code for the marked address interval, so as to reduce the number of times of calculating the check code as much as possible.
  • FIG. 9 is a schematic flowchart of terminal operation provided by an embodiment of the present application.
  • the running process after the terminal is powered on includes the following steps.
  • Step S1 After each time the terminal restores power supply, first determine the time length of the last power outage. If the power-off time is too long, that is, T off >T UB , the terminal restarts or restores to the last detection point stored on the NVM.
  • T off represents the power-off duration of the terminal
  • T UB represents the above-mentioned second duration, that is, the upper limit of the time during which the data on the volatile memory must be in error.
  • the flag is used to mark the correctness of the data on the volatile memory. When the flag is 0, it indicates that the data is correct, and the verification operation on the data can be skipped.
  • Step S4 In the case of T LB ⁇ T off ⁇ T UB , before the terminal executes the program segment, it is necessary to verify whether the check code corresponding to the data on the volatile memory is correct. That is, the terminal verifies whether the check code corresponding to the data on the volatile memory is correct by comparing whether the check code stored in the volatile memory is the same as the check code stored on the NVM. If the verification fails (that is, the check codes are not the same), it means that an error occurs in the data on the volatile memory, and the terminal restarts or restores to the latest detection point stored on the NVM.
  • Step S5 the terminal determines whether the current voltage V is greater than the threshold voltage V T .
  • Step S6 when the voltage V is higher than the threshold voltage VT , it means that the terminal is currently at a high battery level, and the high battery level working mode can be executed, that is, the check code does not need to be calculated after each execution of the program segment.
  • Step S7 If the data to be used in the program segment passes the verification or does not need to be verified for the data to be used in the program segment, the terminal copies the data in the backup section to the work section.
  • Step S8 the terminal executes the program segment.
  • Step S9 After the execution of the program segment is completed, the terminal marks the modified address range (ie, marks the address range where the data used by the program segment is located), then schedules the next ready program segment, and repeats steps S6 to S9.
  • the modified address range ie, marks the address range where the data used by the program segment is located
  • Step S10 when the voltage V is lower than the threshold voltage VT , it means that the terminal is currently at a low battery level and needs to execute the low battery level working mode, that is, the check code is calculated after each execution of the program segment.
  • the terminal calculates the check code of the marked address range, calculates and obtains the total check code of the address range used by the whole program, and stores the total check code in the NVM.
  • the terminal may copy all data on the volatile memory to the NVM as a detection point.
  • Step S12 the terminal exchanges the pointers of the backup interval and the working interval, namely marking the original backup interval in the volatile memory as the working interval and marking the original working interval as the backup interval, and copying the data in the backup interval after the exchange of pointers to the work area.
  • Step S15 the terminal determines whether the data to be used in the program segment passes the verification, and if the verification fails, the terminal restarts or restores to the latest detection point stored on the NVM.
  • Step S16 if the verification is passed, the terminal executes the program segment.
  • Step S17 After executing the program segment, the terminal exchanges the pointers of the backup area and the working area.
  • Step S18 the terminal calculates the check code corresponding to the address interval used to execute the program segment in the backup interval, and calculates the total check code corresponding to the address interval used by the program according to the check code, and calculates the total check code. Stored in NVM.
  • Step S19 the terminal copies the data in the backup section to the working section, then schedules the next ready program segment, and repeats steps S13 to S19 until the power is turned off.
  • FIG. 10a is a schematic diagram of a relationship between a program segment and an address interval provided by an embodiment of the present application.
  • the code of the application program includes program segment 1, program segment 2, and program segment 3, and program segment 1, program segment 2, and program segment 3 use address ranges DB1, DB2, and DB3 respectively.
  • FIG. 10b is a schematic flowchart of a terminal executing a program segment at a low battery level according to an embodiment of the present application. As shown in Fig. 10b, the process of the terminal executing the program segment at a low power level includes the following steps.
  • the terminal successfully executes program segment 1.
  • DB1 in the workspace is updated to DB1'.
  • the terminal detects and finds that the current voltage value is lower than the threshold voltage, and the terminal enters the low power level working mode.
  • the terminal calculates the check code of the modified address range, that is, calculates the check code of DB1', and obtains CS1.
  • the terminal when executing the previous program segment, the terminal also calculates and obtains the check codes of other address ranges in the working range, which are CS0, CS_delta and CSn respectively. In this way, the terminal can calculate the total check code CS_total corresponding to the working interval according to the multiple sub-check codes corresponding to the working interval, and store the CS_total in the NVM.
  • the terminal also copies the data in the working area to the backup area.
  • the terminal is ready to schedule and execute program segment 2, and program segment 2 will use the address range DB2 in the work range. Since the data correctness of DB2 has not been verified in this power-on cycle, the terminal can verify the correctness of the data intervals DB2, DB3 and DB4 through the verification code CS_delta. If the verification result is that there is no error in the data, the terminal can execute program segment 2.
  • the terminal schedules the execution of program segment 2, and the modifications to DB2 during the execution of program segment 2 all occur in the work area.
  • the terminal successfully executes program segment 2, and DB2 in the work area is updated to DB2'.
  • the terminal quickly updates DB2' to the backup range by exchanging pointers.
  • the terminal calculates the check code of the modified address range, that is, calculates the check code of DB2', and obtains CS2.
  • the terminal can obtain it by calculating the check codes CS_delta of DB2 to DB4 and the check codes CS(DB2) of DB2, that is, CS_delta-CS(DB2).
  • the terminal can calculate the total check code CS_total according to the multiple sub-check codes CS0, CS1, CS2, CS_delta-CS(DB2) and CSn corresponding to the working interval, and store the CS_total in the NVM.
  • the terminal copies DB2' in the backup section to the working section, and verifies the data correctness of DB3. Since DB2 has been verified through CS_delta at time t2, the terminal can determine that program segment 3 is scheduled to be executed.
  • the terminal schedules the execution of program segment 3, and the modifications to DB3 during the execution of program segment 3 all occur in the work area.
  • FIG. 11 is a schematic diagram of operation of a terminal after power supply is restored according to an embodiment of the present application. As shown in Figure 11, the terminal performs the following steps after power is restored.
  • Step 1101 the terminal verifies whether the check code on the volatile memory is correct through the total check code CS_total on the NVM. That is, the terminal recalculates a new total check code based on the check code on the volatile memory (ie CS0, CS1, CS2, CS_delta and CSn), and compares the new total check code with the total check code stored on the NVM. The check codes are compared. If the two are the same, it means that the check code on the volatile memory is correct. If the two are different, it means that the data on the volatile memory is wrong.
  • Step 1102 if the verification code on the volatile memory is correct, the terminal verifies whether the data to be used by the program segment 3 (ie DB3 ) is correct based on the verification code CS_delta.
  • Step 1103 when the data to be used in the program segment 3 is verified to be correct, the terminal copies the data in the backup section to the working section.
  • Step 1104 the terminal schedules the execution of program segment 3.
  • FIG. 12 is a schematic structural diagram of a terminal 1200 provided by an embodiment of the present application.
  • the terminal 1200 includes: a processing unit 1201 and an obtaining unit 1202; the processing unit 1201 is used for executing the first program segment; the processing unit 1201, which is also used to calculate the first check code corresponding to the first address range, where the first address range is the address range used when executing the first program segment; the obtaining unit 1202 is used to obtain the second address range corresponding to the second address range.
  • the second address interval is the address interval other than the first address interval in the third address interval
  • the third address interval is the address interval used when executing the program to which the first program segment belongs
  • the processing unit 1201 also It is used to determine the third check code according to the first check code and the second check code
  • the third check code is the check code corresponding to the third address interval
  • the processing unit 1201 is also used for the third check code.
  • the code is stored in the non-volatile memory
  • the third verification code is used to verify the correctness of the data in the volatile memory after the terminal restores power supply
  • the third address range is located in the volatile memory.
  • the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed; wherein, the third address interval is It is marked as a working area, the fourth address area is marked as a backup area, the working area is an area used when the program is executed, and the backup area is used for backing up data in the working area.
  • the processing unit 1201 is specifically configured to: calculate the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; Check code, determine the second check code.
  • the processing unit 1201 is further configured to: mark the fourth address range as a working range, and mark the third address range as a backup range; and copy the data of the third address range to the fourth address range.
  • the processing unit 1201 is further configured to: store the first check code and the second check code in a volatile memory, and the first check code and the second check code are used for recovery at the terminal After the power is supplied, it is compared with the third check code to verify the correctness of the data in the volatile memory.
  • the processing unit 1201 is further configured to: obtain the power-off duration of the terminal after the power supply of the terminal is restored; if the power-off duration is less than the first duration, determine that the data in the volatile memory is correct; If the power-on duration is greater than the first duration and less than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified; if the power-off duration is greater than the second duration, it is determined that the data in the volatile memory is incorrect; wherein , the first duration is less than the second duration.
  • the processing unit 1201 is further configured to: execute one or more second program segments according to the voltage of the terminal being higher than the threshold voltage; mark the address range used when executing the one or more second program segments ; Calculate the check code corresponding to the marked address interval according to the voltage of the terminal being lower than the threshold voltage.
  • the processing unit 1201 is further configured to: determine the first address range corresponding to the first program segment; obtain the check code corresponding to the first address range, and store the check code corresponding to the first address range in an easy-to-use In the volatile memory; according to the check code corresponding to the first address interval, it is determined that the data in the first address interval is correct; based on the correctness of the data in the first address interval, it is determined to execute the first program segment.
  • the processing unit 1201 is further configured to: periodically store the data in the volatile memory to the non-volatile memory.
  • FIG. 13 is a schematic structural diagram of a terminal 100 according to an embodiment of the present application.
  • the terminal 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, an energy collection module 140, a power management module 141, a battery 142, Antenna 1, Antenna 2, mobile communication module 150, wireless communication module 160, sensor module 170, etc.
  • the sensor module 170 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
  • the terminal 100 may include more or less components than shown, or some components may be combined, or some components may be separated, or different component arrangements.
  • the illustrated components may be implemented in hardware, software, or a combination of software and hardware.
  • the pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the gyro sensor may be used to determine the motion attitude of the terminal 100 .
  • Air pressure sensors are used to measure air pressure.
  • the acceleration sensor can detect the magnitude of the acceleration of the terminal 100 in various directions (including three axes or six axes). When the terminal 100 is stationary, the magnitude and direction of gravity can be detected.
  • the ambient light sensor is used to sense ambient light brightness.
  • the fingerprint sensor is used to collect fingerprints.
  • a temperature sensor is used to detect temperature.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU) Wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • graphics processor graphics processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • the controller may be the nerve center and command center of the terminal 100 .
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I1C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I1S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I1C integrated circuit
  • I1S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the terminal 100 .
  • the terminal 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the energy collection module 140 is used to obtain energy input from the operating environment, such as light energy, radio frequency, pressure or heat energy, and converts the energy into electrical energy to be stored in the battery 142 .
  • the power management module 141 is used to connect the battery 142 , the energy collection module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the energy collection module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the wireless communication module 160, and the like.
  • the wireless communication function of the terminal 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in terminal 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 may provide a wireless communication solution including 1G/3G/4G/5G, etc. applied on the terminal 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then convert it into electromagnetic waves and radiate it out through the antenna 2 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 .
  • at least some of the functional modules of the mobile communication module 150 may be provided in the same device as at least some of the modules of the processor 110.
  • the wireless communication module 160 can provide applications on the terminal 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • WLAN wireless local area networks
  • BT wireless fidelity
  • GNSS global navigation satellite system
  • frequency modulation frequency modulation, FM
  • NFC near field communication technology
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 1 , modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation
  • the antenna 1 of the terminal 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the terminal 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the processor 110 executes various functional applications and data processing of the terminal 100 by executing the instructions stored in the internal memory 121 .
  • the internal memory 121 may include a volatile memory 121A and a non-volatile memory 121B, the volatile memory 121A is used to store data used in the process of executing the program, and the non-volatile memory 121B is used to save the data in the volatile memory 121A.
  • the check code corresponding to the data and the data in the backup volatile memory 121A.
  • the disclosed system, apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: a U disk, a removable hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk and other media that can store program codes.

Abstract

The present application discloses a data processing method, applicable to an intermittently working terminal, and comprising: executing a first program segment; calculating a first check code corresponding to a first address interval, the first address interval being an address interval used when executing the first program segment; obtaining a second check code corresponding to a second address interval, the second address interval being an address interval in a third address interval excluding the first address interval, and the third address interval being an address interval used when executing a program to which the first program segment belongs; and determining a third check code according to the first check code and the second check code, and storing the third check code in a non-volatile memory, so as to check data in a volatile memory after power supply is restored. According to the present solution, there is no need to calculate a check code for the entire address interval where data is stored, and thus, energy consumption and time for calculating the check code can be reduced, thereby making the terminal continue to run, and ensuring the real-time response performance of the terminal.

Description

一种数据处理方法及相关装置A data processing method and related device
本申请要求于2020年9月21日提交中国专利局、申请号为202010997523.3、发明名称为“一种数据处理方法及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on September 21, 2020 with the application number 202010997523.3 and the invention titled "A data processing method and related device", the entire contents of which are incorporated herein by reference middle.
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种数据处理方法及相关装置。The present application relates to the field of computer technology, and in particular, to a data processing method and related apparatus.
背景技术Background technique
随着物联网技术的发展,越来越多的物联网设备采用能量采集的方式来驱动,并且基于间歇性工作的方式来运行。物联网设备在运行的过程中,需要频繁地在非易失性存储器(Non-Volatile Memory,NVM)上备份运行状态,以便于在遭遇断电且恢复供电后,能够基于已备份的运行状态恢复运行。With the development of IoT technology, more and more IoT devices are driven by energy harvesting and operate based on intermittent work. During the operation of IoT devices, it is necessary to frequently backup the operating state on the Non-Volatile Memory (NVM), so that it can be restored based on the backed-up operating state after a power failure and power recovery. run.
目前,为避免频繁备份运行状态,相关技术中采用易失性存储器(Volatile Memory)来保存数据,以实现在短暂断电时不采用NVM备份运行状态。具体地,通过设定预警电压阈值,在物联网设备的电压低于预警电压阈值时,对易失性存储器中的全部数据进行校验,并将得到的校验码存储至NVM中,物联网设备再停止运行。在供电恢复后,基于NVM中的校验码,验证易失性存储器中的数据是否发生错误。At present, in order to avoid frequent backup of the running state, a volatile memory (Volatile Memory) is used in the related art to save data, so as to realize that the NVM is not used to backup the running state during a brief power failure. Specifically, by setting the pre-warning voltage threshold, when the voltage of the IoT device is lower than the pre-warning voltage threshold, all data in the volatile memory is verified, and the obtained verification code is stored in the NVM. The device stops running again. After the power supply is restored, based on the check code in the NVM, it is verified whether the data in the volatile memory is in error.
然而,由于计算易失性存储器中的全部数据的校验码需要花费较长的时间,为保证能够顺利计算得到校验码并且将该校验码存储至NVM中,预警电压阈值通常设定为较高的电压值,容易导致物联网设备在剩余较多电量时就停止了运行,影响了物联网设备的实时响应性能。However, since it takes a long time to calculate the check code of all the data in the volatile memory, in order to ensure that the check code can be successfully calculated and stored in the NVM, the warning voltage threshold is usually set as A higher voltage value is likely to cause the IoT device to stop running when there is more power remaining, which affects the real-time response performance of the IoT device.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种数据处理方法及相关装置,在终端的运行过程中,终端执行完程序段之后,计算该程序段所使用的地址区间的校验码,并且基于该校验码以及整个程序所使用的地址区间中的其他地址区间的校验码,确定程序所使用的地址区间的总校验码,无需对整个保存数据的地址区间进行校验码的计算,从而减少计算校验码的能耗和时间,使得终端能够持续运行,保证了终端的实时响应性能。The present application provides a data processing method and related device. During the operation of the terminal, after the terminal executes the program segment, the check code of the address range used by the program segment is calculated, and based on the check code and the entire program The check code of other address ranges in the used address range determines the total check code of the address range used by the program, and there is no need to calculate the check code for the entire address range where the data is stored, thereby reducing the time required to calculate the check code. Energy consumption and time enable the terminal to run continuously and ensure the real-time response performance of the terminal.
本申请第一方面提供一种数据处理方法,该方法应用于间歇性工作的终端,即在频繁断电情况下间歇性地工作的终端。该方法可以包括:终端执行第一程序段,该第一程序段可以为一个应用程序的多个程序段中的一个。在终端执行第一程序段期间,终端需要使用并修改第一地址区间中的数据。终端在执行完第一程序段之后,计算第一地址区间对应的第一校验码,例如基于循环冗余校验(Cyclic Redundancy Check,CRC)运算来计算得到第一校验码。终端获取第二地址区间对应的第二校验码,该第二地址区间为第三地址区间中除第一地址区间之外的地址区间,该第三地址区间为执行第一程序段所属的程序时所使用的地址区间,该第二校验码可以是终端执行完其他程序段时,计算得到的。由于第三地址区间是由第一地址区间和第二地址区间所构成,终端根据第一校验码和第二校验码,可以 确定第三地址区间对应的第三校验码。终端将第三校验码存储于非易失性存储器,该第三校验码用于在终端恢复供电后校验易失性存储器中的数据的正确性,该第三地址区间位于易失性存储器中。A first aspect of the present application provides a data processing method, which is applied to a terminal that works intermittently, that is, a terminal that works intermittently in the case of frequent power failures. The method may include: the terminal executes a first program segment, where the first program segment may be one of multiple program segments of an application program. During the execution of the first program segment by the terminal, the terminal needs to use and modify the data in the first address interval. After executing the first program segment, the terminal calculates the first check code corresponding to the first address interval, for example, the first check code is calculated based on a cyclic redundancy check (Cyclic Redundancy Check, CRC) operation. The terminal obtains a second check code corresponding to a second address interval, where the second address interval is an address interval other than the first address interval in the third address interval, and the third address interval is for executing the program to which the first program segment belongs. The address range used when the second check code can be calculated when the terminal finishes executing other program segments. Since the third address interval is composed of the first address interval and the second address interval, the terminal can determine the third check code corresponding to the third address interval according to the first check code and the second check code. The terminal stores the third check code in the non-volatile memory, where the third check code is used to verify the correctness of the data in the volatile memory after the terminal restores power supply, and the third address interval is located in the volatile memory. in memory.
本方案中,终端通过在执行完程序段之后,计算该程序段所使用的地址区间的校验码,并且基于该校验码以及整个程序所使用的地址区间中的其他地址区间的校验码,可以确定程序所使用的地址区间的总校验码。终端不再需要对整个保存数据的地址区间进行校验码的计算,从而减少计算校验码的能耗和时间,使得终端能够持续运行,保证了终端的实时响应性能。In this solution, the terminal calculates the check code of the address range used by the program segment after executing the program segment, and based on the check code and the check codes of other address ranges in the address range used by the whole program , the total check code of the address range used by the program can be determined. The terminal no longer needs to calculate the check code for the entire address range where the data is stored, thereby reducing the energy consumption and time for calculating the check code, enabling the terminal to run continuously, and ensuring the real-time response performance of the terminal.
在一些可能的实现方式中,该易失性存储器中还可以包括第四地址区间,该第四地址区间存储的数据与执行第一程序段前第三地址区间存储的数据相同,即第四地址区间用于备份第三地址区间中的数据。其中,第三地址区间被标记为工作区间,第四地址区间被标记为备份区间,工作区间为程序执行时所使用的区间,备份区间用于备份工作区间的数据。In some possible implementations, the volatile memory may further include a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed, that is, the fourth address The interval is used to back up the data in the third address interval. The third address interval is marked as a working interval, the fourth address interval is marked as a backup interval, the working interval is an interval used when the program is executed, and the backup interval is used for backing up data in the working interval.
也就是说,在执行第一程序段之前,终端可以将第三地址区间中的数据拷贝至第三地址区间中,以保证作为工作区间的第三地址区间中的数据与作为备份区间的第四地址区间中的数据相同,实现工作区间中的数据的备份。这样,如果终端在执行第一程序段的期间发生了断电,那么终端可以在恢复供电之后,将备份区间中的数据拷贝至工作区间,以恢复工作区间中的数据。That is to say, before executing the first program segment, the terminal may copy the data in the third address interval to the third address interval, so as to ensure that the data in the third address interval serving as the working interval is the same as the data in the fourth address interval serving as the backup interval. The data in the address range is the same, and the data in the work range is backed up. In this way, if the terminal is powered off during the execution of the first program segment, the terminal can copy the data in the backup section to the working section after restoring the power supply, so as to restore the data in the working section.
在一些可能的实现方式中,终端获取第二地址区间对应的第二校验码,包括:终端计算第四地址区间中与第一地址区间对应的地址区间的第四校验码;终端根据第四地址区间对应的校验码以及第四校验码,确定第二校验码。In some possible implementation manners, obtaining the second check code corresponding to the second address interval by the terminal includes: the terminal calculates the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; The check code corresponding to the four address intervals and the fourth check code determine the second check code.
简单来说,在第一程序段执行完毕之后,由于第三地址区间上的第一地址区间中的数据发生了改变,因此第四地址区间中与第三地址区间上的数据不相同的地址区间为第一地址区间所对应的地址区间。而第四地址区间中的其他地址区间实际上还是与第三地址区间中的第二地址区间上的数据相同。这样,终端可以通过计算第四地址区间中与第一地址区间对应的地址区间的校验码,并且基于校验运算的zero-padding性质以及第四地址区间的校验码,确定得到第四地址区间中的其他地址区间的校验码,即第二地址区间对应的第二校验码。Simply put, after the first program segment is executed, since the data in the first address interval on the third address interval has changed, the address interval in the fourth address interval is different from the data in the third address interval. is the address interval corresponding to the first address interval. However, the other address intervals in the fourth address interval are actually still the same as the data on the second address interval in the third address interval. In this way, the terminal can determine to obtain the fourth address by calculating the check code of the address range corresponding to the first address range in the fourth address range, and based on the zero-padding property of the check operation and the check code of the fourth address range The check codes of other address ranges in the range, that is, the second check codes corresponding to the second address range.
本方案中,通过基于备份区间上的数据来计算工作区间中的第二地址区间对应的第二校验码,可以在第一地址区间较小时,有效地降低进行CRC运算所消耗的时间和能耗,提高终端在执行完程序段后计算校验码的效率,从而能够节省终端的电能,延长终端有效运行的时间。In this solution, by calculating the second check code corresponding to the second address interval in the working interval based on the data in the backup interval, when the first address interval is small, the time and energy consumed by the CRC operation can be effectively reduced This improves the efficiency of the terminal in calculating the check code after executing the program segment, thereby saving the power of the terminal and prolonging the effective operation time of the terminal.
在一些可能的实现方式中,在第一程序段执行完毕之后,该方法还包括:终端将第四地址区间标记为工作区间,以及将第三地址区间标记为备份区间;终端将第三地址区间的数据拷贝至第四地址区间。In some possible implementations, after the execution of the first program segment is completed, the method further includes: the terminal marks the fourth address interval as a working interval, and marks the third address interval as a backup interval; the terminal marks the third address interval as a backup interval; The data is copied to the fourth address range.
本方案中,在执行完程序段之后,通过更换地址区间的标记来实现工作区间和备份区间的快速互换,可以有效避免在数据拷贝过程中发生断电而出现数据错误的现象。In this solution, after the program segment is executed, the rapid exchange of the working area and the backup area is realized by replacing the mark of the address area, which can effectively avoid the phenomenon of data errors due to power failure during the data copying process.
在一些可能的实现方式中,该方法还包括:终端将第一校验码和第二校验码存储于易失性存储器,第一校验码和第二校验码用于在终端恢复供电后与第三校验码进行比对,以验证易失性存储器中的数据的正确性。也就是说,在终端恢复供电之后,可以直接基于易失性存储器中的第一校验码和第二校验码计算新的校验码,并且将该新的校验码与存储于NVM中的第三校验码进行比对,来验证易失性存储器中的数据在断电期间是否发生错误。In some possible implementations, the method further includes: the terminal stores the first check code and the second check code in a volatile memory, where the first check code and the second check code are used to restore power supply at the terminal Then, it is compared with the third check code to verify the correctness of the data in the volatile memory. That is to say, after the power supply of the terminal is restored, a new check code can be calculated directly based on the first check code and the second check code in the volatile memory, and the new check code and the new check code can be stored in the NVM. The third check code of the volatile memory is compared to verify whether the data in the volatile memory has an error during the power failure.
本方案中,通过将第一校验码和第二校验码存储于易失性存储器中,来实现易失性存储器中的数据的正确性的验证,可以省去重新计算易失性存储器中数据的校验码的过程,节省了终端验证数据正确性的时间,延长终端有效运行的时间。In this solution, by storing the first check code and the second check code in the volatile memory, the verification of the correctness of the data in the volatile memory can be realized, which can save the need to recalculate the data in the volatile memory. The process of data check code saves the time for the terminal to verify the correctness of the data and prolongs the effective operation time of the terminal.
在一些可能的实现方式中,该方法还包括:在恢复供电后,终端获取终端的断电时长;若断电时长小于第一时长,则确定易失性存储器中的数据正确;若断电时长大于第一时长且小于第二时长,则确定需要校验易失性存储器中的数据的正确性;若断电时长大于第二时长,则确定易失性存储器中的数据不正确。其中,第一时长表示终端断电的时间足够短,易失性存储器上的数据保证不会出错,因此,在终端的断电时长小于第一时长时,终端可以跳过数据验证的步骤。类似地,第二时长表示终端的断电时间足够长,易失性存储器上的数据肯定已经发生错误。In some possible implementations, the method further includes: after the power supply is restored, the terminal obtains the power-off duration of the terminal; if the power-off duration is less than the first duration, determining that the data in the volatile memory is correct; if the power-off duration is correct; If it is longer than the first duration and shorter than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified; if the power-off duration is longer than the second duration, it is determined that the data in the volatile memory is incorrect. The first duration indicates that the power-off time of the terminal is short enough to ensure that the data on the volatile memory will not be wrong. Therefore, when the power-off duration of the terminal is shorter than the first duration, the terminal can skip the step of data verification. Similarly, the second time period indicates that the power-off time of the terminal is long enough that the data on the volatile memory must have been erroneous.
本方案中,通过设定第一时长和第二时长,可以使得终端能够根据实际断电时长决定是否需要进行数据验证,避免了每次恢复供电后都进行数据验证,节省了终端进行数据验证的时间,延长终端有效运行的时间。In this solution, by setting the first duration and the second duration, the terminal can decide whether to perform data verification according to the actual power-off duration, which avoids performing data verification every time the power is restored, and saves the terminal having to perform data verification. time to prolong the effective operation time of the terminal.
在一些可能的实现方式中,在终端执行第一程序段之前,该方法还包括:根据终端的电压高于阈值电压,执行一个或多个第二程序段。第二程序段可以是指第一程序段所属的程序中的任意一个其他的程序段,该程序中可以包括有一个或多个第二程序段。终端标记执行一个或多个第二程序段时所使用的地址区间。根据当前电压低于阈值电压,终端计算被标记的地址区间对应的校验码。In some possible implementations, before the terminal executes the first program segment, the method further includes: executing one or more second program segments according to the voltage of the terminal being higher than the threshold voltage. The second program segment may refer to any other program segment in the program to which the first program segment belongs, and the program may include one or more second program segments. The terminal marks the address range used when executing one or more second program segments. According to the current voltage lower than the threshold voltage, the terminal calculates the check code corresponding to the marked address interval.
换句话说,在终端处于高电量水平时,终端在执行完程序段之后只标记已修改的地址区间;在终端处于低电量水平时,终端再统一对已标记的地址区间进行校验码计算,以尽可能减少计算校验码的次数。In other words, when the terminal is at a high battery level, the terminal will only mark the modified address range after executing the program segment; when the terminal is at a low battery level, the terminal will uniformly calculate the check code for the marked address range. In order to reduce the number of times of calculating the check code as much as possible.
在一些可能的实现方式中,在终端执行第一程序段之前,该方法还包括:终端确定第一程序段对应的第一地址区间;终端获取第一地址区间对应的校验码,第一地址区间对应的校验码存储于易失性存储器中;终端根据第一地址区间对应的校验码确定第一地址区间中的数据正确;基于第一地址区间中的数据正确,终端确定可以执行第一程序段。In some possible implementations, before the terminal executes the first program segment, the method further includes: the terminal determines a first address interval corresponding to the first program segment; the terminal obtains a check code corresponding to the first address interval, the first address The check code corresponding to the interval is stored in the volatile memory; the terminal determines that the data in the first address interval is correct according to the check code corresponding to the first address interval; based on the correctness of the data in the first address interval, the terminal determines that the first address interval can be executed. a program segment.
本方案中,基于易失性存储器中的数据是随机性发生变化的特性,在确定校验码无误的情况下,基于校验码确定程序段要使用的数据是否正确,能够进一步确保数据的正确性,保证终端的正常运行。In this solution, based on the characteristics of random changes in the data in the volatile memory, when the check code is determined to be correct, it is determined whether the data to be used in the program segment is correct based on the check code, which can further ensure the correctness of the data. to ensure the normal operation of the terminal.
在一些可能的实现方式中,方法还包括:终端周期性地将易失性存储器中的数据存储至非易失性存储器,从而实现定期在非易失性存储器中备份检测点。这样,在终端恢复供电后,确定易失性存储器中的数据验证有误时,可以恢复到最近一次存储在NVM中的检测点,避免终端频繁地重复执行程序。In some possible implementation manners, the method further includes: the terminal periodically stores data in the volatile memory to the non-volatile memory, so as to periodically backup the detection point in the non-volatile memory. In this way, after the terminal restores power supply, when it is determined that the data in the volatile memory is verified incorrectly, the detection point stored in the NVM can be restored to the latest detection point, so as to avoid the terminal repeatedly executing the program frequently.
本申请第二方面提供一种终端,该终端包括:处理单元和获取单元;处理单元,用于执行第一程序段;处理单元,还用于计算第一地址区间对应的第一校验码,第一地址区间为执行第一程序段时所使用的地址区间;获取单元,用于获取第二地址区间对应的第二校验码,第二地址区间为第三地址区间中除第一地址区间之外的地址区间,第三地址区间为执行第一程序段所属的程序时所使用的地址区间;处理单元,还用于根据第一校验码和第二校验码,确定第三校验码,第三校验码为第三地址区间对应的校验码;处理单元,还用于将第三校验码存储于非易失性存储器,第三校验码用于在终端恢复供电后校验易失性存储器中的数据的正确性,第三地址区间位于易失性存储器中。A second aspect of the present application provides a terminal, the terminal includes: a processing unit and an obtaining unit; a processing unit configured to execute a first program segment; and a processing unit configured to calculate a first check code corresponding to a first address interval, The first address interval is the address interval used when executing the first program segment; the obtaining unit is used to obtain the second check code corresponding to the second address interval, and the second address interval is the third address interval except the first address interval The third address interval is the address interval used when executing the program to which the first program segment belongs; the processing unit is also used to determine the third check code according to the first check code and the second check code The third check code is the check code corresponding to the third address interval; the processing unit is also used to store the third check code in the non-volatile memory, and the third check code is used after the terminal restores power supply The correctness of the data in the volatile memory is checked, and the third address range is located in the volatile memory.
在一些可能的实现方式中,易失性存储器中还包括第四地址区间,第四地址区间存储的数据与执行第一程序段前第三地址区间存储的数据相同;其中,第三地址区间被标记为工作区间,第四地址区间被标记为备份区间,工作区间为程序执行时所使用的区间,备份区间用于备份工作区间的数据。In some possible implementations, the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed; wherein, the third address interval is It is marked as a working area, the fourth address area is marked as a backup area, the working area is an area used when the program is executed, and the backup area is used for backing up data in the working area.
在一些可能的实现方式中,处理单元具体用于:计算第四地址区间中与第一地址区间对应的地址区间的第四校验码;根据第四地址区间对应的校验码以及第四校验码,确定第二校验码。In some possible implementations, the processing unit is specifically configured to: calculate the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; Check the code to determine the second check code.
在一些可能的实现方式中,处理单元还用于:将第四地址区间标记为工作区间,以及将第三地址区间标记为备份区间;将第三地址区间的数据拷贝至第四地址区间。In some possible implementations, the processing unit is further configured to: mark the fourth address interval as a working interval, and mark the third address interval as a backup interval; and copy the data of the third address interval to the fourth address interval.
在一些可能的实现方式中,处理单元还用于:将第一校验码和第二校验码存储于易失性存储器,第一校验码和第二校验码用于在终端恢复供电后与第三校验码进行比对,以验证易失性存储器中的数据的正确性。In some possible implementations, the processing unit is further configured to: store the first check code and the second check code in a volatile memory, and the first check code and the second check code are used to restore power at the terminal Then, it is compared with the third check code to verify the correctness of the data in the volatile memory.
在一些可能的实现方式中,处理单元还用于:在终端恢复供电后,获取终端的断电时长;若断电时长小于第一时长,则确定易失性存储器中的数据正确;若断电时长大于第一时长且小于第二时长,则确定需要校验易失性存储器中的数据的正确性;若断电时长大于第二时长,则确定易失性存储器中的数据不正确;其中,第一时长小于第二时长。In some possible implementation manners, the processing unit is further configured to: obtain the power-off duration of the terminal after the power supply of the terminal is restored; if the power-off duration is less than the first duration, determine that the data in the volatile memory is correct; if the power-off duration is correct; If the duration is greater than the first duration and less than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified; if the power-off duration is greater than the second duration, it is determined that the data in the volatile memory is incorrect; wherein, The first duration is shorter than the second duration.
在一些可能的实现方式中,处理单元还用于:根据终端的电压高于阈值电压,执行一个或多个第二程序段;标记执行一个或多个第二程序段时所使用的地址区间;根据终端的电压低于阈值电压,计算被标记的地址区间对应的校验码。In some possible implementations, the processing unit is further configured to: execute one or more second program segments according to the voltage of the terminal being higher than the threshold voltage; mark the address range used when executing the one or more second program segments; According to the voltage of the terminal being lower than the threshold voltage, the check code corresponding to the marked address interval is calculated.
在一些可能的实现方式中,处理单元还用于:确定第一程序段对应的第一地址区间;获取第一地址区间对应的校验码,第一地址区间对应的校验码存储于易失性存储器中;根据第一地址区间对应的校验码确定第一地址区间中的数据正确;基于第一地址区间中的数据正确,确定执行第一程序段。In some possible implementations, the processing unit is further configured to: determine a first address interval corresponding to the first program segment; acquire a check code corresponding to the first address interval, and store the check code corresponding to the first address interval in a volatile According to the check code corresponding to the first address interval, it is determined that the data in the first address interval is correct; based on the correctness of the data in the first address interval, it is determined to execute the first program segment.
在一些可能的实现方式中,处理单元还用于:将易失性存储器中的数据周期性地存储至非易失性存储器。In some possible implementations, the processing unit is further configured to: periodically store data in the volatile memory to the non-volatile memory.
本申请第三方面提供一种终端,该终端包括:处理器、非易失性存储器和易失性存储器;其中,非易失性存储器或易失性存储器中存储有计算机可读指令;处理器读取所述计算机可读指令以使终端实现如第一方面任意一种实现方式所述的方法。A third aspect of the present application provides a terminal, the terminal includes: a processor, a nonvolatile memory, and a volatile memory; wherein the nonvolatile memory or the volatile memory stores computer-readable instructions; the processor The computer-readable instructions are read to cause the terminal to implement the method according to any one of the implementations of the first aspect.
本申请第四方面提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第一方面任意一种实现方式所述的方法。A fourth aspect of the present application provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when it runs on a computer, causes the computer to execute any one of the implementation manners of the first aspect. method.
本申请第五方面提供一种计算机程序产品,当其在计算机上运行时,使得计算机执行如第一方面任意一种实现方式所述的方法。A fifth aspect of the present application provides a computer program product, which, when executed on a computer, causes the computer to execute the method described in any one of the implementation manners of the first aspect.
本申请第六方面提供一种芯片,包括一个或多个处理器。所述处理器中的部分或全部用于读取并执行存储器中存储的计算机程序,以执行上述任一方面任意可能的实现方式中的方法。可选地,该芯片该包括存储器,该存储器与该处理器通过电路或电线与存储器连接。进一步可选地,该芯片还包括通信接口,处理器与该通信接口连接。通信接口用于接收需要处理的数据和/或信息,处理器从该通信接口获取该数据和/或信息,并对该数据和/或信息进行处理,并通过该通信接口输出处理结果。该通信接口可以是输入输出接口。本申请提供的方法可以由一个芯片实现,也可以由多个芯片协同实现。A sixth aspect of the present application provides a chip including one or more processors. Part or all of the processor is used to read and execute the computer program stored in the memory, so as to execute the method in any possible implementation manner of any of the above aspects. Optionally, the chip includes a memory, and the memory and the processor are connected to the memory through a circuit or a wire. Further optionally, the chip further includes a communication interface, and the processor is connected to the communication interface. The communication interface is used for receiving data and/or information to be processed, the processor obtains the data and/or information from the communication interface, processes the data and/or information, and outputs the processing result through the communication interface. The communication interface may be an input-output interface. The method provided by the present application may be implemented by one chip, or may be implemented by multiple chips cooperatively.
附图说明Description of drawings
图1为本申请实施例提供的一种物联网设备备份运行状态的示意图;FIG. 1 is a schematic diagram of a backup running state of an Internet of Things device according to an embodiment of the present application;
图2为本申请实施例提供的一种数据处理方法的流程示意图;2 is a schematic flowchart of a data processing method provided by an embodiment of the present application;
图3为本申请实施例提供的一种地址区间的分布示意图;3 is a schematic diagram of the distribution of an address range provided by an embodiment of the present application;
图4为本申请实施例提供的另一种地址区间的分布示意图;FIG. 4 is a schematic diagram of the distribution of another address range provided by an embodiment of the present application;
图5为本申请实施例提供的一种终端的运行对比示意图;FIG. 5 is a schematic diagram of an operation comparison of a terminal according to an embodiment of the present application;
图6a为本申请实施例提供的一种用于确定断电时长的电路的结构示意图;6a is a schematic structural diagram of a circuit for determining a power-off duration provided by an embodiment of the present application;
图6b为本申请实施例提供的一种时间保持电路的电压变化曲线示意图;6b is a schematic diagram of a voltage change curve of a time keeping circuit provided by an embodiment of the application;
图7为本申请实施例提供的一种执行程序段的流程示意图;FIG. 7 is a schematic flowchart of an execution program segment provided by an embodiment of the present application;
图8为本申请实施例提供的一种计算校验码的示意图;8 is a schematic diagram of calculating a check code according to an embodiment of the present application;
图9为本申请实施例提供的一种终端运行的流程示意图;FIG. 9 is a schematic flowchart of terminal operation according to an embodiment of the present application;
图10a为本申请实施例提供的一种程序段与地址区间之间的关系示意图;10a is a schematic diagram of the relationship between a program segment and an address interval provided by an embodiment of the present application;
图10b为本申请实施例提供的一种终端在低电量水平下执行程序段的流程示意图;10b is a schematic flowchart of a terminal executing a program segment at a low battery level according to an embodiment of the present application;
图11为本申请实施例提供的一种终端在恢复供电后的运行示意图;11 is a schematic diagram of the operation of a terminal after power supply is restored according to an embodiment of the present application;
图12为本申请实施例提供的一种终端1200的结构示意图;FIG. 12 is a schematic structural diagram of a terminal 1200 according to an embodiment of the present application;
图13为本申请实施例提供的一种终端100的结构示意图。FIG. 13 is a schematic structural diagram of a terminal 100 according to an embodiment of the present application.
具体实施方式detailed description
下面结合附图,对本申请的实施例进行描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The embodiments of the present application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Those of ordinary skill in the art know that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。 此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或模块的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或模块,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或模块。在本申请中出现的对步骤进行的命名或者编号,并不意味着必须按照命名或者编号所指示的时间/逻辑先后顺序执行方法流程中的步骤,已经命名或者编号的流程步骤可以根据要实现的技术目的变更执行次序,只要能达到相同或者相类似的技术效果即可。The terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It is to be understood that data so used may be interchanged under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or modules is not necessarily limited to those expressly listed Rather, those steps or modules may include other steps or modules not expressly listed or inherent to the process, method, product or apparatus. The naming or numbering of the steps in this application does not mean that the steps in the method flow must be executed in the time/logical sequence indicated by the naming or numbering, and the named or numbered process steps can be implemented according to the The technical purpose is to change the execution order, as long as the same or similar technical effects can be achieved.
随着物联网技术的发展,以及物联网设备的普及,物联网设备的部署数量在不断攀升。面对规模庞大的物联网设备群体,物联网设备并不适合继续采用传统的电池供电方式。具体来说,传统的电池供电方式并不环保,给每一个物联网设备配备一块电池会产生大量的电子垃圾;此外,采用电池供电的物联网设备维护困难,在苛刻的部署环境下难以给电池充电或更换电池。With the development of IoT technology and the popularity of IoT devices, the number of IoT devices deployed is increasing. In the face of a large group of IoT devices, IoT devices are not suitable to continue to use traditional battery-powered methods. Specifically, the traditional battery power supply method is not environmentally friendly. Equipping each IoT device with a battery will generate a large amount of electronic waste; in addition, battery-powered IoT devices are difficult to maintain, and it is difficult to supply batteries in harsh deployment environments. Charge or replace the battery.
因此,基于电池供电方式的限制性,一种新型的供电方式应运而生。通过在物联网设备上配置能量采集装置,可以使得物联网设备能够从运行环境采集能量来实现供电,例如采集光能、无线电射频、压力或热能等能量并且将这些能量转换为电能。采用能量采集的方式来驱动物联网设备,可以使得物联网设备的部署灵活性很强,降低了使用场景的限制,具有很强的健壮性。Therefore, based on the limitation of battery power supply, a new power supply method emerges as the times require. By configuring the energy harvesting device on the IoT device, the IoT device can collect energy from the operating environment to achieve power supply, such as harvesting energy such as light energy, radio frequency, pressure or thermal energy, and converting these energy into electrical energy. Using energy harvesting to drive IoT devices can make the deployment of IoT devices highly flexible, reduce the limitations of usage scenarios, and have strong robustness.
在采用能量采集的方式来驱动物联网设备的情况下,由于外界的能量源是不可预测且不稳定的,物联网设备可能会频繁地断电,导致物联网设备中的程序很难在一个供电周期内完成一次完整的执行。为了使得程序能够在频繁的断电过程中持续执行,间歇计算被提出,并被应用于物联网设备中。In the case of using energy harvesting to drive IoT devices, because the external energy source is unpredictable and unstable, IoT devices may be powered off frequently, making it difficult for programs in IoT devices to supply power in one A complete execution is completed within the cycle. In order to enable the continuous execution of programs during frequent power outages, intermittent computing is proposed and applied in IoT devices.
为了保证物联网设备能够在频繁断电的情况下持续推进执行程序,物联网设备在运行过程中需要频繁地在NVM上备份运行状态,即将寄存器的值以及程序执行时要使用的变量等数据备份至NVM,以便于在遭遇断电且恢复供电后,能够基于已备份的运行状态恢复运行。In order to ensure that the IoT device can continue to execute the program in the case of frequent power failure, the IoT device needs to frequently backup the running state on the NVM during the operation process, that is, the value of the register and the variables to be used when the program is executed. to the NVM, so that after a power outage is encountered and power is restored, the operation can be resumed based on the backed-up operating state.
示例性地,可以参阅图1,图1为本申请实施例提供的一种物联网设备备份运行状态的示意图。如图1所示,程序的执行流程为依次执行程序段1至程序段4。在每个程序段开始执行之前,将当前时刻的运行状态备份至NVM。如果在任一程序段执行过程中发生断电,在物联网设备恢复供电后,从NVM上获取在最近的检测点所备份的运行状态,从而恢复程序的执行,保证了物联网设备在频繁断电情况下的持续推进。Illustratively, reference may be made to FIG. 1 , which is a schematic diagram of a backup running state of an Internet of Things device according to an embodiment of the present application. As shown in FIG. 1 , the execution flow of the program is to execute the program segment 1 to the program segment 4 in sequence. Before each program segment starts to execute, backup the current running state to NVM. If a power failure occurs during the execution of any program segment, after the IoT device is powered back up, the running state backed up at the nearest detection point will be obtained from the NVM, so as to resume the program execution and ensure that the IoT device is frequently powered off. Continued advancement of the situation.
由于NVM写入速度慢且有写入寿命,频繁地向NVM备份运行状态会迅速降低NVM的寿命,最终导致物联网设备不可用。因此,为避免频繁备份运行状态,相关技术中采用易失性存储器来保存数据,以实现在短暂断电时不采用NVM备份运行状态。Due to the slow write speed and write lifetime of NVM, frequently backing up the running state to NVM will quickly reduce the lifetime of NVM and eventually make IoT devices unusable. Therefore, in order to avoid frequent backup of the running state, a volatile memory is used in the related art to save data, so as to realize that the NVM is not used to backup the running state during a brief power failure.
易失性存储器,例如SRAM,相比于NVM具有更快的读写速度、更低的能耗以及更长的使用寿命,并且具有数据保持特性。当处理器的供电电压低于某个阈值(通常为1.8V)时,处理器将停止工作,而SRAM依然能够保持存储的数据不出错误;随着供电电压继续降低,当SRAM的供电电压低于一个更低的阈值(通常为0.4V)后,SRAM上的数据将会陆续出错。Volatile memory, such as SRAM, has faster read and write speed, lower power consumption and longer life than NVM, and has data retention characteristics. When the power supply voltage of the processor is lower than a certain threshold (usually 1.8V), the processor will stop working, and the SRAM can still keep the stored data without errors; as the power supply voltage continues to decrease, when the power supply voltage of the SRAM is low After a lower threshold (usually 0.4V), the data on the SRAM will continue to fail.
由于物联网设备在大部分时间下,断电时间并不是很长。因此,可以利用SRAM的数据保持特性,在短断电的时候不向NVM备份状态,从而减少系统的状态备份开销。但是,由于SRAM保持数据不出错的时长是不确定的,因此需要在恢复供电后检测SRAM上的数据是否出错。Since IoT devices are in most of the time, the power outage time is not very long. Therefore, the data retention feature of SRAM can be used, and the state is not backed up to the NVM during a short power failure, thereby reducing the state backup overhead of the system. However, since the length of time that the SRAM keeps data without errors is uncertain, it is necessary to detect whether the data on the SRAM is erroneous after power is restored.
相关技术中,通过设定预警电压阈值,在物联网设备的电压低于预警电压阈值时,对SRAM中的全部数据进行校验,并将得到的校验码存储至NVM中,物联网设备再停止运行。在供电恢复后,对SRAM中的全部数据重新进行校验,并且得到的校验码与存储于NVM上的校验码进行比对。如果两个校验码相同,则认为断电期间SRAM中的数据没有发生错误,从中断点继续执行程序;如果两个校验码不相同,则认为断电期间SRAM中的数据发生了错误,需要重新开始执行程序。In the related art, by setting an early warning voltage threshold, when the voltage of the IoT device is lower than the warning voltage threshold, all data in the SRAM is verified, and the obtained verification code is stored in the NVM, and the IoT device can be used again. Stop running. After the power supply is restored, all data in the SRAM is re-checked, and the obtained check code is compared with the check code stored on the NVM. If the two check codes are the same, it is considered that there is no error in the data in the SRAM during the power-off, and the program execution continues from the interruption point; Execution program needs to be restarted.
然而,由于计算SRAM中的全部数据的校验码需要花费较长的时间,为保证能够顺利计算得到校验码并且将该校验码存储至非易失性存储器中,相关技术中通常将预警电压阈值设定为较高的电压值,容易导致物联网设备在剩余较多电量时就停止了运行,影响了物联网设备的实时响应性能。However, since it takes a long time to calculate the check code of all the data in the SRAM, in order to ensure that the check code can be successfully calculated and stored in the non-volatile memory, an early warning is usually used in the related art. The voltage threshold is set to a higher voltage value, which easily causes the IoT device to stop running when there is more power remaining, which affects the real-time response performance of the IoT device.
有鉴于此,本申请实施例提供了一种数据处理方法,在终端的运行过程中,终端执行完程序段之后,计算该程序段所使用的地址区间的校验码,并且基于该校验码以及整个程序所使用的地址区间中的其他地址区间的校验码,确定易失性存储器中的数据的总校验码,无需对整个保存数据的地址区间进行校验码的计算,从而减少计算校验码的能耗和时间,使得终端能够持续运行,保证了终端的实时响应性能。In view of this, an embodiment of the present application provides a data processing method. During the operation of the terminal, after the terminal executes the program segment, the check code of the address range used by the program segment is calculated, and based on the check code As well as the check codes of other address ranges in the address range used by the whole program, determine the total check code of the data in the volatile memory, and do not need to calculate the check code for the entire address range where the data is stored, thus reducing the calculation The energy consumption and time of the check code enable the terminal to run continuously and ensure the real-time response performance of the terminal.
为了便于理解,以下将对本申请实施例所涉及一些技术术语做详细的介绍。For ease of understanding, some technical terms involved in the embodiments of the present application will be introduced in detail below.
校验:对目标数据进行校验运算,例如循环冗余校验(Cyclic Redundancy Check,CRC)运算,得到该数据的校验码。Check: perform check operation on the target data, such as Cyclic Redundancy Check (CRC) operation, to obtain the check code of the data.
验证:对目标数据进行校验运算,将得到的新校验码和此前对目标数据进行校验运算获得的校验码比对,以确定目标数据是否发生变化的过程。Verification: The process of performing a check operation on the target data, and comparing the new check code obtained with the check code obtained by performing the check operation on the target data before to determine whether the target data has changed.
异或运算
Figure PCTCN2021118918-appb-000001
一种逻辑运算方式。如果a、b两个值不相同,则a、b执行异或运算后得到的异或结果为1。如果a、b两个值相同,则a、b执行异或运算后得到的异或结果为0。在二进制运算中,
Figure PCTCN2021118918-appb-000002
XOR
Figure PCTCN2021118918-appb-000001
A logical operation. If the two values of a and b are not the same, the XOR result obtained after the XOR operation of a and b is 1. If the two values of a and b are the same, the XOR result obtained by a and b after performing the XOR operation is 0. In binary operations,
Figure PCTCN2021118918-appb-000002
CRC:一种信道编码技术,能够根据网络数据包或计算机文件等数据产生固定位数的校验码,主要用于检测数据传输或者保存后可能出现的错误。CRC具备线性可加性和零填充(zero-padding)等数学性质。CRC: A channel coding technology that can generate a fixed-digit check code based on data such as network packets or computer files, which is mainly used to detect errors that may occur after data transmission or storage. CRC has mathematical properties such as linear additivity and zero-padding.
CRC的线性可加性可以如公式1所示:The linear additivity of CRC can be expressed as Equation 1:
Figure PCTCN2021118918-appb-000003
Figure PCTCN2021118918-appb-000003
其中,A和B为两个独立数据,CRC的线性可加性是指A和B进行异或运算后的CRC结果,与分别对A和B进行CRC运算再进行异或运算的结果相等。Among them, A and B are two independent data, and the linear additivity of CRC refers to the CRC result after A and B perform XOR operation, which is equal to the result of performing CRC operation on A and B respectively and then XOR operation.
CRC的zero-padding性质可以如公式2所示:The zero-padding property of CRC can be shown in Equation 2:
Figure PCTCN2021118918-appb-000004
Figure PCTCN2021118918-appb-000004
其中,A0...0表示在数据A后增加n个0,即将数据A左移n位。CRC的zero-padding性质是指一个数据左移n位后的CRC结果可以由其乘以某个系数直接得出,而不必重新计算整个数据的CRC。Among them, A0...0 means adding n zeros after the data A, that is, shifting the data A to the left by n bits. The zero-padding property of CRC means that the CRC result after a left shift of data by n bits can be directly obtained by multiplying it by a certain coefficient, without having to recalculate the CRC of the entire data.
本申请以下实施例所涉及的终端是指安装有程序应用,且能够间歇性工作的设备,例如可以为物联网设备。该终端中可以设置有能量采集装置,能够从运行环境采集能量来实现终端的供电,例如采集光能、无线电射频、压力或热能等能量并且将这些能量转换为电能,以供该终端间歇性地工作。例如,终端可以是指物联网中具有传感器检测功能或智能功能的接入设备,可以应用于户外、仓库或者室内等环境中,比如支持温度检测的防火设备、光线检测设备、湿度检测设备等监测设备,智能开关、智能摄像头、智能水表、智能家电等智能家居设备。The terminal involved in the following embodiments of the present application refers to a device installed with a program application and capable of working intermittently, for example, an Internet of Things device. The terminal may be provided with an energy collection device, which can collect energy from the operating environment to realize the power supply of the terminal, such as collecting light energy, radio frequency, pressure or heat energy and converting these energy into electric energy for intermittently supplying the terminal Work. For example, a terminal may refer to an access device with a sensor detection function or an intelligent function in the Internet of Things, which can be used in outdoor, warehouse, or indoor environments, such as fire protection equipment that supports temperature detection, light detection equipment, humidity detection equipment and other monitoring equipment , smart switches, smart cameras, smart water meters, smart home appliances and other smart home equipment.
可以参阅图2,图2为本申请实施例提供的一种数据处理方法的流程示意图。如图2所示,本申请实施例提供了一种数据处理方法,该方法应用于间歇性工作的终端,该方法可以包括以下的步骤。Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a data processing method provided by an embodiment of the present application. As shown in FIG. 2 , an embodiment of the present application provides a data processing method. The method is applied to a terminal that works intermittently. The method may include the following steps.
步骤201,终端执行第一程序段。 Step 201, the terminal executes the first program segment.
本实施例中,在终端中可以安装有一个或多个应用程序,每个应用程序可以包括多个程序段。对于一个应用程序而言,应用程序具有其对应的应用程序代码,终端通过执行应用程序代码来实现应用程序的运行。In this embodiment, one or more application programs may be installed in the terminal, and each application program may include multiple program segments. For an application, the application has its corresponding application code, and the terminal implements the running of the application by executing the application code.
一个应用程序代码可以被分隔为多个不重复的子代码片段,子代码片段也可以称为程序段或原子执行片段(Atomic Execution Block,AEB)。将一个应用程序代码分隔为多个程序段的方式可以包括但不限于以下的方式:基于静态检测技术获取应用程序代码中的多个检测点,并且根据该多个检测点来分隔应用程序代码,即相邻的两个检测点之间的代码片段为一个程序段;或者,在应用程序代码是基于任务模型所编写的情况下,一个应用程序代码可以对应多个任务,应用程序代码中的每个程序段即为每个任务对应的子代码片段。An application code can be divided into multiple non-repetitive sub-code segments, which can also be called program segments or Atomic Execution Block (AEB). The manner of dividing an application code into multiple program segments may include, but is not limited to, the following manners: acquiring multiple detection points in the application code based on the static detection technology, and separating the application code according to the multiple detection points, That is, the code segment between two adjacent detection points is a program segment; or, if the application code is written based on the task model, one application code can correspond to multiple tasks, and each application code in the application code can correspond to multiple tasks. Each program segment is the subcode segment corresponding to each task.
由一个应用程序代码分隔成的多个程序段具有固定的执行顺序,终端在运行期间,可以按照多个程序段的执行顺序依次执行该多个程序段。上述的第一程序段则可以为终端当前所执行的程序段。Multiple program segments divided by an application code have a fixed execution sequence, and the terminal can execute the multiple program segments in sequence according to the execution sequence of the multiple program segments during operation. The above-mentioned first program segment may be the program segment currently executed by the terminal.
步骤202,终端计算第一地址区间对应的第一校验码,该第一地址区间为执行第一程序段时所使用的地址区间。 Step 202, the terminal calculates a first check code corresponding to a first address interval, where the first address interval is an address interval used when executing the first program segment.
应理解,在终端执行程序段的过程中,需要访问存储器中的数据,并且对这些数据进行修改,以实现程序段的执行。对于一个程序段而言,终端需要访问的数据通常位于存储器中固定的地址区间中,终端通过访问该地址区间,可以获得并修改该地址区间中的数据,该地址区间可以称为终端执行程序段时所使用的地址区间。It should be understood that, in the process of executing the program segment by the terminal, it is necessary to access data in the memory and modify the data to realize the execution of the program segment. For a program segment, the data that the terminal needs to access is usually located in a fixed address range in the memory. By accessing the address range, the terminal can obtain and modify the data in the address range. This address range can be called the terminal execution program segment. address range used.
通常,对于同一个程序段,终端执行该程序段时所使用的地址区间是固定不变的,终端可以确定执行时每一个程序段时所使用的地址区间。例如,在程序开发者预先指定程序段对应的地址区间,或者基于相关技术中的分析工具捕获得到每一个程序段对应的地址区 间的情况下,终端可以基于程序段与地址区间之间的映射关系,确定在执行每一个程序段时所使用的地址区间。Usually, for the same program segment, the address range used by the terminal when executing the program segment is fixed, and the terminal can determine the address range used when executing each program segment. For example, when the program developer pre-specifies the address range corresponding to the program segment, or captures the address range corresponding to each program segment based on the analysis tool in the related art, the terminal can be based on the mapping relationship between the program segment and the address range. , to determine the address range used when executing each program segment.
本实施例中,终端可以确定执行第一程序段时所使用的第一地址区间,并且在终端执行完第一程序段之后,计算该第一地址区间对应的第一校验码。终端例如可以是通过CRC运算来计算第一地址区间中的数据所对应的校验码,从而得到第一校验码。终端也可以是通过其他的校验运算方式来计算得到该第一校验码,只要该校验运算方式具备上述的线性可加性以及zero-padding性质即可,本实施例不对终端计算校验码的方式做具体限定。为便于描述,以下将以终端基于CRC运算得到校验码的方式为例,对以下的实施例进行描述。In this embodiment, the terminal may determine the first address interval used when executing the first program segment, and after the terminal finishes executing the first program segment, calculate the first check code corresponding to the first address interval. For example, the terminal may calculate the check code corresponding to the data in the first address interval through CRC operation, thereby obtaining the first check code. The terminal may also obtain the first check code by calculating the first check code through other check operation methods, as long as the check operation method has the above-mentioned linear additivity and zero-padding properties, and this embodiment does not calculate the check code for the terminal. The code method is specifically limited. For convenience of description, the following embodiments will be described below by taking the manner in which the terminal obtains the check code based on the CRC operation as an example.
步骤203,终端获取第二地址区间对应的第二校验码,第二地址区间为第三地址区间中除第一地址区间之外的地址区间,第三地址区间为执行第一程序段所属的程序时所使用的地址区间。 Step 203, the terminal obtains the second check code corresponding to the second address interval, the second address interval is the address interval other than the first address interval in the third address interval, and the third address interval is the execution of the first program segment. The address range used in the program.
应理解,由于终端中的每个程序段都有固定对应的地址区间,同一个程序中的所有程序段所对应的多个地址区间可以构成该程序所对应的地址区间。It should be understood that since each program segment in the terminal has a fixed corresponding address range, multiple address ranges corresponding to all the program segments in the same program may constitute the address range corresponding to the program.
例如,程序A包括有程序段A1、程序段A2和程序段A3,三个程序段分别对应地址区间1、地址区间2和地址区间3;那么,由地址区间1、地址区间2和地址区间3所构成的地址区间4即为该程序A对应的地址区间。其中,地址区间1、地址区间2和地址区间3可以为三个分别独立的地址区间,例如地址区间1的范围为1-10,地址区间2的范围为11-15,地址区间3的范围为16-20,地址区间4的范围即为1-20。地址区间1、地址区间2和地址区间3之间也可以具有重合的地址范围,例如地址区间1的范围为1-10,地址区间2的范围为5-15,地址区间3的范围为10-20,地址区间4的范围同样为1-20。For example, program A includes program segment A1, program segment A2 and program segment A3, and the three program segments correspond to address interval 1, address interval 2 and address interval 3 respectively; then, the address interval 1, address interval 2 and address interval 3 The formed address range 4 is the address range corresponding to the program A. Wherein, address interval 1, address interval 2 and address interval 3 may be three separate address intervals, for example, the range of address interval 1 is 1-10, the range of address interval 2 is 11-15, and the range of address interval 3 is 16-20, the range of address interval 4 is 1-20. Address interval 1, address interval 2 and address interval 3 may also have overlapping address ranges. For example, the range of address interval 1 is 1-10, the range of address interval 2 is 5-15, and the range of address interval 3 is 10-10. 20, the range of address interval 4 is also 1-20.
也就是说,在本实施例中,终端可以确定执行第一程序段所属的程序时所使用的地址区间(即第三地址区间),并且根据该第三地址区间以及第一地址区间,确定第三地址区间中除第一地址区间之外的地址区间(即第二地址区间)。由于第二地址区间是终端执行该程序中的其他程序段时所使用的地址区间,在其他程序段执行完毕时,终端同样会计算得到其他程序段所使用的地址区间的校验码,因此终端可以获取到该第二地址区间对应的第二校验码。That is to say, in this embodiment, the terminal may determine the address interval (ie, the third address interval) used when executing the program to which the first program segment belongs, and determine the first address interval according to the third address interval and the first address interval. Among the three address intervals, an address interval other than the first address interval (ie, the second address interval). Since the second address interval is the address interval used by the terminal when executing other program segments in the program, when the execution of other program segments is completed, the terminal will also calculate the check code of the address interval used by other program segments, so the terminal The second check code corresponding to the second address interval can be obtained.
步骤204,终端根据第一校验码和第二校验码,确定第三校验码,第三校验码为第三地址区间对应的校验码。 Step 204, the terminal determines a third check code according to the first check code and the second check code, where the third check code is a check code corresponding to the third address interval.
在终端获得第一校验码和第二校验码之后,终端可以基于校验运算的zero-padding性质,根据第一校验码和第二校验码确定第三地址区间对应的第三校验码。After the terminal obtains the first check code and the second check code, the terminal may determine the third check code corresponding to the third address interval according to the first check code and the second check code based on the zero-padding property of the check operation. code verification.
示例性地,可以参阅图3,图3为本申请实施例提供的一种地址区间的分布示意图。如图3所示,假设第一地址区间的数据表示为1010,第二地址区间的数据表示为2020,则第一地址区间对应的第一校验码可以表示为CS1=CRC(1010),第二地址区间对应的第二校验码可以表示为CS2=CRC(2020),第三地址区间对应的第三校验码可以表示为CS3=CRC(1010,2020)。基于CRC的zero-padding性质可知,第三校验码CS3可以根据以下的公式3计算得到:Illustratively, reference may be made to FIG. 3 , which is a schematic diagram of distribution of an address range provided by an embodiment of the present application. As shown in FIG. 3 , assuming that the data in the first address interval is represented as 1010 and the data in the second address interval is represented as 2020, the first check code corresponding to the first address interval can be represented as CS1=CRC(1010), The second check code corresponding to the second address interval may be expressed as CS2=CRC(2020), and the third check code corresponding to the third address interval may be expressed as CS3=CRC(1010, 2020). Based on the zero-padding property of CRC, the third check code CS3 can be calculated according to the following formula 3:
Figure PCTCN2021118918-appb-000005
Figure PCTCN2021118918-appb-000005
其中,公式3中的常数为给定的一个常数值。由公式3可知,基于两个地址区间分别对应的校验码,可以计算得到两个地址区间对应的总校验码。Among them, the constant in formula 3 is a given constant value. It can be known from Equation 3 that, based on the check codes corresponding to the two address ranges respectively, the total check codes corresponding to the two address ranges can be calculated.
应理解,以上公式3是以第二校验码为第二地址区间对应的一个校验码为例,描述了基于第一校验码和第二校验码计算得到第三校验码的过程。在实际情况中,第二地址区间也可以被分为多个地址区间,且构成第二地址区间的多个地址区间均有对应的校验码,则第二校验码也可以是指第二地址区间中的多个地址区间所对应的多个校验码。It should be understood that the above formula 3 takes the second check code as a check code corresponding to the second address interval as an example, and describes the process of calculating the third check code based on the first check code and the second check code. . In an actual situation, the second address interval can also be divided into multiple address intervals, and the multiple address intervals constituting the second address interval have corresponding check codes, so the second check code may also refer to the second check code. Multiple check codes corresponding to multiple address ranges in the address range.
示例性地,可以参阅图4,图4为本申请实施例提供的另一种地址区间的分布示意图。如图4所示,第一地址区间包括地址区间1,第一校验码可以是指地址区间1对应的校验码,即第一校验码为CRC(1010);第二地址区间则包括地址区间2以及地址区间3,第二校验码可以是指地址区间2以及地址区间3对应的校验码,第二校验码可以包括CRC(1010)和CRC(1010)。Exemplarily, reference may be made to FIG. 4 , which is a schematic diagram of distribution of another address range provided by this embodiment of the present application. As shown in FIG. 4 , the first address interval includes address interval 1, and the first check code may refer to the check code corresponding to address interval 1, that is, the first check code is CRC (1010); the second address interval includes In address interval 2 and address interval 3, the second check code may refer to the check codes corresponding to address interval 2 and address interval 3, and the second check code may include CRC(1010) and CRC(1010).
类似地,在第二校验码是指第二地址区间对应的多个校验码的情况下,同样可以基于CRC的zero-padding性质,由第一校验码和第二校验码计算得到第三校验码,本实施例不再对具体的计算过程赘述。Similarly, when the second check code refers to multiple check codes corresponding to the second address interval, it can also be calculated from the first check code and the second check code based on the zero-padding property of CRC. For the third check code, the specific calculation process is not repeated in this embodiment.
步骤205,将第三校验码存储于NVM,第三校验码用于在终端恢复供电后校验易失性存储器中的数据的正确性,第三地址区间位于易失性存储器中。Step 205: Store the third check code in the NVM, the third check code is used to check the correctness of the data in the volatile memory after the terminal restores power supply, and the third address interval is located in the volatile memory.
终端在计算得到第三校验码之后,可以将第三校验码存储至NVM中,以保证第三校验码在终端断电之后的正确性。由于在终端断电之后,NVM中的数据也不会发生错误,因此,当终端经历断电并恢复供电之后,终端可以根据存储于NVM中的第三校验码,对第三地址区间中的数据进行验证。也就是说,在恢复供电之后,终端可以重新计算位于易失性存储器中的第三地址区间的校验码,并且将重新计算得到的校验码与存储于NVM中的第三校验码进行比对。如果两个校验码相同,则可以认为易失性存储器中的数据在断电期间没有发生错误,终端可以基于易失性存储器中的数据继续执行程序;如果两个校验码不相同,则可以认为易失性存储器中的数据在断电期间发生了错误,终端不能够再基于易失性存储器中的数据执行程序。After the terminal calculates and obtains the third check code, the third check code may be stored in the NVM to ensure the correctness of the third check code after the terminal is powered off. Since the data in the NVM will not be wrong after the terminal is powered off, after the terminal is powered off and the power is restored, the terminal can check the data in the third address range according to the third check code stored in the NVM. data is verified. That is to say, after the power supply is restored, the terminal can recalculate the check code of the third address interval located in the volatile memory, and compare the recalculated check code with the third check code stored in the NVM. Comparison. If the two check codes are the same, it can be considered that there is no error in the data in the volatile memory during the power-off, and the terminal can continue to execute the program based on the data in the volatile memory; if the two check codes are different, then It can be considered that the data in the volatile memory has an error during the power failure, and the terminal can no longer execute the program based on the data in the volatile memory.
本实施例中,终端通过在执行完程序段之后,计算该程序段所使用的地址区间的校验码,并且基于该校验码以及整个程序所使用的地址区间中的其他地址区间的校验码,可以确定程序所使用的地址区间的总校验码。终端不再需要对整个保存数据的地址区间进行校验码的计算,从而减少计算校验码的能耗和时间,使得终端能够持续运行,保证了终端的实时响应性能。In this embodiment, after executing the program segment, the terminal calculates the check code of the address range used by the program segment, and checks the check code and other address ranges in the address range used by the whole program based on the check code. The total check code of the address range used by the program can be determined. The terminal no longer needs to calculate the check code for the entire address range where the data is stored, thereby reducing the energy consumption and time for calculating the check code, enabling the terminal to run continuously, and ensuring the real-time response performance of the terminal.
可以参阅图5,图5为本申请实施例提供的一种终端的运行对比示意图。如图5所示,在相关技术中,终端在其电压达到预警电压之后则停止执行程序,而处理器实际上在一段 时间之后才会真正断电。在终端停止执行程序直至处理器断电的时间内,终端处于待机状态,程序无法持续推进,导致终端的实时响应性较差。Referring to FIG. 5 , FIG. 5 is a schematic diagram of operation comparison of a terminal according to an embodiment of the present application. As shown in Figure 5, in the related art, the terminal stops executing the program after its voltage reaches the pre-warning voltage, and the processor is actually powered off after a period of time. During the time when the terminal stops executing the program until the processor is powered off, the terminal is in a standby state, and the program cannot be continuously advanced, resulting in poor real-time responsiveness of the terminal.
在本实施例提供的方案中,终端在其电压达到预警电压之后,可以持续执行程序段,并且对程序段所使用的地址区间进行校验,以保证恢复供电后的数据正确性。这样一来,在处理器真正断电之前,终端一直在推进程序的执行,直至处理器断电停止运行。也就是说,在本方案中,终端能够尽可能地延长其执行程序的时间,保证了终端的实时响应性能。In the solution provided by this embodiment, the terminal can continue to execute the program segment after its voltage reaches the pre-warning voltage, and verify the address range used by the program segment to ensure the correctness of the data after the power supply is restored. In this way, until the processor is actually powered off, the terminal continues to advance the execution of the program until the processor is powered off and stops running. That is to say, in this solution, the terminal can prolong the execution time of the program as much as possible, which ensures the real-time response performance of the terminal.
在一个可能的实施例中,终端可以周期性地将易失性存储器中的数据存储至NVM。例如,终端可以每隔5分钟或10分钟,则将易失性存储器中的数据拷贝至NVM中,从而实现定期在NVM中备份检测点。这样,在终端恢复供电后,确定易失性存储器中的数据验证有误时,可以恢复到最近一次存储在NVM中的检测点,避免终端频繁地重复执行程序。In one possible embodiment, the terminal may periodically store the data in the volatile memory to the NVM. For example, the terminal may copy the data in the volatile memory to the NVM every 5 minutes or 10 minutes, so as to periodically back up the detection point in the NVM. In this way, after the terminal restores power supply, when it is determined that the data in the volatile memory is verified incorrectly, the detection point stored in the NVM can be restored to the latest detection point, so as to avoid the terminal repeatedly executing the program frequently.
在一个可能的实施例中,终端还可以是将第一校验码和第二校验码存储于易失性存储器,将第三校验码存储于NVM。这样,终端在发生断电且恢复供电之后,可以直接基于易失性存储器中的第一校验码和第二校验码计算新的校验码,并且将该新的校验码与存储于NVM中的第三校验码进行比对。如果新的校验码与第三校验码相同,则可以确定易失性存储器中的第一校验码和第二校验码没有发生错误,即可以认为易失性存储器中的数据在断电期间没有发生错误;如果新的校验码与第三校验码不相同,则可以确定易失性存储器中的第一校验码或第二校验码发生了错误,即可以认为易失性存储器中的数据在断电期间已经发生错误。In a possible embodiment, the terminal may also store the first check code and the second check code in a volatile memory, and store the third check code in the NVM. In this way, after a power failure occurs and the power is restored, the terminal can directly calculate a new check code based on the first check code and the second check code in the volatile memory, and store the new check code with the The third check code in the NVM is compared. If the new check code is the same as the third check code, it can be determined that there is no error in the first check code and the second check code in the volatile memory, that is, it can be considered that the data in the volatile memory is broken. There is no error during the power-up period; if the new check code is different from the third check code, it can be determined that the first check code or the second check code in the volatile memory has an error, that is, it can be considered as volatile The data in the nonvolatile memory has been corrupted during the power outage.
通过将第一校验码和第二校验码存储于易失性存储器中,来实现易失性存储器中的数据的正确性的验证,可以省去重新计算易失性存储器中数据的校验码的过程,节省了终端验证数据正确性的时间,延长终端有效运行的时间。By storing the first check code and the second check code in the volatile memory, the verification of the correctness of the data in the volatile memory can be realized, and the verification of the data in the volatile memory can be omitted. The code process saves the time for the terminal to verify the correctness of the data and prolongs the effective operation time of the terminal.
在一个可能的实施例中,在终端通过存储于易失性存储器中的校验码以及存储于NVM中的校验码,来验证断电后易失性存储器中的数据的正确性时,终端还可以在执行每个程序段之前,基于易失性存储器中的校验码对程序段进行验证,以进一步确保数据的正确性。In a possible embodiment, when the terminal uses the check code stored in the volatile memory and the check code stored in the NVM to verify the correctness of the data in the volatile memory after power off, the terminal Before executing each program segment, the program segment can also be verified based on the check code in the volatile memory to further ensure the correctness of the data.
示例性地,终端在执行第一程序段之前,可以确定第一程序段对应的第一地址区间,并且获取第一地址区间对应的校验码,第一地址区间对应的校验码存储于易失性存储器中。如果终端根据第一地址区间对应的校验码确定第一地址区间中的数据正确之后,则确定可以执行第一程序段。如果第一地址区间的数据不正确,则终端可以重新启动系统或恢复至NVM上存储的最近的一个检测点。Exemplarily, before executing the first program segment, the terminal may determine the first address interval corresponding to the first program segment, and obtain the check code corresponding to the first address interval, and the check code corresponding to the first address interval is stored in an easy-to-use address. in volatile memory. If the terminal determines that the data in the first address interval is correct according to the check code corresponding to the first address interval, it determines that the first program segment can be executed. If the data in the first address interval is incorrect, the terminal can restart the system or restore to the latest detection point stored on the NVM.
应理解,由于易失性存储器中的数据是随机性发生变化的,在确定校验码无误的情况下,在执行程序段之前,基于校验码确定该程序段对应的地址区间中的数据是否正确,能够进一步确保数据的正确性,保证终端的正常运行。It should be understood that since the data in the volatile memory changes randomly, in the case of determining that the check code is correct, before executing the program segment, it is determined whether the data in the address interval corresponding to the program segment is based on the check code. Correct, can further ensure the correctness of the data and ensure the normal operation of the terminal.
由于易失性存储器具有数据保持特性,在终端断电时间较短的情况下,即便是不验证 易失性存储器中的数据,也可以确定易失性存储器没有发生错误。而在终端断电时间较长的情况下,即便是不验证易失性存储器中的数据,也可以确定易失性存储器已经发生了错误。Since the volatile memory has data retention characteristics, it can be determined that no error has occurred in the volatile memory even if the data in the volatile memory is not verified when the terminal is powered off for a short time. In the case that the terminal is powered off for a long time, even if the data in the volatile memory is not verified, it can be determined that an error has occurred in the volatile memory.
基于此,在一个可能的实施例中,终端在恢复供电后,可以获取自身的断电时长。若终端的断电时长小于第一时长,则确定易失性存储器中的数据正确;若终端的断电时长大于第一时长且小于第二时长,则确定需要校验易失性存储器中的数据的正确性;若终端的断电时长大于第二时长,则确定易失性存储器中的数据不正确;其中,第一时长小于第二时长。Based on this, in a possible embodiment, the terminal may obtain its own power-off duration after power is restored. If the power-off duration of the terminal is less than the first duration, it is determined that the data in the volatile memory is correct; if the power-off duration of the terminal is greater than the first duration and less than the second duration, it is determined that the data in the volatile memory needs to be verified If the power-off duration of the terminal is longer than the second duration, it is determined that the data in the volatile memory is incorrect; wherein, the first duration is less than the second duration.
应理解,尽管易失性存储器的数据保持特性会因其工作环境、自身材质等因素产生一定的波动,终端的设计者仍然确定出两个能够保证准确的时长,即上述的第一时长和第二时长。其中,第一时长表示终端断电的时间足够短,易失性存储器上的数据保证不会出错,因此,在终端的断电时长小于第一时长时,终端可以跳过数据验证的步骤。类似地,第二时长表示终端的断电时间足够长,易失性存储器上的数据肯定已经发生错误,因此,在终端的断电时长大于第二时长时,终端可以重新启动系统或恢复至NVM上存储的最近的一个检测点。It should be understood that although the data retention characteristics of the volatile memory may fluctuate to a certain extent due to factors such as its working environment and its own material, the designer of the terminal still determines two durations that can guarantee the accuracy, namely the first duration and the third duration. Two hours. The first duration indicates that the power-off time of the terminal is short enough to ensure that the data on the volatile memory will not be wrong. Therefore, when the power-off duration of the terminal is shorter than the first duration, the terminal can skip the step of data verification. Similarly, the second duration indicates that the power-off time of the terminal is long enough, and the data on the volatile memory must have been wrong. Therefore, when the power-off duration of the terminal is longer than the second duration, the terminal can restart the system or restore to NVM. The most recent detection point stored on it.
通过设定第一时长和第二时长,可以使得终端能够根据实际断电时长决定是否需要进行数据验证,避免了每次恢复供电后都进行数据验证,节省了终端进行数据验证的时间,延长终端有效运行的时间。By setting the first duration and the second duration, the terminal can decide whether to perform data verification according to the actual power-off duration, which avoids performing data verification every time the power supply is restored, saves the time for the terminal to perform data verification, and prolongs the time of the terminal. Effective time to run.
作为一种可能的示例,可以参阅图6a,图6a为本申请实施例提供的一种用于确定断电时长的电路的结构示意图。如图6a所示,该电路包括左边虚线框所示的间歇供电电路以及右边虚线框所示的时间保持电路。该时间保持电路由开关S1、开关S2、电容C2以及电阻构成。该时间保持电路的工作模式为:As a possible example, reference may be made to FIG. 6a, which is a schematic structural diagram of a circuit for determining a power-off duration provided by an embodiment of the present application. As shown in Figure 6a, the circuit includes an intermittent power supply circuit shown in the left dashed box and a time keeping circuit shown in the right dashed box. The time keeping circuit is composed of a switch S1, a switch S2, a capacitor C2 and a resistor. The working mode of the time keeping circuit is:
1、终端的处理器断电时,断开开关S1和S2,使得电容C2为电阻供电。1. When the processor of the terminal is powered off, disconnect the switches S1 and S2, so that the capacitor C2 supplies power to the resistor.
2、当电容C1充电达到处理器的启动阈值后,检测电容C2的两端电压,从而推测计算断电时长T off与第一时长T LB和第二时长T UB之间的大小关系。 2. After the capacitor C1 is charged and reaches the start-up threshold of the processor, the voltage across the capacitor C2 is detected to calculate the magnitude relationship between the power-off duration T off and the first duration T LB and the second duration T UB .
3、闭合开关S1和开关S2,给电容C2充电,以便下次测量断电时长。3. Close the switch S1 and the switch S2 to charge the capacitor C2, so as to measure the power off time next time.
具体地,电容C2的两端电压在断电后的变化曲线可以参阅图6b,图6b为本申请实施例提供的一种时间保持电路的电压变化曲线示意图。Specifically, the variation curve of the voltage across the capacitor C2 after the power is turned off can be referred to FIG. 6b, which is a schematic diagram of the voltage variation curve of a time keeping circuit provided by the embodiment of the present application.
在一个可能的实施例中,终端中的易失性存储器中还可以包括第四地址区间,并且该第四地址区间存储的数据与执行第一程序段前该第三地址区间所存储的数据相同。其中,该第三地址区间被标记为工作区间(working buffer),工作区间是指程序执行时所使用的区间,即程序中在执行过程中是在工作区间访问并且修改相应的数据。该第四地址区间被标记为备份区间(backup buffer),备份区间则是用于备份工作区间的数据。In a possible embodiment, the volatile memory in the terminal may further include a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before executing the first program segment . The third address interval is marked as a working buffer, and the working buffer refers to the interval used when the program is executed, that is, during the execution of the program, the corresponding data is accessed and modified in the working buffer. The fourth address interval is marked as a backup buffer, and the backup buffer is used to back up the data of the working area.
也就是说,在执行第一程序段之前,终端可以将第三地址区间中的数据拷贝至第三地址区间中,以保证作为工作区间的第三地址区间中的数据与作为备份区间的第四地址区间中的数据相同,实现工作区间中的数据的备份。这样,如果终端在执行第一程序段的期间 发生了断电,那么终端可以在恢复供电之后,将备份区间中的数据拷贝至工作区间,以恢复工作区间中的数据。That is to say, before executing the first program segment, the terminal may copy the data in the third address interval to the third address interval, so as to ensure that the data in the third address interval serving as the working interval is the same as the data in the fourth address interval serving as the backup interval. The data in the address range is the same, and the data in the work range is backed up. In this way, if the terminal is powered off during the execution of the first program segment, the terminal can copy the data in the backup section to the working section after restoring the power supply, so as to restore the data in the working section.
示例性地,可以参阅图7,图7为本申请实施例提供的一种执行程序段的流程示意图。如图7所示,终端在断电前后执行程序段的流程包括以下的步骤。For example, reference may be made to FIG. 7 , which is a schematic flowchart of an execution program segment provided by an embodiment of the present application. As shown in FIG. 7 , the flow of the terminal executing the program segment before and after the power failure includes the following steps.
在步骤701中,终端执行程序段1。In step 701, the terminal executes program segment 1.
其中,该程序段1包括对变量x进行加操作。因此,终端对工作区间中的变量x进行加操作,从而将变量x的值从0修改为1。此外,在终端执行程序段1的过程中,即终端执行了对变量x进行加操作之后,终端发生了断电,并且在短暂断电之后,终端恢复了供电。Among them, the program segment 1 includes adding operation to the variable x. Therefore, the terminal performs an addition operation on the variable x in the working range, thereby modifying the value of the variable x from 0 to 1. In addition, during the process of the terminal executing the program segment 1, that is, after the terminal performs the adding operation to the variable x, the terminal is powered off, and after a brief power off, the terminal restores the power supply.
在步骤702中,在终端恢复供电之后,终端将备份区间中的数据拷贝至工作区间。In step 702, after the terminal restores the power supply, the terminal copies the data in the backup section to the working section.
由于终端在断电之前对工作区间中的变量x执行了加操作,因此,在恢复供电之后,工作区间中的变量x的值为1,而备份区间中的变量x的值仍然为0。终端可以将备份区间中的数据拷贝至工作区间,从而使得工作区间中的变量x的值仍然为0。Since the terminal performs an addition operation on the variable x in the working area before the power failure, after the power supply is restored, the value of the variable x in the working area is 1, and the value of the variable x in the backup area is still 0. The terminal may copy the data in the backup section to the working section, so that the value of the variable x in the working section is still 0.
在步骤703中,终端重新执行程序段1。In step 703, the terminal executes program segment 1 again.
在终端恢复了工作区间中的数据之后,终端继续运行,即重新执行程序段1,并且对工作区间中的变量x执行加操作,从而将变量x的值从0修改为1。After the terminal restores the data in the work area, the terminal continues to run, that is, executes the program segment 1 again, and performs an addition operation on the variable x in the work area, thereby changing the value of the variable x from 0 to 1.
由图7以及上述的步骤可知,如果终端中没有设置备份区间,那么在终端恢复供电之后,工作区间中的变量x的值为1。这样一来,终端在重新执行程序段1时,变量x的初始值不是0,终端会将变量x的值从1修改为2,从而导致数据出现错误,影响了终端的正常运行。It can be seen from FIG. 7 and the above steps that if the terminal does not have a backup interval set, after the terminal restores power supply, the value of the variable x in the working interval is 1. In this way, when the terminal re-executes the program segment 1, the initial value of the variable x is not 0, and the terminal will change the value of the variable x from 1 to 2, resulting in data errors and affecting the normal operation of the terminal.
本实施例中,通过设置备份区间,在终端执行程序段之前,保证备份区间能够备份有工作区间中的数据,确保了在终端断电且恢复供电之后,工作区间中的数据能够得以恢复,以避免终端出现数据错误的现象,保证了数据的正确性。In this embodiment, by setting the backup interval, before the terminal executes the program segment, it is ensured that the backup interval can back up the data in the working area, so as to ensure that after the terminal is powered off and the power supply is restored, the data in the working area can be restored, so that the data in the working area can be restored. The phenomenon of data errors in the terminal is avoided, and the correctness of the data is ensured.
应理解,为了保证备份区间能够起到数据备份的有效作用,终端在每次执行完程序段之后,需要进行数据拷贝,以保证备份区间和工作区间的数据相同。It should be understood that, in order to ensure that the backup interval can play an effective role in data backup, the terminal needs to perform data copy after each execution of the program segment, so as to ensure that the data in the backup interval and the working interval are the same.
在一个可能的实施例中,终端执行数据拷贝的过程可以包括:在第一程序段执行完毕之后,终端将第四地址区间标记为工作区间,以及将第三地址区间标记为备份区间;然后,终端再将第三地址区间的数据拷贝至第四地址区间。In a possible embodiment, the process of performing data copying by the terminal may include: after the execution of the first program segment is completed, the terminal marks the fourth address interval as a working interval, and marks the third address interval as a backup interval; then, The terminal then copies the data in the third address range to the fourth address range.
也就是说,在执行完第一程序段之后,终端通过执行交换指针的操作,将原先作为工作区间的第三地址区间标记为备份区间,而将原先作为备份区间的第四地址区间标记为工作区间,以实现工作区间和备份区间的交换。然后,终端再将第四地址区间的数据拷贝至第三地址区间,保证数据的一致性。例如,在执行第一程序段之前,终端通过指针“0”标记第三地址区间为工作区间,以及通过指针“1”标记第四地址区间为备份区间;在执行完第一程序段之后,终端通过交换指针,以实现通过指针“1”标记第三地址区间为备份区间,以及通过指针“0”标记第四地址区间为工作区间。That is to say, after executing the first program segment, the terminal marks the third address range, which was originally a working range, as a backup range by performing an operation of exchanging pointers, and marks the fourth address range, which was originally a backup range, as a work range. range to realize the exchange of the working range and the backup range. Then, the terminal copies the data in the fourth address interval to the third address interval to ensure data consistency. For example, before executing the first program segment, the terminal marks the third address range as the working range with the pointer "0", and marks the fourth address range as the backup range with the pointer "1"; after executing the first program segment, the terminal By exchanging the pointers, the third address range is marked as a backup range by the pointer "1", and the fourth address range is marked as the working range by the pointer "0".
本实施例中,在执行完程序段之后,通过交换指针来实现工作区间和备份区间的快速互换,可以有效避免在数据拷贝过程中发生断电而出现数据错误的现象。In this embodiment, after the program segment is executed, the quick interchange between the working area and the backup area is realized by exchanging pointers, which can effectively avoid the phenomenon of data errors due to power failure during the data copying process.
示例性地,如果在执行完第一程序段之后,直接将第三地址区间中的数据拷贝至第四地址区间中。那么,如果终端在数据拷贝过程中断电,在终端恢复供电后,终端仍然需要将备份区间(即第四地址区间)的数据拷贝至工作区间(即第三地址区间)。然而,由于此时备份区间在断电之前已经拷贝有部分工作区间中的数据,因此备份区间中的数据实际上已经受到污染,是错误的数据。这样一来,将备份区间中的数据恢复至工作区间,同样会导致工作区间中的数据是错误的数据,从而影响了终端的正常运行。Exemplarily, if the data in the third address interval is directly copied to the fourth address interval after the first program segment is executed. Then, if the terminal is powered off during the data copying process, after the terminal restores power supply, the terminal still needs to copy the data in the backup area (ie the fourth address area) to the working area (ie the third address area). However, since the backup interval has already copied some data in the working interval before the power failure, the data in the backup interval has actually been contaminated and is wrong data. In this way, restoring the data in the backup area to the working area will also cause the data in the working area to be wrong data, thereby affecting the normal operation of the terminal.
对于本实施例中交换指针的方案而言,即便终端在将第三地址区间中的数据拷贝至第四地址区间的过程中发生了断电,由于第三地址区间已经被标记为备份区间,在数据拷贝过程中,备份区间中的数据并不会被污染。终端恢复供电后,仍然可以保证备份区间中的数据是正确的,从而保证终端的正常运行。For the solution of exchanging pointers in this embodiment, even if the terminal is powered off during the process of copying the data in the third address range to the fourth address range, since the third address range has been marked as a backup range, During the data copying process, the data in the backup interval will not be polluted. After the power supply of the terminal is restored, the data in the backup area can still be guaranteed to be correct, thereby ensuring the normal operation of the terminal.
在一个可能的实施例中,在终端设置有工作区间以及备份区间的情况下,终端还可以基于备份区间中的数据来获取第二地址区间对应的第二校验码。In a possible embodiment, when the terminal is provided with a working area and a backup area, the terminal may also acquire the second check code corresponding to the second address interval based on the data in the backup area.
具体地,终端获取第二地址区间对应的第二校验码的过程,可以包括:终端计算第四地址区间中与第一地址区间对应的地址区间的第四校验码;根据第四地址区间对应的校验码以及第四校验码,确定第二校验码。Specifically, the process that the terminal obtains the second check code corresponding to the second address interval may include: the terminal calculates the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; The corresponding check code and the fourth check code determine the second check code.
可以理解的是,由于第四地址区间为第三地址区间对应的备份区间,第四地址区间的地址范围与第三地址区间的地址范围是相同的且固定不变的。例如,第三地址区间的地址范围可以为1-100,第四地址区间的地址范围则可以为101-200。那么,在执行第一程序段之前,对于第三地址区间中的任意一段地址区间,在第四地址区间中均有对应的地址区间,以使得这两段地址区间上的数据是相同的。例如,第三地址区间中地址范围为50-60的地址区间与第四地址区间中地址范围为150-160的地址区间对应,且地址范围为50-60的地址区间与地址范围为150-160的地址区间上的数据相同。It can be understood that, since the fourth address interval is a backup interval corresponding to the third address interval, the address scope of the fourth address interval and the address scope of the third address interval are the same and fixed. For example, the address range of the third address interval may be 1-100, and the address range of the fourth address interval may be 101-200. Then, before executing the first program segment, for any address interval in the third address interval, there is a corresponding address interval in the fourth address interval, so that the data on the two address intervals are the same. For example, the address range with the address range of 50-60 in the third address range corresponds to the address range with the address range of 150-160 in the fourth address range, and the address range with the address range of 50-60 and the address range of 150-160 The data on the address range is the same.
也就是说,在第一程序段执行完毕之后,由于第三地址区间上的第一地址区间中的数据发生了改变,因此第四地址区间中与第三地址区间上的数据不相同的地址区间则为:第一地址区间对应的地址区间。而第四地址区间中的其他地址区间实际上还是与第三地址区间中的第二地址区间上的数据相同。这样一来,终端可以通过计算第四地址区间中与第一地址区间对应的地址区间的校验码,并且基于上述的zero-padding性质以及第四地址区间的校验码,确定得到第四地址区间中的其他地址区间的校验码,即第二地址区间对应的第二校验码。That is to say, after the execution of the first program segment is completed, since the data in the first address interval in the third address interval has changed, the address interval in the fourth address interval is different from the data in the third address interval Then: the address range corresponding to the first address range. However, the other address intervals in the fourth address interval are actually still the same as the data on the second address interval in the third address interval. In this way, the terminal can determine to obtain the fourth address by calculating the check code of the address range corresponding to the first address range in the fourth address range, and based on the above-mentioned zero-padding property and the check code of the fourth address range The check codes of other address ranges in the range, that is, the second check codes corresponding to the second address range.
示例性地,可以参阅图8,图8为本申请实施例提供的一种计算校验码的示意图。如图8所示,在执行程序段之前,备份区间与工作区间中的数据相同,备份区间中的地址区间S0、地址区间S1分别与工作区间中的地址区间S0'、地址区间S1'对应,且地址区间S0以及地址区间S1对应的校验码均是在执行其他的程序段之后计算得到的。在执行程序段1之后,程序段1访问并修改了工作区间中的地址区间S2',从而使得工作区间划分成为S01'、S2'、S11'三个地址区间。对应的,备份区间同样可以划分为三个之对应的地址区间:S01、S02+S12、S11。Illustratively, reference may be made to FIG. 8 , which is a schematic diagram of calculating a check code according to an embodiment of the present application. As shown in Figure 8, before the program segment is executed, the data in the backup section is the same as that in the working section, and the address section S0 and the address section S1 in the backup section correspond to the address section S0' and the address section S1' in the working section, respectively. And the check codes corresponding to the address interval S0 and the address interval S1 are calculated after executing other program segments. After the program segment 1 is executed, the program segment 1 accesses and modifies the address range S2' in the work range, so that the work range is divided into three address ranges: S01', S2', and S11'. Correspondingly, the backup interval can also be divided into three corresponding address intervals: S01, S02+S12, and S11.
由图8可知,执行程序段1之后的工作区间所对应的校验码实际上可以基于地址区间S01'、地址区间S2'以及地址区间S11'分别对应的校验码计算得到。其中,地址区间S2'的子校验码可以直接对地址区间S2'上的数据进行校验码计算得到。对于地址区间S01'、以及地址区间S11'对应的校验码,则可以通过计算备份区间中的地址区间S01以及地址区间S11对应的校验码得到。通过直接计算备份区间中的地址区间S02的校验码,并且基于已知的地址区间S0的校验码,则可以计算得到地址区间S01的校验码,即CS(S01')=CS(S01)=CS(S0)-CS(S02)。类似地,通过直接计算备份区间中的地址区间S12的校验码,并且基于已知的地址区间S1的校验码,则可以计算得到地址区间S11的校验码,即CS(S11')=CS(S11)=CS(S1)-CS(S12)。As can be seen from FIG. 8 , the check code corresponding to the work interval after executing the program segment 1 can actually be calculated based on the check codes corresponding to the address interval S01 ′, the address interval S2 ′ and the address interval S11 ′ respectively. Wherein, the sub-check code of the address interval S2' can be obtained by directly performing the check code calculation on the data in the address interval S2'. The check codes corresponding to the address interval S01' and the address interval S11' can be obtained by calculating the check codes corresponding to the address interval S01 and the address interval S11 in the backup interval. By directly calculating the check code of the address range S02 in the backup range, and based on the known check code of the address range S0, the check code of the address range S01 can be calculated, that is, CS(S01')=CS(S01 )=CS(S0)-CS(S02). Similarly, by directly calculating the check code of the address range S12 in the backup range, and based on the known check code of the address range S1, the check code of the address range S11 can be calculated, that is, CS(S11')= CS(S11)=CS(S1)-CS(S12).
通过基于备份区间上的数据来计算工作区间中的第二地址区间对应的第二校验码,可以在第一地址区间较小时,有效地降低进行CRC运算所消耗的时间和能耗,提高终端在执行完程序段后计算校验码的效率,从而能够节省终端的电能,延长终端有效运行的时间。By calculating the second check code corresponding to the second address interval in the working interval based on the data in the backup interval, when the first address interval is small, the time and energy consumed by the CRC operation can be effectively reduced, and the terminal can be improved. After the execution of the program segment, the efficiency of the check code is calculated, so that the electric power of the terminal can be saved and the effective operation time of the terminal can be prolonged.
可以理解的是,在运行环境的能量源充足的情况下,终端中的电量可以保持较高的水平,从而确保终端在接下来较长的一段时间内不会发生断电。在这种情况下,终端并不需要在每次执行完程序段之后都计算一次校验码,以节省终端的能耗。It can be understood that, when the energy source of the operating environment is sufficient, the power in the terminal can be maintained at a relatively high level, so as to ensure that the terminal will not be powered off for a long period of time in the future. In this case, the terminal does not need to calculate the check code every time after executing the program segment, so as to save the energy consumption of the terminal.
示例性地,在终端执行第一程序段之前,终端根据终端的电压高于阈值电压,执行一个或多个第二程序段。第二程序段可以是指第一程序段所属的程序中的任意一个其他的程序段,该程序中可以包括有一个或多个第二程序段。终端标记执行一个或多个第二程序段时所使用的地址区间。根据当前电压低于阈值电压,终端计算被标记的地址区间对应的校验码。该阈值电压用于表示终端处于低电量水平,即终端随时可能面临断电。阈值电压的取值可以根据终端实际的能量采集能力而定,本实施例不做具体限定。Exemplarily, before the terminal executes the first program segment, the terminal executes one or more second program segments according to whether the voltage of the terminal is higher than the threshold voltage. The second program segment may refer to any other program segment in the program to which the first program segment belongs, and the program may include one or more second program segments. The terminal marks the address range used when executing one or more second program segments. According to the current voltage lower than the threshold voltage, the terminal calculates the check code corresponding to the marked address interval. This threshold voltage is used to indicate that the terminal is at a low battery level, that is, the terminal may face power outage at any time. The value of the threshold voltage may be determined according to the actual energy harvesting capability of the terminal, which is not specifically limited in this embodiment.
其中,终端可以是在每执行完一个程序段之后,则标记执行该程序段时所使用的地址区间;终端也可以是在执行完多个程序段之后,再标记执行该多个程序段时所使用的地址区间。Wherein, the terminal can be used to mark the address range used when executing the program segment after each program segment is executed; the terminal can also be used to mark the address range used when executing the multiple program segments after executing the multiple program segments. The address range to use.
此外,终端在每执行完一个程序段之后,可以检测一次终端当前的电压,以确定当前的电压是否低于阈值电压。这样,在终端确定当前电压低于阈值电压时,终端统一对已标记的地址区间进行校验码计算,以尽可能减少计算校验码的次数。In addition, after each program segment is executed by the terminal, the current voltage of the terminal may be detected once to determine whether the current voltage is lower than the threshold voltage. In this way, when the terminal determines that the current voltage is lower than the threshold voltage, the terminal uniformly calculates the check code for the marked address interval, so as to reduce the number of times of calculating the check code as much as possible.
为便于理解,以下将结合具体例子对本申请实施例提供的数据处理方法进行详细描述。可以参阅图9,图9为本申请实施例提供的一种终端运行的流程示意图。For ease of understanding, the data processing method provided by the embodiments of the present application will be described in detail below with reference to specific examples. Referring to FIG. 9 , FIG. 9 is a schematic flowchart of terminal operation provided by an embodiment of the present application.
如图9所示,终端上电后的运行过程包括以下的步骤。As shown in FIG. 9 , the running process after the terminal is powered on includes the following steps.
步骤S1、终端每次恢复供电后,首先确定上一次断电的时间长度。如果断电时间过长,即T off>T UB,终端重启或恢复至NVM上存储的最近一个检测点。其中,T off表示终端的断电时长,T UB表示上述的第二时长,即易失性存储器上的数据一定出错的时间上限。 Step S1: After each time the terminal restores power supply, first determine the time length of the last power outage. If the power-off time is too long, that is, T off >T UB , the terminal restarts or restores to the last detection point stored on the NVM. Wherein, T off represents the power-off duration of the terminal, and T UB represents the above-mentioned second duration, that is, the upper limit of the time during which the data on the volatile memory must be in error.
步骤S2、如果断电时间足够短,即T off<T LB,则将易失性存储器上的数据的标记位(flag)置为0,即置flag=0。其中,flag用于标记易失性存储器上的数据的正确性,在flag 为0的情况下,表示数据正确,可以跳过对数据的验证操作。 Step S2, if the power-off time is short enough, that is, T off < T LB , set the flag bit (flag) of the data on the volatile memory to 0, that is, set flag=0. Among them, the flag is used to mark the correctness of the data on the volatile memory. When the flag is 0, it indicates that the data is correct, and the verification operation on the data can be skipped.
步骤S3、如果断电时长介于T UB和T LB之间,即T LB<T off<T UB,则将易失性存储器上的数据的flag置为1,即置flag=1,表示数据不一定正确,需要对数据进行验证。 Step S3, if the power-off duration is between T UB and T LB , that is, T LB <T off < T UB , set the flag of the data on the volatile memory to 1, that is, set flag=1, indicating that the data Not necessarily correct, the data needs to be validated.
步骤S4、在T LB<T off<T UB的情况下,终端执行程序段之前,需要验证易失性存储器上的数据对应的校验码是否正确。即终端通过比对易失性存储器上所存储的校验码与NVM上所存储的校验码是否相同,来验证易失性存储器上的数据对应的校验码是否正确。如果验证不通过(即校验码不相同),则代表易失性存储器上的数据发生错误,终端重启或恢复至NVM上存储的最近一个检测点。 Step S4: In the case of T LB < T off < T UB , before the terminal executes the program segment, it is necessary to verify whether the check code corresponding to the data on the volatile memory is correct. That is, the terminal verifies whether the check code corresponding to the data on the volatile memory is correct by comparing whether the check code stored in the volatile memory is the same as the check code stored on the NVM. If the verification fails (that is, the check codes are not the same), it means that an error occurs in the data on the volatile memory, and the terminal restarts or restores to the latest detection point stored on the NVM.
步骤S5、终端判断当前的电压V是否大于阈值电压V TStep S5, the terminal determines whether the current voltage V is greater than the threshold voltage V T .
步骤S6、当电压V高于阈值电压V T时,表示终端当前处于高电量水平,可以执行高电量水平工作模式,即不需要在每次执行完程序段之后都计算校验码。 Step S6, when the voltage V is higher than the threshold voltage VT , it means that the terminal is currently at a high battery level, and the high battery level working mode can be executed, that is, the check code does not need to be calculated after each execution of the program segment.
终端确定准备执行的程序段需要使用的数据的flag,如果flag=1,则终端需要验证该程序段要使用的数据,且这部分数据验证不通过时终端重启或恢复至NVM上存储的最近一个检测点。如果flag=0,则终端不需要验证该程序段要使用的数据。The terminal determines the flag of the data to be used by the program segment to be executed. If flag=1, the terminal needs to verify the data to be used by the program segment, and if the verification of this part of data fails, the terminal restarts or restores to the latest one stored on the NVM. check Point. If flag=0, the terminal does not need to verify the data to be used by this program segment.
步骤S7、如果程序段要使用的数据验证通过或不需要验证该程序段要使用的数据,则终端将备份区间中的数据拷贝至工作区间。Step S7: If the data to be used in the program segment passes the verification or does not need to be verified for the data to be used in the program segment, the terminal copies the data in the backup section to the work section.
步骤S8、终端执行该程序段。Step S8, the terminal executes the program segment.
步骤S9、在该程序段执行完毕后,终端标记已修改的地址区间(即标记该程序段使用的数据所在的地址区间),然后调度下一个就绪的程序段,重复执行步骤S6至S9。Step S9: After the execution of the program segment is completed, the terminal marks the modified address range (ie, marks the address range where the data used by the program segment is located), then schedules the next ready program segment, and repeats steps S6 to S9.
步骤S10、当电压V低于阈值电压V T时,表示终端当前处于低电量水平,需要执行低电量水平工作模式,即在每次执行完程序段之后都计算校验码。终端计算已标记的地址区间的校验码,以及计算得到整个程序所使用的地址区间的总校验码并将该总校验码存储至NVM。 Step S10, when the voltage V is lower than the threshold voltage VT , it means that the terminal is currently at a low battery level and needs to execute the low battery level working mode, that is, the check code is calculated after each execution of the program segment. The terminal calculates the check code of the marked address range, calculates and obtains the total check code of the address range used by the whole program, and stores the total check code in the NVM.
步骤S11、可选的,终端可以将易失性存储器上的所有数据拷贝至NVM中作为一个检测点。Step S11. Optionally, the terminal may copy all data on the volatile memory to the NVM as a detection point.
步骤S12、终端交换备份区间和工作区间的指针,即将易失性存储器中原先的备份区间标记为工作区间并将原先的工作区间标记为备份区间,并且将交换指针后的备份区间中的数据拷贝至工作区间。Step S12, the terminal exchanges the pointers of the backup interval and the working interval, namely marking the original backup interval in the volatile memory as the working interval and marking the original working interval as the backup interval, and copying the data in the backup interval after the exchange of pointers to the work area.
步骤S13、终端确定准备执行的程序段需要使用的数据的flag,如果flag=1,则终端需要验证该程序段要使用的数据,且这部分数据验证不通过时终端重启或恢复至NVM上存储的最近一个检测点。如果flag=0,则终端不需要验证该程序段要使用的数据。Step S13, the terminal determines the flag of the data to be used by the program segment to be executed, if flag=1, the terminal needs to verify the data to be used by the program segment, and the terminal restarts or restores to the NVM when the verification of this part of the data fails. the most recent detection point. If flag=0, the terminal does not need to verify the data to be used by this program segment.
步骤S14、终端验证工作区间中下一个程序段要使用的数据,即通过保存在易失性存储器中的校验码验证程序段要使用的数据。Step S14 , the terminal verifies the data to be used in the next program segment in the working area, that is, the data to be used in the program segment is verified by the check code stored in the volatile memory.
步骤S15、终端确定该程序段要使用的数据是否验证通过,如果验证不通过,则终端重启或恢复至NVM上存储的最近一个检测点。Step S15, the terminal determines whether the data to be used in the program segment passes the verification, and if the verification fails, the terminal restarts or restores to the latest detection point stored on the NVM.
步骤S16、如果验证通过,终端执行该程序段。Step S16, if the verification is passed, the terminal executes the program segment.
步骤S17、在执行完程序段之后,终端交换备份区间和工作区间的指针。Step S17: After executing the program segment, the terminal exchanges the pointers of the backup area and the working area.
步骤S18、终端计算备份区间中执行该程序段所使用的地址区间对应的校验码,以及根据该校验码计算程序所使用的地址区间对应的总校验码,并将该总校验码存储至NVM中。Step S18, the terminal calculates the check code corresponding to the address interval used to execute the program segment in the backup interval, and calculates the total check code corresponding to the address interval used by the program according to the check code, and calculates the total check code. Stored in NVM.
步骤S19、终端将备份区间的数据拷贝至工作区间,然后调度下一个就绪的程序段,重复执行步骤S13至S19,直至断电。Step S19, the terminal copies the data in the backup section to the working section, then schedules the next ready program segment, and repeats steps S13 to S19 until the power is turned off.
以上对终端上电后的运行过程进行了详细的描述,以下将结合附图详细描述终端运行过程中易失性存储区中的数据的变化过程。The operation process after the terminal is powered on has been described in detail above, and the following will describe the change process of data in the volatile storage area during the operation of the terminal in detail with reference to the accompanying drawings.
可以参阅图10a,图10a为本申请实施例提供的一种程序段与地址区间之间的关系示意图。Referring to FIG. 10a, FIG. 10a is a schematic diagram of a relationship between a program segment and an address interval provided by an embodiment of the present application.
如图10a所示,应用程序的代码中包括程序段1、程序段2和程序段3,程序段1、程序段2和程序段3分别会使用地址区间DB1、DB2和DB3。As shown in Figure 10a, the code of the application program includes program segment 1, program segment 2, and program segment 3, and program segment 1, program segment 2, and program segment 3 use address ranges DB1, DB2, and DB3 respectively.
可以参阅图10b,图10b为本申请实施例提供的一种终端在低电量水平下执行程序段的流程示意图。如图10b所示,终端在低电量水平下执行程序段的过程包括以下的步骤。Referring to FIG. 10b, FIG. 10b is a schematic flowchart of a terminal executing a program segment at a low battery level according to an embodiment of the present application. As shown in Fig. 10b, the process of the terminal executing the program segment at a low power level includes the following steps.
在t0时刻,终端成功执行程序段1。工作区间中的DB1更新为DB1’。并且,终端检测发现当前电压值已低于阈值电压,终端进入低电量水平工作模式。At time t0, the terminal successfully executes program segment 1. DB1 in the workspace is updated to DB1'. Moreover, the terminal detects and finds that the current voltage value is lower than the threshold voltage, and the terminal enters the low power level working mode.
在t1时刻,终端计算已修改的地址区间的校验码,即计算DB1’的校验码,得到CS1。另外,在执行之前的程序段时,终端还计算得到工作区间中其他地址区间的校验码,分别为CS0、CS_delta以及CSn。这样,终端可以根据工作区间对应的多个子校验码计算出工作区间对应的总校验码CS_total,并且将CS_total存储至NVM。此外,终端还将工作区间的数据拷贝至备份区间。At time t1, the terminal calculates the check code of the modified address range, that is, calculates the check code of DB1', and obtains CS1. In addition, when executing the previous program segment, the terminal also calculates and obtains the check codes of other address ranges in the working range, which are CS0, CS_delta and CSn respectively. In this way, the terminal can calculate the total check code CS_total corresponding to the working interval according to the multiple sub-check codes corresponding to the working interval, and store the CS_total in the NVM. In addition, the terminal also copies the data in the working area to the backup area.
在t2时刻,终端准备调度执行程序段2,程序段2会用到工作区间中的地址区间DB2。由于DB2的数据正确性在本上电周期内未被校验过,终端可以通过校验码CS_delta验证数据区间DB2、DB3和DB4的正确性。如果验证结果为数据未发生错误,终端可以执行程序段2。At time t2, the terminal is ready to schedule and execute program segment 2, and program segment 2 will use the address range DB2 in the work range. Since the data correctness of DB2 has not been verified in this power-on cycle, the terminal can verify the correctness of the data intervals DB2, DB3 and DB4 through the verification code CS_delta. If the verification result is that there is no error in the data, the terminal can execute program segment 2.
在t3时刻,终端调度执行程序段2,且执行程序段2期间对DB2的修改均发生在工作区间上。At time t3, the terminal schedules the execution of program segment 2, and the modifications to DB2 during the execution of program segment 2 all occur in the work area.
在t4时刻,终端成功执行程序段2,工作区间中的DB2更新至DB2’。终端通过交换指针,将DB2’快速更新至备份区间。At time t4, the terminal successfully executes program segment 2, and DB2 in the work area is updated to DB2'. The terminal quickly updates DB2' to the backup range by exchanging pointers.
在t5时刻,终端计算已修改的地址区间的校验码,即计算DB2’的校验码,得到CS2。对于DB3至DB4的校验码,终端可以通过DB2至DB4的校验码CS_delta以及DB2的校验码CS(DB2)计算得到,即CS_delta-CS(DB2)。这样,终端可以根据工作区间对应的多个子校验码CS0、CS1、CS2、CS_delta-CS(DB2)以及CSn计算出总校验码CS_total,并且将CS_total存储至NVM。At time t5, the terminal calculates the check code of the modified address range, that is, calculates the check code of DB2', and obtains CS2. For the check codes of DB3 to DB4, the terminal can obtain it by calculating the check codes CS_delta of DB2 to DB4 and the check codes CS(DB2) of DB2, that is, CS_delta-CS(DB2). In this way, the terminal can calculate the total check code CS_total according to the multiple sub-check codes CS0, CS1, CS2, CS_delta-CS(DB2) and CSn corresponding to the working interval, and store the CS_total in the NVM.
在t6时刻,终端将备份区间中的DB2’拷贝至工作区间中,并且验证DB3的数据正确性。由于DB2已在t2时刻通过CS_delta一并验证了,因此终端可以确定调度执行程序段3。At time t6, the terminal copies DB2' in the backup section to the working section, and verifies the data correctness of DB3. Since DB2 has been verified through CS_delta at time t2, the terminal can determine that program segment 3 is scheduled to be executed.
在t7时刻,终端调度执行程序段3,程序段3执行期间对DB3的修改均发生在工作区间上。At time t7, the terminal schedules the execution of program segment 3, and the modifications to DB3 during the execution of program segment 3 all occur in the work area.
在t8时刻,终端执行程序段3的期间发生断电。工作区间上的数据可能存在问题,因此工作区间上的数据已不可用。At time t8, a power outage occurs while the terminal is executing program segment 3. There might be a problem with the data on the workspace, so the data on the workspace is no longer available.
可以参阅图11,图11为本申请实施例提供的一种终端在恢复供电后的运行示意图。如图11所示,终端在恢复供电后执行以下的步骤。Referring to FIG. 11 , FIG. 11 is a schematic diagram of operation of a terminal after power supply is restored according to an embodiment of the present application. As shown in Figure 11, the terminal performs the following steps after power is restored.
步骤1101,终端通过NVM上的总校验码CS_total,验证易失性存储器上的校验码是否正确。即终端基于易失性存储器上的校验码(即CS0、CS1、CS2、CS_delta以及CSn),重新计算一个新的总校验码,并且将新的总校验码与存储于NVM上的总校验码进行比对,如果两者相同,则代表易失性存储器上的校验码正确,如果两者不相同,则代表易失性存储器上的数据发生了错误。Step 1101, the terminal verifies whether the check code on the volatile memory is correct through the total check code CS_total on the NVM. That is, the terminal recalculates a new total check code based on the check code on the volatile memory (ie CS0, CS1, CS2, CS_delta and CSn), and compares the new total check code with the total check code stored on the NVM. The check codes are compared. If the two are the same, it means that the check code on the volatile memory is correct. If the two are different, it means that the data on the volatile memory is wrong.
步骤1102,在易失性存储器上的校验码验证正确的情况下,终端基于校验码CS_delta验证程序段3要使用的数据(即DB3)是否正确。Step 1102 , if the verification code on the volatile memory is correct, the terminal verifies whether the data to be used by the program segment 3 (ie DB3 ) is correct based on the verification code CS_delta.
步骤1103,在程序段3要使用的数据验证正确的情况下,终端将备份区间的数据拷贝至工作区间。Step 1103 , when the data to be used in the program segment 3 is verified to be correct, the terminal copies the data in the backup section to the working section.
步骤1104,终端调度执行程序段3。Step 1104, the terminal schedules the execution of program segment 3.
在图1至图11所对应的实施例的基础上,为了更好的实施本申请实施例的上述方案,下面还提供用于实施上述方案的相关设备。具体可以参阅图12,图12为本申请实施例提供的一种终端1200的结构示意图,该终端1200包括:处理单元1201和获取单元1202;处理单元1201,用于执行第一程序段;处理单元1201,还用于计算第一地址区间对应的第一校验码,第一地址区间为执行第一程序段时所使用的地址区间;获取单元1202,用于获取第二地址区间对应的第二校验码,第二地址区间为第三地址区间中除第一地址区间之外的地址区间,第三地址区间为执行第一程序段所属的程序时所使用的地址区间;处理单元1201,还用于根据第一校验码和第二校验码,确定第三校验码,第三校验码为第三地址区间对应的校验码;处理单元1201,还用于将第三校验码存储于非易失性存储器,第三校验码用于在终端恢复供电后校验易失性存储器中的数据的正确性,第三地址区间位于易失性存储器中。On the basis of the embodiments corresponding to FIG. 1 to FIG. 11 , in order to better implement the above solutions of the embodiments of the present application, related equipment for implementing the above solutions is also provided below. For details, please refer to FIG. 12, which is a schematic structural diagram of a terminal 1200 provided by an embodiment of the present application. The terminal 1200 includes: a processing unit 1201 and an obtaining unit 1202; the processing unit 1201 is used for executing the first program segment; the processing unit 1201, which is also used to calculate the first check code corresponding to the first address range, where the first address range is the address range used when executing the first program segment; the obtaining unit 1202 is used to obtain the second address range corresponding to the second address range. Check code, the second address interval is the address interval other than the first address interval in the third address interval, and the third address interval is the address interval used when executing the program to which the first program segment belongs; the processing unit 1201, also It is used to determine the third check code according to the first check code and the second check code, and the third check code is the check code corresponding to the third address interval; the processing unit 1201 is also used for the third check code. The code is stored in the non-volatile memory, the third verification code is used to verify the correctness of the data in the volatile memory after the terminal restores power supply, and the third address range is located in the volatile memory.
在一些可能的实现方式中,易失性存储器中还包括第四地址区间,第四地址区间存储的数据与执行第一程序段前第三地址区间存储的数据相同;其中,第三地址区间被标记为工作区间,第四地址区间被标记为备份区间,工作区间为程序执行时所使用的区间,备份区间用于备份工作区间的数据。In some possible implementations, the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the third address interval before the first program segment is executed; wherein, the third address interval is It is marked as a working area, the fourth address area is marked as a backup area, the working area is an area used when the program is executed, and the backup area is used for backing up data in the working area.
在一些可能的实现方式中,处理单元1201具体用于:计算第四地址区间中与第一地址区间对应的地址区间的第四校验码;根据第四地址区间对应的校验码以及第四校验码,确定第二校验码。In some possible implementations, the processing unit 1201 is specifically configured to: calculate the fourth check code of the address interval corresponding to the first address interval in the fourth address interval; Check code, determine the second check code.
在一些可能的实现方式中,处理单元1201还用于:将第四地址区间标记为工作区间,以及将第三地址区间标记为备份区间;将第三地址区间的数据拷贝至第四地址区间。In some possible implementations, the processing unit 1201 is further configured to: mark the fourth address range as a working range, and mark the third address range as a backup range; and copy the data of the third address range to the fourth address range.
在一些可能的实现方式中,处理单元1201还用于:将第一校验码和第二校验码存储于易失性存储器,第一校验码和第二校验码用于在终端恢复供电后与第三校验码进行比对,以验证易失性存储器中的数据的正确性。In some possible implementations, the processing unit 1201 is further configured to: store the first check code and the second check code in a volatile memory, and the first check code and the second check code are used for recovery at the terminal After the power is supplied, it is compared with the third check code to verify the correctness of the data in the volatile memory.
在一些可能的实现方式中,处理单元1201还用于:在终端恢复供电后,获取终端的断电时长;若断电时长小于第一时长,则确定易失性存储器中的数据正确;若断电时长大于第一时长且小于第二时长,则确定需要校验易失性存储器中的数据的正确性;若断电时长大于第二时长,则确定易失性存储器中的数据不正确;其中,第一时长小于第二时长。In some possible implementations, the processing unit 1201 is further configured to: obtain the power-off duration of the terminal after the power supply of the terminal is restored; if the power-off duration is less than the first duration, determine that the data in the volatile memory is correct; If the power-on duration is greater than the first duration and less than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified; if the power-off duration is greater than the second duration, it is determined that the data in the volatile memory is incorrect; wherein , the first duration is less than the second duration.
在一些可能的实现方式中,处理单元1201还用于:根据终端的电压高于阈值电压,执行一个或多个第二程序段;标记执行一个或多个第二程序段时所使用的地址区间;根据终端的电压低于阈值电压,计算被标记的地址区间对应的校验码。In some possible implementations, the processing unit 1201 is further configured to: execute one or more second program segments according to the voltage of the terminal being higher than the threshold voltage; mark the address range used when executing the one or more second program segments ; Calculate the check code corresponding to the marked address interval according to the voltage of the terminal being lower than the threshold voltage.
在一些可能的实现方式中,处理单元1201还用于:确定第一程序段对应的第一地址区间;获取第一地址区间对应的校验码,第一地址区间对应的校验码存储于易失性存储器中;根据第一地址区间对应的校验码确定第一地址区间中的数据正确;基于第一地址区间中的数据正确,确定执行第一程序段。In some possible implementations, the processing unit 1201 is further configured to: determine the first address range corresponding to the first program segment; obtain the check code corresponding to the first address range, and store the check code corresponding to the first address range in an easy-to-use In the volatile memory; according to the check code corresponding to the first address interval, it is determined that the data in the first address interval is correct; based on the correctness of the data in the first address interval, it is determined to execute the first program segment.
在一些可能的实现方式中,处理单元1201还用于:将易失性存储器中的数据周期性地存储至非易失性存储器。In some possible implementations, the processing unit 1201 is further configured to: periodically store the data in the volatile memory to the non-volatile memory.
可以参阅图13,图13为本申请实施例提供的一种终端100的结构示意图。Referring to FIG. 13 , FIG. 13 is a schematic structural diagram of a terminal 100 according to an embodiment of the present application.
如图13所示,终端100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,能源采集模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,传感器模块170等。其中,传感器模块170可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。As shown in FIG. 13 , the terminal 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, an energy collection module 140, a power management module 141, a battery 142, Antenna 1, Antenna 2, mobile communication module 150, wireless communication module 160, sensor module 170, etc. The sensor module 170 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
可以理解的是,本申请实施例示意的结构并不构成对终端100的具体限定。在本申请另一些实施例中,终端100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the terminal 100 . In other embodiments of the present application, the terminal 100 may include more or less components than shown, or some components may be combined, or some components may be separated, or different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
压力传感器用于感受压力信号,可以将压力信号转换成电信号。陀螺仪传感器可以用于确定终端100的运动姿态。气压传感器用于测量气压。The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The gyro sensor may be used to determine the motion attitude of the terminal 100 . Air pressure sensors are used to measure air pressure.
加速度传感器可检测终端100在各个方向上(包括三轴或六轴)加速度的大小。当终端100静止时可检测出重力的大小及方向。The acceleration sensor can detect the magnitude of the acceleration of the terminal 100 in various directions (including three axes or six axes). When the terminal 100 is stationary, the magnitude and direction of gravity can be detected.
距离传感器,用于测量距离。Distance sensor for measuring distance.
环境光传感器用于感知环境光亮度。The ambient light sensor is used to sense ambient light brightness.
指纹传感器用于采集指纹。The fingerprint sensor is used to collect fingerprints.
温度传感器用于检测温度。A temperature sensor is used to detect temperature.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器 (application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU) Wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
其中,控制器可以是终端100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the terminal 100 . The controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I1C)接口,集成电路内置音频(inter-integrated circuit sound,I1S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I1C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I1S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对终端100的结构限定。在本申请另一些实施例中,终端100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the terminal 100 . In other embodiments of the present application, the terminal 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
能源采集模块140用于从运行环境获取能源输入,例如获取光能、无线电射频、压力或热能等能量,并将这些能量转化为电能储存于电池142。The energy collection module 140 is used to obtain energy input from the operating environment, such as light energy, radio frequency, pressure or heat energy, and converts the energy into electrical energy to be stored in the battery 142 .
电源管理模块141用于连接电池142,能源采集模块140以及处理器110。电源管理模块141接收电池142和/或能源采集模块140的输入,为处理器110,内部存储器121,外部存储器和无线通信模块160等供电。The power management module 141 is used to connect the battery 142 , the energy collection module 140 and the processor 110 . The power management module 141 receives input from the battery 142 and/or the energy collection module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the wireless communication module 160, and the like.
终端100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the terminal 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
天线1和天线2用于发射和接收电磁波信号。终端100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。 Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
移动通信模块150可以提供应用在终端100上的包括1G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线2转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动 通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 may provide a wireless communication solution including 1G/3G/4G/5G, etc. applied on the terminal 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then convert it into electromagnetic waves and radiate it out through the antenna 2 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 . In some embodiments, at least some of the functional modules of the mobile communication module 150 may be provided in the same device as at least some of the modules of the processor 110.
无线通信模块160可以提供应用在终端100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线1接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the terminal 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 1 , modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2 .
在一些实施例中,终端100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得终端100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the terminal 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the terminal 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展终端100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal 100. The external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行终端100的各种功能应用以及数据处理。内部存储器121可以包括易失性存储器121A和非易失性存储器121B,易失性存储器121A用于存储执行程序过程中所使用的数据,非易失性存储器121B用于保存易失性存储器121A中的数据对应的校验码以及备份易失性存储器121A中的数据。 Internal memory 121 may be used to store computer executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the terminal 100 by executing the instructions stored in the internal memory 121 . The internal memory 121 may include a volatile memory 121A and a non-volatile memory 121B, the volatile memory 121A is used to store data used in the process of executing the program, and the non-volatile memory 121B is used to save the data in the volatile memory 121A. The check code corresponding to the data and the data in the backup volatile memory 121A.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above may refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a removable hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk and other media that can store program codes.

Claims (20)

  1. 一种数据处理方法,其特征在于,所述方法应用于间歇性工作的终端,包括:A data processing method, wherein the method is applied to a terminal that works intermittently, comprising:
    执行第一程序段;Execute the first program segment;
    计算第一地址区间对应的第一校验码,所述第一地址区间为执行所述第一程序段时所使用的地址区间;calculating a first check code corresponding to a first address interval, where the first address interval is an address interval used when executing the first program segment;
    获取第二地址区间对应的第二校验码,所述第二地址区间为第三地址区间中除所述第一地址区间之外的地址区间,所述第三地址区间为执行所述第一程序段所属的程序时所使用的地址区间;Obtain a second check code corresponding to a second address interval, where the second address interval is an address interval other than the first address interval in the third address interval, and the third address interval is for executing the first address interval. The address range used by the program to which the block belongs;
    根据所述第一校验码和所述第二校验码,确定第三校验码,所述第三校验码为所述第三地址区间对应的校验码;Determine a third check code according to the first check code and the second check code, where the third check code is a check code corresponding to the third address interval;
    将所述第三校验码存储于非易失性存储器,所述第三校验码用于在所述终端恢复供电后校验易失性存储器中的数据的正确性,所述第三地址区间位于所述易失性存储器中。Store the third check code in the non-volatile memory, where the third check code is used to verify the correctness of the data in the volatile memory after the terminal is powered back up, and the third address The interval is located in the volatile memory.
  2. 根据权利要求1所述的数据处理方法,其特征在于,所述易失性存储器中还包括第四地址区间,所述第四地址区间存储的数据与执行所述第一程序段前所述第三地址区间存储的数据相同;The data processing method according to claim 1, wherein the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the data stored in the fourth address interval before executing the first program segment. The data stored in the three address ranges are the same;
    其中,所述第三地址区间被标记为工作区间,所述第四地址区间被标记为备份区间,所述工作区间为程序执行时所使用的区间,所述备份区间用于备份所述工作区间的数据。The third address interval is marked as a working interval, the fourth address interval is marked as a backup interval, the working interval is an interval used during program execution, and the backup interval is used to back up the working interval The data.
  3. 根据权利要求2所述的数据处理方法,其特征在于,所述获取第二地址区间对应的第二校验码,包括:The data processing method according to claim 2, wherein the acquiring the second check code corresponding to the second address interval comprises:
    计算所述第四地址区间中与所述第一地址区间对应的地址区间的第四校验码;calculating the fourth check code of the address interval corresponding to the first address interval in the fourth address interval;
    根据所述第四地址区间对应的校验码以及所述第四校验码,确定所述第二校验码。The second check code is determined according to the check code corresponding to the fourth address interval and the fourth check code.
  4. 根据权利要求2或3所述的数据处理方法,其特征在于,在所述第一程序段执行完毕之后,所述方法还包括:The data processing method according to claim 2 or 3, characterized in that, after the execution of the first program segment is completed, the method further comprises:
    将所述第四地址区间标记为工作区间,以及将所述第三地址区间标记为备份区间;marking the fourth address interval as a working interval, and marking the third address interval as a backup interval;
    将所述第三地址区间的数据拷贝至所述第四地址区间。Copy the data of the third address interval to the fourth address interval.
  5. 根据权利要求1至4任意一项所述的数据处理方法,其特征在于,所述方法还包括:The data processing method according to any one of claims 1 to 4, wherein the method further comprises:
    将所述第一校验码和所述第二校验码存储于所述易失性存储器,所述第一校验码和所述第二校验码用于在所述终端恢复供电后与所述第三校验码进行比对,以验证所述易失性存储器中的数据的正确性。The first check code and the second check code are stored in the volatile memory, and the first check code and the second check code are used to communicate with the terminal after the power supply is restored. The third check code is compared to verify the correctness of the data in the volatile memory.
  6. 根据权利要求1至5任意一项所述的数据处理方法,其特征在于,所述方法还包括:The data processing method according to any one of claims 1 to 5, wherein the method further comprises:
    在所述终端恢复供电后,获取所述终端的断电时长;After the power supply of the terminal is restored, acquiring the power-off duration of the terminal;
    若所述断电时长小于第一时长,则确定所述易失性存储器中的数据正确;If the power-off duration is less than the first duration, it is determined that the data in the volatile memory is correct;
    若所述断电时长大于所述第一时长且小于第二时长,则确定需要校验所述易失性存储器中的数据的正确性;If the power-off duration is greater than the first duration and less than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified;
    若所述断电时长大于所述第二时长,则确定所述易失性存储器中的数据不正确;If the power-off duration is greater than the second duration, determining that the data in the volatile memory is incorrect;
    其中,所述第一时长小于所述第二时长。Wherein, the first duration is shorter than the second duration.
  7. 根据权利要求1至6任意一项所述的数据处理方法,其特征在于,所述执行第一程序段之前,所述方法还包括:The data processing method according to any one of claims 1 to 6, wherein before executing the first program segment, the method further comprises:
    根据所述终端的电压高于阈值电压,执行一个或多个第二程序段;Execute one or more second program segments according to the voltage of the terminal being higher than the threshold voltage;
    标记执行所述一个或多个第二程序段时所使用的地址区间;marking the address range used when executing the one or more second program segments;
    根据所述终端的电压低于所述阈值电压,计算被标记的地址区间对应的校验码。According to the voltage of the terminal being lower than the threshold voltage, the check code corresponding to the marked address interval is calculated.
  8. 根据权利要求1至7任意一项所述的数据处理方法,其特征在于,所述执行第一程序段之前,所述方法还包括:The data processing method according to any one of claims 1 to 7, wherein before executing the first program segment, the method further comprises:
    确定所述第一程序段对应的第一地址区间;determining a first address range corresponding to the first program segment;
    获取所述第一地址区间对应的校验码,所述第一地址区间对应的校验码存储于所述易失性存储器中;obtaining a check code corresponding to the first address interval, where the check code corresponding to the first address interval is stored in the volatile memory;
    根据所述第一地址区间对应的校验码确定所述第一地址区间中的数据正确;Determine that the data in the first address interval is correct according to the check code corresponding to the first address interval;
    基于所述第一地址区间中的数据正确,确定执行所述第一程序段。Based on the correct data in the first address interval, it is determined to execute the first program segment.
  9. 根据权利要求1至8任意一项所述的数据处理方法,其特征在于,所述方法还包括:The data processing method according to any one of claims 1 to 8, wherein the method further comprises:
    将所述易失性存储器中的数据周期性地存储至所述非易失性存储器。The data in the volatile memory is periodically stored to the non-volatile memory.
  10. 一种终端,其特征在于,所述终端包括:处理器、非易失性存储器和易失性存储器;所述处理器用于:A terminal, characterized in that the terminal comprises: a processor, a non-volatile memory and a volatile memory; the processor is used for:
    执行第一程序段;Execute the first program segment;
    计算第一地址区间对应的第一校验码,所述第一地址区间为执行所述第一程序段时所使用的地址区间;calculating a first check code corresponding to a first address interval, where the first address interval is an address interval used when executing the first program segment;
    获取第二地址区间对应的第二校验码,所述第二地址区间为第三地址区间中除所述第一地址区间之外的地址区间,所述第三地址区间为执行所述第一程序段所属的程序时所使用的地址区间;Obtain a second check code corresponding to a second address interval, where the second address interval is an address interval other than the first address interval in the third address interval, and the third address interval is for executing the first address interval. The address range used by the program to which the block belongs;
    根据所述第一校验码和所述第二校验码,确定第三校验码,所述第三校验码为所述第三地址区间对应的校验码;Determine a third check code according to the first check code and the second check code, where the third check code is a check code corresponding to the third address interval;
    将所述第三校验码存储于所述非易失性存储器,所述第三校验码用于在所述终端恢复供电后校验所述易失性存储器中的数据的正确性,所述第三地址区间位于所述易失性存储器中。The third check code is stored in the non-volatile memory, and the third check code is used to verify the correctness of the data in the volatile memory after the terminal restores power, so The third address interval is located in the volatile memory.
  11. 根据权利要求10所述的终端,其特征在于,所述易失性存储器中还包括第四地址区 间,所述第四地址区间存储的数据与执行所述第一程序段前所述第三地址区间存储的数据相同;The terminal according to claim 10, wherein the volatile memory further includes a fourth address interval, and the data stored in the fourth address interval is the same as the third address before executing the first program segment The data stored in the interval is the same;
    其中,所述第三地址区间被标记为工作区间,所述第四地址区间被标记为备份区间,所述工作区间为程序执行时所使用的区间,所述备份区间用于备份所述工作区间的数据。The third address interval is marked as a working interval, the fourth address interval is marked as a backup interval, the working interval is an interval used when the program is executed, and the backup interval is used to back up the working interval The data.
  12. 根据权利要求11所述的终端,其特征在于,所述处理器具体用于:The terminal according to claim 11, wherein the processor is specifically configured to:
    计算所述第四地址区间中与所述第一地址区间对应的地址区间的第四校验码;calculating the fourth check code of the address interval corresponding to the first address interval in the fourth address interval;
    根据所述第四地址区间对应的校验码以及所述第四校验码,确定所述第二校验码。The second check code is determined according to the check code corresponding to the fourth address interval and the fourth check code.
  13. 根据权利要求11或12所述的终端,其特征在于,所述处理器还用于:The terminal according to claim 11 or 12, wherein the processor is further configured to:
    将所述第四地址区间标记为工作区间,以及将所述第三地址区间标记为备份区间;marking the fourth address interval as a working interval, and marking the third address interval as a backup interval;
    将所述第三地址区间的数据拷贝至所述第四地址区间。Copy the data of the third address interval to the fourth address interval.
  14. 根据权利要求10至13任意一项所述的终端,其特征在于,所述处理器还用于:The terminal according to any one of claims 10 to 13, wherein the processor is further configured to:
    将所述第一校验码和所述第二校验码存储于所述易失性存储器,所述第一校验码和所述第二校验码用于在所述终端恢复供电后与所述第三校验码进行比对,以验证所述易失性存储器中的数据的正确性。The first check code and the second check code are stored in the volatile memory, and the first check code and the second check code are used to communicate with the terminal after the power supply is restored. The third check code is compared to verify the correctness of the data in the volatile memory.
  15. 根据权利要求10至14任意一项所述的终端,其特征在于,所述处理器还用于:The terminal according to any one of claims 10 to 14, wherein the processor is further configured to:
    在所述终端恢复供电后,获取所述终端的断电时长;After the power supply of the terminal is restored, acquiring the power-off duration of the terminal;
    若所述断电时长小于第一时长,则确定所述易失性存储器中的数据正确;If the power-off duration is less than the first duration, it is determined that the data in the volatile memory is correct;
    若所述断电时长大于所述第一时长且小于第二时长,则确定需要校验所述易失性存储器中的数据的正确性;If the power-off duration is longer than the first duration and shorter than the second duration, it is determined that the correctness of the data in the volatile memory needs to be verified;
    若所述断电时长大于所述第二时长,则确定所述易失性存储器中的数据不正确;If the power-off duration is greater than the second duration, determining that the data in the volatile memory is incorrect;
    其中,所述第一时长小于所述第二时长。Wherein, the first duration is shorter than the second duration.
  16. 根据权利要求10至15任意一项所述的终端,其特征在于,所述处理器还用于:The terminal according to any one of claims 10 to 15, wherein the processor is further configured to:
    根据所述终端的电压高于阈值电压,执行一个或多个第二程序段;Execute one or more second program segments according to the voltage of the terminal being higher than the threshold voltage;
    标记执行所述一个或多个第二程序段时所使用的地址区间;marking the address range used when executing the one or more second program segments;
    根据所述终端的电压低于所述阈值电压,计算被标记的地址区间对应的校验码。According to the voltage of the terminal being lower than the threshold voltage, the check code corresponding to the marked address interval is calculated.
  17. 根据权利要求10至16任意一项所述的终端,其特征在于,所述处理器还用于:The terminal according to any one of claims 10 to 16, wherein the processor is further configured to:
    确定所述第一程序段对应的第一地址区间;determining a first address range corresponding to the first program segment;
    获取所述第一地址区间对应的校验码,所述第一地址区间对应的校验码存储于所述易失性存储器中;obtaining a check code corresponding to the first address interval, where the check code corresponding to the first address interval is stored in the volatile memory;
    根据所述第一地址区间对应的校验码确定所述第一地址区间中的数据正确;Determine that the data in the first address interval is correct according to the check code corresponding to the first address interval;
    基于所述第一地址区间中的数据正确,确定执行所述第一程序段。Based on the correct data in the first address interval, it is determined to execute the first program segment.
  18. 根据权利要求10至17任意一项所述的终端,其特征在于,所述处理器还用于:The terminal according to any one of claims 10 to 17, wherein the processor is further configured to:
    将所述易失性存储器中的数据周期性地存储至所述非易失性存储器。The data in the volatile memory is periodically stored to the non-volatile memory.
  19. 一种计算机可读存储介质,其特征在于,包括计算机可读指令,当所述计算机可读指令在计算机上运行时,使得所述计算机执行如权利要求1至9中任一项所述的方法。A computer-readable storage medium, characterized by comprising computer-readable instructions, which, when the computer-readable instructions are executed on a computer, cause the computer to execute the method according to any one of claims 1 to 9 .
  20. 一种计算机程序产品,其特征在于,包括计算机可读指令,当所述包括计算机可读指令,在计算机上运行时,使得所述计算机执行如权利要求1至9任一项所述的方法。A computer program product, characterized by comprising computer-readable instructions, which, when executed on a computer, cause the computer to perform the method according to any one of claims 1 to 9.
PCT/CN2021/118918 2020-09-21 2021-09-17 Data processing method and related apparatus WO2022057872A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010997523.3A CN114253758A (en) 2020-09-21 2020-09-21 Data processing method and related device
CN202010997523.3 2020-09-21

Publications (1)

Publication Number Publication Date
WO2022057872A1 true WO2022057872A1 (en) 2022-03-24

Family

ID=80776443

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/118918 WO2022057872A1 (en) 2020-09-21 2021-09-17 Data processing method and related apparatus

Country Status (2)

Country Link
CN (1) CN114253758A (en)
WO (1) WO2022057872A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220382563A1 (en) * 2021-05-31 2022-12-01 Autochips Inc. Program startup method, electronic system, and non-transitory storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140519A (en) * 2006-09-04 2008-03-12 广达电脑股份有限公司 Embedded system and starting up procedure code automatic backup method thereof
CN101710253A (en) * 2009-11-25 2010-05-19 安凯(广州)微电子技术有限公司 Deep-sleep method of embedded system
CN103763064A (en) * 2014-01-26 2014-04-30 中国电子科技集团公司第五十八研究所 CRC code generating method and circuit applicable to ultra-high-speed communication system
CN108038021A (en) * 2017-11-13 2018-05-15 北京全路通信信号研究设计院集团有限公司 A kind of computer program operation phase code memory method of calibration
CN109426579A (en) * 2017-08-28 2019-03-05 西门子公司 The interruption restoration methods of machine tooling file and the lathe for being applicable in this method
WO2019132464A1 (en) * 2017-12-28 2019-07-04 삼성전자 주식회사 Display apparatus and operating method thereof
CN111552590A (en) * 2020-04-16 2020-08-18 国电南瑞科技股份有限公司 Detection and recovery method and system for memory bit overturning of power secondary equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140519A (en) * 2006-09-04 2008-03-12 广达电脑股份有限公司 Embedded system and starting up procedure code automatic backup method thereof
CN101710253A (en) * 2009-11-25 2010-05-19 安凯(广州)微电子技术有限公司 Deep-sleep method of embedded system
CN103763064A (en) * 2014-01-26 2014-04-30 中国电子科技集团公司第五十八研究所 CRC code generating method and circuit applicable to ultra-high-speed communication system
CN109426579A (en) * 2017-08-28 2019-03-05 西门子公司 The interruption restoration methods of machine tooling file and the lathe for being applicable in this method
CN108038021A (en) * 2017-11-13 2018-05-15 北京全路通信信号研究设计院集团有限公司 A kind of computer program operation phase code memory method of calibration
WO2019132464A1 (en) * 2017-12-28 2019-07-04 삼성전자 주식회사 Display apparatus and operating method thereof
CN111552590A (en) * 2020-04-16 2020-08-18 国电南瑞科技股份有限公司 Detection and recovery method and system for memory bit overturning of power secondary equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220382563A1 (en) * 2021-05-31 2022-12-01 Autochips Inc. Program startup method, electronic system, and non-transitory storage medium

Also Published As

Publication number Publication date
CN114253758A (en) 2022-03-29

Similar Documents

Publication Publication Date Title
US10261701B2 (en) Methods to communicate a timestamp to a storage system
TWI592800B (en) Memory management method and storage controller using the same
EP1818829B1 (en) Apparatus for collecting garbage block of nonvolatile memory according to power state and method of collecting the same
EP2581826A1 (en) Method and device for cold starting android mobile terminal
US10592126B2 (en) Memory management method, memory storage device and memory control circuit unit
JP2008518283A (en) Optimized non-volatile storage system
KR20140050290A (en) Application processor, mobile device having the same, and method of selecting a clock signal for an application processor
TWI489466B (en) Memory erasing method, memory controller and memory storage apparatus
TW201917561A (en) Managing operational state data in memory module
US10089182B2 (en) Energy-efficient nonvolatile microprocessor
WO2022057872A1 (en) Data processing method and related apparatus
KR20150045253A (en) Data storage device
TWI648634B (en) Memory management method, memory storage device and memory control circuit unit
US11693567B2 (en) Memory performance optimization method, memory control circuit unit and memory storage device
CN112817527A (en) Power failure data storage method, single chip microcomputer and computer readable storage medium
TWI473103B (en) Flash memory storage device and method for determining bad storage area thereof
KR20210039171A (en) Apparatus and method for tranceiving operation information in data processing system including memory system
CN115687174A (en) Method for recovering dynamic garbage of solid state disk and solid state disk
US20190146909A1 (en) Valid data management method and storage controller
TW201721653A (en) Memory management method, memory control circuit unit, and memory storage apparatus
US20210263846A1 (en) Processor system
US11513919B2 (en) System and method of generating automatic checkpoints of a distributed file system
US7743277B2 (en) System and method for detecting and reducing data corruption in a storage device
WO2022057933A1 (en) Application running method and apparatus, and a computer device
CN116414618A (en) Data backup method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21868694

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21868694

Country of ref document: EP

Kind code of ref document: A1