Task scheduling method and device, equipment, storage medium and product
By dynamically adjusting the task scheduling strategy, optimizing task queue management based on system load and task virtual time, the problem of low task scheduling efficiency in the existing technology is solved, and system stability and resource utilization under high load conditions are achieved.
Patent Information
- Application Number
- CN202510669095.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-09-02
AI Technical Summary
Existing task scheduling strategies fail to effectively cope with dynamic changes in system load and complex dependencies between tasks, resulting in low task scheduling efficiency, tasks with high priority may be blocked for a long time due to waiting for resources, and the system stability and resource utilization rate are not high.
By obtaining the virtual time and task request time of the task to be scheduled, the task is added to the initial queue based on the task request time, the target fence threshold and traversal interval are dynamically adjusted, and the task scheduling strategy is dynamically adjusted according to the system load, ensuring the rapid execution of high-priority tasks and avoiding low-priority tasks starvation.
It improves the efficiency of task scheduling and the stability of the system, reduces task waiting time, optimizes resource allocation, and ensures the stability and reliability of the system under high load conditions.
Smart Images

Figure CN120578464A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of task scheduling technology, and in particular to task scheduling methods, devices, equipment, storage media and products. Background Art
[0002] In the field of task scheduling, conventional approaches typically employ simple strategies such as round-robin, priority scheduling, or shortest job first (SJF). These strategies can improve system resource utilization and task execution efficiency to a certain extent. However, they often overlook the dynamic changes in system load and the complex dependencies between tasks, resulting in inefficient task scheduling. High-priority tasks may be blocked for extended periods waiting for resources. Summary of the Invention
[0003] The main purpose of this application is to provide a task scheduling method, device, equipment, storage medium and product, aiming to solve the technical problem of low efficiency in target task scheduling.
[0004] To achieve the above objectives, the present application proposes a task scheduling method, which includes:
[0005] When scheduling tasks, obtain the virtual time and task request time of the task to be scheduled;
[0006] Adding the tasks to be scheduled to an initial queue in order based on the task request time, the initial queue is used to store the tasks to be scheduled and the virtual time of the tasks to be scheduled;
[0007] Get the traversal interval and the target barrier threshold that is dynamically adjusted according to the current load of the system;
[0008] Traversing the initial queue according to the traversal interval, and determining a target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time;
[0009] The target task to be scheduled is removed from the initial queue and added to the work queue, and task scheduling is completed according to the work queue.
[0010] In one embodiment, the step of obtaining the traversal interval and the target barrier threshold value dynamically adjusted according to the current load of the system includes:
[0011] Traverse the work queue and calculate the total time required for all tasks in the work queue;
[0012] determining a traversal interval for traversing the initial queue according to the time sum;
[0013] Monitor the current load of the system through preset monitoring frequency;
[0014] The initial barrier threshold is dynamically adjusted according to the current load of the system to obtain a target barrier threshold.
[0015] In one embodiment, the step of dynamically adjusting the initial barrier threshold according to the current load of the system to obtain the target barrier threshold includes:
[0016] comparing the current load of the system with a set load threshold;
[0017] When the current load of the system is greater than the set load threshold for a consecutive preset number of times, determining that the current load of the system meets a preset condition;
[0018] Determining an adjustment step size according to a deviation degree of the current load of the system or a tolerance of the system to a response time;
[0019] The initial barrier threshold is dynamically adjusted according to the adjustment step size to obtain a target barrier threshold.
[0020] In one embodiment, the step of traversing the initial queue according to the traversal interval and determining the target to-be-scheduled task from the initial queue according to the target barrier threshold and the virtual time includes:
[0021] traverse the initial queue according to the traversal interval, and compare the virtual time of the task to be scheduled with the target barrier threshold;
[0022] When the virtual time of the task to be scheduled is less than or equal to the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
[0023] In one embodiment, the method further comprises:
[0024] Get the fixed time reduction value;
[0025] When the virtual time of the task to be scheduled is greater than the target barrier threshold, the virtual time of the task to be scheduled is reduced according to the fixed time reduction value to obtain an updated virtual time, and the position of the task to be scheduled in the initial queue is maintained.
[0026] In one embodiment, the initial queue further stores the expected response time of the task to be scheduled;
[0027] The step of traversing the initial queue according to the traversal interval and determining the target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time includes:
[0028] Traversing the initial queue according to the traversal interval to determine the current waiting time of each task to be scheduled;
[0029] comparing the current waiting time with the expected response time;
[0030] When the time difference between the current waiting time and the expected response time is less than a preset time threshold and the virtual time of the task to be scheduled is greater than the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
[0031] In addition, to achieve the above objectives, the present application also proposes a task scheduling device, which includes:
[0032] The acquisition module is used to obtain the virtual time and task request time of the task to be scheduled when performing task scheduling;
[0033] An adding module, configured to sequentially add the tasks to be scheduled to an initial queue based on the task request time, wherein the initial queue is configured to store the tasks to be scheduled and the virtual time of the tasks to be scheduled;
[0034] The acquisition module is further used to obtain the traversal interval and the target barrier threshold value that is dynamically adjusted according to the current load of the system;
[0035] a traversal module, configured to traverse the initial queue according to the traversal interval, and determine a target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time;
[0036] The scheduling module is used to remove the target task to be scheduled from the initial queue and add it to the work queue, and complete task scheduling according to the work queue.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a task scheduling device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the task scheduling method described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the steps of the task scheduling method described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the steps of the task scheduling method described above.
[0040] One or more technical solutions proposed in this application are as follows: when performing task scheduling, the virtual time and task request time of the task to be scheduled are obtained; based on the task request time, the task to be scheduled is sequentially added to the initial queue, and the initial queue is used to store the task to be scheduled and the virtual time of the task to be scheduled; a traversal interval and a target barrier threshold dynamically adjusted according to the current load of the system are obtained; the initial queue is traversed according to the traversal interval, and the target task to be scheduled is determined from the initial queue according to the target barrier threshold and the virtual time; the target task to be scheduled is removed from the initial queue and added to the work queue, and task scheduling is completed according to the work queue. The task scheduling strategy is dynamically adjusted according to the system load to ensure that the system will not be overloaded under high load, improve system stability and reliability, and determine high-priority scheduling tasks according to virtual time to reduce task waiting time and improve scheduling efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 A flowchart of the first embodiment of the task scheduling method of this application is provided;
[0044] Figure 2 A flowchart of the second embodiment of the task scheduling method of this application is provided;
[0045] Figure 3 A flowchart of the third embodiment of the task scheduling method of this application is provided;
[0046] Figure 4 A flowchart of the fourth embodiment of the task scheduling method of this application is provided;
[0047] Figure 5 This is a schematic diagram of the module structure of the task scheduling device according to an embodiment of the present application;
[0048] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the task scheduling method in the embodiment of the present application.
[0049] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0051] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0052] The main solution of the embodiments of this application is to propose a technical solution that can dynamically adapt to changes in system load, flexibly adjust task priorities, and effectively manage inter-task dependencies and resource competition. This solution should ensure the timely execution of high-priority tasks while preventing starvation of low-priority tasks; accurately estimate task execution times and optimize task scheduling sequences; and monitor system load in real time, dynamically adjusting scheduling strategies to meet business needs in different scenarios.
[0053] Due to the lack of flexibility of existing technologies, it is difficult to dynamically adjust scheduling strategies based on real-time changes in system load. Secondly, while priority scheduling takes into account the urgency of tasks, it can easily lead to starvation of low-priority tasks. Thirdly, the shortest job first strategy can cause long wait times for longer jobs due to inaccurate estimates. Finally, these strategies often fail to fully consider inter-task dependencies and resource competition, resulting in low resource utilization.
[0054] Due to the diverse nature of services, large data volumes, and high real-time requirements, conventional task scheduling strategies are insufficient. Under high load, intense contention for system resources and inefficient task scheduling lead to delays in critical business processing and a degraded user experience. Furthermore, existing technologies are unable to effectively handle sudden traffic spikes, challenging system stability and making it difficult to ensure business continuity and stability.
[0055] The present application provides a solution that, when performing task scheduling, obtains the virtual time and task request time of the task to be scheduled; adds the task to be scheduled to the initial queue in order based on the task request time, and the initial queue is used to store the task to be scheduled and the virtual time of the task to be scheduled; obtains the traversal interval and the target barrier threshold value that is dynamically adjusted according to the current load of the system; traverses the initial queue according to the traversal interval, and determines the target task to be scheduled from the initial queue according to the target barrier threshold value and the virtual time; removes the target task to be scheduled from the initial queue and adds it to the work queue, and completes task scheduling according to the work queue. Through flexible and efficient scheduling strategies, system resource allocation is optimized to ensure that high-priority and urgent tasks can be executed quickly, while maintaining the overall stability and fairness of the system.
[0056] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device or task scheduling device capable of implementing the above functions. The following describes this embodiment and the following embodiments using a task scheduling device as an example.
[0057] Based on this, the embodiment of the present application provides a task scheduling method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the task scheduling method of this application.
[0058] In this embodiment, the task scheduling method includes steps S10 to S50:
[0059] Step S10: When performing task scheduling, the virtual time and task request time of the task to be scheduled are obtained.
[0060] It should be noted that this embodiment proposes two key data structures: the initial queue and the work queue. The initial queue stores all pending tasks in the order of their request time (first-in, first-out, FIFO), while the work queue stores tasks that are currently ready and available for execution. During task scheduling, the system calculates the virtual time of a task based on its priority and required time. Tasks with higher priorities have slower virtual time growth, giving them a scheduling advantage.
[0061] Therefore, when task scheduling is required, the virtual time and task request time of the task to be scheduled can be obtained first. The task request time is the time requested by the task to be scheduled when scheduling. The request times of the tasks to be scheduled have a sequence, so the task request time of the task to be scheduled can be obtained to sort the tasks to be scheduled.
[0062] The virtual time of the task to be scheduled can be calculated based on the relevant attributes of the task to be scheduled. Specifically, the step of obtaining the virtual time of the task to be scheduled includes: obtaining the priority of the task to be scheduled and the actual scheduling time required, and calculating the virtual time of the task to be scheduled based on the priority and the actual scheduling time required.
[0063] In practice, tasks with higher priorities have a lower ratio of virtual time to actual time. Virtual time can be calculated using the following formula:
[0064] Virtual Time=Actual Time*(1 / Priority Factor)
[0065] Among them, Priority Factor is a coefficient set according to the priority. The higher the priority, the larger the Priority Factor, which makes the virtual time grow slower. Virtual Time is the virtual time, and Actual Time is the actual time required for scheduling.
[0066] Step S20: adding the tasks to be scheduled to an initial queue in order based on the task request time, wherein the initial queue is used to store the tasks to be scheduled and the virtual time of the tasks to be scheduled.
[0067] It should be noted that the initial queue is used to store all tasks to be scheduled. The sorting basis of the initial queue is according to the order of the task request time of the tasks to be scheduled (i.e. first in first out, FIFO). This means that the earliest scheduled task will be at the front of the queue and wait to be scheduled.
[0068] In a specific implementation, all tasks to be scheduled can be placed into the initial queue in a first-in-first-out order according to the task request time. When each task to be scheduled is queued, its corresponding virtual time is queued, and other relevant attributes of the task to be scheduled are initialized.
[0069] Step S30: Obtain the traversal interval and the target barrier threshold value that is dynamically adjusted according to the current load of the system.
[0070] It should be noted that the traversal interval is the time interval for triggering the traversal of the initial queue. For example, if the traversal interval is set to 4s, the initial queue will be traversed every 4s. The traversal interval can be set to a fixed number or calculated based on other data, such as calculating the traversal interval based on the time required for task scheduling in the work queue.
[0071] In practice, the target barrier threshold is dynamically adjusted based on the current system load. Different system loads correspond to different barrier thresholds. Load can be measured using metrics like CPU usage and memory utilization. When the load is high, the barrier threshold is lowered; when the load is low, the barrier threshold is increased.
[0072] Step S40: traverse the initial queue according to the traversal interval, and determine the target to-be-scheduled task from the initial queue according to the target barrier threshold and the virtual time.
[0073] In a specific implementation, the operation of traversing the initial queue can be triggered regularly by a timer or a scheduler, and the target task to be scheduled can be determined from the initial queue according to the dynamically adjusted barrier threshold and the virtual time of the task to be scheduled.
[0074] It should be noted that the target task to be scheduled is a task that meets the requirements of being added to the work queue. There is a certain relationship between the virtual time of the target task to be scheduled and the target barrier threshold, which can be determined based on the comparison result between the virtual time and the target barrier threshold.
[0075] Step S50: removing the target task to be scheduled from the initial queue and adding it to the work queue, and completing task scheduling according to the work queue.
[0076] In a specific implementation, after the target scheduling task is determined, the target to-be-scheduled task can be removed from the initial queue and added to the work queue. The work queue is used to store tasks that are currently ready and can be executed. Although the tasks in the work queue are also executed in a certain order (which can be regarded as a variant of first-in-first-out), the main ordering basis is based on the scheduling decision of the task, such as virtual time, priority or other scheduling strategies (such as shortest remaining time first). Therefore, although the newly added task to the work queue is usually at the end of the queue, the execution order may vary depending on the scheduling strategy.
[0077] In a specific implementation, during the interval of traversing the initial queue, tasks are taken out from the work queue according to the first-in-first-out principle for execution until all tasks are completed or a specific end condition is reached, completing the task scheduling.
[0078] This embodiment provides a task scheduling method, which obtains the virtual time and task request time of the task to be scheduled during task scheduling; adds the task to be scheduled to an initial queue in order based on the task request time, and the initial queue is used to store the task to be scheduled and the virtual time of the task to be scheduled; obtains a traversal interval and a target barrier threshold value dynamically adjusted according to the current load of the system; traverses the initial queue according to the traversal interval, and determines the target task to be scheduled from the initial queue according to the target barrier threshold value and the virtual time; removes the target task to be scheduled from the initial queue and adds it to a work queue, and completes task scheduling according to the work queue. Dynamically adjust the task scheduling strategy according to the system load to ensure that the system will not be overloaded under high load, improve system stability and reliability, and determine high-priority scheduling tasks according to the virtual time, reduce task waiting time, and improve scheduling efficiency.
[0079] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 , step S30 includes steps S301 to S304:
[0080] Step S301: traverse the work queue and calculate the total time required for all tasks in the work queue.
[0081] It should be noted that the traversal interval is related to the tasks in the work queue. Therefore, when calculating the traversal interval, you can first traverse the work queue and calculate the sum of the time required for all tasks in the work queue (Sum of Required Times). By calculating the sum of the time required for all tasks, the system can roughly understand the total time required to complete all tasks in the work queue.
[0082] Step S302: determining a traversal interval for traversing the initial queue according to the total time.
[0083] In practice, half of the total time can be set as the traversal interval for traversing the initial queue (Interval = Sum of Required Times / 2). This is intended to maintain a relatively balanced system load while responding to tasks as quickly as possible. This setting avoids overly frequent or sparse traversals, thereby helping to reduce system idle time and overload risks.
[0084] Step S303: monitoring the current load of the system using a preset monitoring frequency.
[0085] In a specific implementation, the preset monitoring frequency is a set reasonable monitoring frequency, such as monitoring the system load once per second or every few minutes.
[0086] The current system load is a collection of various system performance indicators, including CPU usage, memory utilization, and disk I / O wait time. These indicators can be obtained through operating system APIs (such as Windows Performance Counters and Linux's / proc file system or system calls). In practice, you can write scripts or programs to periodically poll these indicators and store or process them for subsequent analysis.
[0087] Step S304: dynamically adjusting the initial barrier threshold according to the current load of the system to obtain a target barrier threshold.
[0088] It should be noted that the initial barrier threshold may be dynamically adjusted according to the specific situation of the current system load, thereby obtaining an adjusted barrier threshold, ie, a target barrier threshold.
[0089] In a feasible implementation, step S304 may include steps A11 to A14:
[0090] Step A11: Compare the current load of the system with a set load threshold.
[0091] It should be noted that setting load thresholds means setting baseline thresholds for CPU usage, memory usage, etc. based on historical system operation data and expected performance. These baseline values serve as a reference for judging the level of system load.
[0092] By comparing the current system load with the set load threshold, it is determined whether the system load is high or low.
[0093] Step A12: When the current load of the system is greater than the set load threshold for a preset number of consecutive times, it is determined that the current load of the system meets a preset condition.
[0094] In a specific implementation, the continuous preset number of times can be set to 3 times or 5 times. In order to avoid the accidental nature of monitoring, the monitoring accuracy is improved by setting the continuous preset number of times. For example, the preset continuous number of times is set to 3 times. When the current load of the system exceeds the set load threshold for 3 consecutive times, such as the CPU usage rate or the memory occupancy rate continues to be higher than the set benchmark threshold for a period of time, it is determined that the current load of the system meets the preset situation, and the preset situation is that the current load of the system is high.
[0095] Step A13: Determine the adjustment step size according to the deviation degree of the current load of the system or the tolerance of the system to the response time.
[0096] In specific implementation, when the current system load is high, the initial barrier threshold should be appropriately lowered. On the contrary, if the system load is monitored to be continuously lower than the baseline threshold, it indicates that the system resources are relatively abundant. At this time, the barrier threshold can be appropriately increased to allow more tasks to enter the work queue and improve system utilization.
[0097] It should be noted that the magnitude of the adjustment of the barrier threshold should be determined based on the deviation of the current system load and the system's tolerance for response time. For example, a fixed adjustment step size can be set (such as a 10% decrease or increase each time), or the adjustment amount can be dynamically calculated based on the percentage change in load.
[0098] Step A14: Dynamically adjust the initial barrier threshold according to the adjustment step size to obtain a target barrier threshold.
[0099] In a specific implementation, the initial barrier threshold can be dynamically adjusted by adjusting the step size. If the current system load is too high, the barrier threshold is lowered; if the current system load is too low, the barrier threshold is increased.
[0100] Furthermore, in order to avoid the negative impact of frequent fluctuations in the barrier threshold on the system scheduling performance, a smoothing mechanism, such as a moving average method or an exponential smoothing method, can be introduced to process the monitored load data before using it to adjust the barrier threshold.
[0101] This embodiment traverses a work queue and calculates the total time required for all tasks in the work queue; determines a traversal interval for traversing the initial queue based on the total time; monitors the current system load at a preset monitoring frequency; and dynamically adjusts the initial barrier threshold based on the current system load to obtain a target barrier threshold. Dynamically adjusting the barrier threshold based on the current load ensures that the number of tasks entering the work queue is reduced during high load periods, preventing system overload; and increasing the threshold during low load periods to improve system resource utilization.
[0102] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 3 , step S40 includes steps S401 to S402:
[0103] Step S401: traverse the initial queue according to the traversal interval, and compare the virtual time of the task to be scheduled with the target barrier threshold.
[0104] It should be noted that each time the initial queue is traversed, the barrier threshold can be re-evaluated and adjusted according to the current system load to obtain the target barrier threshold. For each task to be scheduled, the size relationship between the virtual time of the task to be scheduled and the target barrier threshold is compared.
[0105] Step S402: When the virtual time of the task to be scheduled is less than or equal to the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
[0106] In a specific implementation, if the virtual time is less than or equal to the target barrier threshold, the task is removed from the initial queue and added to the work queue, that is, the corresponding task to be scheduled is the target task to be scheduled.
[0107] It should be noted that the virtual time may be greater than the target barrier threshold. At this time, the priority of the tasks to be scheduled in the initial queue needs to be adjusted so that more tasks to be scheduled have the opportunity to pass the target barrier threshold and be scheduled from the initial queue to the work queue.
[0108] Therefore, after step S401, the method also includes: obtaining a fixed time reduction value; when the virtual time of the task to be scheduled is greater than the target barrier threshold, reducing the virtual time of the task to be scheduled according to the fixed time reduction value to obtain an updated virtual time, and maintaining the position of the task to be scheduled in the initial queue.
[0109] It should be noted that the Fixed Time Decrement is a pre-set amount of time used to adjust the virtual time of tasks whose virtual time exceeds the target barrier threshold during task scheduling. For tasks whose virtual time exceeds the barrier threshold, the fixed time value is reduced each time.
[0110] If the virtual time of a task to be scheduled is greater than the target barrier threshold, its virtual time is reduced (minus the fixed time reduction value) and it is retained in the initial queue (maintaining its original position). This reduction only affects the task's virtual time and does not affect its actual execution time. The actual execution time of a task is still determined by its own characteristics and system resource allocation.
[0111] By adjusting the virtual time of tasks, a more flexible and efficient task scheduling strategy can be achieved. This helps optimize the allocation of system resources, ensuring that high-priority or urgent tasks can be scheduled and executed more quickly, while maintaining the overall stability and fairness of the system.
[0112] This embodiment traverses the initial queue based on the traversal interval, compares the virtual time of the task to be scheduled with the target barrier threshold, and sets the task to be scheduled as the target task to be scheduled if the virtual time of the task to be scheduled is less than or equal to the target barrier threshold. By adding tasks to the work queue whose virtual time is less than or equal to the target barrier threshold, task waiting time is reduced, system response speed is increased, and user experience is enhanced, thereby strengthening user stickiness.
[0113] Based on the first embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 4 In this embodiment, the initial queue also stores the expected response time of the task to be scheduled. Step S40 includes steps S401' to S403':
[0114] Step S401 ′: traverse the initial queue according to the traversal interval to determine the current waiting time of each task to be scheduled.
[0115] It should be noted that when each task is queued, in addition to calculating its virtual time and initializing related properties, its expected response time must also be set.
[0116] Therefore, when traversing the initial queue according to the traversal interval, the current waiting time of each task to be scheduled can also be obtained, thereby determining whether the current waiting time exceeds its expected response time.
[0117] Step S402 ′: Compare the current waiting time with the expected response time.
[0118] It should be noted that the current waiting time can be compared with the corresponding expected response time to determine whether the current waiting time is about to exceed the expected response time. If the current waiting time is not close to the expected response time, the current waiting time of the next task to be scheduled can be compared with the corresponding expected response time.
[0119] Step S403 ′: when the time difference between the current waiting time and the expected response time is less than a preset time threshold and the virtual time of the task to be scheduled is greater than the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
[0120] In a specific implementation, the preset time threshold can be set to 1s, 2s, etc. When the time difference between the current waiting time and the expected response time is less than the preset time threshold, it means that the current waiting time is about to exceed the expected response time. At this time, it is necessary to give priority to this task to be scheduled. It is then further determined whether the virtual time of the task to be scheduled is greater than the target barrier threshold. If the virtual time is greater than the target barrier threshold, the task to be scheduled is directly added to the work queue. If the virtual time of the task to be scheduled is less than or equal to the barrier threshold, it is used as the target task to be scheduled, and it is normally removed from the initial queue and added to the work queue.
[0121] During the interval of traversing the initial queue, tasks are taken from the work queue for execution. If the task has a response time guarantee requirement, execution is ensured to start within the expected response time of the task.
[0122] This embodiment traverses the initial queue according to the traversal interval to determine the current waiting time of each task to be scheduled; compares the current waiting time with the expected response time; and when the time difference between the current waiting time and the expected response time is less than a preset time threshold and the virtual time of the task to be scheduled is greater than the target barrier threshold, the task to be scheduled is used as the target task to be scheduled. By considering the expected scheduling time of the task, the task scheduling strategy is adjusted in real time, allowing the system to respond to high-priority and urgent tasks more quickly, reducing task waiting time, improving the overall system response speed, and flexibly responding to various complex scenarios to ensure the smooth execution of tasks.
[0123] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the task scheduling method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0124] This application also provides a task scheduling device, please refer to Figure 5 , the task scheduling device includes:
[0125] The acquisition module 10 is used to acquire the virtual time and task request time of the task to be scheduled when performing task scheduling.
[0126] The adding module 20 is used to add the tasks to be scheduled to an initial queue in order based on the task request time, and the initial queue is used to store the tasks to be scheduled and the virtual time of the tasks to be scheduled.
[0127] The acquisition module 10 is further configured to acquire the traversal interval and the target barrier threshold value that is dynamically adjusted according to the current load of the system;
[0128] a traversal module 30, configured to traverse the initial queue according to the traversal interval, and determine a target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time;
[0129] The scheduling module 40 is configured to remove the target task to be scheduled from the initial queue and add it to a work queue, and complete task scheduling according to the work queue.
[0130] The task scheduling device provided in this application utilizes the task scheduling method of the aforementioned embodiment to resolve the technical problem of low target task scheduling efficiency. Compared to the prior art, the beneficial effects of the task scheduling device provided in this application are the same as those of the task scheduling method provided in the aforementioned embodiment, and the other technical features of the task scheduling device are the same as those disclosed in the aforementioned embodiment, and are not further described here.
[0131] In one embodiment, the acquisition module 10 is also used to traverse the work queue and calculate the total time required for all tasks in the work queue; determine the traversal interval of traversing the initial queue based on the total time; monitor the current load of the system through a preset monitoring frequency; and dynamically adjust the initial barrier threshold according to the current load of the system to obtain a target barrier threshold.
[0132] In one embodiment, the acquisition module 10 is also used to compare the current load of the system with a set load threshold; when the current load of the system is greater than the set load threshold for a consecutive preset number of times, determine that the current load of the system meets the preset situation; determine the adjustment step size according to the degree of deviation of the current load of the system or the system's tolerance for response time; and dynamically adjust the initial barrier threshold according to the adjustment step size to obtain the target barrier threshold.
[0133] In one embodiment, the traversal module 30 is further used to traverse the initial queue according to the traversal interval, compare the virtual time of the task to be scheduled with the target barrier threshold; when the virtual time of the task to be scheduled is less than or equal to the target barrier threshold, the task to be scheduled is used as the target task to be scheduled.
[0134] In one embodiment, the traversal module 30 is also used to obtain a fixed time reduction value; when the virtual time of the task to be scheduled is greater than the target barrier threshold, the virtual time of the task to be scheduled is reduced according to the fixed time reduction value to obtain an updated virtual time, and the position of the task to be scheduled in the initial queue is maintained.
[0135] In one embodiment, the initial queue also stores the expected response time of the task to be scheduled; the traversal module 30 is also used to traverse the initial queue according to the traversal interval to determine the current waiting time of each task to be scheduled; compare the current waiting time with the expected response time; when the time difference between the current waiting time and the expected response time is less than a preset time threshold and the virtual time of the task to be scheduled is greater than the target fence threshold, the task to be scheduled is used as the target task to be scheduled.
[0136] The present application provides a task scheduling device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the task scheduling method in the above-mentioned embodiment one.
[0137] Reference below Figure 6 , which shows a schematic diagram of the structure of a task scheduling device suitable for implementing the embodiments of the present application. The task scheduling device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The task scheduling device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0138] like Figure 6As shown, the task scheduling device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in ROM (Read Only Memory) 1002 or programs loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the task scheduling device. Processing device 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output device 1008 including, for example, LCD (Liquid Crystal Display), speaker, vibrator, etc.; storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and communication device 1009. Communication device 1009 can allow the task scheduling device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a task scheduling device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0139] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0140] The task scheduling device provided in this application utilizes the task scheduling method of the aforementioned embodiment to resolve the technical problem of low target task scheduling efficiency. Compared to the prior art, the beneficial effects of the task scheduling device provided in this application are the same as those of the task scheduling method provided in the aforementioned embodiment, and the other technical features of the task scheduling device are the same as those disclosed in the aforementioned embodiment, and are not further described here.
[0141] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0142] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0143] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, wherein the computer-readable program instructions are used to execute the task scheduling method in the above embodiment.
[0144] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash memory), optical fiber, CD-ROM (CD-Read Only Memory, portable compact disk read-only memory), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0145] The computer-readable storage medium may be included in the task scheduling device; or may exist independently without being assembled into the task scheduling device.
[0146] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the task scheduling device, the task scheduling device: obtains the virtual time and task request time of the task to be scheduled when performing task scheduling; adds the tasks to be scheduled to the initial queue in sequence based on the task request time, and the initial queue is used to store the tasks to be scheduled and the virtual time of the tasks to be scheduled; obtains the traversal interval and the target fence threshold dynamically adjusted according to the current load of the system; traverses the initial queue according to the traversal interval, and determines the target task to be scheduled from the initial queue according to the target fence threshold and the virtual time; removes the target task to be scheduled from the initial queue and adds it to the work queue, and completes task scheduling according to the work queue.
[0147] The computer program code for performing the operations of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a LAN (Local Area Network) or a WAN (Wide Area Network), or can be connected to an external computer (e.g., using an Internet service provider to connect via the Internet).
[0148] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0149] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0150] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., a computer program) for executing the above-mentioned task scheduling method, and can solve the technical problem of low efficiency in scheduling target tasks. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the task scheduling method provided in the above-mentioned embodiment, and will not be elaborated here.
[0151] The present application also provides a computer program product, including a computer program, which implements the steps of the task scheduling method described above when executed by a processor.
[0152] The computer program product provided in this application can solve the technical problem of low efficiency in target task scheduling. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the task scheduling method provided in the above embodiment, and will not be repeated here.
[0153] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A task scheduling method, characterized in that: The task scheduling method includes: When scheduling tasks, obtain the virtual time and task request time of the task to be scheduled; Adding the tasks to be scheduled to an initial queue in order based on the task request time, the initial queue is used to store the tasks to be scheduled and the virtual time of the tasks to be scheduled; Get the traversal interval and the target barrier threshold that is dynamically adjusted according to the current load of the system; Traversing the initial queue according to the traversal interval, and determining a target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time; The target task to be scheduled is removed from the initial queue and added to the work queue, and task scheduling is completed according to the work queue.
2. The method according to claim 1, wherein The steps of obtaining the traversal interval and the target barrier threshold value dynamically adjusted according to the current load of the system include: Traverse the work queue and calculate the total time required for all tasks in the work queue; determining a traversal interval for traversing the initial queue according to the time sum; Monitor the current load of the system through preset monitoring frequency; The initial barrier threshold is dynamically adjusted according to the current load of the system to obtain a target barrier threshold.
3. The method according to claim 2, wherein The step of dynamically adjusting the initial barrier threshold according to the current load of the system to obtain the target barrier threshold comprises: comparing the current load of the system with a set load threshold; When the current load of the system is greater than the set load threshold for a consecutive preset number of times, determining that the current load of the system meets a preset condition; Determining an adjustment step size according to a deviation degree of the current load of the system or a tolerance of the system to a response time; The initial barrier threshold is dynamically adjusted according to the adjustment step size to obtain a target barrier threshold.
4. The method according to claim 1, wherein The step of traversing the initial queue according to the traversal interval and determining the target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time includes: traverse the initial queue according to the traversal interval, and compare the virtual time of the task to be scheduled with the target barrier threshold; When the virtual time of the task to be scheduled is less than or equal to the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
5. The method according to claim 4, wherein The method further comprises: Get the fixed time reduction value; When the virtual time of the task to be scheduled is greater than the target barrier threshold, the virtual time of the task to be scheduled is reduced according to the fixed time reduction value to obtain an updated virtual time, and the position of the task to be scheduled in the initial queue is maintained.
6. The method according to any one of claims 1 to 5, characterized in that The initial queue also stores the expected response time of the task to be scheduled; The step of traversing the initial queue according to the traversal interval and determining the target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time includes: Traversing the initial queue according to the traversal interval to determine the current waiting time of each task to be scheduled; comparing the current waiting time with the expected response time; When the time difference between the current waiting time and the expected response time is less than a preset time threshold and the virtual time of the task to be scheduled is greater than the target barrier threshold, the task to be scheduled is used as a target task to be scheduled.
7. A task scheduling device, characterized in that: The device comprises: The acquisition module is used to obtain the virtual time and task request time of the task to be scheduled when performing task scheduling; An adding module, configured to sequentially add the tasks to be scheduled to an initial queue based on the task request time, wherein the initial queue is configured to store the tasks to be scheduled and the virtual time of the tasks to be scheduled; The acquisition module is further used to obtain the traversal interval and the target barrier threshold value that is dynamically adjusted according to the current load of the system; a traversal module, configured to traverse the initial queue according to the traversal interval, and determine a target task to be scheduled from the initial queue according to the target barrier threshold and the virtual time; The scheduling module is used to remove the target task to be scheduled from the initial queue and add it to the work queue, and complete task scheduling according to the work queue.
8. A task scheduling device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the task scheduling method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Task allocation method, device and equipment of robot cluster and medium
CN122392858A