Program execution method, program processing method and related equipment
By introducing the first jump instruction into the program of the intermittent system device and equivalent to a detection point, only the modified variables in the corresponding AEB are saved, the problem of large amount of variable storage data and low operation efficiency in the synchronization processing of multi-task concurrent, and more efficient variable storage and operation performance is achieved.
Patent Information
- Application Number
- CN202010961301.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-06-09
- Filing Date
- 2020-09-14
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2040-09-14
AI Technical Summary
In the synchronization processing of multi-task concurrent, intermittent system devices need to save all variables that may be modified, resulting in large amount of data and low operational efficiency.
By introducing a first jump instruction in the program, it is equivalent to a detection point, and only the variables modified in the corresponding AEB are saved before the first jump instruction, thereby reducing the amount of variable data to be saved.
It effectively reduces the amount of variable data that intermittent system equipment needs to save, improves the operating efficiency of the equipment, and solves the problem of repeated AEB execution caused by multiple rollbacks in cascading rollback technology.
Smart Images

Figure CN113778742B_ABST
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on June 9, 2020, with application number 202010526406.9 and invention name “A Synchronous Multi-Tasking Concurrent Intermittent System and Computer Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of multi-task concurrent intermittent systems, and in particular to a program execution method, a program processing method and related equipment. Background Art
[0003] Intermittent system devices are usually powered by collecting energy from the environment, including solar energy, wind energy, thermal energy, radio frequency energy, etc., so there is no need to connect to the power supply all the time, and there is no need to replace or charge the battery. Therefore, intermittent system devices can be used in a wider range of scenarios. However, the environment in which intermittent system devices are located may be very unstable, and the energy collected by the device cannot keep the device running continuously, and the device will frequently lose power.
[0004] In order to promote the execution of the program, the intermittent system device inserts a checkpoint in the program. When the program runs to the checkpoint, the device saves the variables to ensure that the device can continue to execute from the last recorded checkpoint after restart until the program is completed. The following example illustrates the amount of data that the intermittent system device needs to save for variables. In a program, three checkpoints are arranged in succession, namely, checkpoint 1, checkpoint 2, and checkpoint 3. The device executes the program in sequence. When the program runs to checkpoint 2, the device needs to save all the variables that have been modified during the execution from checkpoint 1 to checkpoint 2. When the intermittent system device is applied to the synchronous processing of multi-task concurrency, the synchronous processing enables different programs in the device to run collaboratively and execute alternately. The intermittent system device inserts a checkpoint under the coordination of multiple programs. In the case of such a collaborative checkpoint, the device cannot determine which variables are modified at checkpoint 2, that is, it is not enough for the device to only save the above variables. In order to ensure that the system can return to checkpoint 2 and run normally after restart, the system saves the variables that may be modified by all concurrent programs.
[0005] In the synchronous processing of multi-tasking concurrency, different programs can be executed alternately, so that all variables that may be modified are often all variables of the entire intermittent system equipment, which greatly increases the amount of data saved when saving variables and reduces the operating efficiency of the equipment. Summary of the invention
[0006] The present application provides a program execution method and related equipment, which can reduce the amount of variable data that needs to be saved by intermittent system equipment, thereby improving the operating efficiency of the equipment. In a first aspect, the present application provides a program execution method.
[0007] The method includes: an intermittent system device acquires a first program, the first program includes one or more atomic execution blocks (AEBs), the one or more AEBs include a first target AEB, the first target AEB includes a first jump instruction, the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, the second target AEB is before the first jump instruction, the third target AEB is after the first jump instruction, and the first jump instruction is used to indicate a jump from the first program to the second program. After the second target AEB is executed by the intermittent system device, before executing the first jump instruction, the intermittent system device saves the modified variables in the second target AEB. If the first jump instruction is executed by the intermittent system device, the intermittent system device jumps from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0008] It can be seen that the method proposed in the present application equates the first jump instruction to a detection point. In other words, the operation of saving variables is also performed at the first jump instruction.
[0009] It should be noted that making the first jump instruction equivalent to a detection point does not mean replacing the first jump instruction with a detection point to cancel the first jump instruction, because the original jump relationship of the program cannot be changed due to this application. The first jump instruction equivalent to a detection point mentioned in this application can be achieved in any of the following ways: 1. The intermittent system device uses the first jump instruction as an interface of a subroutine, saves the modified variables in the second target AEB by calling the subroutine, and executes the jump after saving the variables; 2. The intermittent system device or the first device adds the code for implementing the detection point before the first jump instruction (for example, the attached Figure 6 b). The so-called first jump instruction that divides the first target AEB into the second target AEB and the third target AEB can be considered as the first jump instruction being equivalent to a detection point, and the detection point divides the first target AEB into the second target AEB and the third target AEB.
[0010] Since the gap system device saves the modified variables in the second target AEB when executing the first node code or the first jump instruction in the first target AEB, the first target AEB is substantially divided into two AEBs. Figure 6 The AEB2 in the first program can be understood as the two AEBs in the first program, and the two AEBs are the second target AEB ( Figure 6 The second target AEB604) and the third target AEB ( Figure 6The second target AEB606 in the intermittent system is before the first jump instruction, and the third target AEB is after the first jump instruction. At this time, the intermittent system device equates the first jump instruction or the first node code to a detection point. Since the second target AEB does not include a jump instruction, the intermittent system device can determine the variables that have been modified in the second target AEB at the detection point. And since the third target AEB does not include a jump instruction, after the intermittent system device executes the third target AEB, the intermittent system device can determine the variables that have been modified in the third target AEB. Therefore, the variables modified by each AEB in the first target AEB are determined, so that after the intermittent system device executes the second target AEB, it can only save the variables modified in the second target AEB; after the intermittent system device executes the third target AEB, it can only save the variables modified in the third target AEB. The variables saved by the two AEBs are the variables modified in the first target AEB. Compared with the need to save all the variables of the entire intermittent system device in the collaborative detection point technology, the program execution method in the present application can reduce the amount of data of the variables that the intermittent system device needs to save, thereby improving the operation efficiency of the device.
[0011] Based on the first aspect of the present application, in a first implementation of the first aspect of the present application, after the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the method further includes: the intermittent system saves the modified variables in the third target AEB, the modified variables in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB. The second AEB and the first target AEB are different AEBs in the first program, and the first AEB is an AEB in the second program. For example, Figure 8For example, the first target AEB is AEB2, the second AEB is AEB3, and the first AEB is the AEB between detection point 5 and detection point 6. Since the intermittent system device will save the variables modified in the second target AEB when executing the first node code or the first jump instruction in the first target AEB, the first target AEB is substantially divided into two AEBs. Therefore, the first target AEB and the first AEB and the second AEB are named differently. In the present application, the variable modified in the second target AEB is not saved, which means that the action of saving the variable is not executed in the above time period, and the action of saving the variable can be executed in other time periods. The above time period refers to the time between the first jump instruction and the next detection point after the intermittent system device executes the third target AEB. The above time period can also be understood as the time between the first jump instruction and the next detection point. In the cascade rollback technology and the background technology, the variables that need to be saved at least at this detection point are the variables to be modified in the first target AEB. The present application reduces the amount of data that needs to be saved by the intermittent system device and improves the operating efficiency of the device by not saving the variables modified in the second target AEB.
[0012] Based on the first implementation of the first aspect of the present application, in the second implementation of the first aspect of the present application, the intermittent system device obtains a third program, the third program includes the first program, and the third program includes a first node code before the first jump instruction and after the second target AEB. The intermittent system device saves the modified variables in the second target AEB by executing the first node code. Among them, adding the first node code can be understood as a preprocessing process for the first program. The first node code is specifically used to save the modified variables in the second target AEB. By preprocessing the first program before executing the first program, the operating efficiency of the third program in the intermittent system device is improved.
[0013] Based on the second implementation of the first aspect of the present application, in the third implementation of the first aspect of the present application, the first node code is added according to the position of the first jump instruction after the first device determines the first jump instruction, and the position of the first node code may be before the first jump instruction and after the second target AEB. The first device is not an intermittent system device, and the intermittent system device receives the third program sent by the first device. Among them, the power supply and data processing capabilities of the intermittent system device are generally limited. By completing the preprocessing process by the first device, the workload of the intermittent system device can be reduced and the operating efficiency of the intermittent system device can be improved.
[0014] Based on the first aspect of the present application, or any one of the first to third embodiments of the first aspect, in the fourth embodiment of the first aspect of the present application, the first program includes a target identifier. If the target identifier is detected, the intermittent system device determines that the first program meets the requirements of the intermittent system device for the first program, and the requirements of the intermittent system device for the first program are that a node code is added before each jump instruction in the first program, each jump instruction includes a first jump instruction, and the node code includes a first node code. Among them, the first program in this embodiment is a preprocessed first program, which can also be referred to as a third program. When the intermittent system device runs a jump instruction, the intermittent system device jumps from the first program to other programs. The present application defines that the first device adds a node code before each jump instruction in the first program. It should be noted that if a node code is already included before a jump instruction in the first program, the first device may not need to add a node code before the jump instruction. If the intermittent system device executes the first program that has not been preprocessed, errors may occur in the operation of the intermittent system device. By adding a target identifier to the preprocessed first program, the intermittent system device can reversely determine that the program without the target identifier is a program that has not been preprocessed, thereby reducing errors in the operation of the intermittent system device.
[0015] Based on the fourth implementation of the first aspect of the present application, in the fifth implementation of the first aspect of the present application, if the first program does not meet the requirements of the intermittent system device for the first program, the intermittent system device displays a prompt message. Among them, the first program does not meet the requirements of the intermittent system device for the first program means that the intermittent system device does not detect the target identifier. If the first program does not meet the requirements of the intermittent system device for the first program, an error will occur when the intermittent system device runs the first program. If the intermittent system does not display a prompt message, the debugger or user may not be able to find that the first program cannot run. However, intermittent system devices generally cannot be connected to the network via wired or even wireless connections. In an installation or data update, if the configuration of the first program cannot be completed, subsequent reconfiguration will cause greater losses. Therefore, the intermittent system displays a prompt message to prompt the user to pre-process the first program and reduce configuration costs.
[0016] Based on the first aspect of the present application, or any one of the first to fifth embodiments of the first aspect, in a sixth embodiment of the first aspect of the present application, the method further includes: the intermittent system device acquires a second program, the second program includes one or more AEBs, the one or more AEBs include a fourth target AEB, the fourth target AEB includes a second jump instruction, the second jump instruction divides the fourth target AEB into a fifth target AEB and a sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and the second jump instruction is used to indicate a jump from the second program to the first program. After the fifth target AEB is executed by the intermittent system device, before executing the second jump instruction, the intermittent system device saves the modified variables in the fifth target AEB; if the second jump instruction is executed by the intermittent system device, the operation of the intermittent system device jumps from the fifth target AEB of the second program to the third target AEB of the first program. Among them, even if the second jump instruction jumps back to the third target AEB of the first program, after the intermittent system device executes the third target AEB, the variables modified in the third target AEB can also be determined, that is, the variables that need to be saved at the next detection point of the third target AEB will not include the variables modified in the fifth target AEB, and the variables modified in the third target AEB and the variables modified in the fifth target AEB are independent of each other. Therefore, not only can the amount of data that the intermittent system device needs to save in the first program and the second program be reduced, but also the stability of the intermittent system device can be improved.
[0017] A second aspect of the present application provides a method for processing a program, wherein the program runs on a gap system device.
[0018] The method includes: a first device acquires a first program. The first device determines a first jump instruction in the first program so that after the second target AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved. The first device may be an intermittent system device or may not be an intermittent system device. When the first device is not the intermittent system device, the first device may add a node code or an identifier before the first jump instruction after determining the first jump instruction in the first program. If the node code is added, the intermittent system device may save the modified variables in the second target AEB according to the node code after the second target AEB is executed by the intermittent system device; if the identifier is added, the intermittent system device may add a node code at the identifier, and the intermittent system device may save the modified variables in the second target AEB according to the node code. When the first device is the intermittent system device, the first device may add a node code before the first jump instruction or use the first jump instruction as a program interface for jumping to the node code, so that after the first device executes the second target AEB, the node code is first executed, and then the action of jumping to the second program is executed. The variable modified in the second target AEB refers to the corresponding variable modified according to the instruction in the second target AEB during the process of the intermittent system device executing the second target AEB, and the variable is the modified variable. The first jump instruction is in the middle of the first target AEB, dividing the first target AEB into the second target AEB and the third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction. The first program includes one or more AEBs, and the one or more AEBs include the first target AEB. After the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0019] Among them, the intermittent system device equates the first jump instruction or the first node code to a detection point. Since the second target AEB does not include a jump instruction, the intermittent system device can determine the variables that have been modified in the second target AEB at the detection point. And since the third target AEB does not include a jump instruction, after the intermittent system device executes the third target AEB, the intermittent system device can determine the variables that have been modified in the third target AEB. Therefore, the variables modified by each AEB in the first target AEB are determined, so that after the intermittent system device executes the second target AEB, it can only save the variables modified in the second target AEB; after the intermittent system device executes the third target AEB, it can only save the variables modified in the third target AEB. The variables saved by the two AEBs in total are the variables modified in the first target AEB. Compared with the need to save all the variables of the entire intermittent system device in the collaborative detection point technology, the program execution method in the present application can reduce the amount of data of the variables that the intermittent system device needs to save, thereby improving the operating efficiency of the device.
[0020] Based on the second aspect of the present application, in a first implementation of the second aspect of the present application, after the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the variables modified in the third target AEB are saved, and the variables modified in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB. Among them, the variables modified in the second target AEB are not saved, which means that within the above time period, the action of saving the variable is not performed, and within other time periods, the action of saving the variable can be performed. The above time period refers to after the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB. In the cascade rollback technology and the background technology, the variables that need to be saved at least at this detection point are the variables modified in the first target AEB. The present application reduces the amount of data that needs to be saved by the intermittent system device and improves the operating efficiency of the device by not saving the variables modified in the second target AEB.
[0021] Based on the first implementation of the second aspect of the present application, in the second implementation of the second aspect of the present application, after the first device determines the first jump instruction in the first program, the method further includes: the first device adds a first node code before the first jump instruction of the first program and after the second target AEB to generate a third program, and the first node code is used to be executed by the intermittent system device to save the modified variables in the second target AEB. Among them, adding the first node code can be understood as a preprocessing process for the first program. The first node code is specifically used to save the modified variables in the second target AEB. By preprocessing the first program before executing the first program, the operating efficiency of the third program in the intermittent system device is improved.
[0022] Based on the second implementation of the second aspect of the present application, in the third implementation of the second aspect of the present application, after generating the third program, the method further includes: the first device sends the third program to the intermittent system device. Among them, the present application defines that the first device is not an intermittent system device. The power supply and data processing capabilities of intermittent system devices generally have limitations. By completing the preprocessing process by the first device, the workload of the intermittent system device can be reduced and the operating efficiency of the intermittent system device can be improved.
[0023] Based on the second aspect of the present application, or any one of the first to third embodiments of the second aspect, in the fourth embodiment of the second aspect of the present application, after the first device determines the first jump instruction in the first program, the method further includes: the first device adds a target identifier in the first program, and the target identifier is used to be detected by the intermittent system device, so that the intermittent system device determines that the first program meets the requirements of the intermittent system device for the first program, and the requirements of the intermittent system device for the first program are that a node code is added before each jump instruction in the first program, each jump instruction includes a first jump instruction, and the node code includes a first node code. Wherein, when the intermittent system device runs the jump instruction, the intermittent system device jumps from the first program to other programs. The present application defines that the first device adds a node code before each jump instruction in the first program. It should be noted that if a node code is already included before a jump instruction in the first program, the first device may not need to add a node code before the jump instruction. If the intermittent system device executes the first program without preprocessing, the operation of the intermittent system device will be wrong. By adding a target identifier to the preprocessed first program, the intermittent system device can reversely determine that the program without the target identifier is a program that has not been preprocessed, thereby reducing errors in the operation of the intermittent system device.
[0024] Based on the second aspect of the present application, or any one of the first to fourth embodiments of the second aspect, in the fifth embodiment of the first aspect of the present application, the method further comprises: the first device determines a second jump instruction in the second program, so that after the fifth target AEB is executed by the intermittent system device, before the second jump instruction is executed, the modified variables in the fifth target AEB are saved, the second jump instruction is in the middle of the fourth target AEB, the fourth target AEB is divided into the fifth target AEB and the sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and after the second jump instruction is executed, the intermittent system can jump from the fifth target AEB of the second program to the third target AEB of the first program. Among them, even if the second jump instruction jumps back to the third target AEB of the first program, after the intermittent system device executes the third target AEB, the modified variables in the third target AEB can also be determined, that is, the variables that need to be saved at the next detection point of the third target AEB will not include the modified variables in the fifth target AEB, and the modified variables in the third target AEB and the modified variables in the fifth target AEB are independent of each other. Therefore, not only can the amount of data that needs to be saved in the intermittent system device for the first program and the second program be reduced, but the stability of the intermittent system device can also be improved.
[0025] The third aspect of the present application provides a device for executing a program. The device includes: an acquisition module, which is used to acquire a first program, the first program includes one or more atomic execution modules AEB, the one or more AEBs include a first target AEB, the first target AEB includes a first jump instruction, the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, the second target AEB is before the first jump instruction, the third target AEB is after the first jump instruction, and the first jump instruction is used to indicate jumping from the first program to the second program; a saving module, which is used to save the modified variables in the second target AEB after the second target AEB is executed by the device and before the first jump instruction is executed; a jump module, which is used to jump from the first program to the first AEB of the second program if the first jump instruction is executed by the device, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0026] Based on the third aspect of the present application, in a first implementation of the third aspect of the present application, after the device executes the third target AEB and before the device executes the second AEB of the first program, the saving module is also used to save the modified variables in the third target AEB, and the modified variables in the second target AEB are not saved, and the second AEB is the first AEB after the first target AEB.
[0027] Based on the first implementation manner of the third aspect of the present application, in the second implementation manner of the third aspect of the present application, the acquisition module is specifically used to acquire a third program, the third program includes the first program, and the third program includes a first node code before the first jump instruction and after the second target AEB; the saving module is specifically used to save the modified variables in the second target AEB by executing the first node code.
[0028] Based on the second implementation manner of the third aspect of the present application, in the third implementation manner of the third aspect of the present application, the first node code is added according to the position of the first jump instruction after the first device determines the first jump instruction; the acquisition module is specifically used to receive the third program sent by the first device.
[0029] Based on the third aspect of the present application, or any one of the first to third embodiments of the third aspect, in a fourth embodiment of the third aspect of the present application, the first program includes a target identifier; the device also includes: a determination module, for determining that the first program meets the requirements of the intermittent system device for the first program if the target identifier is detected, and the requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
[0030] Based on the fourth implementation of the third aspect of the present application, in the fifth implementation of the third aspect of the present application, the device further includes: a display module, which is used to display a prompt message if the third program does not meet the requirements of the device for the third program.
[0031] Based on the third aspect of the present application, or any one of the first to fifth embodiments of the third aspect, in a sixth embodiment of the third aspect of the present application, the acquisition module is also used to acquire the second program, the second program includes one or more AEBs, the one or more AEBs include the fourth target AEB, the fourth target AEB includes a second jump instruction, the second jump instruction divides the fourth target AEB into a fifth target AEB and a sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and the second jump instruction is used to indicate a jump from the second program to the first program; the saving module is also used to save the modified variables in the fifth target AEB after the fifth target AEB is executed by the device and before the second jump instruction is executed; the jump module is also used to jump from the fifth target AEB of the second program to the third target AEB of the first program if the second jump instruction is executed by the device.
[0032] For the description of the beneficial effects of the third aspect of the present application, reference may be made to the relevant description of the aforementioned first aspect.
[0033] In a fourth aspect, the present application provides a device for processing a program. The device includes: an acquisition module for acquiring a first program; a determination module for determining a first jump instruction in the first program, so that after the second target atomic execution module AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and the third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0034] Based on the fourth aspect of the present application, in a first implementation of the fourth aspect of the present application, after the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the modified variables in the third target AEB are saved, and the modified variables in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB.
[0035] Based on the first implementation of the fourth aspect of the present application, in the second implementation of the fourth aspect of the present application, the device also includes: an adding module for adding a first node code before the first jump instruction of the first program and after the second target AEB to generate a third program, and the first node code is used to be executed by the intermittent system device to save the modified variables in the second target AEB.
[0036] Based on the second implementation of the fourth aspect of the present application, in a third implementation of the fourth aspect of the present application, the device further includes:
[0037] The sending module is used to send the third program to the intermittent system device.
[0038] Based on the fourth aspect of the present application, or any one of the first to third embodiments of the fourth aspect, in the fourth embodiment of the fourth aspect of the present application, the adding module is also used to add a target identifier in the first program, and the target identifier is used to enable the intermittent system device to determine that the first program meets the requirements of the intermittent system device for the first program when it is detected by the intermittent system device, and the requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
[0039] Based on the fourth aspect of the present application, or any one of the first to fourth embodiments of the fourth aspect, in a fifth embodiment of the fourth aspect of the present application, the determination module is further used to determine a second jump instruction in the second program, so that after the fifth target AEB is executed by the intermittent system device, before the second jump instruction is executed, the modified variable in the fifth target AEB is saved, the second jump instruction is in the middle of the fourth target AEB, and the fourth target AEB is divided into the fifth target AEB and the sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and after the second jump instruction is executed, the intermittent system device can jump from the fifth target AEB of the second program to the third target AEB of the first program. The description of the beneficial effects of the fourth aspect of the present application can refer to the relevant description of the aforementioned second aspect.
[0040] In a fifth aspect, the present application provides a device for executing a program. The device includes a processor and a memory, wherein a first program and a processing program are stored in the memory, wherein the processor is used to obtain the first program from the memory, and to process the first program according to the processing program, wherein the first program includes one or more atomic execution modules AEB, wherein the one or more AEBs include a first target AEB, and the first target AEB includes a first jump instruction, wherein the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, wherein the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, and wherein the first jump instruction is used to indicate jumping from the first program to the second program; wherein the processor is specifically used to save the modified variables in the second target AEB after the second target AEB is executed by the device and before the first jump instruction is executed; wherein the processor is specifically used to jump from the first program to the first AEB of the second program if the first jump instruction is executed by the device, wherein the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0041] Based on the fifth aspect of the present application, in a first implementation of the fifth aspect of the present application, after the device executes the third target AEB and before the device executes the second AEB of the first program, the processor is specifically used to save the modified variables in the third target AEB, and the modified variables in the second target AEB are not saved, and the second AEB is the first AEB after the first target AEB.
[0042] Based on the first implementation manner of the fifth aspect of the present application, in the second implementation manner of the fifth aspect of the present application, the processor is specifically used to obtain a third program, the third program includes the first program, and the third program includes a first node code before the first jump instruction and after the second target AEB; the processor is specifically used to save the modified variables in the second target AEB by executing the first node code.
[0043] Based on the second implementation of the fifth aspect of the present application, in the third implementation of the fifth aspect of the present application, the first node code is added according to the position of the first jump instruction after the first device determines the first jump instruction; the processor is specifically used to receive the third program sent by the first device.
[0044] Based on the fifth aspect of the present application, or any one of the first to third embodiments of the fifth aspect, in the fourth embodiment of the fifth aspect of the present application, the first program includes a target identifier; the processor is specifically used to determine that the first program meets the requirements of the intermittent system device for the first program if the target identifier is detected, and the requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
[0045] Based on the fourth implementation of the fifth aspect of the present application, in the fifth implementation of the fifth aspect of the present application, the processor is specifically used to display a prompt message if the third program does not meet the requirements of the device for the third program.
[0046] Based on the fifth aspect of the present application, or any one of the first to fifth embodiments of the fifth aspect, in a sixth embodiment of the fifth aspect of the present application, the processor is specifically used to obtain the second program, the second program includes one or more AEBs, the one or more AEBs include the fourth target AEB, the fourth target AEB includes a second jump instruction, the second jump instruction divides the fourth target AEB into a fifth target AEB and a sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and the second jump instruction is used to indicate a jump from the second program to the first program; the processor is specifically used to save the modified variables in the fifth target AEB after the fifth target AEB is executed by the device and before the second jump instruction is executed; the processor is specifically used to jump from the fifth target AEB of the second program to the third target AEB of the first program if the second jump instruction is executed by the device.
[0047] In a sixth aspect, the present application provides a device for processing a program. The device includes a processor and a memory, wherein a first program and a processing program are stored in the memory, wherein the processor is used to obtain the first program from the memory and process the first program according to the processing program; the processor is specifically used to obtain the first program; the processor is specifically used to determine a first jump instruction in the first program, so that after a second target atomic execution module AEB is executed by an intermittent system device, before the first jump instruction is executed, the modified variable in the second target AEB is saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and a third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0048] Based on the sixth aspect of the present application, in a first implementation of the sixth aspect of the present application, after the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the modified variables in the third target AEB are saved, and the modified variables in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB.
[0049] Based on the first implementation of the sixth aspect of the present application, in the second implementation of the sixth aspect of the present application, the processor is specifically used to add a first node code before the first jump instruction of the first program and after the second target AEB to generate a third program, and the first node code is used to be executed by the intermittent system device to save the modified variables in the second target AEB.
[0050] Based on the second implementation of the sixth aspect of the present application, in the third implementation of the sixth aspect of the present application, the processor is specifically used to send a third program to the intermittent system device.
[0051] Based on the sixth aspect of the present application, or any one of the first to third embodiments of the sixth aspect, in the fourth embodiment of the sixth aspect of the present application, the processor is specifically used to add a target identifier in the first program, and the target identifier is used to enable the intermittent system device to determine that the first program meets the requirements of the intermittent system device for the first program when it is detected by the intermittent system device. The requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
[0052] Based on the sixth aspect of the present application, or any one of the first to fourth embodiments of the sixth aspect, in the fifth embodiment of the sixth aspect of the present application, the processor is specifically used to determine the second jump instruction in the second program, so that after the fifth target AEB is executed by the intermittent system device, before the second jump instruction is executed, the modified variable in the fifth target AEB is saved, the second jump instruction is in the middle of the fourth target AEB, and the fourth target AEB is divided into the fifth target AEB and the sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and after the second jump instruction is executed, the intermittent system device can jump from the fifth target AEB of the second program to the third target AEB of the first program. The description of the beneficial effects of the fourth aspect of the present application can refer to the relevant description of the aforementioned second aspect.
[0053] The seventh aspect of the embodiments of the present application provides a computer storage medium, in which instructions are stored. When the instructions are executed on a computer, the computer executes a method as in the first aspect or any one of the embodiments of the first aspect; or executes a method as in the second aspect or any one of the embodiments of the second aspect.
[0054] An eighth aspect of an embodiment of the present application provides a computer program product. When the computer program product is executed on a computer, when instructions are executed on the computer, the computer executes a method as in the first aspect or any one of the embodiments of the first aspect; or, executes a method as in the second aspect or any one of the embodiments of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A flow chart of the atomic execution procedure for intermittent system equipment;
[0056] Figure 2a A schematic diagram of the program execution flow for the collaborative detection point technology;
[0057] Figure 2b A schematic diagram of the program execution flow of the cascade rollback technology;
[0058] Figure 3 A flowchart of the processing procedure in the embodiment of the present application;
[0059] Figure 4 A schematic diagram of an application scenario in an embodiment of the present application;
[0060] Figure 5 A flowchart of a program processing method in an embodiment of the present application;
[0061] Figure 6 A structural diagram of the first program before and after adding the first node code in the embodiment of the present application;
[0062] Figure 7 Another structural diagram of the first program before and after adding the first node code in the embodiment of the present application;
[0063] Figure 8 A schematic diagram of a flow chart of the operation of the first program in the embodiment of the present application;
[0064] Fig. 9 A flow chart showing n applications running in an intermittent system device;
[0065] Fig.10 Another flow chart for n applications running in an intermittent system device;
[0066] Fig.11 A schematic diagram of the structure of a device for processing a program in an embodiment of the present application;
[0067] Fig.12 A schematic diagram of the structure of a device for executing a program in an embodiment of the present application;
[0068] Fig.13 It is a structural schematic diagram of the first device or gap system device in an embodiment of the present application. DETAILED DESCRIPTION
[0069] The embodiments of the present application provide a program execution method, a program processing method and related equipment, which are applied to the field of intermittent systems with multi-tasking concurrency, and can reduce the variables that need to be saved by intermittent system devices, thereby improving the operating efficiency of the devices.
[0070] With the popularization of the Internet of Things and the development of communication technology, the number of IoT devices will explode in the next decade. Therefore, how to drive such a huge number of IoT devices has become a challenge. The traditional battery-powered form is limited by the usage scenarios and environmental disadvantages, which will become a bottleneck for the development of the Internet of Things. The latest research proposes an intermittent system. The intermittent system runs in intermittent system devices. Intermittent system devices can collect energy in the environment, such as solar energy, wind energy, and thermal energy, to maintain the operation of the device. The intermittent system breaks through the limitations of batteries on IoT devices, allowing intermittent system devices to be used in a wider range of scenarios and making the energy supply method of intermittent system devices more environmentally friendly. However, the environment in which the intermittent system devices are located may be very unstable, and the energy collected by the system may not be able to keep the system running continuously, and there is a phenomenon of frequent power outages in the system.
[0071] After a traditional operating system loses power, it restarts and re-executes the required operations from the program entry point before the power outage. In intermittent system devices, in the case of frequent power outages, in order to ensure the system's advancement and implement intermittent computing technology, the following methods can be used: the intermittent system device frequently saves the system status during operation, that is, inserts detection points in the program. Since each detection point saves the necessary information for the system to continue executing, the system continues to execute from the last detection point after each power outage, rather than continuing to execute from the program entry point before the power outage. Figure 1 As shown, Figure 1 The figure is a flow chart of the atomic execution of a program in an intermittent system device. Program 1 includes detection point 1, detection point 2, detection point 3 and detection point 4. The four detection points are set in a front-to-back order. In the embodiment of the present application, the front-to-back order of the program is determined according to the execution order of the program. Figure 1As shown, program 1 first executes to detection point 1, and then executes detection point 2, so detection point 1 is before detection point 2, and detection point 2 is after detection point 1. Between detection point 1 and detection 2, program 1 includes atomic execution block (AEB) 1. Between detection point 2 and detection 3, program 1 includes AEB2. Between detection point 3 and detection 4, program 1 includes AEB3. For the convenience of description, it is assumed that AEB1 includes variable modification code: a=x1; AEB2 includes variable modification code: a=x2, b=x3; AEB3 includes variable modification code: c=x4, d=x5. The intermittent system device carries an intermittent system, and the intermittent system runs the first program 1. When running to detection point 2, the intermittent system saves the variables modified in AEB1, that is, saves a=x1; when running to detection point 3, the intermittent system saves the variables modified in AEB2, that is, saves a=x2, b=x3. And so on, until program 1 is executed. If the intermittent system device loses power at D1, the intermittent system will be restored to checkpoint 3 after restarting, and execution will continue from checkpoint 3. It should be noted that the code fragment between two checkpoints in the checkpoint technology or each TASK in the TASK-based intermittent system can be regarded as an AEB. When an application only saves the variables modified in the application at the end, it can be considered that the application includes an AEB and meets the conditions for atomic execution.
[0072] exist Figure 1 In the process, the intermittent system will not jump to other programs for execution between every two detection points, so the variables modified between each detection point and the previous detection point can be statically predicted, and other programs refer to programs other than program 1. Programs are sometimes also called tasks. For example, during the alternating execution of multiple programs, one or more of the multiple programs will not be executed in one execution process. Therefore, the alternating execution of multiple programs is also called multi-task concurrent synchronization processing. When the intermittent system device is applied to the synchronous processing of multi-task concurrency and the synchronization between programs is added, due to synchronization operations, such as access to mutually exclusive resources, high-priority programs being awakened, and so on, the executing program may jump to execute other programs at any time. Therefore, at a certain detection point in a certain program, it is difficult to determine the variables modified during the execution of the program from the detection point to the previous detection point of the program. Therefore, in order to ensure the normal operation of the system, the collaborative detection point technology needs to back up the data of the entire system at each detection point, resulting in low system operation efficiency. Such as Figure 2a As shown, Figure 2a Schematic diagram of the program execution flow of the collaborative detection point technology. Figure 2aIncluding program 1, program 2 and program 3. When the intermittent system device runs to the jump instruction 201 between detection point 2 and detection point 3, the intermittent system device will jump from program 1 to detection point 5 of program 2. When the intermittent system device runs to the jump instruction 202 between detection point 6 and detection point 7, the intermittent system device will jump from program 2 to program 3, and then jump back to program 2 through the jump instruction 203 in program 3. At detection point 3, due to the jump between programs, it is difficult for the intermittent system device to determine the variables modified outside program 1 between detection point 3 and detection point 2, such as the variables modified between detection point 5 and detection point 7 in program 2, so it can only pessimistically save all variables of all programs in the intermittent system device. Similarly, at detection point 2, since the system may also jump from program 1 to other programs during the execution of detection point 1 to detection point 2, the intermittent system device cannot determine whether there is a jump instruction between detection point 1 and detection point 2. Therefore, at detection point 2, all variables in the intermittent system also need to be saved, that is, the variables of the entire system need to be saved at each detection point.
[0073] In addition, there are multiple rollback problems in the existing cascade rollback technology, which will cause AEB to be executed repeatedly. Figure 2b As shown, Figure 2b Schematic diagram of program execution flow of cascading rollback technology. Figure 2b Including program 1 and program 2. When the intermittent system device runs to the jump instruction 204 between detection point 2 and detection point 3, the intermittent system device will jump from program 1 to detection point 5 of program 2. Starting from detection point 5, the intermittent system device executes program 2 according to the code sequence of program 2, and after running to the jump instruction 205 after detection point 7, it jumps back to the jump instruction 204 of the program to continue execution. In the cascade rollback technology, the intermittent system device will only save the variables modified between the detection point and the previous detection point at each detection point. If a power outage occurs at point D2 in program 2, after the intermittent system device is restarted, the intermittent system device should return to detection point 6 to continue execution. However, the variables modified between detection point 2 and jump instruction 204 are not saved. Program 1 also needs to return to detection 2 from jump instruction 204 and start re-execution. At this time, if the intermittent system device starts executing at detection point 2, since the re-execution of detection point 2 will cause the program between detection point 5 and detection point 6 to be re-executed, the variables modified between detection point 5 and detection point 6 do not need to be saved. Therefore, the state of program 2 should not only return to detection point 6, but should return to detection point 5. Therefore, program 2 rolled back 2 detection points, and program 1 rolled back 1 detection point, which can be understood as program 2 rolled back 2 times and program 1 rolled back 1 time. After rolling back to detection point 2, the code between detection point 2 and jump instruction 204, the code between detection point 5 and detection point 6, and the code between detection point 6 and point D2 need to be executed repeatedly, that is, 3 AEBs are executed repeatedly. Figure 2b This is just a simple example. In actual applications, if there are other detection points between detection point 5 and detection point 6, program 2 needs to be rolled back more times and more AEBs need to be repeatedly executed.
[0074] In order to reduce the amount of data of variables that need to be saved at the detection point of the intermittent system, an embodiment of the present application provides a method for processing an intermittent system program. In this method, by preprocessing the program (also referred to as the first program in the following embodiment), the intermittent system device, during the execution of the program, will equate a jump instruction to a detection point, and divide the first target AEB where the jump instruction is located into a second target AEB and a third target AEB, so that the intermittent system device can determine the modified variables in the second target AEB and the third target AEB respectively, thereby reducing the amount of data of variables that need to be saved by the intermittent system device and improving the operating efficiency of the intermittent system device. Furthermore, the method in the embodiment of the present application can solve the problem of repeated execution of AEB due to multiple rollbacks in the cascade rollback technology.
[0075] It should be noted that the modifiers such as first, second, and third mentioned in the embodiments of the present application are only for distinguishing different objects and do not mean a sequence of precedence.
[0076] In order to facilitate understanding of the method provided in the embodiments of the present application, the processing flow of the program is first described. Figure 3 , Figure 3 Schematic diagram of the process flow of the processing program in the embodiment of the present application. Figure 3As shown, the processing flow of the program may include program writing 301, program preprocessing 302, and program execution 303. Program writing 301 refers to the process of generating a program, including but not limited to manual input, software generation, etc. Program preprocessing 302 refers to the process of preprocessing all or part of the completed program on the basis of program writing, such as automatic correction, compilation, adding detection points, etc. Adding detection points is essentially adding node codes. When the node code is run, the work required to complete the detection points needs to be completed. The program preprocessing in the embodiment of the present application mainly includes scanning the first program, determining the first jump instruction in the first program, and adding the first node code before the first jump instruction. It should be noted that the program preprocessing in the embodiment of the present application can be performed simultaneously with other preprocessing, such as being performed simultaneously with compilation, or being performed simultaneously with automatic correction. In particular, determining the first jump instruction in the first program and adding the first node code before the first jump instruction can be achieved by writing and running software code; or, determining the first jump instruction in the first program can be completed by automatic scanning by a computer, and adding the first node code before the first jump instruction is completed manually. For example, after determining the first jump instruction in the first program, if there is no first node code before the first jump instruction, the device can issue a prompt to prompt the user to add the first node code before the first jump instruction. It should be noted that the program processing flow is divided into program writing 301, program preprocessing 302, and program execution 303 for the convenience of understanding the present application, and should not be used as a condition to limit the present application, or the boundary of the program flow division does not need to be clearly defined. For example, in the process of program writing, the first jump instruction in the first program can also be determined, and the first node code can be added before the first jump instruction.
[0077] The above describes the processing flow of the program, which is roughly divided into program writing 301, program preprocessing 302 and program execution 303. The processing flow requires a specific computer device to execute, and different steps can be completed in different computer devices or in the same computer device. For example, program writing 301 is completed in the first device, and the first device sends the completed first program to the intermittent system device, which performs program preprocessing 302 and program execution 303. Alternatively, please refer to Figure 4 , Figure 4 is a schematic diagram of an application scenario in an embodiment of the present application, such as Figure 4As shown, the first device 401 obtains the first program, which may be written in the first device 401 or in another device. After obtaining the first program, the first device 401 preprocesses the first program 302 to obtain the third program. After obtaining the third program, the first device transmits the third program to the intermittent system device 402, and performs the program execution 303 in the intermittent system device 402. In the embodiment of the present application, the following will be Figure 4 For other scenarios, please refer to Figure 4 Description of the scene in .
[0078] exist Figure 4 In the scenario, the first device 401 can be a desktop computer, a notebook, or a smart phone. The intermittent system device 402 can be a bracelet, a Bluetooth headset, a shared bicycle lock, or a sweeping robot. The first device 401 can establish a connection with the intermittent system device 402, or it can not establish a connection. If the first device 401 establishes a connection with the intermittent system device 402, the connection method can be a wired connection or a wireless connection, and the wireless connection can be a wireless hotspot or Bluetooth. If the first device 401 does not establish a connection with the intermittent system device 402, the third program can be transmitted by a storage medium, such as a USB flash drive. It should be determined that if the intermittent system device 402 can complete the steps performed by the first device 401, the method for processing the intermittent system program provided in the implementation of this application can be completed by the intermittent system device 402 alone, and it can also be understood that the first device is an intermittent system device.
[0079] The technical solution in the present application will be described below in conjunction with the accompanying drawings. For example, the features or contents marked with dotted lines in the accompanying drawings related to the embodiments of the present application can be understood as optional operations or optional structures of the embodiments.
[0080] See also Figure 5 , Figure 5 A flowchart of a method for processing an intermittent system program supporting synchronization in an embodiment of the present application is provided.
[0081] In step 501, a first device obtains a first program.
[0082] A first program is obtained on the first device. The first program may be written in the first device or in another device.
[0083] In step 502, the first device determines a first jump instruction in a first program.
[0084] The first device can scan the first program through software to determine the first jump instruction in the first program. The function of the first jump instruction is to enable the intermittent system device to jump from the first program to the second program after running the first jump instruction. Therefore, the first jump instruction will have a special format, or a special code, so by scanning the first program, the location of the first jump instruction can be determined. When the first program includes 1000 lines of code executed in sequence, the location of the first jump instruction can be understood as the number of lines where the first jump instruction is located. It should be determined that the first jump instruction contains a special format, or the special code is determined based on the requirements of the intermittent system device for the running program, or industry specifications, etc. The embodiment of the present application does not impose relevant restrictions on the specific code structure of the first jump instruction.
[0085] It should be noted that the line number is not the only way to identify the "position" of the first jump instruction. If it is based on the writing specifications of the first program, the "position" can be determined by other methods, such as segment number, function name, etc., and the "position" of the first jump instruction can also be identified by these other methods.
[0086] In step 503, the first device adds a first node code before the first jump instruction to generate a third program.
[0087] The first device adds the first node code, which is equivalent to adding a detection point at the position of the first node code. Before the first device adds the first node code, the first program may or may not have undergone AEB division. In other words, the addition of the first node code by the first device in the embodiment of the present application can be understood as a supplement to the AEB division, or it can be understood as being performed simultaneously with the AEB division. These two situations will be described separately below. According to the previous description, AEB division may include adding detection points, or performing TASK division, etc.
[0088] First, the first device adds the first node code as a supplement to the AEB division. Figure 6 , Figure 6 A schematic diagram of the structure before and after adding the first node code to the first program (corresponding to program 1 in the figure) in the embodiment of the present application. Among them, Figure 6 a is a schematic diagram of the structure of the first program before adding the first node code, and the first program has been divided by AEB. The first jump instruction 601 is included between the detection point 2 and the detection point 3, that is, the first jump instruction 601 is included in AEB2. After the first device determines the position of the first jump instruction 601, the first device adds the first node code before the first jump instruction 601. Figure 6 As shown in b, Figure 6b is a structural diagram of the first program after adding the first node code in the embodiment of the present application. The first program after adding the first node code can also be called the third program. Among them, the position of node code 602 is equivalent to the position of detection point 1; the position of node code 603 is equivalent to the position of detection point 2; the position of node code 607 is equivalent to the position of detection point 3; the position of node code 608 is equivalent to the position of detection point 4. The first jump instruction 601 divides AEB2 into the second target AEB604 and the third target AEB606 in the execution order. AEB2 can be understood as the first target AEB. The first device adds the first node code 605 between the second target AEB604 and the first jump instruction 601 to obtain the third program.
[0089] It should be understood that for the convenience of expression, the present application embodiment distinguishes between the common code and the node code in AEB. Figure 6 The definition of AEB in b is only for the convenience of understanding the technical solution in the embodiment of the present application. Figure 6 The AEB and node code in b, such as AEB3 and node code 608, are understood as one AEB, and will not affect the technical effect of the technical solution provided in the embodiment of the present application.
[0090] Here, an explanation is given for the node code, and the node code may be the above-mentioned first node code 605. Here, the node code is divided into two types, one is a substantial node code, and the other is an identifying node code.
[0091] The substantial node code includes the information of the variable that needs to be modified. For example, AEB1 includes the code: a=x1; this code is used to assign the value of x1 to the variable a. If the node code 603 is a substantial node code, the node code 603 includes the variable a, and the node code 603 does not complete the action of saving a=x1 by jumping to a program or calling a program. When the intermittent system device executes the first program after adding the first node code, that is, when executing the third program, the intermittent system device can complete the action of saving a=x1 through the node code 603 without calling other programs.
[0092] The identifying node code does not include variable information. For example, AEB1 includes the code: a=x1. If node code 603 is an identifying node code, node code 603 includes or excludes variable a, that is, node code 603 itself does not need to know the specific modified variables. When the intermittent system device specifically executes the first program after adding the first node code, that is, executes the third program, the intermittent system device treats node code 603 as a saved node. At node code 603, the intermittent system device obtains the variables that the intermittent system has modified in the time period from the last saved node (node code 602) to the saved node (node code 603), such as variable a=x1, by jumping the program or calling the program.
[0093] The substantive node code determines which variables need to be saved before the variables are modified; the identifying node code determines which variables are saved after the variables are modified. The number of variables actually saved by the two may be different.
[0094] First, the case where the node code 603 is a substantial node code is described. For example, AEB1 also includes an if statement: when a certain condition is met, b=x2. Assume that before executing AEB1, b=x0. If the node code 603 is a substantial node code, the node code 603 includes a and b. When the condition is met, the variables saved by the intermittent system device according to the node code 603 are: a=x1, b=x2. When the condition is not met, the variables saved by the intermittent system device according to the node code 603 are: a=x1, b=x0. It should be determined that it is not stated here that the intermittent system device can also determine whether to save b by judging whether the value of b is the same before and after executing AEB1. For example, when the condition is not met, the value of b will not change before and after executing AEB1, so the intermittent system device may not save b at the node code 603; if the condition is met, the value of b changes before and after executing AEB1, and the intermittent system device saves the new value of b at the node code 603.
[0095] Next, the case where node code 603 is an identifying node code is described. For example, AEB1 also includes an if statement: under condition 1, b=x2. Assume that before executing AEB1, b=x0. If node code 603 is an identifying node code, node code 603 does not include a and b. When condition 1 is met, the variables saved by the intermittent system device according to node code 603 are: a=x1, b=x2. When condition 1 is not met, the variables saved by the intermittent system device according to node code 603 are: a=x1. Because condition 1 is not met, the instruction of b=x2 is not executed, that is, in the time period from the last saved node (node code 602) to the saved node (node code 603), the modified variables do not include b=x2.
[0096] Here is a summary of substantial node codes and identifying node codes. Program 1 using identifying node codes can have a smaller size than Program 1 using substantial node codes. Because the identifying code is generally the entrance to a subroutine, it does not need to include the code for executing the specific save action. Among them, the code for the save action includes the modified variables, and the size is the data size of Program 1. However, an additional program is required in the intermittent system device to identify and execute the identifying node code. Program 1 using substantial node codes has better generalization than Program 1 using identifying node codes. Intermittent system devices do not need additional programs to identify and execute substantial node codes, and can run relatively well in different intermittent devices. When the intermittent system device needs to execute more programs, it is advantageous to use identifying node codes, because the additional programs can be common to multiple programs, thereby reducing the size of each of the multiple programs.
[0097] Returning to the previous description, the relationship between the first device adding the first node code and the AEB division is defined.
[0098] Secondly, the description of adding the first node code to the first device is understood to be performed simultaneously with the AEB division, or in other words, it is the AEB division. Figure 7 , Figure 7 This is another structural diagram of the first program before and after adding the first node code in the embodiment of the present application. Among them, Figure 7 a is a schematic diagram of the structure of the first program before adding the first node code. Figure 7 In a, program 1 includes a first jump instruction 701. After the first device determines the location of the first jump instruction 701, the first device performs AEB division on the first program, wherein the AEB division includes adding a first node code before the first jump instruction 701. Figure 7 As shown in b, Figure 7 b is a schematic diagram of the structure of the first program after AEB division is performed in the embodiment of the present application. Figure 7 In b, the first device divides the first program into four AEBs, namely AEB1709, the second target AEB704, the third target AEB706 and AEB3710. The four AEBs are divided by node code 703, the first node code 705 and the node code 707. The first node code 705 is between the second target AEB704 and the first jump instruction 701. Before AEB1, it also includes node code 702, and after AEB3, it also includes node code 708.
[0099] Here are a few additional points about the above description.
[0100] 1. It should be understood that, because the embodiment of the present application needs to distinguish between the common code and the node code in AEB, Figure 7 The definition of AEB in b is only for the convenience of understanding the technical solution in the embodiment of the present application. Figure 7 The AEB3 and node code 708 in b are understood as one AEB, and the technical effect of the technical solution provided by the embodiment of the present application will not be affected. Ordinary code refers to the code used to complete the function of program 1 except the node code. The node code is used to save variables. If the intermittent system device does not have power failure and other events, the existence of the node code will not affect the realization of the function of program 1.
[0101] 2. The program 1 in the example may be a part of a certain program. This is just for illustration and does not limit whether the program 1 in the example is complete.
[0102] 3. Figure 7 b and Figure 6 b has no necessary connection, that is, Figure 7 b and Figure 6 b can be different, for example Figure 7 The code length of the second target AEB704 in b may not be equal to Figure 6 The code length of the second target AEB 604 in b, or the position of the node code 603 may not be equal to the position of the node code 703 .
[0103] 4. Figure 7 The jump instructions included in program 1 in a do not necessarily have only one first jump instruction 701. In actual applications, program 1 may include one or more jump instructions. When program 1 includes multiple jump instructions, after different jump instructions are executed by the intermittent system device, the operation of the intermittent system device can jump to the same program or to different programs. For example, the first jump instruction indicates a jump to the second program, the fourth jump instruction indicates a jump to the fourth program, and the fifth jump instruction indicates a jump to the second program. Even if multiple jump instructions jump to the same program, they can also jump to different locations of the same program, or the same location.
[0104] After adding the first node code to the first program after AEB division, or after adding the first node code during AEB division, the obtained program is called the third program in this embodiment, and can also be understood as the first program in other embodiments, but it is modified to add the first node code.
[0105] In step 504, the first device adds a target identifier to the third program.
[0106] The first device can add a target identifier to the third program after adding a node code before all jump instructions in program 1. The target identifier is used to, when detected by the gap system device, enable the gap system device to determine that the third program meets the requirements of the gap system device for the third program. The requirement of the intermittent system device for the third program is that a node code is added before each jump instruction in the third program. Regarding the format of the target identifier, the first device can agree with the intermittent system device in advance, and the specific format of the target identifier is not limited here. It should be noted that if a node code is already included before a jump instruction in program 1, the first device does not need to add a node code before the jump instruction.
[0107] It should be noted that the third program will run in the intermittent system device, and the first device needs to transfer the third program to the intermittent system device. Therefore, the target identifier does not necessarily need to be carried inside the third program, as long as the target identifier and the third program are associated. For example, the first device carries the target identifier and the third program in a folder and transfers the folder to the intermittent system device. When the target identifier is carried inside the third program, the target identifier can be carried at the beginning of the third program. Since the processing capacity of the intermittent system device is generally limited, by carrying the target identifier at the beginning of the third program, when the intermittent system device starts to run the third program, the target identifier can be scanned, thereby reducing the data processing amount of the intermittent system device.
[0108] In step 505, the first device sends a third program to the intermittent system device.
[0109] The first device sends a third program to the intermittent system device, which may also include a target identifier and a corresponding relationship between the third program and the target identifier.
[0110] In step 506, the intermittent system device detects whether a third identifier exists.
[0111] The third program is used to run in the intermittent system device, so the intermittent system device can detect whether there is a target identifier corresponding to the third program. If the first device does not perform step 504, the intermittent system device will not detect the target identifier corresponding to the third program.
[0112] In step 507, if the target identifier is not detected, the intermittent system device displays a prompt message.
[0113] If the target identifier cannot be detected, the intermittent system device determines that the third program does not meet the requirements of the intermittent system device for the third program. The requirements of the intermittent system device for the third program are that a node code is added before each jump instruction in the third program, each jump instruction includes a first jump instruction, and the node code includes a first node code. If the intermittent system device executes the first program that does not meet the requirements, the operation of the intermittent system device may fail. Figure 6 a, and the related description of the background technology, it can be obtained that at the detection point 3, the intermittent system equipment in the background technology needs to save all the variables of the entire intermittent system, and in the implementation of this application, combined with Figure 6 b. The intermittent system device can reduce the variables that are saved, for example, only save the variables modified in AEB2, or only save the variables modified in the third target AEB. If the first node code is not added before the first jump instruction 601, that is, the third program does not meet the requirements of the intermittent system device, the intermittent system device should save the variables of the entire intermittent system, but the intermittent system device adds the first node code before the first jump instruction by default, and only saves the variables modified in the third target AEB at detection point 3. Therefore, if an event such as a power outage occurs, an operation error may occur. By adding a target identifier to the preprocessed third program, the intermittent system device can reversely determine that the program without the target identifier is a program that has not been preprocessed, thereby reducing errors in the operation of the intermittent system device. The above preprocessing can be understood as adding the first node code before all jump instructions in program 1.
[0114] If the target identifier corresponding to the third program is not detected, the intermittent system device determines that the third program does not meet the requirements. The intermittent system device can display a prompt message, which is used to inform the user or program debugger that the third program does not meet the requirements of the intermittent system device for programs. For example, the prompt message may include the following content: the program has not been pre-processed and does not meet the requirements of the intermittent system for programs. If it is forced to run, an error may occur.
[0115] Alternatively, if Figure 4 If the intermittent system device 402 is connected to the first device 401, the intermittent system device can also display prompt information through the first device.
[0116] In step 508, if the target identifier is detected, the intermittent system device may run a third program.
[0117] If the intermittent system device detects the target identifier corresponding to the third program, the intermittent system device determines that the third program meets the requirements of the intermittent system device for programs. It should be determined that if the first device does not add the first node code before the first jump instruction, but still adds the target identifier to the first program, the intermittent system device can still determine that the first program meets the requirements of the intermittent system device for programs. Because the processing capacity of the intermittent system device is generally limited, the intermittent system device may not substantially confirm whether the first node code is added before the first jump instruction.
[0118] It is an optional operation for the first device to add a target identifier to the third program. Therefore, if the first device does not add a target identifier to the third program, the intermittent system device can directly run the third program without executing the step of detecting the target identifier.
[0119] The following describes the actions that occur when the intermittent system device runs the third program. For ease of understanding, Figure 6 b is used as an example to illustrate this. Figure 8 , Figure 8 This is a flow chart of the program running in the embodiment of the present application. Figure 8 a is equivalent to Figure 6 b is a schematic diagram of the program structure. Figure 6 b, Figure 8 a is clearer in reflecting the process, so Figure 8 b is used to reflect the difference between the operation of the third program after preprocessing and the collaborative detection point technology and the cascade rollback technology. For the operation of the first program in the collaborative detection point technology, please refer to the above Figure 2a For the description of program 1 in the cascade rollback technology, please refer to the above Figure 2b The description of procedure 1 in . Compared to Figure 8 a, Figure 6 b is more clear in terms of structure. Figure 6 b is used to show the modification of the program structure of the first device.
[0120] like Figure 8 As shown in a, Figure 8 Program 2 described in a can be understood as the second program, and program 3 can be understood as the aforementioned third program, or the first program after adding the first node code. The intermittent system device executes the third program in the code order in the third program. When the intermittent system device executes the first node code 605, the intermittent system device saves the variables modified in the second target AEB. In the traditional collaborative checkpoint technology and cascade rollback technology, no variables are saved here.
[0121] In step 509 , the intermittent system device jumps to the first AEB of the second program according to the first jump instruction 601 .
[0122] The first AEB is the first AEB to be executed in the second program. Figure 8 In b, the first AEB can be understood as the AEB between detection point 5 and detection point 6. The above jump can also be understood as jumping to detection point 5.
[0123] In step 510 , after the intermittent system device runs to the fourth target AEB, the modified variables in the fifth target AEB are saved according to the second jump instruction in the second program.
[0124] like Figure 8 As shown in FIG. 1 , the fourth target AEB can be understood as the AEB between detection point 7 and detection point 8 in program 2. Program 2 is also preprocessed accordingly, and the preprocessing includes adding node code 801 before the second jump instruction 802. When the intermittent system device executes node code 801, the intermittent system device saves the modified variables in the fifth target AEB. The second jump instruction 802 divides the fourth target AEB into the fifth target AEB and the sixth target AEB. The fifth target AEB can be understood as the AEB between detection point 7 and node code 801, and the sixth target AEB can be understood as the AEB between node code 801 and detection point 8.
[0125] In other embodiments, the fourth target AEB may be the first AEB.
[0126] In step 511, the intermittent system device jumps to the first jump instruction according to the second jump instruction and continues to execute.
[0127] See also Figure 8 After the intermittent system device executes the second jump instruction 802, it jumps to the first jump instruction 601 and continues to execute program 1.
[0128] In other embodiments, when the subsequent execution reaches the detection point 3, the intermittent system device only saves the variables modified in the third target AEB606, and does not save the variables modified in the second target AEB604. In the collaborative detection point technology, the intermittent system device will save the variables of the entire system at the detection point 3. In the cascade rollback technology, the intermittent system device will save the variables modified in AEB2. Whether compared with the cascade rollback technology or the collaborative detection point technology, the embodiments of the present application retain fewer variables at the detection point 3.
[0129] Compared with the coordinated checkpoint technology, although the embodiment of the present application will increase the variables saved at the first node code 605, overall, the variables saved can be reduced. Compared with the cascade rollback, please refer to Figure 8b. If a power failure occurs at D3 in program 2. In the embodiment of the present application, since the variables modified between detection point 2 and the first jump instruction 601 are saved at the first node code 605, program 1 does not need to be rolled back, and program 2 only needs to be rolled back to detection point 6. After power is restored, the gap system device continues to execute from detection point 6 of program 2 according to the data saved in detection point 6. Figure 2b In the power failure event of the cascade rollback described in the embodiment of the present application, the number of rollbacks in the embodiment of the present application is 1, and the number of AEBs to be repeatedly executed is 1. It should be noted that after the gap system device restores power, it is possible to determine which program to execute through the priority determination of the scheduler. For example, the gap system device includes program 4. If the priority of program 4 is higher than the priority of program 2, program 4 will be executed after the gap system device restores power. If the priority of program 2 is higher than that of program 4, execution will start from detection point 6.
[0130] In the above description of the technical solution in the embodiment of the present application, the first program includes only one jump instruction. Furthermore. In actual applications, if the first program includes one or more jump instructions, a node code is added before each jump instruction. It should be determined that if a node code is already included before some jump instructions, there is no need to add a node code before these jump instructions. If a node code is added before each jump instruction, the intermittent system device can ensure that the intermittent system device must have executed the action of saving variables before jumping from the third program to the second program during the execution of the first program 1. For the convenience of description, the condition that a node code is added before each jump instruction in the third program is called condition 1. If the first program does not include a jump instruction, the first program also satisfies condition 1.
[0131] In an embodiment of the present application, the first program may be an application program interface (API), a scheduler, or an application, and an application is also called an application task. API is an agreement for connecting different components of a software system, also known as an application programming interface. The main purpose of API is to provide applications and developers with the ability to access a set of routines without having to access the source code or understand the details of the internal working mechanism. It mainly includes Windows API, Linux API, and APIs provided by various embedded operating systems. A scheduler is an application that determines the order in which programs are executed. Generally, it determines the priorities of different programs and allows programs with higher priorities to be executed first. In an intermittent system with multiple concurrent programs, the existence of a scheduler can reasonably allocate programs that are executed with priority. In a broad sense, API and scheduler are also a kind of application.
[0132] The third program in the embodiment of the present application meets the conditions for atomic execution, that is, the third program includes one or more AEBs, and at the end of the AEB there is an action to execute and save variables, or in other words, the first program has undergone AEB division. The preprocessing process of the first program in the embodiment of the present application can be understood as a supplement to the AEB division, or can be understood as a part of the AEB division. If the preprocessing process in the embodiment of the present application is understood as a supplement to the AEB division, the first program may have undergone AEB division before preprocessing. The following will take the first program as an API as an example, and divide an API into an AEB as an example for explanation. In order for the API to meet the requirements of atomic execution, the AEB division can also be understood as a modification of the API.
[0133] The API code before AEB division is as follows:
[0134]
[0135] The API code after AEB division is as follows:
[0136]
[0137]
[0138] In the API code after AEB division, or in this AEB, the code __COMMIT(__share) and the code under __share() can be understood as node code.
[0139] In the above AEB transformation, Schedule() was moved. This code is used to jump to the scheduler for execution, so Schedule() is a jump instruction. When the API meets condition 1, no jump instruction will appear in the middle of any AEB in the API, so Schedule() is moved. Although Schedule() is not reflected in the above program, after executing the API, the scheduler can be called by default, that is, after this API, Schedule() can be included, that is, the jump instruction can still exist. That is, in this API transformation, the node code __COMMIT(__share) is actually added before the jump instruction on the basis of moving the jump instruction. Therefore, this is just an example of an AEB transformation method.
[0140] It should be noted that the above only transforms the API into an AEB. In actual applications, an API can be transformed into one or more AEBs. Moreover, the transformation method here is only an example. In actual applications, there may be other transformation methods, which will not be elaborated here.
[0141] The above describes that the third program can be an API, and describes the modification method of the API. The following describes the application program in the intermittent system device, the API and the scheduler all meet the conditions for atomic execution, and when condition 1 is met, the intermittent system device runs a flow chart of n applications, where n is an integer greater than 1.
[0142] See also Fig. 9 , Fig. 9 A flow chart of n applications running in an intermittent system device.
[0143] After the intermittent system device executes AEB1a in application 1, it saves the variables modified in AEB1a. AEB1a is not necessarily the first AEB in application 1. And, Fig. 9 The node code is omitted in the figure, which can also be understood as the node code at the end of each AEB. After executing an AEB, the scheduler is entered for execution. The scheduler determines which application to execute next. Assuming that the scheduler determines to continue to execute application 1, the intermittent system device executes jump instruction 1a, and jump instruction 1a is after AEB1a. The intermittent system device jumps to API1a according to jump instruction 1a. API1a can be considered as an AEB. After executing an AEB, the scheduler is entered for execution. The scheduler determines which application to execute next. Assuming that the scheduler determines to execute application 2 next. The intermittent system device starts execution from AEB2a in application 2, where AEB2a is not necessarily the first AEB in application 1. After the intermittent system device executes AEB2a in application 2, it saves the modified variables in AEB2a. The subsequent derivation is similar to the above and will not be repeated here. By allowing the application, API and scheduler to meet the conditions for atomic execution and satisfying condition 1, the intermittent system device will perform the action of saving variables before each jump instruction is executed during operation. In other words, the intermittent system device in the implementation example of the present application will only execute the jump instruction after an AEB ends, and will not execute the jump instruction in the middle of an AEB.
[0144] Fig. 9 In the embodiment, after each AEB is executed, the scheduler needs to process it. In other embodiments, when the API is called after the AEB of the application is completed, the scheduler may not be processed. Fig.10 As shown, Fig.10Another flowchart of n applications running in an intermittent system device is shown in Figure 1. After AEB1a is completed, API1a needs to be called. During this process, the scheduler is not involved. After AEB1a is executed, API1a is directly executed through jump instruction 1a. Because calling API is an operation that applications often need to do, it is hoped that the process does not require the participation of the scheduler to improve the operating efficiency of the intermittent system device.
[0145] It should be determined that Fig. 9 It is just a flow chart of the intermittent system device running n applications in the embodiment of the present application. In actual application, the flow chart is not certain. For example, the jump instruction 1a does not necessarily jump to API1a, but jumps to application 3, or there is no jump instruction 1a in application 1, and API1a and API2a can be the same API. Therefore, there are too many changes in the process of the intermittent system device. Fig. 9 Just as a hint.
[0146] The program processing method and program execution method in the embodiments of the present application are described above. The device for processing the program in the embodiments of the present application is described below.
[0147] See also Fig.11 , Fig.11 A schematic diagram of the structure of a device for processing a program in an embodiment of the present application.
[0148] The device includes:
[0149] An acquisition module 1101 is used to acquire a first program;
[0150] The determination module 1102 is used to determine the first jump instruction in the first program, so that after the second target atomic execution module AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and the third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0151] In other embodiments, the device may further include a sending module or an adding module. The modules in the device are specifically used to execute the aforementioned Figure 5The first device in the corresponding embodiment may perform all or part of the operations.
[0152] See also Fig.12 , Fig.12 A schematic diagram of the structure of a device for executing a program in an embodiment of the present application.
[0153] The device includes:
[0154] An acquisition module 1201 is used to acquire a first program, wherein the first program includes one or more atomic execution modules AEB, wherein the one or more AEBs include a first target AEB, wherein the first target AEB includes a first jump instruction, wherein the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, wherein the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, wherein the first jump instruction is used to instruct to jump from the first program to the second program;
[0155] A saving module 1202, configured to save the modified variables in the second target AEB after the second target AEB is executed by the device and before the first jump instruction is executed;
[0156] The jump module 1203 is used to jump from the first program to the first AEB of the second program if the first jump instruction is executed by the device, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0157] In other embodiments, the device may also include a determination module or a display module. The modules in the device are specifically used to perform the above Figure 5 or Figure 8 The gap system device in the corresponding embodiment can perform all or part of the operations.
[0158] The above describes the apparatus for executing the program in the embodiment of the present application. The following describes the first device and the intermittent system device in the embodiment of the present application.
[0159] See also Fig.13 , Fig.13 It is a structural diagram of a device for processing a program or a device for executing a program in an embodiment of the present application.
[0160] like Fig.13As shown, the device for processing a program or executing a program 1300 includes a processor 1310 and a memory 1320 coupled to the processor 1310. The processor 1310 may be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and a NP. The processor may also be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. The processor 1310 may refer to one processor or may include multiple processors.
[0161] The memory 1320 may include a volatile memory, such as a random-access memory (RAM); the memory 1320 may also include a non-volatile memory, such as a read-only memory (ROM), a FRAM memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 1320 may also include a combination of the above types of memory.
[0162] when Fig.13 When it is a schematic diagram of the structure of the device that handles the program:
[0163] The processor 1310 is configured to obtain a first program;
[0164] The processor 1310 is also used to determine the first jump instruction in the first program, so that after the second target atomic execution module AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and the third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
[0165] In other embodiments, the processor 1310 is further configured to execute the computer-readable instructions in the memory 1320 and, according to the instructions of the computer-readable instructions, perform all operations that can be performed by the first device, such as the first device performing the following operations in conjunction with the computer-readable instructions: Figure 5 The operations performed in the corresponding embodiments.
[0166] when Fig.13 When it is a schematic diagram of the structure of the device that executes the program:
[0167] The processor 1310 is used to obtain a first program, where the first program includes one or more atomic execution modules AEB, the one or more AEBs include a first target AEB, the first target AEB includes a first jump instruction, the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, the second target AEB is before the first jump instruction, the third target AEB is after the first jump instruction, and the first jump instruction is used to instruct to jump from the first program to the second program;
[0168] The processor 1310 is further configured to save the modified variable in the second target AEB after the second target AEB is executed by the device and before executing the first jump instruction;
[0169] The processor 1310 is further configured to jump from the first program to the first AEB of the second program if the first jump instruction is executed by the device, the second program including one or more AEBs, the first AEB being the first AEB to be executed after jumping to the second program.
[0170] In other embodiments, the processor 1310 is further configured to execute the computer-readable instructions in the memory 1320 and, according to the instructions of the computer-readable instructions, perform all operations that the gap system device can perform, such as the gap system device in the Figure 5 or Figure 8 The operations performed in the corresponding embodiments.
[0171] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0172] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0173] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0174] If the integrated unit is implemented in the form of 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 the present application is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash drives, mobile hard drives, ROM, RAM, magnetic disks or optical disks.
Claims
1. A program execution method, characterized in that: include: The intermittent system device acquires a first program, the first program includes one or more atomic execution modules AEB, the one or more AEBs include a first target AEB, the first target AEB includes a first jump instruction, the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, the second target AEB is before the first jump instruction, the third target AEB is after the first jump instruction, and the first jump instruction is used to instruct to jump from the first program to the second program; After the second target AEB is executed by the intermittent system device, before executing the first jump instruction, the intermittent system device saves the modified variable in the second target AEB; If the first jump instruction is executed by the intermittent system device, the intermittent system device jumps from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
2. The method according to claim 1, characterized in that After the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first procedure, the method further includes: The intermittent system saves the variables modified in the third target AEB, and the variables modified in the second target AEB are not saved, and the second AEB is the first AEB after the first target AEB.
3. The method according to claim 2, characterized in that The intermittent system equipment obtains the first procedure including: The intermittent system device acquires a third program, the third program includes the first program, and the third program includes a first node code before the first jump instruction and after the second target AEB; If the second target AEB is executed by the intermittent system device, the intermittent system device saves the modified variables in the second target AEB including: The intermittent system device saves the modified variables in the second target AEB by executing the first node code.
4. The method according to claim 3, characterized in that The first node code is added according to the position of the first jump instruction after the first device determines the first jump instruction; The intermittent system equipment obtains the third procedure including: The intermittent system device receives the third program sent by the first device.
5. The method according to any one of claims 1 to 4, characterized in that: The first program includes a target identifier, and the method further includes: If the target identifier is detected, the intermittent system device determines that the first program meets the requirements of the intermittent system device for the first program. The requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
6. The method according to claim 5, characterized in that The method further comprises: If the first program does not meet the requirement of the intermittent system device for the first program, the intermittent system device displays a prompt message.
7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: The intermittent system device acquires the second program, the second program includes one or more AEBs, the one or more AEBs include a fourth target AEB, the fourth target AEB includes a second jump instruction, the second jump instruction divides the fourth target AEB into a fifth target AEB and a sixth target AEB, the fifth target AEB is before the second jump instruction, the sixth target AEB is after the second jump instruction, and the second jump instruction is used to instruct to jump from the second program to the first program; After the fifth target AEB is executed by the intermittent system device, before executing the second jump instruction, the intermittent system device saves the modified variable in the fifth target AEB; If the second jump instruction is executed by the intermittent system device, the intermittent system device jumps from the fifth target AEB of the second program to the third target AEB of the first program.
8. A method for processing a program, wherein the program is run on an intermittent system device, characterized in that: include: The first device obtains the first program; The first device determines the first jump instruction in the first program so that after the second target atomic execution module AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and the third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
9. The method according to claim 8, characterized in that After the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the modified variables in the third target AEB are saved, and the modified variables in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB.
10. The method according to claim 9, characterized in that After the first device determines the first jump instruction in the first program, the method further includes: The first device adds a first node code before the first jump instruction of the first program and after the second target AEB to generate a third program, and the first node code is used to be executed by the intermittent system device to save the variables modified in the second target AEB.
11. The method according to claim 10, characterized in that After generating the third program, the method further includes: The first device sends the third program to the intermittent system device.
12. The method according to any one of claims 8 to 11, characterized in that: After the first device determines the first jump instruction in the first program, the method further includes: The first device adds a target identifier in the first program, and the target identifier is used to enable the intermittent system device to determine that the first program meets the requirements of the intermittent system device for the first program when it is detected by the intermittent system device. The requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
13. The method according to any one of claims 8 to 11, characterized in that: The method further comprises: The first device determines the second jump instruction in the second program so that after the fifth target AEB is executed by the intermittent system device, before the second jump instruction is executed, the modified variables in the fifth target AEB are saved, the second jump instruction is in the middle of the fourth target AEB, and the fourth target AEB is divided into the fifth target AEB and the sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and after the second jump instruction is executed, the intermittent system device can jump from the fifth target AEB of the second program to the third target AEB of the first program.
14. A device for executing a program, characterized in that: include: an acquisition module, configured to acquire a first program, wherein the first program includes one or more atomic execution modules AEB, the one or more AEBs include a first target AEB, the first target AEB includes a first jump instruction, the first jump instruction divides the first target AEB into a second target AEB and a third target AEB, the second target AEB is before the first jump instruction, the third target AEB is after the first jump instruction, and the first jump instruction is used to instruct a jump from the first program to a second program; a saving module, configured to save the modified variables in the second target AEB after the second target AEB is executed by the device and before the first jump instruction is executed; A jump module is used for jumping from the first program to a first AEB of the second program if the first jump instruction is executed by the device, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
15. The device according to claim 14, characterized in that After the device executes the third target AEB and before the device executes the second AEB of the first program, the saving module is further used to save the modified variables in the third target AEB, and the modified variables in the second target AEB are not saved, and the second AEB is the first AEB after the first target AEB.
16. The device according to claim 15, characterized in that The acquisition module is specifically used to acquire a third program, the third program includes the first program, and the third program includes a first node code before the first jump instruction and after the second target AEB; The saving module is specifically configured to save the modified variables in the second target AEB by executing the first node code.
17. The device according to claim 16, characterized in that The first node code is added according to the position of the first jump instruction after the first device determines the first jump instruction; The acquisition module is specifically configured to receive the third program sent by the first device.
18. The device according to any one of claims 14 to 17, characterized in that The first procedure includes target identification; The device also includes: A determination module is used to determine that the first program meets the requirements of the intermittent system device for the first program if the target identifier is detected. The requirements of the intermittent system device for the first program are that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
19. The device according to claim 18, characterized in that The device also includes: The display module is used to display a prompt message if the third program does not meet the requirements of the device for the first program.
20. The device according to any one of claims 14 to 17, characterized in that The acquisition module is further used to acquire the second program, the second program includes one or more AEBs, the one or more AEBs include a fourth target AEB, the fourth target AEB includes a second jump instruction, the second jump instruction divides the fourth target AEB into a fifth target AEB and a sixth target AEB, the fifth target AEB is before the second jump instruction, the sixth target AEB is after the second jump instruction, and the second jump instruction is used to instruct to jump from the second program to the first program; The saving module is further used for saving the modified variables in the fifth target AEB after the fifth target AEB is executed by the device and before executing the second jump instruction; The jump module is further configured to jump from the fifth target AEB of the second program to the third target AEB of the first program if the second jump instruction is executed by the device.
21. A device for processing a program, characterized in that include: An acquisition module, used for acquiring a first program; A determination module is used to determine a first jump instruction in the first program, so that after the second target atomic execution module AEB is executed by the intermittent system device, before the first jump instruction is executed, the modified variables in the second target AEB are saved, the first jump instruction is in the middle of the first target AEB, and the first target AEB is divided into the second target AEB and a third target AEB, the second target AEB is before the first jump instruction, and the third target AEB is after the first jump instruction, the first target AEB is an AEB of the first program, and after the first jump instruction is executed, the intermittent system device can jump from the first program to the first AEB of the second program, the second program includes one or more AEBs, and the first AEB is the first AEB to be executed after jumping to the second program.
22. The device according to claim 21, characterized in that After the intermittent system device executes the third target AEB and before the intermittent system device executes the second AEB of the first program, the modified variables in the third target AEB are saved, and the modified variables in the second target AEB are not saved, and the second AEB is an AEB after the first target AEB.
23. The device according to claim 22, characterized in that The device also includes: An adding module is used to add a first node code before the first jump instruction of the first program and after the second target AEB to generate a third program, wherein the first node code is used to be executed by the intermittent system device to save the modified variables in the second target AEB.
24. The device according to claim 23, characterized in that The device also includes: A sending module is used to send the third program to the intermittent system device.
25. The device according to any one of claims 21 to 24, characterized in that The adding module is also used to add a target identifier in the first program. When the target identifier is detected by the intermittent system device, the intermittent system device determines that the first program meets the requirements of the intermittent system device for the first program. The requirement of the intermittent system device for the first program is that a node code is added before each jump instruction in the first program, each jump instruction includes the first jump instruction, and the node code includes the first node code.
26. The device according to any one of claims 21 to 24, characterized in that The determination module is also used to determine the second jump instruction in the second program, so that after the fifth target AEB is executed by the intermittent system device, before the second jump instruction is executed, the modified variables in the fifth target AEB are saved, the second jump instruction is in the middle of the fourth target AEB, and the fourth target AEB is divided into the fifth target AEB and the sixth target AEB, the fifth target AEB is before the second jump instruction, and the sixth target AEB is after the second jump instruction, and after the second jump instruction is executed, the intermittent system device can jump from the fifth target AEB of the second program to the third target AEB of the first program.
27. A device for executing a program, characterized in that: include: A processor and a memory, wherein the memory stores a first program and a processing program, the processor is used to obtain the first program from the memory, and process the first program according to the processing program, and the processing method includes any one of the methods in claims 1 to 7.
28. An apparatus for processing a program, characterized in that include: A processor and a memory, wherein the memory stores a first program and a processing program, the processor is used to obtain the first program from the memory, and process the first program according to the processing program, and the processing method includes any one of the methods in claims 8 to 13.
Citation Information
Patent Citations
Method for checkpointing and restoring program state
CN102736948A
Program breakpoint processing method and device
CN102831054A