Task scheduling method, intelligent gas stove and computer readable storage medium
By dividing the task into interrupt subtasks when receiving interrupt commands in the intelligent gas stove and executing them according to priority, the problem of missing emergency tasks is solved and the timely processing of tasks is achieved.
Patent Information
- Application Number
- CN202110139457.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-01
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2041-02-01
AI Technical Summary
The problem of missing emergency tasks in smart gas stoves due to failure to be executed in a timely manner.
When an interrupt instruction is received, the task to be executed corresponding to the interrupt instruction is divided into multiple interrupt subtasks, and the first priority of each interrupt subtask is obtained, the first subtask currently executed is stopped, and each interrupt subtask is executed based on the first priority of each interrupt subtask.
By stopping the currently executed subtask and executing each interrupt subtask, the timely execution of the interrupt subtask is achieved, avoiding the situation where emergency tasks are not executed in time.
Smart Images

Figure CN112783630B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of gas stoves, and in particular to a task scheduling method, an intelligent gas stove and a computer-readable storage medium. Background Art
[0002] At present, the system of smart gas stoves is often a polling system. When the smart gas stove is running, it runs the main program after initializing the relevant hardware, and then continuously loops various tasks that need to be executed in the main program, such as LED flipping tasks, serial port output tasks, LCD display tasks, etc. During the operation of the smart gas stove, there are often emergency tasks such as external signal triggering interrupts. However, when a smart gas stove using a polling system detects an emergency task, it needs to complete the currently executing task before executing the emergency task. If the remaining execution time of the currently executing task is greater than the duration of the trigger event corresponding to the emergency task, the emergency task will disappear when the currently executing task is completed, resulting in the emergency task being lost due to failure to execute in time.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a task scheduling method, an intelligent gas stove and a computer-readable storage medium, aiming to solve the technical problem that emergency tasks in the intelligent gas stove are not executed in time and are lost.
[0005] To achieve the above object, the present invention provides a task scheduling method, which is applied to a smart gas stove. The task scheduling method comprises the following steps:
[0006] When receiving an interrupt instruction, dividing the to-be-executed task corresponding to the interrupt instruction into a plurality of interrupt subtasks, and obtaining the first priority of each interrupt subtask;
[0007] The currently executed first subtask is stopped, and each interrupt subtask is executed based on the first priority of each interrupt subtask.
[0008] In one embodiment, the step of executing each interrupt subtask based on the first priority of each interrupt subtask includes:
[0009] Based on the priority of each interrupt subtask, each interrupt subtask is added to the priority index table, wherein the priority of each interrupt subtask is greater than the priority of other subtasks except the interrupt subtask;
[0010] Based on the priority index table, each interrupt subtask is executed in sequence.
[0011] In one embodiment, the step of sequentially executing each interrupt subtask based on the priority index table includes:
[0012] Periodically obtain the second subtask with the highest priority in the current priority index table, and determine the first target subtask based on the second subtask;
[0013] Execute the first target subtask, and delete the first target subtask from the priority index table.
[0014] In one embodiment, the step of determining the first target subtask based on the second subtask further includes:
[0015] If there is no unfinished third subtask currently, obtaining the first priority of the second subtask, wherein the second priority of the third subtask is greater than the third priority of the first subtask;
[0016] The first target subtask is determined based on the first priority and the third priority.
[0017] In one embodiment, the step of determining the first target subtask based on the first priority and the third priority includes:
[0018] If the first priority is greater than the third priority, taking the second subtask as the first target subtask;
[0019] If the first priority is less than or equal to the third priority, the first subtask is taken as the first target subtask to continue executing the first subtask.
[0020] In one embodiment, the step of determining the first target subtask based on the first priority of the first target subtask and the second priority of the second subtask further includes:
[0021] If there is currently an uncompleted second subtask, the first target subtask is determined based on the first priority and the second priority.
[0022] In one embodiment, the step of determining the first target subtask based on the first priority and the second priority includes:
[0023] If the first priority is greater than the second priority, stopping execution of the third subtask and taking the second subtask as the first target subtask;
[0024] If the first priority is less than or equal to the second priority, the third subtask is taken as the first target subtask to continue executing the third subtask.
[0025] In one embodiment, the task scheduling method further includes:
[0026] If no interrupt instruction is currently received, periodically obtain the fourth subtask with the highest priority in the current priority index table, and determine the second target subtask based on the fourth subtask;
[0027] Execute the second target subtask, and delete the second target subtask in the priority index table.
[0028] In one embodiment, the step of determining the second target subtask based on the fourth subtask includes:
[0029] If there is currently an uncompleted fifth subtask, obtaining the fourth priority of the fourth subtask and the fifth priority of the fifth subtask;
[0030] Based on the fourth priority and the fifth priority, the second target subtask is determined.
[0031] In one embodiment, the step of determining the second target subtask based on the fourth priority and the fifth priority includes:
[0032] determining whether the fourth priority is greater than the fifth priority;
[0033] If the fourth priority is greater than the fifth priority, the fifth subtask is stopped from being executed, and the fourth subtask is used as the second target subtask.
[0034] In one embodiment, after the step of determining whether the fourth priority is greater than the fifth priority, the method further includes:
[0035] If the fourth priority is less than or equal to the fifth priority, the fifth subtask is used as the second target subtask to continue executing the fifth subtask.
[0036] In one embodiment, the step of determining the second target subtask based on the fourth subtask further includes:
[0037] If there is no uncompleted fifth subtask currently, the fourth subtask is used as the second target subtask.
[0038] In one embodiment, the interruption instruction includes a key instruction triggered by a key of the smart gas stove and a safety alarm instruction triggered by a sensor.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also provides a smart gas stove, which includes: a memory, a processor, and a task scheduling program stored in the memory and executable on the processor, and the task scheduling program implements the steps of the aforementioned task scheduling method when executed by the processor.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a task scheduling program is stored, and when the task scheduling program is executed by a processor, the steps of the above-mentioned task scheduling method are implemented.
[0041] The present invention divides the to-be-executed task corresponding to the interrupt instruction into multiple interrupt subtasks when receiving the interrupt instruction, obtains the first priority of each interrupt subtask, then stops the currently executed first subtask, and executes each interrupt subtask based on the first priority of each interrupt subtask. By stopping the currently executed subtask and then executing each interrupt subtask, timely execution of the interrupt subtask is achieved, thus avoiding the situation where the emergency task is not executed in time and is lost. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a structural schematic diagram of an intelligent gas stove in a hardware operating environment involved in an embodiment of the present invention;
[0043] Figure 2 It is a flowchart of the first embodiment of the task scheduling method of the present invention.
[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0046] like Figure 1 As shown, Figure 1 It is a structural schematic diagram of an intelligent gas stove in a hardware operating environment involved in an embodiment of the present invention.
[0047] like Figure 1As shown, the smart gas stove may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0048] Optionally, the smart gas stove may also include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. Among them, the sensors include light sensors, motion sensors, and other sensors. Of course, the smart gas stove may also be equipped with other sensors such as a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be described in detail here.
[0049] Those skilled in the art will understand that Figure 1 The terminal structure shown in the figure does not constitute a limitation on the intelligent gas stove, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0050] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a task scheduling program.
[0051] exist Figure 1 In the smart gas stove shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the task scheduling program stored in the memory 1005.
[0052] In this embodiment, the smart gas stove includes: a memory 1005, a processor 1001, and a task scheduler stored in the memory 1005 and executable on the processor 1001, wherein the processor 1001 calls the task scheduler stored in the memory 1005 and performs the following operations:
[0053] When receiving an interrupt instruction, dividing the to-be-executed task corresponding to the interrupt instruction into a plurality of interrupt subtasks, and obtaining the first priority of each interrupt subtask;
[0054] The currently executed first subtask is stopped, and each interrupt subtask is executed based on the first priority of each interrupt subtask.
[0055] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0056] The step of executing each interrupt subtask based on the first priority of each interrupt subtask includes:
[0057] Based on the priority of each interrupt subtask, each interrupt subtask is added to the priority index table, wherein the priority of each interrupt subtask is greater than the priority of other subtasks except the interrupt subtask;
[0058] Based on the priority index table, each interrupt subtask is executed in sequence.
[0059] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0060] The step of sequentially executing each interrupt subtask based on the priority index table includes:
[0061] Periodically obtain the second subtask with the highest priority in the current priority index table, and determine the first target subtask based on the second subtask;
[0062] Execute the first target subtask, and delete the first target subtask from the priority index table.
[0063] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0064] The step of determining the first target subtask based on the second subtask also includes:
[0065] If there is no unfinished third subtask currently, obtaining the first priority of the second subtask, wherein the second priority of the third subtask is greater than the third priority of the first subtask;
[0066] The first target subtask is determined based on the first priority and the third priority.
[0067] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0068] The step of determining the first target subtask based on the first priority and the third priority includes:
[0069] If the first priority is greater than the third priority, taking the second subtask as the first target subtask;
[0070] If the first priority is less than or equal to the third priority, the first subtask is taken as the first target subtask to continue executing the first subtask.
[0071] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0072] The step of determining the first target subtask based on the first priority of the first target subtask and the second priority of the second subtask further includes:
[0073] If there is currently an uncompleted second subtask, the first target subtask is determined based on the first priority and the second priority.
[0074] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0075] The step of determining the first target subtask based on the first priority and the second priority includes:
[0076] If the first priority is greater than the second priority, stopping execution of the third subtask and taking the second subtask as the first target subtask;
[0077] If the first priority is less than or equal to the second priority, the third subtask is taken as the first target subtask to continue executing the third subtask.
[0078] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0079] The task scheduling method further includes:
[0080] If no interrupt instruction is currently received, periodically obtain the fourth subtask with the highest priority in the current priority index table, and determine the second target subtask based on the fourth subtask;
[0081] Execute the second target subtask, and delete the second target subtask in the priority index table.
[0082] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0083] The step of determining the second target subtask based on the fourth subtask comprises:
[0084] If there is currently an uncompleted fifth subtask, obtaining the fourth priority of the fourth subtask and the fifth priority of the fifth subtask;
[0085] Based on the fourth priority and the fifth priority, the second target subtask is determined.
[0086] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0087] The step of determining the second target subtask based on the fourth priority and the fifth priority includes:
[0088] determining whether the fourth priority is greater than the fifth priority;
[0089] If the fourth priority is greater than the fifth priority, the fifth subtask is stopped from being executed, and the fourth subtask is used as the second target subtask.
[0090] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0091] After the step of determining whether the fourth priority is greater than the fifth priority, the method further includes:
[0092] If the fourth priority is less than or equal to the fifth priority, the fifth subtask is used as the second target subtask to continue executing the fifth subtask.
[0093] Further, the processor 1001 may call the task scheduling program stored in the memory 1005, and further perform the following operations:
[0094] The step of determining the second target subtask based on the fourth subtask also includes:
[0095] If there is no uncompleted fifth subtask currently, the fourth subtask is used as the second target subtask.
[0096] Furthermore, the processor 1001 may call the task scheduling program stored in the memory 1005 and perform the following operations: the interruption instruction includes a key instruction triggered by a key of the smart gas stove and a safety alarm instruction triggered by a sensor.
[0097] The present invention also provides a task scheduling method, referring to Figure 2 , Figure 2 It is a flowchart of the first embodiment of the task scheduling method of the present invention.
[0098] In this embodiment, the task scheduling method is applied to an intelligent gas stove, which includes an intelligent control module, a temperature detection sensor, a combustible gas detector, a safety protection device, a display screen, a gas control valve, etc. Specifically, the task scheduling method includes the following steps:
[0099] Step S101, when an interrupt instruction is received, the to-be-executed task corresponding to the interrupt instruction is divided into a plurality of interrupt subtasks, and the first priority of each interrupt subtask is obtained;
[0100] In this embodiment, the interruption instruction includes a key instruction triggered by a button of the smart gas stove and a safety alarm instruction triggered by a sensor. For example, during the operation of the smart gas stove, when the user controls the smart gas stove through the buttons on the control panel of the smart gas stove, the smart gas stove will receive the key instruction triggered by the button. Alternatively, during the operation of the smart gas stove, the temperature detected by the temperature detection sensor is greater than the preset temperature threshold, which will trigger a safety alarm instruction for excessive temperature. Alternatively, during the operation of the smart gas stove, the combustible gas detector detects that the combustible gas concentration in the environment where the smart gas stove is located exceeds the preset concentration, which will trigger a safety alarm instruction for combustible gas leakage.
[0101] In this embodiment, if an interrupt instruction is received, the task to be executed corresponding to the interrupt instruction is obtained, and the task to be executed is divided into multiple interrupt sub-tasks, that is, the task to be executed is divided into multiple sub-tasks that can be executed separately, and the first priority of each interrupt sub-task is obtained. Specifically, according to the function of the program corresponding to the task to be executed, the main body of the program is divided into independent, infinitely looping and non-returning small programs, namely interrupt sub-tasks. Each interrupt sub-task is independent and does not interfere with each other, and each interrupt sub-task has its own priority. The interrupt sub-task is managed by the system scheduling center. At the same time, each interrupt sub-task is assigned a maximum running time, and the priority of each interrupt sub-task is greater than the priority of other sub-tasks except the interrupt sub-task.
[0102] Step S102 , stopping the currently executed first subtask, and executing each interruption subtask based on the first priority of each interruption subtask.
[0103] In this embodiment, for normal tasks executed by the intelligent gas stove except the tasks to be executed corresponding to the interrupt instruction, the program of each task is uniformly decomposed into multiple small, schedulable, and serialized subtasks. For example, the acquisition and display task includes collecting data through sensors and displaying the data through a display screen. The acquisition and display task can be decomposed into two subtasks, one acquisition subtask continuously reads sensor data and writes the data to a shared memory, and the other display subtask periodically reads data from the shared memory and outputs the sensor data to the display screen. Among them, each subtask is provided with a corresponding priority, wherein the priority of the acquisition subtask is higher than the priority of the display subtask. In this embodiment, the priority is set to 32, that is, 0 to 31 levels, 0 and 31 are the lowest priority and the highest priority respectively, and the priority index table includes the 32-bit priority. When a subtask exists at a certain position in the priority index table, it indicates that the subtask corresponding to the position is in a ready state.
[0104] In this embodiment, after obtaining the first priority of each interrupt subtask, the currently executing first subtask is stopped, the subtask being executed is interrupted by the newly generated interrupt, and at the same time, the scene is protected and the scene of the first subtask is saved to facilitate the subsequent execution of the first subtask; then, based on the first priority of each interrupt subtask, each interrupt subtask is executed, specifically, each interrupt subtask is executed in order from high to low priority in the first priority.
[0105] The task scheduling method proposed in this embodiment divides the to-be-executed task corresponding to the interrupt instruction into multiple interrupt subtasks when an interrupt instruction is received, obtains the first priority of each interrupt subtask, then stops the currently executed first subtask, and executes each interrupt subtask based on the first priority of each interrupt subtask. By stopping the currently executed subtask and then executing each interrupt subtask, timely execution of the interrupt subtask is achieved, thereby avoiding the situation where the emergency task is not executed in time and is lost.
[0106] Based on the first embodiment, a second embodiment of the task scheduling method of the present invention is proposed. In this embodiment, step S102 includes:
[0107] Step S201, adding each interruption subtask to a priority index table based on the priority of each interruption subtask, wherein the priority of each interruption subtask is greater than the priority of other subtasks except the interruption subtask;
[0108] Step S202: Execute each interrupt subtask in sequence based on the priority index table.
[0109] In this embodiment, the priority of each interrupt subtask is greater than the priority of other subtasks except the interrupt subtask. After obtaining the priority of each interrupt subtask, each interrupt subtask is added to the priority index table according to the priority of each interrupt subtask. Specifically, the priority index table includes the position (address) corresponding to each priority. The interrupt subtask is added to the corresponding position in the priority index table according to the priority of each interrupt subtask. Then, according to the priority index table, each interrupt subtask is executed in sequence to ensure that the interrupt subtask with a high priority is executed first.
[0110] The task scheduling method proposed in this embodiment adds each interrupt subtask to a priority index table based on the order of priority of each interrupt subtask, wherein the first priority is greater than the priority of other subtasks except the interrupt subtask, and then executes each interrupt subtask in sequence based on the priority index table. The orderly execution of each interrupt subtask is achieved through the priority index table, and each interrupt subtask is executed in time, thereby avoiding the situation where an emergency task is not executed in time and is lost.
[0111] Based on the second embodiment, a third embodiment of the task scheduling method of the present invention is proposed. In this embodiment, step S202 includes:
[0112] Step S301, periodically obtaining the second subtask with the highest priority in the current priority index table, and determining the first target subtask based on the second subtask;
[0113] Step S302: execute the first target subtask and delete the first target subtask from the priority index table.
[0114] In the present embodiment, a time metronome of the control system of the smart gas stove is pre-set, and the metronome represents the minimum scheduling unit cycle of the control system, that is, the time interval for periodically obtaining the second subtask. The control system scans the priority index table at the arrival of each cycle to realize periodic scanning of the priority index table. Specifically, after adding each interrupt subtask to the priority index table, the second subtask with the highest priority in the current priority index table is periodically obtained, and the first target subtask is determined based on the second subtask, and then the first target subtask is executed, and the first target subtask is deleted from the priority index table. Specifically, if the first target subtask currently exists in the priority index table, the first target subtask is deleted from the priority index table.
[0115] The task scheduling method proposed in this embodiment periodically obtains the second subtask with the highest priority in the current priority index table, determines the first target subtask based on the second subtask, then executes the first target subtask, and deletes the first target subtask in the priority index table. The target subtask is determined according to the subtask with the highest priority in the priority index table to achieve timely execution of the interrupted subtask, further avoiding the situation where the emergency task is not executed in time and is lost.
[0116] Based on the third embodiment, a fourth embodiment of the task scheduling method of the present invention is proposed. In this embodiment, step S301 includes:
[0117] Step S401, if there is no unfinished third subtask, obtaining the first priority of the second subtask, wherein the second priority of the third subtask is greater than the third priority of the first subtask;
[0118] Step S402: determining the first target subtask based on the first priority and the third priority.
[0119] In this embodiment, after obtaining the second subtask, it is determined whether there is an unfinished third subtask, the third subtask is different from the first subtask, and the second priority of the third subtask is greater than the third priority of the first subtask; if there is no unfinished third subtask, the first priority of the second subtask is obtained, for example, the first priority is obtained through a priority index table.
[0120] Then, based on the first priority and the third priority, the first target subtask is determined.
[0121] Specifically, in one embodiment, step S402 includes:
[0122] Step a: if the first priority is greater than the third priority, taking the second subtask as the first target subtask;
[0123] Step b: If the first priority is less than or equal to the third priority, taking the first subtask as the first target subtask to continue executing the first subtask.
[0124] In this embodiment, after obtaining the first priority and the third priority, it is determined whether the first priority is greater than the third priority. If the first priority is greater than the third priority, the second subtask is used as the first target subtask, otherwise the first subtask is used as the first target subtask to continue executing the first subtask, thereby executing the subtask with the highest priority to ensure that the subtask with the highest priority is executed in a timely manner.
[0125] Furthermore, in one embodiment, step S301 further includes:
[0126] Step c: if there is currently an uncompleted second subtask, determining the first target subtask based on the first priority and the second priority.
[0127] Furthermore, in one embodiment, the steps include:
[0128] Step d: if the first priority is greater than the second priority, stop executing the third subtask and use the second subtask as the first target subtask;
[0129] Step e: if the first priority is less than or equal to the second priority, taking the third subtask as the first target subtask to continue executing the third subtask.
[0130] In this embodiment, after obtaining the first priority and the second priority, it is determined whether the first priority is greater than the second priority. If the first priority is greater than the second priority, the second subtask is used as the first target subtask, otherwise the third subtask is used as the first target subtask to continue executing the third subtask, thereby executing the subtask with the highest priority to ensure that the subtask with the highest priority is executed in a timely manner.
[0131] The task scheduling method proposed in this embodiment obtains the first priority of the second subtask if there is no unfinished third subtask at present, wherein the second priority of the third subtask is greater than the third priority of the first subtask; then determines the first target subtask based on the first priority and the third priority, and executes the subtask with the highest priority in time by accurately determining the first target subtask according to the priority.
[0132] Based on the above embodiments, a fifth embodiment of the task scheduling method of the present invention is proposed. In this embodiment, the task scheduling method further includes:
[0133] Step S501, if no interruption instruction is currently received, periodically obtain the fourth subtask with the highest priority in the current priority index table, and determine the second target subtask based on the fourth subtask;
[0134] Step S502: execute the second target subtask and delete the second target subtask in the priority index table.
[0135] In this embodiment, if no interrupt instruction is received, the fourth subtask with the highest priority in the current priority index table is obtained in a timely manner, that is, the fourth subtask with the highest priority in the priority index table is queried in a timely manner through the metronome of the smart gas stove, and then the second target subtask is determined based on the fourth subtask, and then the second target subtask is executed, and the second target subtask is deleted from the priority index table. Specifically, if the second target subtask exists in the priority index table, the second target subtask is deleted from the priority index table to execute the subtask with the highest current priority.
[0136] The task scheduling method proposed in this embodiment is as follows: if no interrupt instruction is currently received, the fourth subtask with the highest priority in the current priority index table is periodically obtained, and the second target subtask is determined based on the fourth subtask; then the second target subtask is executed, and the second target subtask is deleted from the priority index table, so that the smart gas stove executes the subtask with the highest priority, thereby ensuring that high-priority tasks are executed in a timely manner.
[0137] Based on the fifth embodiment, a sixth embodiment of the task scheduling method of the present invention is proposed. In this embodiment, step S502 includes:
[0138] Step S601, if there is currently an uncompleted fifth subtask, obtaining the fourth priority of the fourth subtask and the fifth priority of the fifth subtask;
[0139] Step S602: Determine the second target subtask based on the fourth priority and the fifth priority.
[0140] In this embodiment, after the fourth subtask is obtained, it is determined whether there is an unfinished fifth subtask. If there is no unfinished fifth subtask, the fourth priority of the fourth subtask is obtained, for example, by using a priority index table. Then, based on the fourth priority and the fifth priority, the second target subtask is determined.
[0141] Further, in one embodiment, step S602 includes:
[0142] Step f, determining whether the fourth priority is greater than the fifth priority;
[0143] Step g: if the fourth priority is greater than the fifth priority, stop executing the fifth subtask and use the fourth subtask as the second target subtask.
[0144] In this embodiment, after obtaining the fourth priority and the fifth priority, it is determined whether the fourth priority is greater than the fifth priority. If the fourth priority is greater than the fifth priority, the execution of the fifth subtask is stopped, and the fourth subtask is used as the second target subtask to ensure that the subtask with the highest priority is executed in a timely manner.
[0145] Furthermore, in yet another embodiment, step S602 further includes:
[0146] Step h: if the fourth priority is less than or equal to the fifth priority, taking the fifth subtask as the second target subtask to continue executing the fifth subtask.
[0147] In this embodiment, if the fourth priority is less than or equal to the fifth priority, the fifth subtask is used as the second target subtask to continue executing the fifth subtask, thereby executing the subtask with the highest priority.
[0148] Furthermore, in yet another embodiment, step S502 further includes:
[0149] Step i: If there is no unfinished fifth subtask, the fourth subtask is used as the second target subtask.
[0150] However, the present design is not limited to this. In other embodiments, if other tasks to be executed other than the task to be executed corresponding to the interrupt instruction are received, the other tasks to be executed are divided into multiple ordinary subtasks, and the priority of each ordinary subtask is obtained, and then based on the priority of each ordinary subtask, each ordinary subtask is added to the priority index table.
[0151] Among them, if there is a subtask with the same priority as the ordinary subtask to be added in the priority index table, the ready time of the subtask with the same priority and the ordinary subtask are respectively noted, and step S501 includes: if the subtask with the highest priority in the current priority index table is obtained regularly, and there are multiple subtasks, then the subtask with the earliest ready time among the multiple subtasks with the highest priority is used as the fourth subtask. Alternatively, if there is a subtask with the same priority as the ordinary subtask to be added in the priority index table, when the subtask with the same priority is scheduled for execution, the ordinary subtask is added to the priority index table.
[0152] The task scheduling method proposed in this embodiment obtains the fourth priority of the fourth subtask and the fifth priority of the fifth subtask if there is currently an unfinished fifth subtask; then determines the second target subtask based on the fourth priority and the fifth priority, and determines the second target subtask based on the fourth priority and the fifth priority, so that the smart gas stove executes the subtask with the highest priority, thereby ensuring that high-priority tasks are executed in a timely manner.
[0153] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a task scheduling program is stored. When the task scheduling program is executed by a processor, the following operations are implemented:
[0154] When receiving an interrupt instruction, dividing the to-be-executed task corresponding to the interrupt instruction into a plurality of interrupt subtasks, and obtaining the first priority of each interrupt subtask;
[0155] The currently executed first subtask is stopped, and each interrupt subtask is executed based on the first priority of each interrupt subtask.
[0156] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0157] The step of executing each interrupt subtask based on the first priority of each interrupt subtask includes:
[0158] Based on the priority of each interrupt subtask, each interrupt subtask is added to the priority index table, wherein the priority of each interrupt subtask is greater than the priority of other subtasks except the interrupt subtask;
[0159] Based on the priority index table, each interrupt subtask is executed in sequence.
[0160] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0161] The step of sequentially executing each interrupt subtask based on the priority index table includes:
[0162] Periodically obtain the second subtask with the highest priority in the current priority index table, and determine the first target subtask based on the second subtask;
[0163] Execute the first target subtask, and delete the first target subtask from the priority index table.
[0164] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0165] The step of determining the first target subtask based on the second subtask also includes:
[0166] If there is no unfinished third subtask currently, obtaining the first priority of the second subtask, wherein the second priority of the third subtask is greater than the third priority of the first subtask;
[0167] The first target subtask is determined based on the first priority and the third priority.
[0168] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0169] The step of determining the first target subtask based on the first priority and the third priority includes:
[0170] If the first priority is greater than the third priority, taking the second subtask as the first target subtask;
[0171] If the first priority is less than or equal to the third priority, the first subtask is taken as the first target subtask to continue executing the first subtask.
[0172] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0173] The step of determining the first target subtask based on the first priority of the first target subtask and the second priority of the second subtask further includes:
[0174] If there is currently an uncompleted second subtask, the first target subtask is determined based on the first priority and the second priority.
[0175] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0176] The step of determining the first target subtask based on the first priority and the second priority includes:
[0177] If the first priority is greater than the second priority, stopping execution of the third subtask and taking the second subtask as the first target subtask;
[0178] If the first priority is less than or equal to the second priority, the third subtask is taken as the first target subtask to continue executing the third subtask.
[0179] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0180] The task scheduling method further includes:
[0181] If no interrupt instruction is currently received, periodically obtain the fourth subtask with the highest priority in the current priority index table, and determine the second target subtask based on the fourth subtask;
[0182] Execute the second target subtask, and delete the second target subtask in the priority index table.
[0183] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0184] The step of determining the second target subtask based on the fourth subtask comprises:
[0185] If there is currently an uncompleted fifth subtask, obtaining the fourth priority of the fourth subtask and the fifth priority of the fifth subtask;
[0186] Based on the fourth priority and the fifth priority, the second target subtask is determined.
[0187] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0188] The step of determining the second target subtask based on the fourth priority and the fifth priority includes:
[0189] determining whether the fourth priority is greater than the fifth priority;
[0190] If the fourth priority is greater than the fifth priority, the fifth subtask is stopped from being executed, and the fourth subtask is used as the second target subtask.
[0191] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0192] After the step of determining whether the fourth priority is greater than the fifth priority, the method further includes:
[0193] If the fourth priority is less than or equal to the fifth priority, the fifth subtask is used as the second target subtask to continue executing the fifth subtask.
[0194] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0195] The step of determining the second target subtask based on the fourth subtask also includes:
[0196] If there is no uncompleted fifth subtask currently, the fourth subtask is used as the second target subtask.
[0197] Furthermore, when the task scheduling program is executed by the processor, the following operations are also implemented:
[0198] The interruption instruction includes a key instruction triggered by a key of the smart gas stove and a safety alarm instruction triggered by a sensor.
[0199] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0200] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0201] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0202] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A task scheduling method, applied to a smart gas stove, characterized in that: The task scheduling method comprises the following steps: When receiving an interrupt instruction, dividing the to-be-executed task corresponding to the interrupt instruction into a plurality of interrupt subtasks, and obtaining the first priority of each interrupt subtask; Stop the currently executed first subtask, and execute each interrupt subtask based on the first priority of each interrupt subtask; The step of executing each interrupt subtask based on the first priority of each interrupt subtask includes: Based on the priority of each interrupt subtask, each interrupt subtask is added to the priority index table, wherein the priority of each interrupt subtask is greater than the priority of other subtasks except the interrupt subtask; Periodically obtain the second subtask with the highest priority in the current priority index table, and if there is no unfinished third subtask, obtain the first priority of the second subtask, wherein the second priority of the third subtask is greater than the third priority of the first subtask; Determining a first target subtask based on the first priority and the third priority; Execute the first target subtask, and delete the first target subtask from the priority index table.
2. The task scheduling method according to claim 1, characterized in that: The step of determining the first target subtask based on the first priority and the third priority includes: If the first priority is greater than the third priority, taking the second subtask as the first target subtask; If the first priority is less than or equal to the third priority, the first subtask is taken as the first target subtask to continue executing the first subtask.
3. The task scheduling method according to claim 1, characterized in that: The step of determining the first target subtask based on the first priority of the first target subtask and the second priority of the second subtask further includes: If there is currently an uncompleted second subtask, the first target subtask is determined based on the first priority and the second priority.
4. The task scheduling method according to claim 3, characterized in that: The step of determining the first target subtask based on the first priority and the second priority includes: If the first priority is greater than the second priority, stopping execution of the third subtask and taking the second subtask as the first target subtask; If the first priority is less than or equal to the second priority, the third subtask is taken as the first target subtask to continue executing the third subtask.
5. The task scheduling method according to claim 1, characterized in that: The task scheduling method further includes: If no interrupt instruction is currently received, periodically obtain the fourth subtask with the highest priority in the current priority index table, and determine the second target subtask based on the fourth subtask; Execute the second target subtask, and delete the second target subtask in the priority index table.
6. The task scheduling method according to claim 5, characterized in that: The step of determining the second target subtask based on the fourth subtask comprises: If there is currently an uncompleted fifth subtask, obtaining the fourth priority of the fourth subtask and the fifth priority of the fifth subtask; Based on the fourth priority and the fifth priority, the second target subtask is determined.
7. The task scheduling method according to claim 6, characterized in that: The step of determining the second target subtask based on the fourth priority and the fifth priority includes: determining whether the fourth priority is greater than the fifth priority; If the fourth priority is greater than the fifth priority, the fifth subtask is stopped from being executed, and the fourth subtask is used as the second target subtask.
8. The task scheduling method according to claim 7, characterized in that: After the step of determining whether the fourth priority is greater than the fifth priority, the method further includes: If the fourth priority is less than or equal to the fifth priority, the fifth subtask is used as the second target subtask to continue executing the fifth subtask.
9. The task scheduling method according to claim 6, characterized in that: The step of determining the second target subtask based on the fourth subtask also includes: If there is no uncompleted fifth subtask currently, the fourth subtask is used as the second target subtask.
10. The task scheduling method according to any one of claims 1 to 9, characterized in that: The interruption instruction includes a key instruction triggered by a key of the smart gas stove and a safety alarm instruction triggered by a sensor.
11. An intelligent gas stove, characterized in that: The smart gas stove comprises: a memory, a processor, and a task scheduling program stored in the memory and executable on the processor. When the task scheduling program is executed by the processor, the steps of the task scheduling method according to any one of claims 1 to 10 are implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a task scheduling program, and when the task scheduling program is executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Multi-task management method and intelligent watches
CN108762897A