Task scheduling method, device, computer equipment and storage medium
By using task scheduling methods with dynamic constraint functions and compensation mechanisms in real-time systems, the problems of low task scheduling performance and poor instantaneous overload handling in the existing technology are solved, and more efficient task scheduling and system performance improvement are achieved.
Patent Information
- Application Number
- CN202111560760.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-12-20
AI Technical Summary
The commonly used static priority constraint methods in existing real-time systems have shortcomings in task scheduling performance, especially when facing mixed scheduling of periodic tasks and non-periodic tasks, it is difficult to effectively deal with the problem of instantaneous system overload.
A task scheduling method is proposed, by obtaining the initial task set, determining the target task that meets the preset time conditions, and putting it into the task pool. Then, analyze the attribute parameters of the target task in the task pool, generate a dynamic constraint function, and determine the priority of each target task based on the function. When an instantaneous overload occurs, the target task corresponding to the minimum priority is removed and the removed task is processed through the compensation function to ensure it re-enter the task pool at the appropriate time.
Through the generation of dynamic constraint functions and dynamic adjustment of priority, the task scheduling performance in real-time systems is improved. At the same time, when an instant overload occurs, by removing the minimum priority task and performing compensation processing, the system load pressure can be effectively alleviated and the overall performance of the system can be improved.
Smart Images

Figure CN114253723B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of system scheduling, and in particular to a task scheduling method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, real-time systems with high requirements for system performance have emerged. Since actual real-time systems often have both periodic tasks and non-periodic tasks, the system load changes in real time, which will increase the task pool load to a certain extent and reduce system performance. Moreover, when the tasks arriving at a certain moment exceed the task pool capacity, it will cause instantaneous overload of the system. Therefore, flexible and efficient task scheduling methods are of great significance to improving system performance.
[0003] Currently, most of the commonly used task scheduling methods in real-time systems use static priority constraint methods. However, this method, which only considers task time constraints, has the problem of low task scheduling performance. Summary of the invention
[0004] Based on this, it is necessary to provide a task scheduling method, device, computer equipment, computer-readable storage medium and computer program product that can improve task scheduling performance in order to address the technical problem that traditional static priority constraint methods have low task scheduling performance.
[0005] In a first aspect, the present application provides a task scheduling method. The method comprises:
[0006] Get the initial task set;
[0007] Determine the tasks that meet the preset first time conditions in the initial task set, obtain the target task, and put the target task into the task pool;
[0008] Analyze the attribute parameters of the target task in the task pool and generate the dynamic constraint function of the target task;
[0009] Determine the priority of each target task according to the dynamic constraint function of the target task;
[0010] When a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool.
[0011] In one embodiment, analyzing the attribute parameters of the target task and generating the dynamic constraint function of the target task includes:
[0012] Analyze the attribute parameters of the target task and generate the value constraint function and time constraint function of the target task;
[0013] Concatenate the value constraint function and the time constraint function to generate a dynamic constraint function for the target task.
[0014] In one embodiment, when a momentary overload occurs, after removing the target task corresponding to the minimum priority from the task pool, the method further includes:
[0015] Get the compensation function;
[0016] According to the target task corresponding to the minimum priority, the compensated target task is obtained through the compensation function;
[0017] When the compensated target task meets the preset second time condition, the compensated target task is put into the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition;
[0018] Returns the steps of analyzing the attribute parameters of the target task in the task pool and generating the dynamic constraint function of the target task.
[0019] In one embodiment, according to the target task corresponding to the minimum priority, the compensated target task is obtained through the compensation function, including:
[0020] According to the target task corresponding to the minimum priority, a dynamic constraint function corresponding to the minimum priority is obtained;
[0021] The dynamic constraint function corresponding to the minimum priority is compensated by the compensation function to obtain the compensated dynamic constraint function;
[0022] According to the compensated dynamic constraint function, the compensated target task is obtained.
[0023] In one embodiment, when a momentary overload occurs, removing a target task corresponding to a minimum priority in a task pool includes:
[0024] When a momentary overload occurs, the target task corresponding to the minimum priority in the task pool is searched to obtain the target task with the minimum priority;
[0025] If there are multiple minimum priority target tasks, the minimum priority target task corresponding to the minimum time constraint function is selected;
[0026] Remove the minimum priority target task corresponding to the minimum time constraint function from the task pool.
[0027] In a second aspect, the present application also provides a task scheduling device. The device comprises:
[0028] A task set acquisition module is used to acquire an initial task set;
[0029] A target task acquisition module is used to determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool;
[0030] A dynamic constraint function acquisition module is used to analyze the attribute parameters of the target task in the task pool and generate a dynamic constraint function of the target task;
[0031] A priority acquisition module is used to determine the priority of each target task according to the dynamic constraint function of the target task;
[0032] The task removal module is used to remove the target task corresponding to the minimum priority in the task pool when a momentary overload occurs.
[0033] In one of the embodiments, the dynamic constraint function acquisition module is also used to analyze the attribute parameters of the target task, generate the value constraint function and the time constraint function of the target task; and concatenate the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
[0034] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0035] Obtain an initial task set; determine the tasks in the initial task set that meet the preset first time conditions, obtain the target task, and put the target task into the task pool; analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task; determine the priority of each target task based on the dynamic constraint function of the target task; when a momentary overload occurs, remove the target task corresponding to the minimum priority in the task pool.
[0036] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0037] Obtain an initial task set; determine the tasks in the initial task set that meet the preset first time conditions, obtain the target task, and put the target task into the task pool; analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task; determine the priority of each target task based on the dynamic constraint function of the target task; when a momentary overload occurs, remove the target task corresponding to the minimum priority in the task pool.
[0038] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0039] Obtain an initial task set; determine the tasks in the initial task set that meet the preset first time conditions, obtain the target task, and put the target task into the task pool; analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task; determine the priority of each target task based on the dynamic constraint function of the target task; when a momentary overload occurs, remove the target task corresponding to the minimum priority in the task pool.
[0040] The above-mentioned task scheduling method, device, computer equipment, storage medium and computer program product obtain an initial task set, determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool, analyze the attribute parameters of the target task in the task pool, generate the dynamic constraint function of the target task, and determine the priority of each target task according to the dynamic constraint function of the target task. When a momentary overload occurs, remove the target task corresponding to the minimum priority in the task pool. The above-mentioned scheme, by analyzing the attribute parameters of the target task and generating the method of the dynamic constraint function of the target task, can determine the priority of each target task and improve the task scheduling performance of the real-time system. At the same time, when a momentary overload occurs, by removing the target task corresponding to the minimum priority in the task pool, the system load pressure can be alleviated to a certain extent, and the task scheduling performance of the real-time system can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 An application environment diagram of a task scheduling method in one embodiment;
[0042] Figure 2 A flowchart of a task scheduling method in one embodiment;
[0043] Figure 3 A flowchart of a task scheduling step in an embodiment;
[0044] Figure 4 is a flowchart of a task scheduling method in another embodiment;
[0045] Figure 5 is a structural block diagram of a task scheduling device in one embodiment;
[0046] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] The task scheduling method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 obtains the initial task set, determines the tasks that meet the preset first time conditions in the initial task set, obtains the target task, and puts the target task into the task pool, analyzes the attribute parameters of the target task in the task pool, generates the dynamic constraint function of the target task, and determines the priority of each target task according to the dynamic constraint function of the target task. When a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool, and the priority of the target task is generated to the server 104. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0049] In one embodiment, Figure 2 As shown, a task scheduling method is provided, which is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, and the following steps are included:
[0050] S100: Obtain an initial task set.
[0051] Among them, tasks in real-time systems often include both periodic tasks and non-periodic tasks. Periodic tasks are scheduled at fixed periodic intervals, and the deadline is relatively easy to determine, such as the length of the task cycle located by the deadline. However, the activities of non-periodic tasks are random and sudden, and the deadline of each task cannot be determined. The scheduling method used for periodic tasks is not suitable for the scheduling of non-periodic tasks. For the mixed scheduling of periodic tasks and non-periodic tasks, the task set to be obtained includes periodic tasks and non-periodic tasks. At present, the task scheduling strategy under single-dimensional conditions is generally used in real-time systems. The single-dimensional task scenario is a scenario in which the task meets the executable conditions at a certain moment. The task scheduling method proposed in this scheme is also applicable to task scenarios under multi-dimensional conditions. The single-dimensional scenario tasks can be expanded to multi-dimensional task scenarios to obtain a task scheduling scenario under multi-dimensional arrival conditions. The multi-dimensional arrival scenario refers to a scenario in which the task has multiple arrival conditions after deployment, and the arrival conditions of the task can be switched in real time according to different systems and requirements.
[0052] Specifically, an initial task set is obtained, which includes periodic tasks and non-periodic tasks, and there is at least one non-periodic task. The initial task set can be a single-dimensional scenario task or a multi-dimensional scenario task, and this application does not make specific limitations on this.
[0053] S200: Determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool.
[0054] Among them, due to the randomness and suddenness of the activities of non-periodic tasks, the load in the real-time system will change in real time according to the time. According to different systems and requirements, each moment has different arrival conditions. Let F represent the single-dimensional condition for the arrival of task T in the real-time system. Then, assuming that the system time is θ, if and only if F i =F(θ), task T i Arrival, which is task T i The task arrival condition F that satisfies time θ i =F(θ), expand the single-dimensional scenario task to a multi-dimensional task scenario, and obtain a task scheduling scenario under multi-dimensional arrival conditions, that is, for F = {f m} m=1,2... Each sub-item of is expanded to f m =[f m,1 ,f m,2 ,..] T =f m,n T | n=1,2... It is worth noting that the meaning of each expanded sub-item in the system must be similar, that is, there must be a function h(·) such that f m,n =h(f m,n+k ), k∈N, let F={F m,n} m=1,2...|n=1,2... =[f m,1 ,f m,2 ,..] T [f 1,n ,f 2,n ,...]| m=1,2...|n=1,2... , that is, we get the task scheduling scenario under multi-dimensional arrival conditions. At system time θ, if and only if F m i ,n =F(θ), task T i Arrival, which is task T i The task arrival condition that satisfies time θ is F m i ,n=F(θ). The task pool is an instance pool for sharing tasks between threads. The task pool is created when the task starts and cleared when it stops. At the same time, the task pool provides a cache mechanism for tasks, which can reduce the system overhead caused by frequent creation and recycling of task instances. Therefore, the determined target task will be placed in the task pool and wait for the system to schedule and execute the task.
[0055] Specifically, tasks that meet the preset first time condition in the initial task set are determined, a target task is obtained, and the target task is put into the task pool.
[0056] S300: Analyze the attribute parameters of the target task in the task pool and generate a dynamic constraint function of the target task.
[0057] Among them, there should be corresponding attribute parameters for both periodic tasks and non-periodic tasks in the task set. The task scheduling algorithm in the actual real-time system often uses the time attribute of the task as the priority criterion. However, for non-periodic tasks, only considering the time attribute of the task alone will reduce the system task scheduling performance. On the basis of the time attribute of the task, the value attribute of the task is comprehensively considered to obtain the dynamic constraints of the task that change with time, which will effectively improve the mixed scheduling performance of periodic tasks and non-periodic tasks.
[0058] Specifically, the attribute parameters of the target task in the task pool are analyzed to generate a dynamic constraint function of the target task.
[0059] S400: Determine the priority of each target task according to the dynamic constraint function of the target task.
[0060] Among them, the priority of the task is an indicator used to reflect the order in which the tasks are executed. The dynamic constraint function of the real-time task is a function that changes dynamically over time. For the task that meets the arrival conditions at the system moment, the dynamic constraint data of the task is determined through the dynamic constraint function of the task. The dynamic constraint data reflects the size of the performance indicator of the task. According to the size of the dynamic constraint data of the task, the priority of task scheduling can be determined.
[0061] Specifically, the priority of each target task is determined according to the dynamic constraint function of the target task.
[0062] S500: When a momentary overload occurs, remove the target task corresponding to the minimum priority in the task pool.
[0063] Among them, the task pool has a capacity upper limit. Due to the limitations of the system's software and hardware, the number of task instances in the task pool cannot be infinite. In practical applications, many situations will cause the load of the real-time system to change, and even cause instantaneous overload, such as changes in demand, changes in data flow in the communication network, etc. When the tasks arriving at a certain moment exceed the maximum capacity of the task pool, it will cause an instantaneous overload of the system. The instantaneous overload of the system will cause many tasks in the real-time system to miss the deadline, which will lead to a sharp drop in system performance. Therefore, the task scheduling method under instantaneous overload can alleviate the system load pressure.
[0064] Specifically, when a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool.
[0065] In the above-mentioned task scheduling method, by obtaining the initial task set, determining the tasks in the initial task set that reach the preset first time condition, obtaining the target task, and placing the target task into the task pool, analyzing the attribute parameters of the target task in the task pool, generating the dynamic constraint function of the target task, and determining the priority of each target task according to the dynamic constraint function of the target task, when a momentary overload occurs, removing the target task corresponding to the minimum priority from the task pool. The above-mentioned scheme, by analyzing the attribute parameters of the target task and generating the method of the dynamic constraint function of the target task, can determine the priority of each target task and improve the task scheduling performance of the real-time system. At the same time, when a momentary overload occurs, by removing the target task corresponding to the minimum priority in the task pool, the system load pressure can be alleviated to a certain extent, and the task scheduling performance of the real-time system can be further improved.
[0066] In one embodiment, Figure 3 As shown, the attribute parameters of the target task are analyzed and the dynamic constraint function of the target task is generated, including:
[0067] S320: Analyze the attribute parameters of the target task and generate a value constraint function and a time constraint function of the target task;
[0068] S340: Concatenate the value constraint function and the time constraint function to generate a dynamic constraint function of the target task.
[0069] In this embodiment, the target task includes a periodic task and a non-periodic task. The attribute parameters of any task in the periodic task include the expected value of the task, the theoretical execution time of the task, the deadline of the task, and the arrival period of the task. The attribute parameters of the non-periodic task include the average arrival period of the task and the deadline of the task. The attribute parameters of the target task are analyzed to generate the value constraint function and the time constraint function of the target task. Specifically, the target task is represented by T i Indicates that V i Represents task T i The expected value of Ci Represents task T i Theoretical execution time, d i Represents task T i The deadline, P i Represents task T i The arrival period of task T i is a non-periodic task, whose arrival process follows a Poisson process with constant arrival and arrival rate λ i , then task T i The average arrival period is P i =1 / λ i , then the value constraint function of the target task can be expressed as follows:
[0070]
[0071] Among them, α i (α i ≥0) reflects the task T i The value changes over time. Each task has this characteristic value, and the value constraint function of the target task obtained changes dynamically with time θ.
[0072] The time constraint function of the target task can be expressed as follows:
[0073]
[0074] Among them, q (q ≥ 1) is a constant reflecting the urgency of task execution. Each task has this characteristic value, and the time constraint function of the target task obtained changes dynamically with the time θ.
[0075] Then, the value constraint function and the time constraint function are concatenated to generate the dynamic constraint function of the target task. Specifically, according to the value constraint function and the time constraint function of the target task, the generated dynamic constraint function of the target task can be expressed by the following formula:
[0076]
[0077] Among them, the dynamic constraint function of the target task changes dynamically with the time θ. When α i = 0, the value constraint of the task can be regarded as a constant. At this time, the dynamic constraint function of the target task is reduced to a task scheduling algorithm that relies only on time constraints. When q = 1, the dynamic constraint function of the target task is reduced to a task scheduling algorithm that relies only on value constraints. When θ approaches d i When the time constraint of the target task collapses to task T i Furthermore, the dynamic constraint function J(θ) of the target task i Taking partial derivative of time θ, we can get task Ti The moment when the optimal dynamic constraint is reached By scheduling system tasks based on the optimal dynamic constraint time, the optimal system scheduling performance can be obtained, which is beneficial to improving the task scheduling performance of the real-time system.
[0078] The scheme of the above-mentioned embodiment generates the value constraint function and time constraint function of the target task by analyzing the attribute parameters of the target task, splices the value constraint function and the time constraint function, and generates the dynamic constraint function of the target task. The obtained value constraint function, time constraint function and dynamic constraint function of the target task change dynamically with the time θ. Based on the dynamic constraint function, the priority of the target task is determined, which is beneficial to improving the task scheduling performance of the real-time system.
[0079] In one embodiment, when a momentary overload occurs, after removing the target task corresponding to the minimum priority from the task pool, it also includes: obtaining a compensation function; obtaining a compensated target task through the compensation function based on the target task corresponding to the minimum priority; when the compensated target task meets a preset second time condition, placing the compensated target task into the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; returning to analyze the attribute parameters of the target task in the task pool, and generating a dynamic constraint function of the target task.
[0080] In this embodiment, when a momentary overload occurs, after the target task corresponding to the minimum priority is removed from the task pool, the target task corresponding to the minimum priority that has been removed needs to be processed so that the target task corresponding to the minimum priority can also be called when a momentary overload occurs. Specifically, the target task corresponding to the minimum priority is placed in a compensation queue, which is a cache space for tasks. A compensation function is obtained, and the target task placed in the compensation queue is used to obtain the compensated target task through the compensation function. The compensation function can be obtained based on the corresponding system and task set modeling, and can be a linear compensation function or a nonlinear compensation function. This application does not make specific limitations on this. The target task after compensation When the function meets the preset second time condition, the target task that meets the preset second time condition is obtained, wherein the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition, the compensated target function is put into the task pool together with the target task that meets the second preset time condition, and returns to analyze the attribute parameters of the target task in the task pool, and generates the step of dynamic constraint function of the target task, continues to execute the step of generating the dynamic constraint function of the target task in the task pool, and generates priority to schedule the task, and when instantaneous overload occurs again, continues to remove the target task corresponding to the minimum priority in the task pool, and repeats the above steps until the real-time system is relieved of the overload.
[0081] The scheme of the above embodiment obtains the compensation function, and obtains the compensated target task according to the target task corresponding to the minimum priority through the compensation function. When the compensated target task meets the preset second time condition, the compensated target task is placed in the task pool. The introduction of the compensation function will solve the problem that low-priority tasks cannot be executed in extreme cases. It returns to the step of analyzing the attribute parameters of the target task in the task pool and generating a dynamic constraint function of the target task. When an instantaneous overload occurs, the method of removing and compensating the minimum priority task can alleviate the system load pressure to a certain extent and further improve the task scheduling performance of the real-time system.
[0082] In one embodiment, according to the target task corresponding to the minimum priority, obtaining the compensated target task through the compensation function includes: according to the target task corresponding to the minimum priority, obtaining the dynamic constraint function corresponding to the minimum priority; compensating the dynamic constraint function corresponding to the minimum priority through the compensation function to obtain the compensated dynamic constraint function; according to the compensated dynamic constraint function, obtaining the compensated target task.
[0083] In this embodiment, according to the target task corresponding to the minimum priority, the dynamic constraint function corresponding to the minimum priority is obtained, and the dynamic constraint function corresponding to the minimum priority is compensated by the compensation function to obtain the compensated dynamic constraint function. The dynamic constraint data of the dynamic constraint function of the target task after compensation at the system moment will be greater than the dynamic constraint data before compensation at the system moment. Therefore, the introduction of the compensation function will be beneficial to improving the priority of the target task with minimum priority. According to the compensated dynamic constraint function, when the compensated target task enters the task pool again, it can be executed first, which is beneficial to improving the scheduling performance of the system.
[0084] The scheme of the above-mentioned embodiment obtains the dynamic constraint function corresponding to the minimum priority according to the target task corresponding to the minimum priority, compensates the dynamic constraint function corresponding to the minimum priority through the compensation function to obtain the compensated dynamic constraint function, and obtains the compensated target task according to the compensated dynamic constraint function. When the compensated target task enters the task pool again, the priority of the task can be increased, which is beneficial to improving the scheduling performance of the system.
[0085] In one embodiment, Figure 4 As shown in the figure, when a momentary overload occurs, the target tasks corresponding to the minimum priority are removed from the task pool, including:
[0086] S520: When a momentary overload occurs, find the target task corresponding to the minimum priority in the task pool to obtain the target task with the minimum priority;
[0087] S540: If there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function;
[0088] S560: Remove the minimum priority target task corresponding to the minimum time constraint function from the task pool.
[0089] In this embodiment, when a momentary overload occurs, the target task corresponding to the minimum priority in the task pool is searched to obtain the minimum priority target task. Since the minimum priority target task corresponds to the minimum dynamic constraint, and the dynamic constraint includes the task value constraint and the task time constraint, the minimum dynamic constraint may correspond to a combination of multiple task value constraints and task time constraints, that is, the number of minimum priority target tasks can be one or more. If the number of minimum priority target tasks is multiple, the minimum priority target task corresponding to the minimum time constraint function is selected, and the minimum priority target task corresponding to the minimum time constraint function is removed from the task pool. If the number of minimum priority target tasks is one, the target task corresponding to the minimum priority is removed from the task pool.
[0090] The solution of the above embodiment is to find the target task corresponding to the minimum priority in the task pool when a momentary overload occurs. If there are multiple target tasks with minimum priority, the target task with minimum priority corresponding to the minimum time constraint function is removed from the task pool. This method is helpful in solving the problem that low-priority tasks cannot be executed in extreme cases, and is helpful in improving the scheduling performance of the system.
[0091] To explain the task scheduling method and effect in this solution in detail, a most detailed embodiment is described below:
[0092] Get the initial task set T of multi-dimensional arrival conditions = {T i} i=1,2.... The initial task set includes periodic tasks and non-periodic tasks. According to the current system time θ, the initial task set is determined to meet the preset first time condition task, get the target task T i , and put the target task into the task pool, analyze the target task T i Attribute parameters of the target task T i The value constraint function and time constraint function of the target task T i The value constraint function and time constraint function are:
[0093] and
[0094] Concatenate the value constraint function and the time constraint function to generate the target task T i The dynamic constraint function of the target task Ti The dynamic constraint function is:
[0095]
[0096] According to the dynamic constraint function of the target task, the priority of each target task is determined. When an instantaneous overload occurs, the target task corresponding to the minimum priority in the task pool is found to obtain the minimum priority target task. If there are multiple minimum priority target tasks, the minimum priority target task corresponding to the minimum time constraint function is selected, and the minimum priority target task corresponding to the minimum time constraint function is removed from the task pool to obtain the linear compensation function. The linear compensation function is:
[0097]
[0098] Among them, C i is the parameter that affects the dynamic constraints of the task, k i C i Corresponding to coefficients greater than 1, M i×i is a compensation transfer matrix with i rows and i columns, and b is a compensation constant.
[0099] According to the target task corresponding to the minimum priority, the dynamic constraint function corresponding to the minimum priority is obtained, and the dynamic constraint function corresponding to the minimum priority is compensated by the linear compensation function to obtain the compensated dynamic constraint function. Considering α i (α i ≥0) and q i (q i ≥1) Introduce the compensation function, let M i×i is the unit matrix E, b=0, k1=k2=2, then the dynamic constraint function after linear compensation is:
[0100]
[0101] According to the compensated dynamic constraint function, the compensated target task is obtained. When the compensated target task meets the preset second time condition, the compensated target task is placed in the task pool. The time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition. Return to analyze the attribute parameters of the target task in the task pool and generate the steps of the dynamic constraint function of the target task until the system contacts overload.
[0102] In the above-mentioned task scheduling method, by obtaining the initial task set, determining the tasks in the initial task set that reach the preset first time condition, obtaining the target task, and placing the target task into the task pool, analyzing the attribute parameters of the target task in the task pool, generating the dynamic constraint function of the target task, and determining the priority of each target task according to the dynamic constraint function of the target task, when a momentary overload occurs, removing the target task corresponding to the minimum priority from the task pool. The above-mentioned scheme, by analyzing the attribute parameters of the target task and generating the method of the dynamic constraint function of the target task, can determine the priority of each target task and improve the task scheduling performance of the real-time system. At the same time, when a momentary overload occurs, by removing the target task corresponding to the minimum priority in the task pool, the system load pressure can be alleviated to a certain extent, and the task scheduling performance of the real-time system can be further improved.
[0103] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0104] Based on the same inventive concept, the embodiment of the present application also provides a task scheduling device for implementing the task scheduling method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more task scheduling device embodiments provided below can refer to the limitations on the task scheduling method above, and will not be repeated here.
[0105] In one embodiment, Figure 5 As shown, a task scheduling device 600 is provided, comprising: a task set acquisition module 610, a target task acquisition module 620, a dynamic constraint function acquisition module 630, a priority acquisition module 640 and a task removal module 650, wherein:
[0106] The task set acquisition module 610 is used to acquire an initial task set.
[0107] The target task acquisition module 620 is used to determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool.
[0108] The dynamic constraint function acquisition module 630 is used to analyze the attribute parameters of the target task in the task pool and generate the dynamic constraint function of the target task.
[0109] The priority acquisition module 640 is used to determine the priority of each target task according to the dynamic constraint function of the target task.
[0110] The task removal module 650 is used to remove the target task corresponding to the minimum priority in the task pool when a momentary overload occurs.
[0111] In the above-mentioned task scheduling device, by obtaining the initial task set, determining the tasks in the initial task set that reach the preset first time condition, obtaining the target task, and placing the target task into the task pool, analyzing the attribute parameters of the target task in the task pool, generating the dynamic constraint function of the target task, and determining the priority of each target task according to the dynamic constraint function of the target task, when a momentary overload occurs, removing the target task corresponding to the minimum priority from the task pool. The above-mentioned scheme, by analyzing the attribute parameters of the target task and generating the method of the dynamic constraint function of the target task, can determine the priority of each target task and improve the task scheduling performance of the real-time system. At the same time, when a momentary overload occurs, by removing the target task corresponding to the minimum priority in the task pool, the system load pressure can be alleviated to a certain extent, and the task scheduling performance of the real-time system can be further improved.
[0112] In one embodiment, the dynamic constraint function acquisition module 630 is also used to analyze the attribute parameters of the target task, generate the value constraint function and time constraint function of the target task; and concatenate the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
[0113] In one embodiment, the task scheduling device 600 is also used to obtain a compensation function; according to the target task corresponding to the minimum priority, a compensated target task is obtained through the compensation function; when the compensated target task meets the preset second time condition, the compensated target task is placed in the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; return to analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task.
[0114] In one embodiment, the task scheduling device 600 is also used to obtain a dynamic constraint function corresponding to the minimum priority based on the target task corresponding to the minimum priority; compensate the dynamic constraint function corresponding to the minimum priority through a compensation function to obtain a compensated dynamic constraint function; and obtain a compensated target task based on the compensated dynamic constraint function.
[0115] In one embodiment, the task removal module 650 is also used to find the target task corresponding to the minimum priority in the task pool when a momentary overload occurs, and obtain the minimum priority target task; if there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function; and remove the minimum priority target task corresponding to the minimum time constraint function in the task pool.
[0116] Each module in the above task scheduling device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0117] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store task priority data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task scheduling method is implemented.
[0118] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0120] Get the initial task set;
[0121] Determine the tasks that meet the preset first time conditions in the initial task set, obtain the target task, and put the target task into the task pool;
[0122] Analyze the attribute parameters of the target task in the task pool and generate the dynamic constraint function of the target task;
[0123] Determine the priority of each target task according to the dynamic constraint function of the target task;
[0124] When a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool.
[0125] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0126] Analyze the attribute parameters of the target task to generate the value constraint function and time constraint function of the target task; splice the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
[0127] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0128] Obtain a compensation function; obtain a compensated target task through the compensation function according to the target task corresponding to the minimum priority; when the compensated target task meets the preset second time condition, put the compensated target task into the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; return to analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task.
[0129] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0130] According to the target task corresponding to the minimum priority, the dynamic constraint function corresponding to the minimum priority is obtained; the dynamic constraint function corresponding to the minimum priority is compensated by the compensation function to obtain the compensated dynamic constraint function; according to the compensated dynamic constraint function, the compensated target task is obtained.
[0131] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0132] When a momentary overload occurs, find the target task corresponding to the minimum priority in the task pool to obtain the minimum priority target task; if there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function; remove the minimum priority target task corresponding to the minimum time constraint function in the task pool.
[0133] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0134] Get the initial task set;
[0135] Determine the tasks that meet the preset first time conditions in the initial task set, obtain the target task, and put the target task into the task pool;
[0136] Analyze the attribute parameters of the target task in the task pool and generate the dynamic constraint function of the target task;
[0137] Determine the priority of each target task according to the dynamic constraint function of the target task;
[0138] When a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool.
[0139] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0140] Analyze the attribute parameters of the target task to generate the value constraint function and time constraint function of the target task; splice the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
[0141] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0142] Obtain a compensation function; obtain a compensated target task through the compensation function according to the target task corresponding to the minimum priority; when the compensated target task meets the preset second time condition, put the compensated target task into the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; return to analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task.
[0143] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0144] According to the target task corresponding to the minimum priority, the dynamic constraint function corresponding to the minimum priority is obtained; the dynamic constraint function corresponding to the minimum priority is compensated by the compensation function to obtain the compensated dynamic constraint function; according to the compensated dynamic constraint function, the compensated target task is obtained.
[0145] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0146] When a momentary overload occurs, find the target task corresponding to the minimum priority in the task pool to obtain the minimum priority target task; if there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function; remove the minimum priority target task corresponding to the minimum time constraint function in the task pool.
[0147] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0148] Get the initial task set;
[0149] Determine the tasks that meet the preset first time conditions in the initial task set, obtain the target task, and put the target task into the task pool;
[0150] Analyze the attribute parameters of the target task in the task pool and generate the dynamic constraint function of the target task;
[0151] Determine the priority of each target task according to the dynamic constraint function of the target task;
[0152] When a momentary overload occurs, the target task corresponding to the minimum priority is removed from the task pool.
[0153] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0154] Analyze the attribute parameters of the target task to generate the value constraint function and time constraint function of the target task; splice the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
[0155] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0156] Obtain a compensation function; obtain a compensated target task through the compensation function according to the target task corresponding to the minimum priority; when the compensated target task meets the preset second time condition, put the compensated target task into the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; return to analyze the attribute parameters of the target task in the task pool, and generate a dynamic constraint function of the target task.
[0157] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0158] According to the target task corresponding to the minimum priority, the dynamic constraint function corresponding to the minimum priority is obtained; the dynamic constraint function corresponding to the minimum priority is compensated by the compensation function to obtain the compensated dynamic constraint function; according to the compensated dynamic constraint function, the compensated target task is obtained.
[0159] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0160] When a momentary overload occurs, find the target task corresponding to the minimum priority in the task pool to obtain the minimum priority target task; if there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function; remove the minimum priority target task corresponding to the minimum time constraint function in the task pool.
[0161] It should be noted that the task scheduling method and device disclosed in the present application can be used for task scheduling in real-time systems in the financial field, and can also be used for task scheduling in real-time systems in any field other than the financial field. The application field of the task scheduling method and device disclosed in the present application is not limited. In addition, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0162] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0163] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0164] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A task scheduling method, characterized in that: The method comprises: Get the initial task set; Determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool; Analyze the attribute parameters of the target task in the task pool to generate a dynamic constraint function of the target task; Determining the priority of each target task according to the dynamic constraint function of the target task; When a momentary overload occurs, removing the target task corresponding to the minimum priority in the task pool; and Get the compensation function; According to the target task corresponding to the minimum priority, compensating the dynamic constraint function of the target task corresponding to the minimum priority by the compensation function to obtain the compensated target task; When the compensated target task meets a preset second time condition, the compensated target task is placed in the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; Return to the step of analyzing the attribute parameters of the target task in the task pool and generating a dynamic constraint function of the target task.
2. The task scheduling method according to claim 1, characterized in that: The step of analyzing the attribute parameters of the target task and generating a dynamic constraint function of the target task includes: Analyze the attribute parameters of the target task to generate a value constraint function and a time constraint function of the target task; The value constraint function and the time constraint function are concatenated to generate a dynamic constraint function of the target task.
3. The task scheduling method according to claim 1, characterized in that: The step of compensating the dynamic constraint function of the target task corresponding to the minimum priority by the compensation function according to the target task corresponding to the minimum priority, and obtaining the compensated target task comprises: According to the target task corresponding to the minimum priority, obtaining the dynamic constraint function corresponding to the minimum priority; Compensating the dynamic constraint function corresponding to the minimum priority by the compensation function to obtain a compensated dynamic constraint function; According to the compensated dynamic constraint function, a compensated target task is obtained.
4. The task scheduling method according to claim 1, characterized in that: When a momentary overload occurs, removing the target task corresponding to the minimum priority in the task pool includes: When a momentary overload occurs, the target task corresponding to the minimum priority in the task pool is searched to obtain the target task with the minimum priority; If there are multiple minimum priority target tasks, select the minimum priority target task corresponding to the minimum time constraint function; The minimum priority target task corresponding to the minimum time constraint function is removed from the task pool.
5. A task scheduling device, characterized in that: The device comprises: A task set acquisition module is used to acquire an initial task set; A target task acquisition module, used to determine the tasks in the initial task set that meet the preset first time condition, obtain the target task, and put the target task into the task pool; A dynamic constraint function acquisition module, used for analyzing the attribute parameters of the target task in the task pool and generating a dynamic constraint function of the target task; A priority acquisition module, used to determine the priority of each target task according to the dynamic constraint function of the target task; A task removal module, used for removing the target task corresponding to the minimum priority in the task pool when a momentary overload occurs, and obtaining a compensation function; According to the target task corresponding to the minimum priority, compensating the dynamic constraint function of the target task corresponding to the minimum priority by the compensation function to obtain the compensated target task; When the compensated target task meets a preset second time condition, the compensated target task is placed in the task pool, and the time point corresponding to the preset second time condition is later than the time point corresponding to the preset first time condition; Return to the step of analyzing the attribute parameters of the target task in the task pool and generating a dynamic constraint function of the target task.
6. The task scheduling device according to claim 5, characterized in that: The dynamic constraint function acquisition module is also used to analyze the attribute parameters of the target task to generate the value constraint function and time constraint function of the target task; and to concatenate the value constraint function and the time constraint function to generate the dynamic constraint function of the target task.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Dynamic task scheduling method and device, computer equipment and storage medium
CN111694652A
Apparatus and method for managing stream processing tasks
US20140351820A1