A method, system, device, and computer-readable storage medium for task processing
By using cache queues and waiting execution queues in the cloud platform, conflicts are judged based on tasks' mutex marks and pre-stores, the problem of inefficient task execution on cloud platform is solved, and efficient task execution and full utilization of resources are achieved.
Patent Information
- Application Number
- CN202210453012.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-04-27
AI Technical Summary
When cloud platforms execute tasks, the execution efficiency is inefficient due to conflicts between tasks and waste computing resources. The existing technology cannot effectively solve this problem by using serial execution methods.
By using cache queues and waiting execution queues in the cloud platform, task conflicts are judged based on the task's mutex task marking and pre-stored mutex task library, avoid conflicting tasks being executed simultaneously, and execute tasks to be executed after the conflict is terminated, improving task execution efficiency.
It effectively avoids task conflicts, improves the task execution efficiency of the cloud platform, makes full use of computing resources, and realizes the simultaneous execution of multiple tasks.
Smart Images

Figure CN114661479B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of task execution, and particularly to a method, a system, a device, and a computer-readable storage medium for processing tasks. Background Art
[0002] When a cloud platform is running, it usually requires a virtualization platform to provide virtual resources for the cloud platform. The cloud platform and the virtualization platform are two independent platforms. When the virtual resources of the virtualization platform change, such as during the daily maintenance or update of the virtualization platform, the virtualization platform will send information to the cloud platform to inform it of the change in its virtual resources, so that the cloud platform can obtain new virtual resources in a timely manner. However, when the cloud platform executes certain tasks, it will also cause changes in the virtual resources of the virtualization platform. At this time, the virtualization platform will also send information to the cloud platform, causing the cloud platform to execute the task of obtaining the current virtual resources, which is equivalent to the cloud platform misidentifying abnormal virtual resources as new virtual resources, ultimately affecting subsequent other tasks of the cloud platform; for tasks unrelated to virtual resources, there may also be conflict situations. For example, the cloud platform itself cannot execute the power-on and power-off tasks simultaneously, otherwise it may cause logical errors in the cloud platform. It can be seen that some tasks of the cloud platform conflict with each other.
[0003] The prior art adopts a serial execution method for the cloud platform to execute each task, that is, each task is executed in sequence and only one task is executed at the same time. For example, when the cloud platform executes certain tasks that cause changes in the virtual resources of the virtualization platform, after the virtualization platform sends information to the cloud platform, the cloud platform will not immediately execute the task of obtaining virtual resources, but will wait until the currently executed task ends and then execute the task of obtaining virtual resources to avoid task conflicts. However, the serial execution method has the problems of low task execution efficiency and waste of computing power resources of the cloud platform. Summary of the Invention
[0004] The object of the present invention is to provide a method, a system, a device, and a computer-readable storage medium for processing tasks, which can avoid the simultaneous execution of conflicting tasks, improve the task execution efficiency of the cloud platform at the same time, and effectively utilize the computing power resources of the cloud platform because multiple tasks that do not conflict with each other can be executed simultaneously.
[0005] To solve the above technical problems, the present invention provides a method for processing tasks, including:
[0006] When a request for a task to be executed is obtained, it is determined whether there is an existing task that conflicts with the task to be executed according to the information of each existing task stored in the cache queue. The information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed.
[0007] If there is no existing task conflicting with the to-be-executed task, execute the to-be-executed task and store the information of the to-be-executed task into the cache queue;
[0008] If there is an existing task conflicting with the to-be-executed task, add the to-be-executed task to the waiting execution queue;
[0009] After determining that the information of the existing task conflicting with the to-be-executed task is removed from the cache queue, extract the to-be-executed task from the waiting execution queue, execute the to-be-executed task and store the information of the to-be-executed task into the cache queue.
[0010] Preferably, judging whether there is an existing task conflicting with the to-be-executed task according to the information of each existing task stored in the cache queue includes:
[0011] Obtain the mutex task mark of the to-be-executed task;
[0012] Judge whether there is an existing task in the mutex task mark of the to-be-executed task according to the information of each existing task;
[0013] If there is an existing task in the mutex task mark of the to-be-executed task, it is determined that there is an existing task conflicting with the to-be-executed task;
[0014] If there is no existing task in the mutex task mark of the to-be-executed task, it is determined that there is no existing task conflicting with the to-be-executed task.
[0015] Preferably, determining that the information of the existing task conflicting with the to-be-executed task is removed from the cache queue includes:
[0016] When the information of any existing task is removed from the cache queue, judge whether the to-be-executed task exists in the mutex task mark of the existing task;
[0017] If it exists, determine that the information of the existing task conflicting with the to-be-executed task is removed from the cache queue.
[0018] Preferably, before adding the to-be-executed task to the waiting execution queue, it further includes:
[0019] Judge whether there is a task in the tasks of the waiting execution queue that is the same as the to-be-executed task;
[0020] If there is no task that is the same as the to-be-executed task, add the to-be-executed task to the waiting execution queue;
[0021] If there is a task that is the same as the to-be-executed task, discard the to-be-executed task.
[0022] Preferably, determining whether there is a task among the tasks in the waiting execution queue that is the same as the to-be-executed task includes:
[0023] Obtain the first identification value of the to-be-executed task;
[0024] Determine whether there is a second identification value among the second identification values corresponding to the tasks in the waiting execution queue that is the same as the first identification value;
[0025] If so, it is determined that there is a task that is the same as the to-be-executed task;
[0026] If not, it is determined that there is no task that is the same as the to-be-executed task.
[0027] Preferably, before determining whether there is an existing task that conflicts with the to-be-executed task according to the information of each existing task stored in the cache queue, it further includes:
[0028] Determine whether the to-be-executed task exists in the pre-stored mutually exclusive task library;
[0029] If it does not exist in the pre-stored mutually exclusive task library, execute the to-be-executed task;
[0030] If it exists in the pre-stored mutually exclusive task library, enter the step of determining whether there is an existing task that conflicts with the to-be-executed task according to the information of each existing task stored in the cache queue.
[0031] Preferably, before determining whether there is an existing task that conflicts with the to-be-executed task according to the information of each existing task stored in the cache queue, it further includes:
[0032] Determine whether there is an existing task that is the same as the to-be-executed task according to the information of each existing task;
[0033] If there is, discard the to-be-executed task;
[0034] If not, enter the step of determining whether there is an existing task that conflicts with the to-be-executed task according to the information of each existing task stored in the cache queue.
[0035] This application also provides a task processing system, including:
[0036] A conflict judgment unit, configured to, when a request for a task to be executed is obtained, judge whether there is a conflict between an existing task and the task to be executed according to the information of each existing task stored in the cache queue, where the information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed;
[0037] A first execution unit, configured to, if there is no conflict between an existing task and the task to be executed, execute the task to be executed and store the information of the task to be executed in the cache queue;
[0038] A conflict handling unit, configured to, if there is a conflict between an existing task and the task to be executed, add the task to be executed to the waiting execution queue;
[0039] A second execution unit, configured to, after determining that the information of the existing task conflicting with the task to be executed is removed from the cache queue, extract the task to be executed from the waiting execution queue, execute the task to be executed and store the information of the task to be executed in the cache queue.
[0040] The present application further provides a task processing device, including:
[0041] A memory, configured to store a computer program;
[0042] A processor, configured to implement the steps of the task processing method as described above when executing the computer program.
[0043] The present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the task processing method as described above are implemented.
[0044] The present invention provides a task processing method, system, device and computer-readable storage medium, which relates to the field of cloud platform task execution. After obtaining a request for a task to be executed, it judges whether there is a conflict between an existing task and the task to be executed according to the information of each existing task stored in the cache queue. If there is no conflict between an existing task and the task to be executed, the task to be executed is executed and the information of the task to be executed is added to the cache queue. If there is a conflict, the task to be executed is added to the waiting execution queue until, after determining that the information of the existing task conflicting with the task to be executed is removed from the cache queue, the task to be executed is extracted and executed and its information is stored in the cache queue, which can avoid the simultaneous execution of conflicting tasks, improve the efficiency of cloud platform task execution at the same time, and effectively utilize the computing power resources of the cloud platform because multiple tasks that do not conflict with each other can be executed simultaneously. Description of the Drawings
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required in the prior art and the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0046] Figure 1 It is a flowchart of a method for processing a task provided by this application;
[0047] Figure 2 It is a schematic structural diagram of a system for processing a task provided by this application;
[0048] Figure 3 It is a schematic structural diagram of a device for processing a task provided by this application. Detailed implementation manners
[0049] The core of the present invention is to provide a method, system, device and computer-readable storage medium for processing tasks, which can avoid the simultaneous execution of conflicting tasks, improve the task execution efficiency of the cloud platform at the same time, and effectively utilize the computing power resources of the cloud platform because multiple tasks that do not conflict with each other can be executed simultaneously.
[0050] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0051] Please refer to Figure 1 , Figure 1 It is a flowchart of a method for processing a task provided by this application, including:
[0052] S1: When a request for a task to be executed is obtained, determine whether there is a conflict between an existing task and the task to be executed according to the information of each existing task stored in the cache queue. The information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed;
[0053] S2: If there is no conflict between the existing task and the task to be executed, execute the task to be executed and store the information of the task to be executed in the cache queue;
[0054] S3: If there is a conflict between the existing task and the task to be executed, add the task to be executed to the waiting execution queue;
[0055] S4: After determining that the information of the existing task conflicting with the task to be executed is removed from the cache queue, extract the task to be executed from the queue of tasks to be executed, execute the task to be executed, and store the information of the task to be executed in the cache queue.
[0056] When a request for a task is obtained, the task is regarded as a task to be executed. At this time, the cloud platform may be executing some other logic, so the logic being executed is regarded as an existing task. The maximum number of existing tasks being executed simultaneously is related to the maximum number of tasks that the cloud platform can execute simultaneously. Considering that the task to be executed may conflict with an existing task, if these two tasks are executed simultaneously, it will affect subsequent other tasks. For example, when an existing task is to perform calculations using the current virtual resources, and the task to be executed is to obtain new virtual resources, if these two tasks are executed simultaneously, the existing task may regard the new virtual resources as the current virtual resources, resulting in a calculation result that is not the originally desired result, and further causing subsequent other tasks to go wrong.
[0057] To avoid the impact caused by task conflicts, in this application, after obtaining a request for a task to be executed, the task to be executed is not immediately executed. Instead, it is first determined whether there is an existing task among the existing tasks currently being executed by the cloud platform that conflicts with the task to be executed. Specifically, since the impact caused by each task can be known in advance, for any task, it can be known in advance which tasks among all other tasks will conflict with it when executed simultaneously. Based on this, a mutually exclusive task mark can be set for any task, that is, all other tasks that conflict with this task are recorded on the mutually exclusive task mark of this task. When a task starts to be executed, if it is known that the task does not conflict with any other task, the task will be directly executed and its information will not be added to the cache queue. If it is known that the task will conflict with a certain task when executed simultaneously, the relevant information of the task will be added to the cache queue. That is, the information stored in the cache queue is all information of tasks that will conflict with other tasks when executed simultaneously. After obtaining a request for a task to be executed, if it is determined that there is no existing task conflicting with the task to be executed, the task to be executed is executed. However, if it is determined that there is an existing task conflicting with the task to be executed, it can be seen that it is necessary to avoid these two tasks being executed simultaneously. Therefore, at this time, the task to be executed is first added to the waiting execution queue. After the information of the existing task conflicting with the task to be executed is removed from the cache queue, that is, after the existing task is executed, the task to be executed is then executed to avoid the impact caused by the conflict between the two tasks.
[0058] In summary, after receiving a request for a task to be executed, it is determined whether there is an existing task conflicting with the task to be executed according to the information of each existing task stored in the cache queue. If there is no existing task conflicting with the task to be executed, the task to be executed is executed and the information of the task to be executed is added to the cache queue. If there is a conflict, the task to be executed is added to the waiting execution queue until after the information of the existing task conflicting with the task to be executed is removed from the cache queue, and then the task to be executed is extracted and executed, and its information is stored in the cache queue. This can avoid the simultaneous execution of conflicting tasks, improve the task execution efficiency of the cloud platform, and effectively utilize the computing power resources of the cloud platform because multiple tasks that do not conflict with each other can be executed simultaneously.
[0059] Based on the above embodiments:
[0060] As a preferred embodiment, determining whether there is an existing task conflicting with the task to be executed according to the information of each existing task stored in the cache queue includes:
[0061] Obtain the mutex task flag of the task to be executed;
[0062] Determine whether there is an existing task in the mutex task flag of the task to be executed according to the information of each existing task;
[0063] If there is an existing task in the mutex task flag of the task to be executed, it is determined that there is an existing task conflicting with the task to be executed;
[0064] If there is no existing task in the mutex task flag of the task to be executed, it is determined that there is no existing task conflicting with the task to be executed.
[0065] To determine whether there is an existing task conflicting with the task to be executed, in this application, considering that the impact caused by a task during execution can be known in advance, the mutex tasks of each task can be determined in advance according to the impact caused by each task during execution. For example, when the cloud platform executes a virtual machine startup task, it can be known that this task needs to call resources related to virtual machine startup during execution, and further it can be known that this task conflicts with other tasks that can affect resources related to virtual machine startup. Therefore, for these two tasks, each needs to add the other to its own mutex task flag as its mutex task. It can be seen that after receiving a request for a task to be executed, it is judged according to the mutex task flag of the task to be executed. Since which tasks conflict with the task to be executed are marked in this flag, it is judged whether there is an existing task in these existing tasks being executed in this flag. If there is, it means there is an existing task conflicting with the task to be executed. If not, it means there is no existing task conflicting with the task to be executed. Based on this, it is possible to accurately and simply determine whether there is an existing task conflicting with the task to be executed.
[0066] As a preferred embodiment, determining the information of the existing task conflicting with the task to be executed and removing it from the cache queue includes:
[0067] When the information of any existing task is removed from the cache queue, it is judged whether there is a task to be executed in the mutual exclusion task flag of the existing task;
[0068] If it exists, determine that the information of the existing task conflicting with the task to be executed is removed from the cache queue.
[0069] Considering that after the information of the existing task conflicting with the task to be executed is removed from the cache queue, the task to be executed needs to be executed. In this application, in order to execute the task to be executed, it is necessary to judge according to the mutual exclusion task flag of the existing task. Specifically, for any task, the impact caused when the task is executed can be known in advance, so the mutual exclusion tasks of each task can be determined in advance according to the impact caused when the task is executed, and the other tasks conflicting with the task are added to the mutual exclusion task flag of the task. Since when the task to be executed conflicts with an existing task, the task to be executed will be added to the waiting execution queue instead of being executed, which is equivalent to temporarily shelving the task to be executed. Therefore, in order to resume the execution of the task to be executed, after the information of each existing task is removed from the cache queue, it is determined whether the task to be executed is the mutual exclusion task of the existing task according to the mutual exclusion task flag of the existing task. If it is a mutual exclusion task, it means that the existing task conflicting with the task to be executed has been executed, so as to execute the task to be executed subsequently. If it is not a mutual exclusion task, it means that there is no conflict between these two tasks, that is, at this time the task to be executed still conflicts with an existing task, so it is impossible to determine to execute the task to be executed at this time. Further, when there are multiple tasks to be executed in the waiting execution queue, after each existing task is executed, it is necessary to judge one by one according to the mutual exclusion task flag of the existing task whether there is a task to be executed among these tasks that is the mutual exclusion task of the existing task. If so, execute the corresponding task to be executed. Based on this, the task to be executed can be executed in time to improve the task execution efficiency of the cloud platform and avoid the shelving of tasks.
[0070] As a preferred embodiment, before adding the task to be executed to the waiting execution queue, it further includes:
[0071] Judge whether there is a task in the waiting execution queue that is the same as the task to be executed;
[0072] If there is no task that is the same as the task to be executed, add the task to be executed to the waiting execution queue;
[0073] If there is a task that is the same as the task to be executed, discard the task to be executed.
[0074] In order to avoid repeated execution of tasks, in this application, considering that there may be a problem of generating multiple instructions for a specified task when the specified task is not completed, in order to avoid repeated execution of the same task and reduce the storage burden on the cloud platform, before storing a to-be-executed task that conflicts with an existing task, it is first determined whether there is a task in the waiting execution queue that is exactly the same as the to-be-executed task. If so, it means that the to-be-executed task is a repeatedly generated task, and at this time, the to-be-executed task is discarded. For example, when the cloud platform wants to execute task A, but since task A may conflict with an existing task, it needs to be stored first and wait for a period of time. And the cloud platform finds that task A is still not completed within the specified time, and may generate an instruction for task A again, resulting in a situation of task duplication. When the second task A comes as a to-be-executed task, since task A already exists in the waiting execution queue, the second task A will be discarded to avoid repeated execution of the same task and reduce the storage burden on the cloud platform.
[0075] As a preferred embodiment, determining whether there is a task in the waiting execution queue that is the same as the to-be-executed task includes:
[0076] Obtaining a first identification value of the to-be-executed task;
[0077] Determining whether there is a second identification value among the second identification values corresponding to the tasks in the waiting execution queue that is the same as the first identification value;
[0078] If so, it is determined that there is a task that is the same as the to-be-executed task;
[0079] If not, it is determined that there is no task that is the same as the to-be-executed task.
[0080] In order to determine whether a to-be-executed task is the same as a task in the waiting execution queue, in this application, a unique identification value is set for each different task. This identification value corresponds one-to-one to a type of task, and this identification value can be, but is not limited to, a mapping value based on the corresponding task as a basic element, and it can only map out the corresponding task. Based on this, a linked list containing the mapping values of the stored tasks, that is, the waiting execution queue, can be established. After determining that the to-be-executed task conflicts with an existing task, according to the mapping value of the to-be-executed task, a mapping value that is the same as this mapping value is searched for in this linked list. If there is the same mapping value, it means that the to-be-executed task is a duplicate task. If there is no same mapping value, it means that the to-be-executed task does not exist in the waiting execution queue. Then, the mapping value of the to-be-executed task is recorded in the linked list for subsequent use. By the method of determining through the identification value, it can accurately determine whether the to-be-executed task is a duplicate task.
[0081] As a preferred embodiment, before determining whether there is a conflict between an existing task and a to-be-executed task according to the information of each existing task stored in the cache queue, it further includes:
[0082] Determine whether the to-be-executed task exists in the pre-stored mutually exclusive task library;
[0083] If it does not exist in the pre-stored mutually exclusive task library, execute the to-be-executed task;
[0084] If it exists in the pre-stored mutually exclusive task library, enter the step of determining whether there is a conflict between an existing task and the to-be-executed task according to the information of each existing task stored in the cache queue.
[0085] To improve the task execution efficiency of the cloud platform, in this application, for any task that the cloud platform can execute, the impact caused during the execution of the task can be known in advance, so whether each task will conflict with other tasks can also be known in advance. Therefore, all tasks that conflict with other tasks can be stored in a preset mutually exclusive task library in advance. When a to-be-executed task is obtained, first determine whether the to-be-executed task is in the preset mutually exclusive task library. If not, it means that the to-be-executed task will not conflict with any other task that the cloud platform can execute. So at this time, the to-be-executed task can be directly executed. If the to-be-executed task is in the preset mutually exclusive task library, it means that this task conflicts with a certain task. At this time, enter the subsequent step of determining whether there is a conflict between the existing task and the to-be-executed task. For example, among all the tasks that the cloud platform can execute, add an annotation or an identifier indicating the conflict between this task and other tasks to the tasks that conflict with other tasks. For example, when the cloud platform executes the boot task, if the boot task conflicts with the X task, an annotation indicating the conflict of "boot conflict" can be added to both the boot task and the X task to illustrate that these two tasks conflict and also illustrate that the conflicting part is in the function of "boot".
[0086] It can be seen that when a to-be-executed task is obtained, as long as it exists in the preset mutually exclusive task library, that is, when it has an annotation, no matter what type of annotation it has, as long as it has an annotation, it means that it conflicts with a certain task. At this time, enter the subsequent step of determining whether there is a conflict between the existing task and the to-be-executed task. If it does not exist in the preset mutually exclusive task library, directly execute the to-be-executed task. Based on this, the task execution efficiency of the cloud platform can be improved.
[0087] As a preferred embodiment, before determining whether there is a conflict between an existing task and a to-be-executed task according to the information of each existing task stored in the cache queue, it further includes:
[0088] Judge whether there is an existing task that is the same as the task to be executed according to the information of each existing task;
[0089] If there is, discard the task to be executed;
[0090] If not, enter the step of judging whether there is a conflict between the existing task and the task to be executed according to the information of each existing task stored in the cache queue.
[0091] In order to avoid duplicate execution of tasks, in this application, considering that there may be a problem of generating multiple instructions for the same task when the specified task is not completed, in order to avoid duplicate execution of the same task and reduce the storage burden of the cloud platform, when the task to be executed is obtained, first judge whether there is an existing task that is the same as the task to be executed among each existing task, that is, judge whether the task to be executed is one of the existing tasks that are currently being executed. If so, it means that the task to be executed is a duplicate task of an existing task. At this time, directly discard the task to be executed. Otherwise, enter the subsequent step of judging whether there is a conflict between the existing tasks that are currently being executed and the task to be executed.
[0092] For example, when the cloud platform is executing task Z, but there may be a situation where task Z exceeds the specified completion time of the cloud platform and is still not completed. The cloud platform may generate an instruction for task Z again, resulting in duplicate tasks. Therefore, when the second task Z comes as the task to be executed, since it is determined that there is already a task Z being executed, the second task Z will be discarded to avoid duplicate execution of the same task and reduce the storage burden of the cloud platform.
[0093] Please refer to Figure 2 , Figure 2 For a schematic structural diagram of a task processing system provided by this application, including:
[0094] A conflict judgment unit 21, configured to judge whether there is a conflict between an existing task and the task to be executed according to the information of each existing task stored in the cache queue when a request for the task to be executed is obtained. The information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed;
[0095] A first execution unit 22, configured to execute the task to be executed and store the information of the task to be executed in the cache queue if there is no conflict between the existing task and the task to be executed;
[0096] A conflict handling unit 23, configured to add the task to be executed to the waiting execution queue if there is a conflict between the existing task and the task to be executed;
[0097] The second execution unit 24 is configured to extract the to-be-executed task from the to-be-executed queue after determining that the information of the existing task conflicting with the to-be-executed task is removed from the cache queue, execute the to-be-executed task, and store the information of the to-be-executed task into the cache queue.
[0098] For a detailed introduction to a task processing system provided by the present application, please refer to the embodiments of the above-mentioned task processing method, which will not be elaborated herein.
[0099] Please refer to Figure 3 , Figure 3 which is a schematic structural diagram of a task processing device provided by the present application, including:
[0100] A memory 31 for storing computer programs;
[0101] A processor 32 for implementing the steps of the above-mentioned task processing method when executing the computer program.
[0102] For a detailed introduction to a task processing device provided by the present application, please refer to the embodiments of the above-mentioned task processing method, which will not be elaborated herein.
[0103] The present application also provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned task processing method are implemented.
[0104] For a detailed introduction to a computer-readable storage medium provided by the present application, please refer to the embodiments of the above-mentioned task processing method, which will not be elaborated herein.
[0105] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0106] The foregoing description of the disclosed embodiments enables those skilled in the art to practice or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for processing a task, characterized in that, including: When a request for a task to be executed is obtained, it is determined whether there is an existing task conflicting with the task to be executed according to the information of each existing task stored in the cache queue. The information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed; If there is no existing task conflicting with the task to be executed, then execute the task to be executed and store the information of the task to be executed in the cache queue; If there is an existing task conflicting with the task to be executed, then add the task to be executed to the waiting execution queue; When the information of any existing task is removed from the cache queue, it is determined whether the task to be executed exists in the mutex task flag of the existing task; if it exists, then it is determined that the information of the existing task conflicting with the task to be executed is removed from the cache queue, and then the task to be executed is extracted from the waiting execution queue, the task to be executed is executed and the information of the task to be executed is stored in the cache queue; Among them, determining whether there is an existing task conflicting with the task to be executed according to the information of each existing task stored in the cache queue includes: Obtaining the mutex task flag of the task to be executed; Judging whether there is an existing task in the mutex task flag of the task to be executed according to the information of each existing task; If there is an existing task in the mutex task flag of the task to be executed, it is determined that there is an existing task conflicting with the task to be executed; If there is no existing task in the mutex task flag of the task to be executed, it is determined that there is no existing task conflicting with the task to be executed; When there are multiple tasks to be executed in the waiting execution queue, after each existing task is executed, it is determined one by one according to the mutex task flag of the existing task whether there is a task to be executed among the tasks to be executed that is the mutex task of the existing task, and if so, execute the corresponding task to be executed.
2. The method for processing the task according to claim 1, wherein Before adding the task to be executed to the waiting execution queue, it further includes: Judging whether there is a task in the waiting execution queue that is the same as the task to be executed; If there is no task that is the same as the task to be executed, then add the task to be executed to the waiting execution queue; If there is a task that is the same as the task to be executed, then discard the task to be executed.
3. The method for processing a task according to claim 2, wherein Judging whether there is a task in the waiting execution queue that is the same as the task to be executed includes: Obtaining the first identification value of the task to be executed; Judging whether there is a second identification value in the second identification values corresponding to the tasks in the waiting execution queue that is the same as the first identification value; If so, it is determined that there is a task that is the same as the task to be executed; If not, it is determined that there is no task that is the same as the task to be executed.
4. The method for processing a task according to claim 1, wherein Before determining whether there is an existing task conflicting with the task to be executed according to the information of each existing task stored in the cache queue, it further includes: Judging whether the task to be executed exists in the pre-stored mutex task library; If it does not exist in the pre-stored mutex task library, then execute the task to be executed; If it exists in the pre-stored mutex task library, it enters the step of judging whether there is a conflict between the existing tasks and the to-be-executed task according to the information of each existing task stored in the cache queue.
5. The method for processing a task according to any one of claims 1 to 4, characterized in that, Before judging whether there is a conflict between the existing tasks and the to-be-executed task according to the information of each existing task stored in the cache queue, it further includes: Judging whether there is an existing task that is the same as the to-be-executed task according to the information of each of the existing tasks; If there is, discard the to-be-executed task; If not, enter the step of judging whether there is a conflict between the existing tasks and the to-be-executed task according to the information of each existing task stored in the cache queue.
6. A processing system for a task, characterized in that, It includes: A conflict judgment unit, which is used to judge whether there is a conflict between the existing tasks and the to-be-executed task according to the information of each existing task stored in the cache queue when a request for the to-be-executed task is obtained. The information of the existing task is added to the cache queue when the existing task starts to be executed and removed from the cache queue after the existing task is executed; A first execution unit, which is used to execute the to-be-executed task and store the information of the to-be-executed task into the cache queue if there is no conflict between the existing tasks and the to-be-executed task; A conflict handling unit, which is used to add the to-be-executed task to the waiting execution queue if there is a conflict between the existing tasks and the to-be-executed task; A second execution unit, which is used to judge whether the to-be-executed task exists in the mutex task mark of the existing task when the information of any one of the existing tasks is removed from the cache queue; if it exists, determine that the information of the existing task conflicting with the to-be-executed task is removed from the cache queue, and then extract the to-be-executed task from the to-be-executed queue, execute the to-be-executed task and store the information of the to-be-executed task into the cache queue; Among them, judging whether there is a conflict between the existing tasks and the to-be-executed task according to the information of each existing task stored in the cache queue includes: Obtaining the mutex task mark of the to-be-executed task; Judging whether there is an existing task in the mutex task mark of the to-be-executed task according to the information of each of the existing tasks; If there is an existing task in the mutex task mark of the to-be-executed task, it is determined that there is a conflict between the existing tasks and the to-be-executed task; If there is no existing task in the mutex task mark of the to-be-executed task, it is determined that there is no conflict between the existing tasks and the to-be-executed task; When there are multiple to-be-executed tasks in the waiting execution queue, after each existing task is executed, it is judged one by one according to the mutex task mark of the existing task whether there is a to-be-executed task among the to-be-executed tasks that is the mutex task of the existing task, and if so, execute the corresponding to-be-executed task.
7. A processing device for a task, characterized in that, It includes: A memory, which is used to store a computer program; A processor, which is used to implement the steps of the task processing method as described in any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that, The computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, it implements the steps of the task processing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Equipment state change processing method and device and computer readable storage medium
CN111611042A
Task scheduling method and system in SD-WAN system and computer equipment
CN112217849A