A method, device and computer equipment for running an application

By employing asynchronous DMA backup and error detection mechanisms, the time overhead caused by frequent power outages in IoT devices is resolved, thereby improving the operating efficiency and reliability of applications.

CN114253764BActive Publication Date: 2026-05-22HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2020-09-21
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

IoT devices frequently experience power outages due to unstable external power sources, which increases the time overhead of synchronous DMA backup in intermittent systems and reduces the efficiency of application operation.

Method used

An asynchronous DMA backup method is adopted to back up data while the processor is running program segments. The backup data is checked for errors by checking the backup order to ensure that the program can continue to run with the correct backup data after a power failure and restart.

Benefits of technology

It reduces application time overhead, improves operating efficiency, and avoids program errors caused by incorrect backup data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253764B_ABST
    Figure CN114253764B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a method and device for running an application program and a computer device, which are used for reducing time overhead and improving running efficiency of the application program. The method comprises the following steps: a processor runs a first program segment based on data in a first storage space, the first program segment is used for modifying the data in the first storage space, the data in the first storage space comprises values of M first variables and values of N second variables, and each value of the first variable corresponds to at least one value of the second variable; a DMA backs up the data in the first storage space based on a target rule to obtain first backup data stored in a second storage space; for the first variable and the corresponding second variable, a modification order indicated by the first program segment is opposite to a backup order indicated by the target rule, so if the first backup data comprises at least one value of the first variable after the first program segment is run, the processor determines that the first backup data is incorrect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, and computer device for running an application. Background Technology

[0002] With the development of IoT technology, the number of IoT devices is increasing. Powering these massive IoT devices has become a challenge. Due to the limitations of traditional battery power, a new type of energy harvesting device has emerged.

[0003] This energy harvesting device can collect energy from sources such as light, heat, radio frequency, and pressure to power IoT devices. Therefore, it offers high deployment flexibility and eliminates the need for frequent maintenance and battery replacements, reducing limitations on its application scenarios.

[0004] However, because external energy sources are unpredictable and unstable, IoT devices may face frequent power outages, making it difficult for them to run applications completely within a single power cycle. Therefore, intermittent systems are applied to IoT devices.

[0005] Intermittent systems address the issue of frequent power outages by frequently saving their system state during operation. Specifically, the intermittent system backs up its system state after each program segment. This backup involves copying some data from memory to non-volatile memory (NVM). This ensures that the data in the NVM is not lost when the IoT device loses power, and the program can continue running using the data in the NVM after power is restored.

[0006] Direct Memory Access (DMA) can directly access data in memory without processor intervention, making it widely used for data backup in intermittent systems. However, asynchronous DMA backups can be problematic because the processor might modify the data before the DMA process completes the backup, resulting in a backed-up copy of the modified data instead of the original. Therefore, synchronous DMA backups are now the primary method. In this approach, the DMA backs up the data in memory after the processor has run a program, and only after the backup is complete does the processor run the next program.

[0007] Clearly, synchronous DMA backups incur additional time overhead and reduce application performance. Summary of the Invention

[0008] This application provides a method, apparatus, and computer device for running applications, which reduces time overhead and improves the running efficiency of applications.

[0009] The first aspect of this application provides a method for running an application, applied to a computer device, the computer device including a processor and a direct memory access DMA; the method includes: the processor running a first program segment based on data in a first storage space, the first program segment being one of a plurality of program segments constituting an application, and used to modify the data in the first storage space, the data in the first storage space including the values ​​of M first variables and the values ​​of N second variables, each of the M first variables corresponding to at least one of the N second variables, the first program segment indicating that for each value of a first variable, after modifying the value of a first variable, the value of at least one second variable corresponding to the value of the first variable is modified, the value of each first variable after running the first program segment is known and different from the value before running the first program segment, and M and N are both positive integers. DMA backs up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. The backup order indicates that for each value of the first variable, before backing up the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is backed up. The second storage space is located in non-volatile memory. Based on the fact that the first backup data in the second storage space includes the value of at least one of the M first variables after the execution of the first program segment, the processor determines that the first backup data in the second storage space is incorrect.

[0010] The first storage space may be located in non-volatile memory or in volatile memory; volatile memory includes, but is not limited to, dynamic random access memory (DRAM) and static random access memory (SRAM); non-volatile memory includes, but is not limited to, flash memory (FLASH), ferroelectric memory (FRAM), and electrically erasable programmable read-only memory (EEPROM).

[0011] In existing methods for running applications, the first program segment is run after the data in the first storage space is backed up. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are serial. However, in this application, the first program segment is run simultaneously with the data in the first storage space. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are parallel, which can reduce time overhead and improve the running efficiency of the application. Furthermore, for the values ​​of the first variable and the corresponding second variable, the modification order indicated by the first program segment is the opposite of the backup order indicated by the backup order. Specifically, the first program segment indicates that the value of the first variable should be modified first, and then the value of the corresponding second variable should be modified, while the backup order indicates that the value of the corresponding second variable should be modified first, and then the value of the first variable should be modified. Therefore, if the first backup data contains the modified value of the first variable, it indicates that the processor had already modified the value of the first variable when backing it up. Thus, it is highly likely that the processor modified the value of the second variable before backing up the first variable. Therefore, the value of the second variable in the first backup data can be considered the modified value of the second variable, and the processor determines that the first backup data in the second storage space is incorrect. Based on this determination of the first backup data error, it is possible to prevent the processor from continuing to run the application using erroneous backup data in the second storage space after a power outage and restart of the computer.

[0012] As one implementation, after the processor determines that the first backup data in the second storage space is incorrect, and after the processor runs the first program segment based on the data in the first storage space, the method further includes: DMA backing up the data in the first storage space based on the backup order, so as to replace the first backup data in the second storage space with the second backup data; the processor runs the second program segment based on the data in the first storage space, the second program segment being a program segment that runs after the first program segment in the execution order among multiple program segments, and is used to modify the data in the first storage space, the first program segment indicating the value of each first variable, and after modifying the value of the first variable, modifying the value of at least one second variable corresponding to the value of the first variable; based on the fact that the second backup data in the second storage space does not include the value of any of the M first variables after running the second program segment, the processor determines that the second backup data in the second storage space is correct.

[0013] After determining that the first backup data in the second storage space is incorrect, instead of re-running the program segment that was run first among multiple program segments, the data in the first storage space is backed up again after the first program segment is run, and the second program segment is run at the same time. This replaces the incorrect first backup data in the second storage space with the correct second backup data, thereby reducing the time overhead of running the application.

[0014] As one implementation, after the processor determines that the first backup data in the second storage space is incorrect, and after the processor runs the first program segment based on the data in the first storage space, but before the DMA backs up the data in the first storage space based on the backup order, the method further includes: the processor setting the values ​​of M first variables in the first storage space to the values ​​of the M first variables before running the first program segment.

[0015] The processor sets the values ​​of the M first variables to the values ​​of the M first variables before the execution of the first program segment, thereby resetting the values ​​of the M first variables and avoiding the mistaken assumption that the backup data is incorrect if the values ​​of the first variables are the same before and after the execution of the second program segment.

[0016] As one implementation, after the processor determines that the first backup data in the second storage space is incorrect, the method further includes: after the computer device is powered off and restarted, based on the first backup data in the second storage space that contains the error, the processor executes a third program segment, which is the program segment that runs first in the execution order among multiple program segments.

[0017] After the computer device is powered off and restarted, the processor executes the third program segment based on the first backup data stored in the second storage space, which contains errors. This avoids the processor running the next program segment of the first program segment based on the erroneous first backup data, thereby preventing application errors from occurring.

[0018] As one implementation method, the method further includes: based on the fact that the first backup data in the second storage space does not include the value of any of the M first variables after running the first program segment, the processor determines that the first backup data in the second storage space is correct.

[0019] This implementation provides a feasible solution for determining the correctness of the first backup data.

[0020] As one implementation, after the processor determines that the first backup data in the second storage space is correct, the method further includes: DMA backing up the correct first backup data in the second storage space to a third storage space, which is also located in non-volatile memory.

[0021] The correct first backup data in the second storage space is backed up again. This way, even if the correct first backup data in the second storage space is replaced with incorrect backup data, the processor can still obtain the correct first backup data from the third storage space. Thus, in the event of a power outage, after the computer restarts, to reduce time overhead, the processor can re-run the first program segment based on the correct first backup data in the third storage space, instead of running the third program segment which was executed first among multiple program segments.

[0022] As one implementation, after the DMA backs up the correct first backup data in the second storage space to the third storage space, the method further includes: after the computer device is powered off and restarted, based on the fact that the second storage space contains the incorrect third backup data and the third storage space contains the correct first backup data, the processor runs a first program segment based on the first backup data in the third storage space.

[0023] After backing up the correct first backup data to the third storage space, if the computer device is powered off and restarted, the computer device does not need to rerun the first program segment that runs among the multiple program segments that make up the application. Instead, it can rerun the first program segment based on the first backup data in the third storage space, thereby reducing time overhead.

[0024] As one implementation, the first storage space is located in volatile memory.

[0025] A second aspect of this application provides an apparatus for running an application, applied to a computer device. The apparatus includes a processing unit that runs a first program segment based on data in a first storage space. The first program segment is one of a plurality of program segments constituting an application and is used to modify the data in the first storage space. The data in the first storage space includes values ​​of M first variables and values ​​of N second variables. Each value of the M first variables corresponds to at least one value of the N second variables. The first program segment instructs that for each value of a first variable, after modifying the value of a first variable, the value of at least one second variable corresponding to the value of the first variable is modified. Each first variable is executed... The values ​​after the first program segment are known and different from the values ​​before the execution of the first program segment, where M and N are both positive integers; a data backup unit is used to back up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. The backup order indicates that for each value of the first variable, before backing up the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is backed up. The second storage space is located in non-volatile memory; a processing unit is used to determine that the first backup data in the second storage space is incorrect based on the first backup data in the second storage space, which includes the value of at least one of the M first variables after the execution of the first program segment.

[0026] As one implementation, the data backup unit is further configured to perform DMA backup of data in the first storage space based on the backup order, so as to replace the first backup data in the second storage space with the second backup data; the processing unit is further configured to run a second program segment based on the data in the first storage space, the second program segment being a program segment that runs after the first program segment in the execution order among multiple program segments, and is used to modify the data in the first storage space, the first program segment indicating the value of each first variable, and after modifying the value of the first variable, modifying the value of at least one second variable corresponding to the value of the first variable; the processing unit is further configured to determine that the second backup data in the second storage space is correct based on the fact that the second backup data in the second storage space does not include the value of any of the M first variables after running the second program segment.

[0027] As one implementation, the processing unit is also used by the processor to set the values ​​of the M first variables in the first storage space to the values ​​of the M first variables before the execution of the first program segment.

[0028] As one implementation, the processing unit is also used to execute a third program segment after the computer device is powered off and restarted, based on the first backup data containing errors stored in the second storage space. The third program segment is the program segment that runs first in the execution order among multiple program segments.

[0029] As one implementation, the processing unit is also used to determine that the first backup data in the second storage space is correct based on the fact that the first backup data in the second storage space does not include the value of any of the M first variables after running the first program segment.

[0030] As one implementation, the data backup unit is also used to back up the correct first backup data in the second storage space to the third storage space, which is also located in non-volatile memory.

[0031] As one implementation, the processing unit is also used to run a first program segment based on the first backup data in the third storage space after the computer device is powered off and restarted, based on the fact that the third backup data in the second storage space contains erroneous data and the third storage space contains correct data.

[0032] As one implementation, the first storage space is located in volatile memory.

[0033] For details on the implementation, related explanations, and technical effects of each of the above units, please refer to the description of the first aspect of the embodiments of this application.

[0034] A third aspect of this application provides a computer device, including: one or more processors and a memory; wherein the memory stores computer-readable instructions; the one or more processors read the computer-readable instructions to cause the computer device to perform the method as described in any implementation of the first aspect.

[0035] A fourth aspect of this application provides a computer-readable storage medium including computer-readable instructions that, when executed on a computer, cause the computer to perform the method as described in any implementation of the first aspect.

[0036] A fifth aspect of this application provides a chip including one or more processors. Part or all of the processors are configured to read and execute a computer program stored in a memory to perform the methods in any possible implementation of the first aspect described above.

[0037] Optionally, the chip includes a memory, which is connected to the processor via a circuit or wire. Further optionally, the chip also includes a communication interface, to which the processor is connected. The communication interface is used to receive data and / or information that needs 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 can be an input / output interface.

[0038] In some implementations, some of the processors may implement some steps of the above method through dedicated hardware. For example, the processing of neural network models may be implemented by a dedicated neural network processor or graphics processor.

[0039] The method provided in this application embodiment can be implemented by a single chip or by multiple chips working together.

[0040] A sixth aspect of this application provides a computer program product, which includes computer software instructions that can be loaded by a processor to implement the method described in any of the implementations of the first aspect.

[0041] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0042] In existing methods for running applications, the first program segment is run after the data in the first storage space is backed up. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are serial. However, in the embodiments of this application, the processor runs the first program segment based on the data in the first storage space. The first program segment is one of multiple program segments that constitute the application and is used to modify the data in the first storage space. DMA backs up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. Therefore, the process of the processor running the first program segment does not need to be performed after the backup is completed. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are parallel, which can reduce time overhead and improve the running efficiency of the application.

[0043] Furthermore, the data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables to be backed up. Each of the M first variables corresponds to the value of at least one of the N second variables. The backup order indicates that for each value of a first variable, before backing up the value of the first variable, the value of at least one second variable corresponding to that first variable is backed up. M and N are both positive integers. The first program segment indicates that for each value of a first variable, after modifying the value of the first variable, the value of at least one second variable corresponding to that first variable is modified. The value of each first variable after running the first program segment is known and different from its value before running the first program segment. It can be seen that the modification order indicated by the first program segment is the opposite of the backup order indicated by the backup order. Specifically, the first program segment indicates that the value of the first variable is modified first, and then the value of the second variable corresponding to the first variable is modified, while the backup order indicates that the value of the second variable corresponding to the first variable is modified first, and then the value of the first variable is modified. Therefore, if the first backup data contains the modified value of the first variable, it indicates that the processor had already modified the value of the first variable when backing it up. Thus, it is highly likely that the processor modified the value of the second variable before backing up the first variable. Therefore, the value of the second variable in the first backup data can be considered the modified value of the second variable, and the processor determines that the first backup data in the second storage space is incorrect. Based on this determination of the first backup data error, it is possible to prevent the processor from continuing to run the application using erroneous backup data in the second storage space after a power outage and restart of the computer. Attached Figure Description

[0044] Figure 1 This is a schematic diagram of the architecture of the Internet of Things system in the embodiments of this application;

[0045] Figure 2 This is a first structural schematic diagram of the computer device in an embodiment of this application;

[0046] Figure 3 This is a schematic diagram illustrating the method of running an application in an embodiment of this application;

[0047] Figure 4 This is a schematic diagram of a first embodiment of data in the first storage space in this application.

[0048] Figure 5 This is a schematic diagram of a second embodiment of data in the first storage space in this application.

[0049] Figure 6 This is a schematic diagram of a third embodiment of data in the first storage space in this application.

[0050] Figure 7This is a schematic diagram of a first embodiment of the first program segment in this application;

[0051] Figure 8 This is a schematic diagram of a second embodiment of the first program segment in this application.

[0052] Figure 9 This is a schematic diagram illustrating the time relationship between backing up data in the first storage space and running the first program segment in an embodiment of this application;

[0053] Figure 10 This is a schematic diagram illustrating the operation of an application in a scenario where a computer device is powered off and restarted, as described in this application embodiment.

[0054] Figure 11 This is a schematic diagram of a device for running an application in an embodiment of this application;

[0055] Figure 12 This is a schematic diagram of the second structure of the computer device in an embodiment of this application. Detailed Implementation

[0056] The embodiments of this application are described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. As those skilled in the art will recognize, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0057] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that 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 apparatus that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to such processes, methods, products, or apparatus. The naming or numbering of steps appearing in this application does not imply that the steps in the method flow must be performed in the chronological or logical order indicated by the naming or numbering. The execution order of named or numbered process steps can be changed according to the desired technical purpose, as long as the same or similar technical effect is achieved.

[0058] The embodiments of this application can be applied to Figure 1 The IoT system shown. For example... Figure 1As shown, this IoT system mainly includes IoT devices and energy harvesting devices. The energy harvesting devices can harvest energy from sources such as solar energy, thermal energy, wind energy, radio frequency energy, and pressure. For example, the energy harvesting devices can be solar panels, radio frequency devices, piezoelectric conversion devices, etc. Figure 1 Only energy sources such as light, heat, and wind are shown.

[0059] This IoT device is typically a terminal device deployed in a special environment where it is inconvenient to replace batteries and charge.

[0060] For example, such as Figure 1 As shown, the IoT device can be a fire prevention device deployed in a forest to monitor whether a forest fire has occurred. Since the fire prevention device is deployed in the forest, it is inconvenient to replace the battery and charge it. Therefore, it can collect light energy through an energy harvesting device and convert the light energy into electrical energy to power the fire prevention device.

[0061] For example, such as Figure 1 As shown, the IoT device can be a meteorological information monitoring device deployed at high altitudes such as mountaintops. This meteorological information monitoring device is used to monitor meteorological information. Since the meteorological information monitoring device is mostly deployed at high altitudes such as mountaintops, it is inconvenient to replace batteries and charge them. Therefore, energy harvesting devices can be used to collect solar energy, wind energy, etc., and convert solar energy and wind energy into electrical energy to power the meteorological information monitoring device.

[0062] For example, the IoT device can also be a smart insole, which is used to collect motion information of a person during exercise; since the smart insole is mainly used during exercise, pressure can be collected by an energy harvesting device and converted into electrical energy to power the smart insole.

[0063] It should be understood that energy sources such as solar, thermal, wind, radio frequency, and pressure are all unstable, thus IoT devices powered by these energy sources face frequent power outages. To address this issue, intermittent systems are typically deployed in IoT devices. These systems back up the system state after each program run. Backing up the system state involves copying the data required for program execution to non-volatile memory (NVM). This ensures that the data in the NVM is not lost after a power outage, and the program can continue running using the data after power is restored.

[0064] The data required for program execution mainly includes the values ​​in registers and the values ​​of some variables that the program needs to access. These variable values ​​are typically stored in memory. The following section primarily uses the values ​​of variables accessed by the program as an example to illustrate the system state backup process.

[0065] Because Direct Memory Access (DMA) is a hardware component independent of the processor, and DMA can directly access (read or write) data in memory without processor intervention, it is often used to back up system state in intermittent systems.

[0066] System state backup using DMA includes two methods: synchronous DMA backup and asynchronous DMA backup. Synchronous DMA backup involves alternating between program execution and system state backup; that is, after running a segment of the program, a system state backup is performed, and after the backup is complete, the next segment of the program is run, and then another system state backup is performed. Because synchronous DMA backup incurs additional time overhead and reduces application execution efficiency, this application provides a method for running an application that uses asynchronous DMA backup to back up the system state.

[0067] Asynchronous DMA backup refers to running the program and backing up the system state in parallel. That is, after running a segment of the program, a system state backup is performed, and the next segment of the program runs simultaneously. Because the system state backup and program execution occur concurrently, running the program may cause the values ​​of some variables in memory to be modified before the backup, resulting in incorrect backup data. After the IoT device is powered off and restarted, it will continue running the program using the incorrect backup data.

[0068] The method for running applications provided in this application not only enables asynchronous DMA backup but also detects backup data errors in a timely manner, thereby preventing the application from continuing to run with incorrect backup data after a power outage and restart of the IoT device. The method for running applications provided in this application is described below.

[0069] Specifically, embodiments of this application provide a method for running an application, applied to a computer device, such as... Figure 2 As shown, a computer device includes a processor and a direct memory access (DMA) module.

[0070] The computer device can be a server with an intermittent system or a terminal device with an intermittent system. Specifically, the computer device can be an Internet of Things (IoT) device with an intermittent system. The IoT device includes, but is not limited to, the fire prevention equipment, meteorological information monitoring equipment, and smart insoles mentioned above.

[0071] The processor can be any processor capable of executing program instructions. For example, the processor can be a standalone central processing unit (CPU), a CPU core on a system-on-a-chip (SoC), or a microcontroller unit (MCU).

[0072] Based on the aforementioned computer equipment, such as Figure 3 As shown, the method for running an application provided in this application embodiment includes:

[0073] Step 101: The processor runs the first program segment based on the data in the first storage space.

[0074] like Figure 2 As shown, in a computer device, there is also a first storage space, which can be located in non-volatile memory or volatile memory.

[0075] It should be noted that when the first storage space is located in volatile memory, the data stored in the first storage space will be lost if the computer device loses power. Therefore, it is necessary to back up the data in the first storage space during application operation. When the first storage space is located in non-volatile memory, although the data in the non-volatile memory will not disappear when the computer device loses power, it is still necessary to back up the data in the first storage space during application operation. A specific example will be provided below for illustration.

[0076] For example, the first storage space is located in non-volatile memory and stores the value 'a' of a certain variable. The processor runs a program that increments the value 'b' of the variable in the first storage space.

[0077] Without backing up the value 'a' of the variable in the first storage space: If the program segment has not finished running but has already executed the operation of increasing the value of the variable in the first storage space by 'b', and then the computer suddenly loses power, the value of the variable in the first storage space will become 'a+b'. After the computer restarts, the processor will rerun the program segment, that is, it will continue to increase the value by 'b' based on 'a+b', so the value of the variable in the first storage space will become 'a+2b'.

[0078] In the case where the value 'a' of the variable in the first storage space is backed up: Since the value 'a' of the variable in the first storage space is backed up, under the same scenario described above, after the computer device is powered on and restarted, the processor will re-run the program based on the backed-up value 'a', that is, it will continue to add 'b' to the value 'a', so the value of the variable in the first storage space will still be a+b.

[0079] As shown in the example above, without backing up the value 'a' of the variable in the first storage space, performing the operation of incrementing the value 'b' of the variable in the first storage space twice resulted in an incorrect value for the variable in the first storage space. Therefore, even if the first storage space is located in non-volatile memory, it is still necessary to back up the data in the first storage space.

[0080] In the embodiments of this application, volatile memory includes, but is not limited to, dynamic random access memory (DRAM) and static random access memory (SRAM); non-volatile memory includes, but is not limited to, flash memory (FLASH), ferroelectric memory (FRAM), and electrically erasable programmable read-only memory (EEPROM).

[0081] The first program segment is one of a plurality of program segments that constitute the application and is used to modify data in the first storage space.

[0082] The term "program segment" and the first program segment in the embodiments of this application will be explained below.

[0083] First, a program segment refers to a piece of code.

[0084] As explained above, in an intermittent system, a system state backup is performed after each program segment is run. It should be noted that there are at least two methods to implement this backup process.

[0085] The first method: During the operation of an application, the computer device sets multiple backup points through checkpoints. Whenever a backup point is reached, the application stops running and then the system state is backed up. In this case, the part of the application between two backup points can be regarded as a program segment.

[0086] The second method is to write the part of the application between the two backup points in the first method as a separate piece of code, which can also be called a task. In this way, the application can be regarded as composed of multiple tasks; in this case, a task can be regarded as a program segment.

[0087] Therefore, the program segment in the embodiments of this application can be the program segment in the first method or the program segment in the second method, which will not be elaborated on below.

[0088] In this embodiment of the application, the application consists of multiple program segments, which usually have a certain execution order. The first program segment can be any one of these multiple program segments.

[0089] According to the execution order, when the first program segment is the first program segment to run among multiple program segments, the data in the first storage space is the data after the application is initialized; when the first program segment is any program segment other than the first program segment to run, the data in the first storage space is the data obtained after running the first program segment.

[0090] In this embodiment, modifying data in the first storage space can be understood as the processor executing a write operation instruction in the first program segment to perform a write operation on the data in the first storage space. Typically, the modified data differs from the data before modification.

[0091] In addition to writing instructions for data in the first storage space, the first program segment may also include reading instructions for data in the first storage space. Furthermore, the first program segment may also include other instructions, which are not specifically limited in this embodiment.

[0092] The data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables. Each value of the M first variables corresponds to the value of at least one of the N second variables, where M and N are both positive integers.

[0093] The following is a detailed explanation of the data in the first storage space.

[0094] First, it's understandable that for any given application, the number of variables it needs to access is fixed. Therefore, during application initialization, a fixed amount of storage space is allocated to store the values ​​of the variables the application needs to access.

[0095] In this embodiment, the variable that the application needs to access is referred to as the second variable, and the fixed storage space allocated to the application is referred to as the first storage space. For example, as shown... Figure 4 As shown, the first storage space is used to store the values ​​of the second variable A, the second variable B, the second variable C, and the second variable D.

[0096] The values ​​of the N second variables are the values ​​of the variables that actually need to be backed up. Therefore, the values ​​of the N second variables can also be referred to as the values ​​of the variables to be backed up.

[0097] Specifically, the values ​​of the N second variables can be any of the values ​​of all variables that the application needs to access; for example, such as Figure 4As shown, assuming that all the variables that the application needs to access are second variable A, second variable B, second variable C, and second variable D, then the values ​​of the N second variables to be backed up can be the values ​​of second variable A, second variable B, second variable C, and second variable D.

[0098] The values ​​of the N second variables can also be a subset of the values ​​of all variables that the application needs to access. For example, before executing step 101, the processor runs a program that performs write operations on the values ​​of some variables. In this case, the N second variables to be backed up can be a subset of the values ​​of variables, including the variables whose write operations were performed.

[0099] Specifically, the variables that the application needs to access are second variable A, second variable B, second variable C, and second variable D. Before executing step 101, the processor runs a program segment used to write to the values ​​of second variable B and second variable D. Therefore, the values ​​of the N second variables to be backed up can include only the values ​​of second variable B and second variable D. It is understandable that, normally, read and write operations are performed on data within a contiguous memory space, so the values ​​of the N second variables to be backed up can also include the values ​​of second variable B, second variable C, and second variable D.

[0100] As explained above, the values ​​of the N second variables can be obtained after running a program segment. That is, before running the first program segment, the processor runs other program segments and outputs the values ​​of the N second variables. It's understandable that in practical applications, the operation instructions within a program segment are complex, and the values ​​of the N second variables output by the program segment are related to the values ​​of the input variables. Therefore, before running a program segment, the values ​​of the N second variables output by the program segment are usually unpredictable. As a possible scenario, the value of a certain second variable may not change before or after running the first program segment. Therefore, it is not possible to detect whether the values ​​of the N second variables are stored incorrectly by checking the values ​​of the second variables in the backed-up data.

[0101] To detect whether there are backup errors in the values ​​of the N second variables, this embodiment adds M values ​​of the first variables to the first storage space. Each of the M first variables corresponds to at least one value of the N second variables, where M and N are both positive integers. Furthermore, this embodiment adds instructions to the first program segment to modify the values ​​of the M first variables. These instructions can specifically instruct the N second variables to be modified to specific values.

[0102] Therefore, the value of each first variable after running the first program segment is known compared to its value before running the first program segment. Furthermore, by appropriately setting the values ​​of the M first variables and the modification instructions in the first program segment, it is possible to ensure that the value of each first variable after running the first program segment differs from its value before running the first program segment. In this way, the value of the first variables in the backed-up data can be used to detect whether the values ​​of the N second variables have been stored incorrectly in the backup.

[0103] The values ​​of the M first variables can be set according to actual needs. The values ​​of the M first variables can be completely the same, partially the same, or different. For ease of setting, the values ​​of all M first variables can be set to 0.

[0104] When M is greater than 1, each value of the first variable can correspond to one value of the second variable, or it can correspond to multiple values ​​of the second variable.

[0105] It should be noted that the values ​​of the second variables corresponding to the values ​​of the M first variables can include only a portion of the values ​​of the N second variables. This allows for the detection of backup errors in the values ​​of a portion of the N second variables. Alternatively, the values ​​of the second variables corresponding to the values ​​of the M first variables can include all the values ​​of the N second variables. This allows for the detection of backup errors in the values ​​of all the N second variables.

[0106] In this application embodiment, the relative storage location of the values ​​of the first variable and the second variable in the first storage space is not specifically limited, but can be adjusted according to actual needs.

[0107] To more easily represent the correspondence between the values ​​of the first variable and the second variable, embodiments of this application use the relative storage positions of the values ​​of the first variable and the second variable in the first storage space to represent the correspondence between the values ​​of the first variable and the second variable.

[0108] For example, the storage address of the value of the first variable and the storage address of at least one value of the second variable corresponding to the value of the first variable are contiguous in the first storage space, and the storage address of the value of the first variable is higher than the storage address of any of the values ​​of the second variables corresponding to it.

[0109] For example, M = 1, N = 4. Figure 5As shown, the values ​​of the M first variables include the value of the first variable Z, and the N second variables include the values ​​of the second variable A, the second variable B, the second variable C, and the second variable D. The value of the first variable Z corresponds to the values ​​of the second variables A, B, C, and D. Therefore, in the first storage space, the values ​​of the second variables A, B, C, and D, and the value of the first variable Z are stored sequentially from the low storage address to the high storage address.

[0110] For example, M = 2, N = 4. Figure 6 As shown, the values ​​of the M first variables include the values ​​of the first variable X and the first variable Y, and the values ​​of the N second variables include the values ​​of the second variable A, the second variable B, the second variable C, and the second variable D. The value of the first variable X corresponds to the value of the second variable A and the second variable B, and the value of the first variable Y corresponds to the value of the second variable C and the second variable D. Therefore, in the first storage space, the values ​​of the second variable A, the second variable B, the first variable X, the second variable C, the second variable D, and the first variable Y are stored sequentially from the low storage address to the high storage address.

[0111] The first program segment instructs that, for each value of the first variable, after modifying the value of the first variable, the value of at least one second variable corresponding to the value of the first variable shall be modified.

[0112] Taking any one of the M first variables (here called the target variable) as an example, based on the instructions of the first program segment, when the processor modifies the data in the first storage space, it will first modify the value of the target variable, and then modify the value of at least one second variable corresponding to the value of the target variable.

[0113] For example, the first program segment can be like this: Figure 7 As shown, the values ​​of the first variable Z, the second variable A, the second variable B, the second variable C, and the second variable D are changed to 1, 5, 6, 7, and 8 in sequence.

[0114] For example, the first program segment can also be like this: Figure 8 As shown, the values ​​of the first variable X, the second variable A, the second variable B, the first variable Y, the second variable C, and the second variable D are changed sequentially to 1, 5, 6, 1, 7, and 8.

[0115] Step 102: DMA backs up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space.

[0116] In this embodiment, the DMA can also be referred to as the DMA controller DMAC.

[0117] like Figure 2 As shown, there is also a second storage space in the computer device, which is located in non-volatile memory. Since non-volatile memory has been explained above, it will not be repeated here.

[0118] Backing up the data in the first storage space can be understood as copying the data in the first storage space to the second storage space.

[0119] The backup order instruction specifies that for each value of the first variable, the value of at least one second variable corresponding to the value of the first variable must be backed up before the value of the first variable is backed up.

[0120] Taking any one of the M first variables (here called the target variable) as an example, based on the backup order instruction, during the process of backing up the data in the first storage space, the processor will first back up the value of at least one second variable corresponding to the value of the target variable, and then back up the value of the target variable.

[0121] Comparing the modification order indicated by the first program segment with the backup order indicated by the backup order, it can be seen that the modification order indicated by the first program segment is the opposite of the backup order indicated by the backup order.

[0122] It is understandable that when backing up data in storage space, data is usually read sequentially from low to high storage address. Therefore, to make it easier to configure the backup order, the backup order can be represented by the relative storage positions of the first variable and the second variable in the first storage space.

[0123] Specifically, the storage addresses of the values ​​of the first variable and the second variable can be configured in a reasonable way, such that the storage address of the value of the first variable and the storage address of at least one value of the second variable corresponding to the value of the first variable are contiguous in the first storage space; and the storage addresses of the at least one value of the second variable corresponding to the value of the first variable and the storage address of the value of the first variable are arranged in order from low address to high address.

[0124] by Figure 5For example, in the first storage space, the values ​​of the second variable A, the second variable B, the second variable C, the second variable D, and the first variable Z are stored sequentially from low to high storage addresses. Therefore, backing up the data in the first storage space in order of storage address from low to high is equivalent to backing up the values ​​of the second variable A, the second variable B, the second variable C, the second variable D, and the first variable Z sequentially based on the backup order.

[0125] Similarly, with Figure 6 For example, in the first storage space, the values ​​of the second variable A, the second variable B, the first variable X, the second variable C, the second variable D, and the first variable Y are stored sequentially from low to high storage addresses. Therefore, backing up the data in the first storage space in order of storage address from low to high is equivalent to backing up the values ​​of the second variable A, the second variable B, and the first variable X in sequence, as well as the values ​​of the second variable C, the second variable D, and the first variable Y in sequence based on the backup order.

[0126] It should be noted that the data in the first storage space is the data required to run the first program segment. Therefore, the first backup data in the second storage space corresponds to the first program segment, meaning that the first backup data contains the values ​​of the variables required to run the first program segment. The correspondence between the first backup data and the first program segment can also be stored in the second storage space.

[0127] In this embodiment, steps 101 and 102 are executed in no particular order, meaning they can be executed simultaneously. Correspondingly, the process of backing up the data in the first storage space and the process of running the first program segment to modify the data in the first storage space are parallel. That is, this embodiment uses asynchronous DMA backup to back up the data in the first storage space.

[0128] Step 103: Based on the first backup data in the second storage space, which includes the value of at least one of the M first variables after running the first program segment, the processor determines that the first backup data in the second storage space is incorrect.

[0129] It is understandable that since steps 101 and 102 can be executed simultaneously, the processor may have already modified the value of a second variable before backing it up. In this embodiment, the modification order indicated by the first program segment is the reverse of the backup order indicated by the backup order. Specifically, the first program segment indicates that the value of the first variable should be modified first, and then the value of the corresponding second variable should be modified, while the backup order indicates that the value of the corresponding second variable should be modified first, and then the value of the first variable should be modified. Therefore, if the first backup data contains the modified value of the first variable, it means that the processor has already performed the modification operation on the value of the first variable when backing it up. Thus, it is largely assumed that the processor had already performed the modification operation on the value of the second variable before backing up the value of the first variable. Therefore, the value of the second variable in the first backup data can be considered the modified value of the second variable, and the processor's determination of the first backup data in the second storage space is incorrect.

[0130] Specifically, taking a first variable as an example, since the modification order indicated by the first program segment is the reverse of the backup order indicated by the backup order, if the value of the first variable in the second storage space is the value of the first variable after the execution of the first program segment, it means that the processor had already executed the operation of modifying the value of the first variable in the first program segment before backing up the value of the first variable. In this case, it can be assumed that the processor may have already executed the operation of modifying the value of the second variable corresponding to the value of the first variable in the first program segment before backing up the value of the second variable corresponding to the value of the first variable. Based on this, the processor determines that the backup data in the second storage space is incorrect.

[0131] The following is combined Figures 5 to 8 The above process will be explained in detail.

[0132] First example: According to Figure 7 As shown in the first program segment, the processor sequentially modifies the values ​​of the first variable Z, the second variable A, the second variable B, the second variable C, and the second variable D to 1, 5, 6, 7, and 8; according to Figure 5 As shown in the first storage space, the DMA sequentially backs up the values ​​of the second variable A, the second variable B, the second variable C, the second variable D, and the first variable Z. Here, it is assumed that the value of the first variable Z in the first storage space is 0.

[0133] The following section uses the values ​​of Z and B in the second storage space as examples to illustrate the process by which the processor determines that the backup data in the second storage space is incorrect.

[0134] If the value of the first variable Z in the backup data in the second storage space is 1, it means that the processor had already modified the value of the first variable Z in the first storage space to 1 before backing up the value of the first variable Z. Therefore, before backing up the value of the second variable B, the processor may have already modified the value of the second variable B in the first storage space to 6. Thus, the processor determines that the backup data in the second storage space is incorrect.

[0135] Second example: According to Figure 8 As shown in the first program segment, the processor sequentially modifies the values ​​of the first variable X, the second variable A, the second variable B, the first variable Y, the second variable C, and the second variable D to 1, 5, 6, 1, 7, and 8; according to Figure 6 As shown in the backup order, the DMA backs up the values ​​of the second variable A, the second variable B, the first variable X, the second variable C, the second variable D, and the first variable Y in sequence. Here, it is assumed that the values ​​of the first variable X and the first variable Y in the first storage space are both 0.

[0136] The following section uses the values ​​of X and A in the second storage space as examples to illustrate the process by which the processor determines that the backup data in the second storage space is incorrect.

[0137] If the value of the first variable X in the first backup data in the second storage space is 1, it means that the processor had already modified the value of the first variable X in the first storage space to 1 before backing up the value of the first variable X. Therefore, before backing up the value of the second variable A, the processor may have already modified the value of the second variable A in the first storage space to 5. Thus, the processor determines that the backup data in the second storage space is incorrect.

[0138] It should be noted that in the second storage space, if the value of the first variable is the value of the first variable after the execution of the first program segment, it can be determined that the processor had already executed the operation in the first program segment that modified the value of the first variable before backing up the value of the first variable. It can be determined with a high probability, but not entirely, that the processor may have already executed the operation in the first program segment that modified the value of the second variable corresponding to the value of the first variable before backing up the value of the second variable corresponding to the value of the first variable.

[0139] For example, such as Figure 9 As shown, the direction of the arrows indicates time from morning to night, and the area between the two dashed lines represents the same time period. From Figure 9As can be seen, when the processor backs up the value of the second variable C using DMA, it begins executing the operation in the first program segment that modifies the value of the first variable Z to 1. Therefore, before backing up the values ​​of the second variables A and B, the processor also executes the operations in the first program segment that modify the value of the second variable A to 5 and the value of the second variable B to 6. Thus, in the second memory space, the values ​​of the second variables A and B are correct.

[0140] Before the DMA backup of the first variable Z, the processor has already modified the value of the first variable Z in the first storage space to 1. Therefore, in the second storage space, the value of the first variable Z is also 1.

[0141] After the processor backs up the value of the first variable Z using DMA, it begins executing the operation in the first program segment that modifies the value of the second variable C to 7. Therefore, before backing up the values ​​of the second variables C and D, the processor also executes the operations in the first program segment that modify the value of the second variable C to 7 and the value of the second variable D to 8. Therefore, the values ​​of the second variables C and D in the second memory space are correct.

[0142] This shows that after the data in the first storage space is backed up, the value of the first variable Z in the backup data in the second storage space is 1, which means that the value of the first variable Z in the second storage space is incorrect. However, the values ​​of the second variable A, the second variable B, the second variable C, and the second variable D in the second storage space are all correct.

[0143] Therefore, the backup data in the second storage space is actually correct, but if the judgment is made according to the content in step 103, it will be mistakenly considered that the backup data in the second storage space is incorrect.

[0144] Based on the above analysis, it is evident that the method provided in this application has a certain degree of error in determining errors in the backup data in the second storage space, and this error gradually increases as the number of values ​​of the second variable corresponding to each value of the first variable increases. Therefore, for a certain number of values ​​of the second variable to be backed up, this application typically uses a larger number of values ​​of the first variable to reduce the number of values ​​of the second variable corresponding to each value of the first variable, thereby improving the accuracy of determining errors in the backup data in the second storage space.

[0145] For example, when the number of values ​​for the second variable to be backed up is 4, the method shown in the second example is preferred over the method shown in the first example to run the application.

[0146] In this embodiment, in existing methods for running applications, the first program segment is run after the data in the first storage space is backed up. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are serial. However, in this embodiment, the processor runs the first program segment based on the data in the first storage space. The first program segment is one of multiple program segments constituting the application and is used to modify the data in the first storage space. DMA backs up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. Therefore, the process of the processor running the first program segment does not need to be performed after the backup is completed. That is, the process of backing up the data in the first storage space and the process of the processor running the first program segment are parallel, which can reduce time overhead and improve the running efficiency of the application.

[0147] Furthermore, the data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables to be backed up. Each of the M first variables corresponds to the value of at least one of the N second variables. The backup order indicates that for each value of a first variable, before backing up the value of the first variable, the value of at least one second variable corresponding to that first variable is backed up. M and N are both positive integers. The first program segment indicates that for each value of a first variable, after modifying the value of the first variable, the value of at least one second variable corresponding to that first variable is modified. The value of each first variable after running the first program segment is known and different from its value before running the first program segment. It can be seen that the modification order indicated by the first program segment is the opposite of the backup order indicated by the backup order. Specifically, the first program segment indicates that the value of the first variable is modified first, and then the value of the second variable corresponding to the first variable is modified, while the backup order indicates that the value of the second variable corresponding to the first variable is modified first, and then the value of the first variable is modified. Therefore, if the first backup data contains the modified value of the first variable, it indicates that the processor had already modified the value of the first variable when backing it up. Thus, it is highly likely that the processor modified the value of the second variable before backing up the first variable. Therefore, the value of the second variable in the first backup data can be considered the modified value of the second variable, and the processor determines that the first backup data in the second storage space is incorrect. Based on this determination of the first backup data error, it is possible to prevent the processor from continuing to run the application using erroneous backup data in the second storage space after a power outage and restart of the computer.

[0148] Additionally, when both the first variable and the second variable have multiple possible values, for example... Figure 6As shown, the values ​​of multiple first variables can be used to segment the values ​​of multiple second variables in the first storage space, and the value of each first variable can detect at least one backup error in the value of its corresponding second variable. Therefore, the embodiments of this application can not only determine the backup data errors in the second storage space, but also narrow down the possible range of erroneous backup data in the second storage space in a more granular way.

[0149] For example, in the second example mentioned above, if the value of the first variable X in the second storage space is 1, it can be determined that the value of the second variable A or the value of the second variable B in the second storage space is incorrect; similarly, if the value of the first variable X in the second storage space is 0 and the value of the first variable Y in the second storage space is 1, it can be determined that the value of the second variable C or the value of the second variable D in the second storage space is incorrect.

[0150] Based on steps 101 to 103, the processor can determine that the second backup data in the second storage space is incorrect. After determining that the second backup data in the second storage space is incorrect, the application can be re-executed from the beginning, that is, the program segment that runs first among the multiple program segments constituting the application can be run. However, re-running the first program segment will also increase the time overhead. Therefore, this embodiment of the application adopts a fault-tolerant method for processing. This will be explained below.

[0151] As a feasible approach, such as Figure 3 As shown, after the processor determines that the first backup data in the second storage space is incorrect and the processor runs the first program segment, the method for running the application provided in this application embodiment may further include:

[0152] Step 104: The processor sets the values ​​of the M first variables in the first storage space to the values ​​of the M first variables before the execution of the first program segment.

[0153] Understandably, during the execution of the first program segment, the processor will modify the values ​​of the M first variables. Based on the foregoing explanation, assuming that the values ​​of the M first variables in the first storage space are all 0, after the processor finishes executing the first program segment, the values ​​of some or all of the M first variables will be modified to 1.

[0154] After the processor finishes running the first program segment, it will continue to run the next program segment. In this embodiment of the application, the next program segment is referred to as the second program segment.

[0155] The second program segment may also modify the values ​​of one or more of the M first variables. For example, it can modify the values ​​of one or more first variables to 2. Then, the processor can determine whether there is a first variable with a value of 2 in the second storage space. During the execution of the second program segment, the first variables in the unmodified first storage space still have a value of 1.

[0156] However, within an application, the same program segment may be executed multiple times. For example, after the processor finishes executing the second program segment, it needs to execute the first program segment a second time. Simultaneously, the DMA (Distributed Memory Access) backs up the data in the first memory space after the second program segment has run, resulting in backup data. Since some values ​​of the first variable in the first memory space are 2 and others are 1 after the second program segment, and the first program segment is used to change the value of the first variable to 1, if the processor changes the value of the first variable from 2 to 1 during the second execution of the first program segment before backing up the first variable's value, the backup data will contain a value of 1 for the first variable. Conversely, if the processor does not change the value of the first variable during the second execution of the first program segment before backing up the first variable's value, the backup data will also contain a value of 1 for the first variable.

[0157] Therefore, if the processor judges whether the backup data is correct or incorrect based solely on whether the first variable has a value of 1 in the second storage space, it will lead to a misjudgment.

[0158] Therefore, in this embodiment, step 104 resets the values ​​of the M first variables, setting the values ​​of the M first variables in the first storage space to their values ​​before the execution of the first program segment. For example, if initially the values ​​of the M first variables in the first storage space are all 0, and during the execution of step 101, some of the first variables are modified to 1, then executing step 104 will reset the values ​​of the M first variables to 0.

[0159] Based on the above explanation, when the processor needs to run the same program segment multiple times, the values ​​of the M first variables need to be reset in step 104. For example, when the second program segment is the same as the first program segment, the values ​​of the M first variables are reset in step 104 to avoid the first variables having the same value before and after running the second program segment, which would lead to the mistaken conclusion that the backup data is incorrect.

[0160] Therefore, in this embodiment of the application, step 104 is optional.

[0161] Step 105: DMA backs up the data in the first storage space based on the backup order, so as to replace the first backup data stored in the second storage space with the second backup data.

[0162] In this embodiment of the application, after determining that the second backup data in the second storage space is incorrect, the program segment that was run first among the multiple program segments is not re-run. Instead, after running the first program segment, a second backup is performed on the data in the first storage space to obtain the second backup data.

[0163] As explained above, the number of variables that the application needs to access is fixed, so the size of the first storage space is also fixed. The second storage space is used to store backup data of the variable values, so its size is also fixed. Therefore, during the secondary backup process of the data in the first storage space, the first backup data in the second storage space will be replaced with the second backup data.

[0164] Since step 101 has already described the process of backing up the data in the first storage space, step 105 can be understood by referring to the relevant description of step 101.

[0165] Step 106: The processor runs a second program segment based on the data in the first storage space. The second program segment is a program segment that runs after the first program segment in the execution order among multiple program segments, and is used to modify the data in the first storage space. The first program segment indicates the value of each first variable. After modifying the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is modified.

[0166] As described above, there is a certain execution order among the multiple program segments of the application, which can indicate the program segment that runs after the first program segment, namely the second program segment in this embodiment. The execution order can be preset.

[0167] It should be noted that the process of running the second program segment is the same as the process of running the first program segment. For details, please refer to the relevant instructions in step 102 to understand step 106.

[0168] There is no specific order in which steps 105 and 106 are executed.

[0169] Step 107: Based on the fact that the second backup data in the second storage space does not include the value of any of the M first variables after running the second program segment, the processor determines that the second backup data in the second storage space is correct.

[0170] Based on the relevant explanation in step 103, if the values ​​of the M first variables in the second storage space are all the values ​​of the M first variables before running the second program segment, that is, the second backup data does not include the values ​​of any of the M first variables after running the second program segment, then it can be determined that the second backup data in the second storage space is correct.

[0171] For example, according to Figure 7 As shown in the first program segment, the processor sequentially modifies the values ​​of the first variable Z, the second variable A, the second variable B, the second variable C, and the second variable D to 1, 5, 6, 7, and 8; according to Figure 5 As shown in the first storage space, the DMA sequentially backs up the values ​​of the second variable A, the second variable B, the second variable C, the second variable D, and the first variable Z. Here, it is assumed that the value of the first variable Z in the first storage space is 0.

[0172] If the backup data in the second storage space includes a first variable Z with a value of 0 (i.e., not equal to 1), it means that when backing up the value of the first variable Z, the processor had not yet modified the value of the first variable Z in the first storage space to 1. Therefore, it can be determined that when backing up the value of the second variable B, the processor had not yet modified the value of the second variable B in the first storage space to 6. Similarly, it can be determined that the processor had not modified the value of the second variable A to 5, the value of the second variable C to 7, and the value of the second variable D to 8.

[0173] Therefore, since the values ​​of the first variable Z, the second variable A, the second variable B, the second variable C, and the second variable D were not modified before the backup, the processor can determine that the backup data in the second storage space is correct.

[0174] For example, according to Figure 8 As shown in the first program segment, the processor sequentially modifies the values ​​of the first variable X, the second variable A, the second variable B, the first variable Y, the second variable C, and the second variable D to 1, 5, 6, 1, 7, and 8; according to Figure 6 As shown in the backup order, the DMA backs up the values ​​of the second variable A, the second variable B, the first variable X, the second variable C, the second variable D, and the first variable Y in sequence. Here, it is assumed that the values ​​of the first variable X and the first variable Y in the first storage space are both 0.

[0175] If the value of the first variable X in the backup data in the second storage space is not 1 (let's assume it's 0), it means that when backing up the value of the first variable X, the processor had not yet modified the value of the first variable X in the first storage space to 1. Therefore, it can be determined that when backing up the value of the second variable A, the processor had not yet modified the value of the second variable A in the first storage space to 5. Similarly, it can be determined that the processor had not modified the value of the second variable B to 6.

[0176] At this point, it can be determined that the values ​​of the second variable A and the second variable B in the first storage space were not backed up incorrectly. The same method can be used to determine that the values ​​of the second variable C and the second variable D in the first storage space were also not backed up incorrectly. In this way, it can be determined that the backup data in the second storage space is correct.

[0177] In this embodiment, after determining that the first backup data in the second storage space is incorrect, the program segment that runs first among multiple program segments is not re-run. Instead, after running the first program segment, the data in the first storage space is backed up again, and the second program segment is run at the same time. This replaces the incorrect first backup data in the second storage space with the correct second backup data, thereby reducing the time overhead of running the application.

[0178] For example, according to the preset running program, the application program sequentially includes program segment aa, program segment bb, program segment cc, program segment dd, and program segment ee. After the processor finishes running program segment bb, the DMA backs up the data in the first storage space and runs program segment cc to obtain the erroneous first backup data stored in the second storage space. In this embodiment, program segment aa will not be re-executed because the first backup data is erroneous. Instead, the data in the first storage space after running program segment cc will continue to be backed up, thereby replacing the erroneous first backup data in the third storage space with the correct second backup data.

[0179] This shows that, when the computer equipment is not powered off, after determining that the first backup data in the second storage space is incorrect, instead of re-running the first running program segment aa, continuing to run program segment cc not only allows the application to run normally, but also reduces the time overhead of running the application.

[0180] It is understood that the above embodiments are mainly applied to scenarios where the computer equipment is not powered off. After determining that the second backup data in the second storage space is incorrect, the next program segment can continue to run to reduce time overhead. However, in scenarios where the computer equipment is powered off, the situation may be different. The following describes the scenario where the computer equipment is not powered off.

[0181] As a feasible approach, such as Figure 3As shown, after the processor determines that the first backup data in the second storage space is incorrect, the method for running the application provided in this application embodiment further includes:

[0182] Step 108: After the computer device is powered off and restarted, based on the first backup data containing errors stored in the second storage space, the processor executes the third program segment, which is the program segment that runs first in the execution order among multiple program segments.

[0183] It is understandable that if the DMA performs another backup of the data in the first storage space after executing the first program segment, the first backup data in the second storage space will be replaced. Therefore, the computer device can be restarted after executing step 101 and before the DMA performs a backup of the data in the first storage space after executing the first program segment. At this time, the first backup data is stored in the second storage space.

[0184] For example, after step 101 is completed, but step 102 is in progress, that is, the data in the first storage space has been backed up and the first backup data in the second storage space has been obtained, and the first program segment is still running, if the computer device is powered off and restarted at this time, the processor can run the third program segment.

[0185] It should be noted that since the third program segment is the first program segment to run in the execution order among multiple program segments, the values ​​of the variables required to run the third program segment (which can also be considered as the initial values ​​of the application program's variables) can be obtained from the executable file of the third program segment. This executable file can be stored in the non-volatile memory of the computer device, and this non-volatile memory can be the same as the non-volatile memory where the second storage space is located.

[0186] Specifically, after the computer device is powered off and restarted, the second storage space contains erroneous first backup data, so the processor cannot continue to execute the next program segment of the first program segment based on the erroneous first backup data; in this embodiment of the application, the processor executes the program segment that runs first in the execution order among multiple program segments, namely the third program segment.

[0187] For example, according to the preset running program, the application program sequentially includes program segment aa, program segment bb, program segment cc, program segment dd, and program segment ee. After the processor finishes running program segment bb, the DMA backs up the data in the first storage space, obtaining the erroneous first backup data stored in the second storage space. While backing up the data in the first storage space, the processor runs program segment cc. During the running of program segment cc, the computer device loses power. After the computer device restarts from power failure, because the first backup data in the second storage space is erroneous, the processor will run aa again.

[0188] In this embodiment, after the computer device is powered off and restarted, the processor executes a third program segment based on the first backup data stored in the second storage space that contains errors. This can prevent the processor from running the next program segment of the first program segment based on the erroneous first backup data, thereby avoiding errors in running the application.

[0189] Based on the above explanation, if the first backup data is incorrect and the computer is powered off and restarted, the processor can execute the first running third program segment. If the computer is not powered off and restarted, the processor can continue with the next program segment after the first program segment (i.e., the second program segment) and perform another backup of the data in the first storage space to overwrite the incorrect first backup data. In addition, there is also the case where the first backup data is correct; this will be explained below.

[0190] As a feasible approach, such as Figure 3 As shown, the method for running an application provided in this application embodiment further includes:

[0191] Step 109: Based on the fact that the first backup data in the second storage space does not include the value of any of the M first variables after running the first program segment, the processor determines that the first backup data in the second storage space is correct.

[0192] Based on the relevant explanation of step 107, if the values ​​of the M first variables in the second storage space are all the values ​​before the first program segment is run, that is, the first backup data does not include the values ​​of any of the M first variables after the first program segment is run, then it can be determined that the first backup data in the second storage space is correct.

[0193] It is understandable that in the aforementioned embodiments, assuming that the processor has already run a large number of program segments before running the first program segment, if the second storage space contains erroneous first backup data after the computer device is powered off and restarted, the processor will run the third program segment from the starting point, which will undoubtedly increase the time overhead significantly.

[0194] The following describes a method to avoid the above situation.

[0195] Specifically, as a feasible approach, such as Figure 3 As shown, after the processor determines that the first backup data in the second storage space is correct, the method for running the application provided in this embodiment further includes:

[0196] Step 110: The DMA backs up the correct first backup data in the second storage space to the third storage space, which is also located in non-volatile memory.

[0197] like Figure 2 As shown, in a computer device, there is also a third storage space, which is also located in non-volatile memory; specifically, the third storage space and the second storage space can be located in the same non-volatile memory, but the second storage space and the third storage space have different storage addresses, or the third storage space and the second storage space can be located in different non-volatile memories.

[0198] The process of backing up the correct first backup data to the third storage space is the same as the process of backing up the data in the first storage space to the second storage space, and will not be described in detail in this embodiment. As can be seen from the foregoing description, the correspondence between the first backup data and the first program segment can be stored in the second storage space. Therefore, in the process of backing up the first backup data to the third storage space, the correspondence between the first backup data and the first program segment can also be backed up to the third storage space.

[0199] It should be noted that although the correct first backup data is stored in the second storage space located in non-volatile memory, the correct first backup data in the second storage space will be replaced during the next backup of the data in the first storage space. Moreover, the correct first backup data in the second storage space may be replaced with incorrect backup data.

[0200] Therefore, in this embodiment, the correct first backup data in the second storage space is backed up again. This way, even if the correct first backup data in the second storage space is replaced with incorrect backup data, the processor can still obtain the correct first backup data from the third storage space. Thus, in the event of a power outage, after the computer restarts, to reduce time overhead, the processor can re-run the first program segment based on the correct first backup data in the third storage space, instead of running the third program segment, which was the first program segment to run among multiple program segments.

[0201] Specifically, as a feasible approach, such as Figure 3 As shown, after the DMA backs up the correct first backup data from the second storage space to the third storage space, the method for running the application provided in this application embodiment further includes:

[0202] Step 111: After the computer device is powered off and restarted, based on the fact that the third backup data stored in the second storage space contains erroneous data and the first backup data stored in the third storage space contains correct data, the processor runs the first program segment based on the first backup data in the third storage space.

[0203] The third backup data can be obtained after running the first program segment, or after running at least one program segment after running the first program segment. For example, if the application includes program segments aa, bb, cc, dd, and ee, and the first backup data is obtained after running program segment aa, then the third backup data can be obtained after running program segment bb, or after running program segments cc, dd, or ee.

[0204] As explained above, the correspondence between the first backup data and the first program segment can also be backed up in the third storage space. Therefore, the processor can determine the first program segment based on the first backup data in the third storage space and the correspondence between the first backup data and the first program segment, and then run the first program segment. Specifically, the processor running the first program segment based on the first backup data in the third storage space may include: first copying the first backup data from the third storage space to the first storage space, and then running the first program segment based on the first backup data in the first storage space.

[0205] After backing up the correct first backup data to the third storage space, if the computer device is powered off and restarted, the computer device does not need to rerun the first program segment that runs among the multiple program segments that make up the application. Instead, it can rerun the first program segment based on the first backup data in the third storage space, thereby reducing time overhead.

[0206] The above process will be illustrated with a specific example below.

[0207] like Figure 10 As shown, the application program includes program segments aa, bb, cc, dd, and ee, with DMA respectively located in... Figure 10 The data in the first storage space was backed up at 5 backup points. Backup point 1 was before running program segment aa, backup point 2 was after running program segment aa, backup point 3 was after running program segment bb, backup point 4 was after running program segment cc, and backup point 5 was after running program segment dd.

[0208] At backup point 4, DMA backs up the data in the first storage space and obtains the correct first backup data stored in the second storage space. Then, DMA will back up the first backup data to the third storage space.

[0209] At backup point 5, DMA backs up the data in the first storage space and obtains the incorrect third backup data stored in the second storage space. That is, the correct first backup data in the second storage space is replaced with the incorrect third backup data. However, since the third backup data is incorrect, it will not be backed up to the third storage space. That is, the correct first backup data is still stored in the third storage space.

[0210] If the computer loses power while the processor is executing program segment ee, after the computer restarts, it does not need to return to backup point 1 to re-execute program segment aa. Instead, it can return to backup point 4, that is, re-execute program segment dd based on the correct first backup data in the third storage space. This demonstrates that, in this example, the time overhead of running program segments aa, bb, and cc is reduced.

[0211] Based on the relevant descriptions of steps 101 to 111, it can be understood that in this embodiment of the application, a first storage space, a second storage space, and a third storage space can be allocated in a computer device.

[0212] The first storage space is used to store the values ​​of variables required for the program segment. During the execution of the program segment, the processor can directly read the required values ​​of variables from the first storage space, or write the values ​​of variables in the first storage space.

[0213] The second storage space is used to store backup data from the first storage space. That is, after each program segment is executed, the DMA backs up the data from the first storage space to the second storage space. Therefore, the second storage space always stores backup data from the processor's most recent execution of a program segment. This backup data may be incorrect or correct.

[0214] The third storage space is also used to store backup data from the first storage space. However, unlike the first storage space, the third storage space only stores the correct backup data. That is, DMA will only copy the correct backup data from the second storage space to the third storage space.

[0215] Please see Figure 11 , Figure 11 This is a schematic diagram of an apparatus for running an application according to an embodiment of this application. Figure 11 As shown, this application provides an embodiment of an apparatus for running an application, applied to a computer device, the apparatus comprising:

[0216] Processing unit 201 runs a first program segment based on data in a first storage space. The first program segment is one of a plurality of program segments constituting an application program and is used to modify data in the first storage space. The data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables. The value of each of the M first variables corresponds to the value of at least one of the N second variables. The first program segment indicates that for each value of a first variable, after modifying the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is modified. The value of each first variable after running the first program segment is known and different from the value before running the first program segment. M and N are both positive integers.

[0217] The data backup unit 202 is used to back up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. The backup order indicates that for each value of the first variable, before backing up the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is backed up. The second storage space is located in non-volatile memory.

[0218] Processing unit 201 is used to determine that the first backup data in the second storage space is incorrect based on the value of at least one of the M first variables after running the first program segment.

[0219] As one implementation, the data backup unit 202 is also used for DMA to back up the data in the first storage space based on the backup order, so as to replace the first backup data in the second storage space with the second backup data;

[0220] The processing unit 201 is further configured to run a second program segment based on the data in the first storage space. The second program segment is a program segment that runs after the first program segment in the order of execution among multiple program segments. It is also configured to modify the data in the first storage space. The first program segment indicates the value of each first variable. After modifying the value of the first variable, it modifies the value of at least one second variable corresponding to the value of the first variable.

[0221] Processing unit 201 is further configured to determine that the second backup data in the second storage space is correct based on the fact that the second backup data in the second storage space does not include the value of any of the M first variables after running the second program segment.

[0222] As one implementation, the processing unit 201 is also used to set the values ​​of the M first variables in the first storage space to the values ​​of the M first variables before running the first program segment.

[0223] In one implementation, the processing unit 201 is also used to execute a third program segment based on the first backup data containing errors stored in the second storage space after the computer device is powered off and restarted. The third program segment is the program segment that runs first in the execution order among multiple program segments.

[0224] As one implementation, the processing unit 201 is also used to determine that the first backup data in the second storage space is correct based on the fact that the first backup data in the second storage space does not include the value of any of the M first variables after running the first program segment.

[0225] As one implementation, the data backup unit 202 is also used to back up the correct first backup data in the second storage space to the third storage space, which is also located in non-volatile memory.

[0226] In one implementation, the processing unit 201 is also used to run a first program segment based on the first backup data in the third storage space after the computer device is powered off and restarted, based on the fact that the third backup data in the second storage space contains erroneous data and the third storage space contains correct data.

[0227] As one implementation, the first storage space is located in volatile memory.

[0228] For details regarding the implementation, related explanations, and technical effects of each of the above units, please refer to the embodiments of this application. Figure 3 Description of the various embodiments shown.

[0229] Please refer to Figure 12 , Figure 12 This is a schematic diagram of the structure of a terminal 200 provided in an embodiment of this application.

[0230] like Figure 12 As shown, terminal 200 may include processor 210, external memory interface 220, internal memory 221, universal serial bus (USB) interface 230, energy harvesting module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, sensor module 270, DMA 280, etc. Among them, sensor module 270 may include pressure sensor, gyroscope sensor, barometric pressure sensor, magnetic sensor, accelerometer, distance sensor, proximity sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, bone conduction sensor, etc.

[0231] It is understood that the structure illustrated in the embodiments of this application does not constitute a specific limitation on the terminal 200. In other embodiments of this application, the terminal 200 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0232] A pressure sensor detects pressure signals and converts them into electrical signals. A gyroscope sensor is used to determine the motion attitude of the terminal 200. A barometric pressure sensor measures air pressure.

[0233] The accelerometer can detect the magnitude of acceleration of the terminal 200 in various directions (including three-axis or six-axis). When the terminal 200 is stationary, the magnitude and direction of gravity can be detected.

[0234] Distance sensor, used to measure distance.

[0235] An ambient light sensor is used to detect the brightness of ambient light.

[0236] A fingerprint sensor is used to collect fingerprints.

[0237] Temperature sensors are used to detect temperature.

[0238] Processor 210 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0239] The controller can serve as the central nervous system and command center of the terminal 200. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0240] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0241] In some embodiments, the processor 210 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I1C) interface, an inter-integrated circuit sound (I1S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0242] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the terminal 200. In other embodiments of this application, the terminal 200 may also adopt different interface connection methods or a combination of multiple interface connection methods as described in the above embodiments.

[0243] The energy harvesting module 240 is used to obtain energy input from the operating environment, such as light energy, radio frequency, pressure or heat energy, and convert this energy into electrical energy and store it in the battery 242.

[0244] The power management module 241 is used to connect the battery 242, the energy harvesting module 240, and the processor 210. The power management module 241 receives input from the battery 242 and / or the energy harvesting module 240 to power the processor 210, internal memory 221, external memory, and wireless communication module 260, etc.

[0245] The wireless communication function of terminal 200 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor and baseband processor, etc.

[0246] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal 200 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.

[0247] The mobile communication module 250 can provide solutions for wireless communication applications including 1G / 3G / 4G / 5G on the terminal 200. The mobile communication module 250 may include at least one filter, switch, power amplifier, low-noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 2. In some embodiments, at least some functional modules of the mobile communication module 250 may be housed in the processor 210. In some embodiments, at least some functional modules of the mobile communication module 250 and at least some modules of the processor 210 may be housed in the same device.

[0248] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 270A, receiver 270B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 210 and may be housed in the same device as the mobile communication module 250 or other functional modules.

[0249] The wireless communication module 260 can provide solutions for wireless communication applications on the terminal 200, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via antenna 1, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 210. The wireless communication module 260 can also receive signals to be transmitted from processor 210, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0250] In some embodiments, antenna 1 of terminal 200 is coupled to mobile communication module 250, and antenna 2 is coupled to wireless communication module 260, enabling terminal 200 to communicate with networks and other devices via 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), Wideband 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 technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0251] The external storage interface 220 can be used to connect an external storage card, such as a Micro SD card, to expand the storage capacity of the terminal 200. The external storage card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, music, video, and other files can be saved on the external storage card.

[0252] Internal memory 221 can be used to store computer executable program code, which includes instructions. Processor 210 executes various functional applications and data processing of terminal 200 by running the instructions stored in internal memory 221. Internal memory 221 may include volatile memory 221A and non-volatile memory 221B. Volatile memory 221A is used to store data used during program execution, and non-volatile memory 221B is used to store checksums corresponding to the data in volatile memory 221A and to back up the data in volatile memory 221A.

[0253] A complete DMA process mainly includes the following steps.

[0254] (1) DMA request

[0255] The processor initializes the DMA and sends operation commands to the I / O interface, which then sends a DMA request to the DMA. Upon receiving the request, the DMA sends a request to the processor and adds a request signal to the processor's hold request input.

[0256] (2) DMA response

[0257] After receiving the request, the processor responds to the DMA by adding its response signal to the DMA's hold-acknowledge (HLDA) response output. At the same time, it pre-sets the starting address of the memory space to be accessed, the number of data to be exchanged, and the read / write commands to the DMC, and relinquishes control of the system bus. At this point, the DMA gains control of the system bus.

[0258] (3) DMA transfer

[0259] Once the DMA gains control of the system bus, the processor is immediately suspended or only performs internal operations, with the DMA manipulating the data within the processor.

[0260] (4) DMA ends

[0261] Once the DMA has completed its operations on the data inside the processor, it releases control of the bus and sends a termination signal to the I / O interface.

[0262] This application also provides a chip including one or more processors. Some or all of the processors are used to read and execute computer programs stored in memory to perform... Figure 3 The methods of the corresponding embodiments.

[0263] Optionally, the chip includes a memory, which is connected to the processor via a circuit or wire. Further optionally, the chip also includes a communication interface, to which the processor is connected. The communication interface is used to receive data and / or information that needs 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 can be an input / output interface.

[0264] In some implementations, some of the processors may implement some steps of the above method through dedicated hardware. For example, the processing of neural network models may be implemented by a dedicated neural network processor or graphics processor.

[0265] The method provided in this application embodiment can be implemented by a single chip or by multiple chips working together.

[0266] This application also provides a computer storage medium for storing computer software instructions for use with the aforementioned computer device, including instructions for executing programs designed for the computer device.

[0267] The computer device can be as described above. Figure 11 The device described for running the application.

[0268] This application also provides a computer program product, which includes computer software instructions that can be loaded by a processor to implement the aforementioned features. Figure 3 The process shown is as follows.

[0269] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0270] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0271] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0272] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0273] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for running an application, characterized in that, Applied to a computer device, the computer device including a processor and direct memory access (DMA); the method includes: The processor runs a first program segment based on data in a first storage space. The first program segment is one of a plurality of program segments constituting an application program and is used to modify the data in the first storage space. The data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables. Each of the M first variables corresponds to the value of at least one of the N second variables. The first program segment indicates that for each value of the first variable, after modifying the value of the first variable, the value of the at least one second variable corresponding to the value of the first variable is modified. The value of each first variable after running the first program segment is known and different from the value before running the first program segment. M and N are both positive integers. The DMA backs up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. The backup order indicates the value of each first variable. Before backing up the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is backed up. The second storage space is located in non-volatile memory. Based on the first backup data including the value of at least one of the M first variables after running the first program segment, the processor determines that the first backup data in the second storage space is incorrect.

2. The method according to claim 1, characterized in that, After the processor determines that the first backup data in the second storage space is incorrect, and after the processor runs a first program segment based on the data in the first storage space, the method further includes: The DMA backs up the data in the first storage space based on the backup order, so as to replace the first backup data in the second storage space with the second backup data; The processor runs a second program segment based on the data in the first storage space. The second program segment is the program segment that runs after the first program segment in the execution order among the plurality of program segments, and is used to modify the data in the first storage space. The first program segment indicates the value of each first variable. After modifying the value of the first variable, it modifies the value of at least one second variable corresponding to the value of the first variable. Based on the fact that the second backup data in the second storage space does not include the value of any of the M first variables after running the second program segment, the processor determines that the second backup data in the second storage space is correct.

3. The method according to claim 2, characterized in that, After the processor determines that the first backup data in the second storage space is incorrect, and after the processor runs a first program segment based on the data in the first storage space, but before the DMA backs up the data in the first storage space based on the backup order, the method further includes: The processor sets the values ​​of the M first variables in the first storage space to the values ​​of the M first variables before running the first program segment.

4. The method according to claim 1, characterized in that, After the processor determines that the first backup data in the second storage space is incorrect, the method further includes: After the computer device is powered off and restarted, based on the first backup data stored in the second storage space which contains errors, the processor executes a third program segment, which is the program segment that runs first in the execution order among the plurality of program segments.

5. The method according to claim 1, characterized in that, The method further includes: Based on the fact that the first backup data in the second storage space does not include the value of any of the M first variables after running the first program segment, the processor determines that the first backup data in the second storage space is correct.

6. The method according to claim 5, characterized in that, After the processor determines that the first backup data in the second storage space is correct, the method further includes: The DMA backs up the correct first backup data in the second storage space to the third storage space, which is also located in non-volatile memory.

7. The method according to claim 6, characterized in that, After the DMA backs up the correct first backup data from the second storage space to the third storage space, the method further includes: After the computer device is powered off and restarted, based on the fact that the second storage space contains erroneous third backup data and the third storage space contains correct first backup data, the processor runs the first program segment based on the first backup data in the third storage space.

8. The method according to any one of claims 1 to 7, characterized in that, The first storage space is located in volatile memory.

9. An apparatus for running an application, characterized in that, Applied to computer equipment, the device includes: The processing unit executes a first program segment based on data in a first storage space. The first program segment is one of a plurality of program segments constituting an application program and is used to modify the data in the first storage space. The data in the first storage space includes the values ​​of M first variables and the values ​​of N second variables. Each of the M first variables corresponds to the value of at least one of the N second variables. The first program segment instructs that, for each value of the first variable, after modifying the value of the first variable, the value of the at least one second variable corresponding to the value of the first variable is modified. The value of each first variable after running the first program segment is known and different from the value before running the first program segment. M and N are both positive integers. A data backup unit is used to back up the data in the first storage space based on the backup order to obtain the first backup data stored in the second storage space. The backup order indicates the value of each first variable. Before backing up the value of the first variable, the value of at least one second variable corresponding to the value of the first variable is backed up. The second storage space is located in non-volatile memory. The processing unit is configured to determine that the first backup data in the second storage space is incorrect based on the value of at least one of the M first variables after running the first program segment.

10. A computer device, characterized in that, include: One or more processors and a memory; wherein the memory stores computer-readable instructions; The one or more processors read the computer-readable instructions to cause the computer device to implement the method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, Includes computer-readable instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 8.