Task scheduling method and device, equipment and medium
By dividing tasks into specific tasks and ordinary tasks, and dynamically switching scheduling strategies at the scheduling time, the problem that existing schedulers cannot meet customized needs is solved, and the flexibility of task scheduling and the quality of service are improved.
Patent Information
- Application Number
- CN202511829976.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-05
- Publication Date
- 2026-03-03
AI Technical Summary
Existing schedulers cannot determine specific scheduling strategies based on business characteristics, and cannot meet the customized scheduling needs for specific tasks in cloud infrastructure scenarios.
Tasks are divided into specific tasks and ordinary tasks. By determining whether a specific task is included when the scheduling opportunity arises, different scheduling methods are used for flexible scheduling.
It improves the flexibility of task scheduling and service quality, ensuring low-latency response and efficient resource utilization for critical tasks.
Smart Images

Figure CN121597370A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing technology, and in particular to a task scheduling method and a task scheduling device. Background Technology
[0002] The existing scheduler is embedded in the kernel layer and serves as the heart of the operating system kernel. Although it provides fine-grained priority capabilities and other configuration adjustment capabilities, the overall framework is completely fixed and cannot determine specific scheduling strategies based on business characteristics. It cannot meet the service requirements of customized scheduling strategies for specific tasks that may arise in cloud-based scenarios. Summary of the Invention
[0003] In view of the above problems, embodiments of the present invention are proposed to provide a task scheduling method, apparatus, device and medium that overcomes or at least partially solves the above problems.
[0004] According to a first aspect of the present invention, a task scheduling method is provided, the method comprising: Define multiple tasks; the multiple tasks include specific tasks and general tasks; When the scheduling opportunity arises, determine whether the task to be scheduled among the multiple tasks includes a specific task; If the task to be scheduled does not include a specific task, determine the priority of the task to be scheduled among the ordinary tasks; and schedule the task to be scheduled in order according to the priority. If the task to be scheduled contains a specific task, obtain the target scheduling method for the task to be scheduled; and schedule the task to be scheduled according to the target scheduling method.
[0005] Optionally, the priority of the ordinary task is determined according to the task type; the tasks to be scheduled include tasks of the same priority and tasks of different priorities; scheduling the tasks to be scheduled in sequence according to the priority includes: When the tasks to be scheduled have the same priority, the multiple tasks with the same priority are scheduled in a time-sharing manner using a round-robin approach. If the tasks to be scheduled have different priorities, the tasks to be scheduled shall be scheduled in order of priority.
[0006] Optionally, obtaining the target scheduling method for the task to be scheduled includes: Obtain the runtime characteristic information of the task to be scheduled; The target scheduling method for the task to be scheduled is determined based on the operational characteristic information; the target scheduling method includes a first target scheduling method, a second target scheduling method, and a third target scheduling method; the first target scheduling method is used to set the priority of the task to be scheduled to the highest; the second target scheduling method is used to allocate resources to the task to be scheduled when the task to be scheduled meets the operational conditions; the third target scheduling method is used to set the priority of the task to be scheduled to the lowest.
[0007] Optionally, scheduling the task to be scheduled according to the target scheduling method includes: The urgency score of the task to be scheduled is determined based on the operational characteristic information. If the urgency score of the task to be scheduled is greater than the first score threshold, the task to be scheduled is scheduled according to the first target scheduling method; If the urgency score of the task to be scheduled is greater than or less than the second score threshold, the task to be scheduled is scheduled according to the second target scheduling method. If the urgency score of the task to be scheduled is less than or equal to the second score threshold, the task to be scheduled is scheduled according to the third target scheduling method.
[0008] Optionally, the runtime characteristic information includes at least one of historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; determining the urgency score of the task to be scheduled based on the runtime characteristic information includes: Obtain the weights corresponding to the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; The urgency score of the task to be scheduled is determined by multiplying at least one of the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate with their corresponding weights.
[0009] Optionally, before scheduling the tasks to be scheduled in accordance with the said priority, the method further includes: Get the current task's time slice; Determine if the current task's time slice has expired; If the time slice of the current task is not used up, reduce the time slice of the current task; If the time slice of the current task expires, the highest priority task is determined from the tasks to be scheduled. The highest priority task is added to the beginning of the scheduling queue, and the current task is added to the end of the scheduling queue.
[0010] Optionally, the method further includes: Obtain adjustment instructions; Adjust the scheduling method corresponding to the task according to the adjustment instruction.
[0011] According to a second aspect of the present invention, a task scheduling apparatus is provided, the apparatus comprising: A multi-task determination module is used to determine multiple tasks; the multiple tasks include specific tasks and ordinary tasks; The specific task determination module is used to determine, when the scheduling opportunity arrives, whether the task to be scheduled among the multiple tasks includes a specific task; The first scheduling module is used to determine the priority of the task to be scheduled among the ordinary tasks when the task to be scheduled does not include a specific task; and to schedule the task to be scheduled in sequence according to the priority. The second scheduling module is used to obtain the target scheduling method of the task to be scheduled when the task to be scheduled contains a specific task; and to schedule the task to be scheduled according to the target scheduling method.
[0012] Optionally, the priority of the ordinary task is determined according to the task type, and the tasks to be scheduled include tasks of the same priority and tasks of different priorities. The first scheduling module includes: The first scheduling submodule is used to schedule multiple tasks of the same priority in a time-sharing manner by means of time-slice rotation when the tasks to be scheduled are of the same priority. The second scheduling submodule is used to schedule the tasks to be scheduled in sequence according to their priorities when the tasks to be scheduled have different priorities.
[0013] Optionally, the second scheduling module includes: The runtime characteristic information acquisition submodule is used to acquire the runtime characteristic information of the task to be scheduled. The target scheduling method determination submodule is used to determine the target scheduling method of the task to be scheduled based on the running characteristic information; the target scheduling method includes a first target scheduling method, a second target scheduling method, and a third target scheduling method; the first target scheduling method is used to set the priority of the task to be scheduled to the highest; the second target scheduling method is used to allocate resources to the task to be scheduled when the task to be scheduled meets the running conditions; the third target scheduling method is used to set the priority of the task to be scheduled to the lowest.
[0014] Optionally, the second scheduling module includes: An urgency score determination submodule is used to determine the urgency score of the task to be scheduled based on the operational characteristic information. The third scheduling submodule is used to schedule the task to be scheduled according to the first target scheduling method when the urgency score of the task to be scheduled is greater than the first score threshold. The fourth scheduling submodule is used to schedule the task to be scheduled according to the second target scheduling method when the urgency score of the task to be scheduled is greater than the second score threshold and less than the second score threshold. The fifth scheduling submodule is used to schedule the task to be scheduled according to the third target scheduling method when the urgency score of the task to be scheduled is less than or equal to the second score threshold.
[0015] Optionally, the operational characteristic information includes at least one of historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; the urgency scoring determination submodule includes: The weight acquisition unit is used to acquire the weights corresponding to the historical scheduling delay time, historical resource consumption rate and historical memory allocation rate. An urgency score determination unit is used to determine the urgency score of the task to be scheduled based on the product of at least one of the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate with their corresponding weights.
[0016] Optionally, before scheduling the tasks to be scheduled in accordance with the said priority, the device further includes: The time slice acquisition module is used to acquire the current task's time slice; The time slice determination module is used to determine whether the time slice of the current task has been used up; The time slice reduction module is used to reduce the time slice of the current task if the time slice of the current task has not been used up. The highest priority determination module is used to determine the highest priority task from the tasks to be scheduled when the time slice of the current task has expired. The scheduling queue addition module is used to add the highest priority task to the beginning of the scheduling queue and add the current task to the end of the scheduling queue.
[0017] Optionally, the device further includes: The adjustment instruction acquisition module is used to acquire adjustment instructions; The adjustment module is used to adjust the scheduling method corresponding to the task according to the adjustment instruction.
[0018] This invention provides a task scheduling method. The method involves identifying multiple tasks, including specific tasks and general tasks. When a scheduling opportunity arises, it is determined whether the task to be scheduled contains a specific task. If the task does not contain a specific task, its priority among the general tasks is determined. The tasks are then scheduled sequentially according to their priority. If the task contains a specific task, a target scheduling method for the task is obtained. Finally, the task is scheduled according to the target scheduling method. This invention divides tasks into specific tasks and general tasks. When a task does not contain a specific task, it is scheduled according to the priority of general tasks. When it contains a specific task, it is scheduled using the target scheduling method, thus improving the flexibility of task scheduling and ensuring service quality. Attached Figure Description
[0019] Figure 1 This is a flowchart of the steps of a task scheduling method provided in an embodiment of the present invention; Figure 2 This is a flowchart of another task scheduling method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a scenario for a task scheduling method provided in an embodiment of the present invention; Figure 4 This is a structural block diagram of a task scheduling device provided in an embodiment of the present invention. Detailed Implementation
[0020] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] One of the core concepts of this invention is that by dividing tasks into specific tasks and ordinary tasks, when the task to be scheduled does not contain specific tasks, it is scheduled in a regular manner according to the priority of ordinary tasks; when it contains specific tasks, it is scheduled through the target scheduling method of the task to be scheduled, thereby improving the flexibility of task scheduling and ensuring service quality.
[0022] Reference Figure 1 The diagram illustrates a flowchart of a task scheduling method provided by an embodiment of the present invention. The method may specifically include the following steps: Step 101: Identify multiple tasks; the multiple tasks include specific tasks and general tasks; For example, in cloud-based scenarios, although the business characteristics are relatively simple, there are still significant differences in the business importance, real-time requirements, and resource consumption patterns of different tasks. Specific tasks and ordinary tasks can be scheduled using different schedulers. By pre-identifying task types, the system can distinguish between specific tasks with special requirements or operational characteristics regarding performance, latency, or resource guarantees, such as real-time audio and video processing and core control services, and ordinary tasks with relatively relaxed scheduling response requirements, such as background batch processing and log collection. This classification provides a basis for subsequent scheduling decisions, enabling the system to use customized, high-priority scheduling strategies for critical tasks while adopting a general and fair scheduling approach for ordinary tasks. This design breaks through the limitations of traditional schedulers' "one-size-fits-all" approach, improves the intelligence of resource allocation and service level guarantee capabilities, and is the prerequisite and foundation for achieving a flexible, efficient, and scalable scheduling system.
[0023] Step 102: When the scheduling opportunity arrives, determine whether the task to be scheduled among the multiple tasks includes a specific task; For example, scheduling timing (such as clock interrupts, task blocking, or wake-ups) is a decision point that determines processor resource allocation. If a specific task (such as a real-time or high-priority task) exists at this point, its scheduling request must be responded to first to avoid service timeouts or performance degradation due to delayed scheduling. Lower-priority tasks are allowed to be preempted and promptly yielded. By making this judgment at this point, changes in the task set can be perceived in real time, and scheduling logic can be dynamically switched: if a specific task exists, a customized scheduling strategy is enabled to improve the flexibility of task scheduling; if no specific task exists, the general scheduling process is returned. This mechanism achieves on-demand adaptation of scheduling behavior, ensuring low-latency response for critical tasks while avoiding excessive intervention in ordinary tasks, thus improving the real-time performance, flexibility, and resource utilization efficiency of scheduling decisions.
[0024] Step 103: If the task to be scheduled does not include a specific task, determine the priority of the task to be scheduled among the ordinary tasks; schedule the task to be scheduled in order according to the priority. For example, while ordinary tasks may not have special protection requirements, they still have varying degrees of urgency. Some background services might be more important than log tasks. Through a priority mechanism, the system can differentiate between ordinary tasks of different importance, prioritizing the execution of more critical tasks and preventing low-value tasks from consuming resources for extended periods. For tasks of the same priority, time-slicing round-robin scheduling is used to achieve fair time-sharing and prevent starvation; for tasks of different priorities, scheduling is performed in descending order of priority, reflecting the rationality of resource allocation. This mechanism, as the "default path" of the scheduling system, ensures stable system operation and basic service quality when there is no specific task competition. It is an indispensable fallback logic in the overall scheduling strategy, balancing efficiency, fairness, and predictability.
[0025] Step 104: If the task to be scheduled includes a specific task, obtain the target scheduling method for the task to be scheduled; schedule the task to be scheduled according to the target scheduling method.
[0026] For example, specific tasks often have special performance or latency requirements, and their scheduling needs cannot be simply met by a general priority mechanism. They must be precisely judged based on their actual operational characteristics (such as memory consumption rate, latency sensitivity, etc.) to select the most suitable scheduling strategy. By analyzing operational characteristic information, the system can identify the key attributes of a task: for example, for tasks with extremely high resource requirements and absolute priority, the first objective scheduling method is applied, setting its priority to the highest level to ensure it can immediately preempt the CPU and execute first; for tasks with stringent real-time requirements, the second objective scheduling method is applied, allocating resources immediately when the task meets the running conditions (i.e., is ready), minimizing scheduling latency and ensuring timely response; while for tasks marked as "specific" but actually background computing tasks that need to actively yield resources (such as offline training, batch processing), the third objective scheduling method is applied, setting its priority to the lowest level so that it can only run when the system is idle, actively avoiding high-priority tasks and preventing interference with critical services. This mechanism, which dynamically matches scheduling strategies based on operational characteristics, enables flexible scheduling with "one policy per category" and "one policy per task," ensuring both the performance and stability of core businesses while also taking into account resource utilization efficiency, and significantly improving the intelligence level of the scheduling system.
[0027] This invention provides a task scheduling method. The method involves identifying multiple tasks, including specific tasks and general tasks. When a scheduling opportunity arises, it is determined whether the task to be scheduled contains a specific task. If the task does not contain a specific task, its priority among the general tasks is determined. The tasks are then scheduled sequentially according to their priority. If the task contains a specific task, a target scheduling method for the task is obtained. Finally, the task is scheduled according to the target scheduling method. This invention divides tasks into specific tasks and general tasks. When a task does not contain a specific task, it is scheduled according to the priority of general tasks. When it contains a specific task, it is scheduled using the target scheduling method, thus improving the flexibility of task scheduling and ensuring service quality.
[0028] Reference Figure 2 The diagram illustrates a flowchart of a task scheduling method provided by an embodiment of the present invention. The method may specifically include the following steps: Step 201: Identify multiple tasks; the multiple tasks include specific tasks and general tasks; For example, in cloud-based scenarios, although the business characteristics are relatively simple, there are still significant differences in the business importance, real-time requirements, and resource consumption patterns of different tasks. Specific tasks and ordinary tasks can be scheduled using different schedulers. By pre-identifying task types, the system can distinguish between specific tasks with special requirements or operational characteristics regarding performance, latency, or resource guarantees, such as real-time audio and video processing and core control services, and ordinary tasks with relatively relaxed scheduling response requirements, such as background batch processing and log collection. This classification provides a basis for subsequent scheduling decisions, enabling the system to use customized, high-priority scheduling strategies for critical tasks while adopting a general and fair scheduling approach for ordinary tasks. This design breaks through the limitations of traditional schedulers' "one-size-fits-all" approach, improves the intelligence of resource allocation and service level guarantee capabilities, and is the prerequisite and foundation for achieving a flexible, efficient, and scalable scheduling system.
[0029] Step 202: When the scheduling opportunity arrives, determine whether the task to be scheduled among the multiple tasks includes a specific task; For example, scheduling timing (such as clock interrupts, task blocking, or wake-ups) is a decision point that determines processor resource allocation. If a specific task (such as a real-time or high-priority task) exists at this point, its scheduling request must be responded to first to avoid service timeouts or performance degradation due to delayed scheduling. Lower-priority tasks are allowed to be preempted and promptly yielded. By making this judgment at this point, changes in the task set can be perceived in real time, and scheduling logic can be dynamically switched: if a specific task exists, a customized scheduling strategy is enabled to improve the flexibility of task scheduling; if no specific task exists, the general scheduling process is returned. This mechanism achieves on-demand adaptation of scheduling behavior, ensuring low-latency response for critical tasks while avoiding excessive intervention in ordinary tasks, thus improving the real-time performance, flexibility, and resource utilization efficiency of scheduling decisions.
[0030] Step 203: If the task to be scheduled does not include a specific task, determine the priority of the task to be scheduled among the ordinary tasks; schedule the task to be scheduled in order according to the priority. For example, while ordinary tasks may not have special protection requirements, they still have varying degrees of urgency. Some background services might be more important than log tasks. Through a priority mechanism, the system can differentiate between ordinary tasks of different importance, prioritizing the execution of more critical tasks and preventing low-value tasks from consuming resources for extended periods. For tasks of the same priority, time-slicing round-robin scheduling is used to achieve fair time-sharing and prevent starvation; for tasks of different priorities, scheduling is performed in descending order of priority, reflecting the rationality of resource allocation. This mechanism, as the "default path" of the scheduling system, ensures stable system operation and basic service quality when there is no specific task competition. It is an indispensable fallback logic in the overall scheduling strategy, balancing efficiency, fairness, and predictability.
[0031] In one embodiment, the priority of the ordinary task is determined according to the task type; the tasks to be scheduled include tasks of the same priority and tasks of different priorities; step 203 includes the following sub-steps: Sub-step S11: If the tasks to be scheduled have the same priority, schedule the multiple tasks to be scheduled with the same priority in a time-sharing manner using a round-robin method. For example, the priority of ordinary tasks is determined based on task type because different types of ordinary tasks still differ in business importance, resource requirements, and execution characteristics, requiring a priority mechanism to reflect the rationality and fairness of scheduling. For instance, data synchronization tasks may be more time-sensitive than log archiving tasks and should receive a higher scheduling priority. By binding task type to priority, the system can establish a stable execution order for various ordinary tasks without introducing complex real-time scheduling. Based on this, the tasks to be scheduled may include multiple tasks with the same or different priorities, requiring differentiated scheduling strategies. Under the same priority, time-sharing scheduling using a round-robin approach ensures that tasks of equal importance share CPU resources fairly, preventing a single task from monopolizing the processor for an extended period and causing "starvation" for other tasks. This mechanism achieves smooth task switching and load balancing by allocating fixed or dynamic time slices to each task and switching to the next task after the time slice is exhausted. This not only improves the system's concurrent processing capabilities but also enhances the predictability and uniformity of scheduling. Therefore, setting priorities based on task type and combining time-slice round-robin processing of tasks with the same priority not only ensures the hierarchy of scheduling but also takes into account fairness and efficiency. This is the core mechanism that balances simplicity and practicality in ordinary task scheduling scenarios.
[0032] Sub-step S12: If the tasks to be scheduled have different priorities, schedule the tasks to be scheduled in order of priority.
[0033] For example, in a multi-task concurrent environment, tasks vary in importance and timeliness. If a completely fair scheduling approach is adopted without prioritizing tasks, critical tasks (such as data synchronization and status monitoring) may be delayed by lower-importance tasks (such as log compression and cache cleanup), impacting system stability or user experience. By establishing a clear priority order, the scheduler can prioritize the execution of the highest-priority ready task in each scheduling decision, thus allocating resources to high-value tasks. This "high-priority first" strategy effectively reduces the waiting time and scheduling latency of critical tasks, ensuring timely response and continuous execution. Simultaneously, this mechanism still allows lower-priority tasks to have execution opportunities when higher-priority tasks are idle, balancing resource utilization and fairness. Therefore, priority-based scheduling not only reflects the rationality of resource allocation but also enhances the system's adaptability to business needs. It is an important means of achieving efficient and orderly task management, especially suitable for cloud environments and complex system scenarios with differentiated service level requirements.
[0034] Step 204: If the task to be scheduled includes a specific task, obtain the running characteristic information of the task to be scheduled; determine the target scheduling method of the task to be scheduled based on the running characteristic information; the target scheduling method includes a first target scheduling method, a second target scheduling method, and a third target scheduling method; the first target scheduling method is used to set the priority of the current task to be scheduled to the highest; the second target scheduling method is used to allocate resources to the task to be scheduled when the task to be scheduled has the running conditions; the third target scheduling method is used to set the priority of the current task to be scheduled to the lowest; schedule the task to be scheduled according to the target scheduling method.
[0035] For example, specific tasks often have special performance or latency requirements, and their scheduling needs cannot be simply met by a general priority mechanism. They must be precisely judged based on their actual operational characteristics (such as memory consumption rate, latency sensitivity, etc.) to select the most suitable scheduling strategy. By analyzing operational characteristic information, the system can identify the key attributes of a task: for example, for tasks with extremely high resource requirements and absolute priority, the first objective scheduling method is applied, setting its priority to the highest level to ensure it can immediately preempt the CPU and execute first; for tasks with stringent real-time requirements, the second objective scheduling method is applied, allocating resources immediately when the task meets the running conditions (i.e., is ready), minimizing scheduling latency and ensuring timely response; while for tasks marked as "specific" but actually background computing tasks that need to actively yield resources (such as offline training, batch processing), the third objective scheduling method is applied, setting its priority to the lowest level so that it can only run when the system is idle, actively avoiding high-priority tasks and preventing interference with critical services. This mechanism, which dynamically matches scheduling strategies based on operational characteristics, enables flexible scheduling with "one policy per category" and "one policy per task," ensuring both the performance and stability of core businesses while also taking into account resource utilization efficiency, and significantly improving the intelligence level of the scheduling system.
[0036] Reference Figure 3 This illustration shows a scenario diagram of a task scheduling method provided by an embodiment of the present invention. The system can allocate resources and schedule tasks of multiple applications through different schedulers. For example, a task-type-based scalable scheduler can be used to execute the first and third target scheduling methods in a specific task, a Real Time Scheduler (RT scheduler) can be used to execute the second target scheduling method in a specific task, and a Completely Fair Scheduler (CFS scheduler) can be used to schedule ordinary tasks.
[0037] In one embodiment, step 204 includes the following sub-steps: Sub-step S21: Determine the urgency score of the task to be scheduled based on the operational characteristic information; For example, traditional scheduling relies on preset priorities, making it difficult to adapt to scenarios where task behavior changes over time. However, by collecting historical scheduling latency, resource consumption rate, memory allocation rate, and other operational characteristics of tasks, the system can comprehensively assess their potential impact on system performance, service quality, and resource stability. For instance, tasks that have been delayed for a long time may be in a state of starvation and require increased urgency; tasks with high resource consumption, if blocked, may lead to service backlog or timeouts. Transforming these characteristics into a unified urgency score allows for an objective measurement of task urgency and serves as a basis for selecting the target scheduling method (such as highest priority, real-time response, or low-priority avoidance). This mechanism enhances the intelligence and adaptability of the scheduling system, ensuring that truly "urgent" tasks are identified promptly and receive appropriate resource guarantees in complex and ever-changing load environments.
[0038] In one embodiment, the operational characteristic information includes at least one of historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; sub-step S21 includes the following sub-steps: Sub-step S211: Obtain the weights corresponding to the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; For example, historical scheduling latency reflects how quickly a task was responded to by the system in the past; the longer the latency, the more likely it is to be starved, necessitating an increase in scheduling opportunities. Historical resource consumption rate (such as CPU utilization) reflects the intensity of a task's processor usage; blocking high-consumption tasks may cause performance bottlenecks. Historical memory allocation rate reveals the speed at which tasks expand their memory resource usage; excessively rapid growth may indicate memory leaks or sudden loads, threatening system stability. Relying on a single indicator can easily lead to misjudgments, therefore a comprehensive consideration is necessary. Introducing a weighting mechanism is to adapt to the scheduling preferences of different business scenarios: in real-time sensitive systems, scheduling latency can be given higher weight; in computationally intensive scenarios, resource consumption rate can be emphasized. By configuring weights, the system can flexibly adjust the bias of the scoring model, making the urgency scoring more in line with actual business needs and improving the configurability and applicability of the scheduling strategy.
[0039] Sub-step S212: Determine the urgency score of the task to be scheduled based on the product of at least one of the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate with the corresponding weight.
[0040] For example, since the units of each feature quantity are not directly summed, they need to be normalized first, and then weighted summation is performed. This method transforms qualitative judgment into quantitative calculation, enabling the system to objectively compare the urgency of different tasks. For instance, a task with long scheduling latency but low resource consumption and a task with short latency but rapid memory growth can be prioritized by their scores. The weighted product form preserves the relative importance of each indicator while supporting flexible adjustment strategies (such as emphasizing real-time performance or stability). The final urgency score serves as a unified benchmark, driving the selection of subsequent scheduling methods, achieving a scheduling upgrade from experience-based judgment to data-driven decision-making, and significantly improving the scientific nature and automation level of scheduling decisions.
[0041] Sub-step S22: If the urgency score of the task to be scheduled is greater than the first score threshold, the task to be scheduled is scheduled according to the first target scheduling method. For example, when the urgency score of a task to be scheduled exceeds the first score threshold, it indicates that the task has extremely high scheduling urgency under the current system state, and its operational characteristics (such as long scheduling delays, extremely high resource consumption, or rapid memory growth) have reached a level that seriously affects service quality or system stability. At this point, the most aggressive intervention measures must be taken to ensure that it immediately obtains resources and is executed with priority. The first-target scheduling method sets the task priority to the highest, giving it the ability to preempt all low-priority tasks, allowing it to be scheduled to run on the CPU immediately once ready, minimizing response time. This strategy is suitable for core control tasks, critical real-time services, or tasks exhibiting abnormal behavior (such as memory leaks), preventing further deterioration due to resource contention. By setting the first score threshold as a "red alert line," the system achieves rapid identification and mandatory protection of extremely urgent tasks, which is a core mechanism for ensuring system high availability and critical business continuity, reflecting the proactive defense and priority enhancement capabilities of the scheduling strategy.
[0042] Sub-step S23: If the urgency score of the task to be scheduled is greater than or less than the second score threshold, the task to be scheduled is scheduled according to the second target scheduling method. For example, when the urgency score of a task to be scheduled is greater than the second threshold but less than the first threshold, it indicates that the task has significant scheduling urgency, but has not yet reached the extreme level where absolute priority preemption is necessary. Such tasks typically exhibit moderate scheduling latency, high resource requirements, or a certain memory growth trend, and are common in latency-sensitive services (such as audio / video transmission, interactive applications) or tasks with periodic load increases. In this case, the second-target scheduling approach—allocating resources to the task as soon as it is ready to run—is a compromise strategy that balances responsiveness and system fairness. This approach does not set the task as the highest priority to avoid excessive preemption, but ensures that it receives execution opportunities within an acceptable latency window by optimizing the scheduling path (such as priority queuing and rapid response to ready events). Compared to the "forced preemption" of the first-target scheduling approach, the second-target scheduling emphasizes "timely response" and is suitable for scenarios with real-time requirements but tolerating slight latency. By setting a second scoring threshold as the "early warning interval," the system achieves accurate identification and appropriate acceleration of moderately urgent tasks. This not only improves the user experience but also avoids excessive resource concentration, maintaining the balance and flexibility of overall scheduling. It is a key link in achieving tiered protection and refined service management.
[0043] Sub-step S24: If the urgency score of the task to be scheduled is less than or equal to the second score threshold, the task to be scheduled is scheduled according to the third target scheduling method.
[0044] For example, when the urgency score of a task to be scheduled is less than or equal to the second score threshold, it indicates that the task does not have an urgent scheduling need in the current system. Its operational characteristics are characterized by short scheduling latency, stable resource consumption, or slow memory growth, belonging to background, batch processing, or low-priority tasks. Such tasks are not sensitive to response time, can be frequently preempted by high-priority tasks, and their main goal is to complete computation using idle system resources. Therefore, adopting a third-objective scheduling method, setting its priority to the lowest, ensures that it actively avoids all higher-priority tasks, preventing interference with the execution of critical business operations. This strategy helps improve the overall service quality of the system and prevents low-value tasks from occupying critical resources. Simultaneously, this scheduling method is usually combined with an idle resource detection mechanism, which can still schedule such tasks in a timely manner when CPU load is low, fully utilizing the system's computing power and improving resource utilization. Through this hierarchical mechanism, the system achieves a scheduling order of "critical tasks first, ordinary tasks in order, and background tasks yielding," ensuring the performance of high-priority tasks while also considering the overall efficiency and fairness of the system.
[0045] In one embodiment, before scheduling the tasks to be scheduled in order of priority, the method further includes: obtaining the time slice of the current task; determining whether the time slice of the current task has been used up; if the time slice of the current task has not been used up, reducing the time slice of the current task; if the time slice of the current task has been used up, determining the task with the highest priority from the tasks to be scheduled; adding the task with the highest priority to the beginning of the scheduling queue, and adding the current task to the end of the scheduling queue.
[0046] For example, traditional schedulers typically strictly adhere to time-slice round-robin rules, triggering scheduling decisions only after a time slice has been exhausted. This can lead to high-priority tasks waiting for lower-priority tasks to use up their remaining time slices, causing unnecessary scheduling delays. This method proactively determines whether the current task's time slice has expired. If it hasn't, but a higher-priority or more urgent task (such as a specific task) is ready, the remaining time slice is reduced in advance, shortening the time the task continues to occupy the CPU, accelerating the scheduling switchover, and improving system response speed. When the time slice is indeed exhausted, the system immediately selects the highest-priority task from the list of tasks to be scheduled as a candidate and inserts it at the head of the scheduling queue to ensure it is executed first; simultaneously, the current task is moved to the end of the queue to maintain fairness. This mechanism combines "time-slice driven" and "event-driven" approaches: it retains the fairness of time-slice round-robin while breaking rigid execution through dynamic intervention, supporting rapid response to critical tasks. Especially in scenarios involving specific task wake-ups or sudden increases in urgency scores, this strategy can significantly reduce preemption latency, prevent high-priority tasks from waiting for extended periods due to excessive remaining time slices, and effectively improve the real-time performance, flexibility, and resource utilization efficiency of the scheduling system.
[0047] In one embodiment, the method further includes: obtaining an adjustment instruction; and adjusting the scheduling mode corresponding to the task according to the adjustment instruction.
[0048] For example, in actual system operation, the importance of tasks, resource requirements, or external environment may change over time. For instance, a background task may temporarily need to be accelerated, or a critical service may be downgraded to a regular task due to a failure. If the scheduling method remains fixed, it will be difficult to cope with such dynamic changes. By introducing an adjustment command mechanism, the system supports dynamically modifying the task scheduling strategy at runtime, such as changing it from "avoiding priority" to "highest priority," or switching to different target scheduling methods. This command can come from manual intervention by administrators, automated operation and maintenance systems, or intelligent decision-making modules based on monitoring data. This dynamic adjustment capability gives the scheduling system good manageability and adaptability, enabling it to quickly respond to business changes, performance bottlenecks, or anomalies without restarting tasks or the system, optimizing resource allocation, and ensuring service quality. Simultaneously, it also provides technical support for advanced operation and maintenance scenarios such as canary releases, load balancing, and fault recovery, significantly improving the flexibility, maintainability, and intelligence level of the scheduling system.
[0049] This invention provides a task scheduling method. The method involves identifying multiple tasks, including specific tasks and general tasks. When a scheduling opportunity arises, it is determined whether the task to be scheduled contains a specific task. If the task does not contain a specific task, its priority among the general tasks is determined. The tasks are then scheduled sequentially according to their priority. If the task contains a specific task, a target scheduling method for the task is obtained. Finally, the task is scheduled according to the target scheduling method. This invention divides tasks into specific tasks and general tasks. When a task does not contain a specific task, it is scheduled according to the priority of general tasks. When it contains a specific task, it is scheduled using the target scheduling method, thus improving the flexibility of task scheduling and ensuring service quality.
[0050] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0051] Reference Figure 4 The diagram shows a structural block diagram of a task scheduling device provided in an embodiment of the present invention, which may specifically include the following modules: The task determination module 401 is used to determine multiple tasks; the multiple tasks include specific tasks and ordinary tasks. The specific task determination module 402 is used to determine, when the scheduling opportunity arrives, whether the task to be scheduled among the multiple tasks includes a specific task; The first scheduling module 403 is used to determine the priority of the task to be scheduled among the ordinary tasks when the task to be scheduled does not include a specific task; and to schedule the task to be scheduled in sequence according to the priority. The second scheduling module 404 is used to obtain the target scheduling method of the task to be scheduled when the task to be scheduled contains a specific task; and to schedule the task to be scheduled according to the target scheduling method.
[0052] In one embodiment, the priority of the ordinary task is determined according to the task type, and the tasks to be scheduled include tasks of the same priority and tasks of different priorities. The first scheduling module includes: The first scheduling submodule is used to schedule multiple tasks of the same priority in a time-sharing manner by means of time-slice rotation when the tasks to be scheduled are of the same priority. The second scheduling submodule is used to schedule the tasks to be scheduled in sequence according to their priorities when the tasks to be scheduled have different priorities.
[0053] In one embodiment, the second scheduling module includes: The runtime characteristic information acquisition submodule is used to acquire the runtime characteristic information of the task to be scheduled. The target scheduling method determination submodule is used to determine the target scheduling method of the task to be scheduled based on the running characteristic information; the target scheduling method includes a first target scheduling method, a second target scheduling method, and a third target scheduling method; the first target scheduling method is used to set the priority of the task to be scheduled to the highest; the second target scheduling method is used to allocate resources to the task to be scheduled when the task to be scheduled meets the running conditions; the third target scheduling method is used to set the priority of the task to be scheduled to the lowest.
[0054] In one embodiment, the second scheduling module includes: An urgency score determination submodule is used to determine the urgency score of the task to be scheduled based on the operational characteristic information. The third scheduling submodule is used to schedule the task to be scheduled according to the first target scheduling method when the urgency score of the task to be scheduled is greater than the first score threshold. The fourth scheduling submodule is used to schedule the task to be scheduled according to the second target scheduling method when the urgency score of the task to be scheduled is greater than the second score threshold and less than the second score threshold. The fifth scheduling submodule is used to schedule the task to be scheduled according to the third target scheduling method when the urgency score of the task to be scheduled is less than or equal to the second score threshold.
[0055] In one embodiment, the operational characteristic information includes at least one of historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; the urgency scoring determination submodule includes: The weight acquisition unit is used to acquire the weights corresponding to the historical scheduling delay time, historical resource consumption rate and historical memory allocation rate. An urgency score determination unit is used to determine the urgency score of the task to be scheduled based on the product of at least one of the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate with their corresponding weights.
[0056] In one embodiment, before scheduling the tasks to be scheduled in accordance with the priority, the apparatus further includes: The time slice acquisition module is used to acquire the current task's time slice; The time slice determination module is used to determine whether the time slice of the current task has been used up; The time slice reduction module is used to reduce the time slice of the current task if the time slice of the current task has not been used up. The highest priority determination module is used to determine the highest priority task from the tasks to be scheduled when the time slice of the current task has expired. The scheduling queue addition module is used to add the highest priority task to the beginning of the scheduling queue and add the current task to the end of the scheduling queue.
[0057] In one embodiment, the device further includes: The adjustment instruction acquisition module is used to acquire adjustment instructions; The adjustment module is used to adjust the scheduling method corresponding to the task according to the adjustment instruction.
[0058] This invention provides a task scheduling method. The method involves identifying multiple tasks, including specific tasks and general tasks. When a scheduling opportunity arises, it is determined whether the task to be scheduled contains a specific task. If the task does not contain a specific task, its priority among the general tasks is determined. The tasks are then scheduled sequentially according to their priority. If the task contains a specific task, a target scheduling method for the task is obtained. Finally, the task is scheduled according to the target scheduling method. This invention divides tasks into specific tasks and general tasks. When a task does not contain a specific task, it is scheduled according to the priority of general tasks. When it contains a specific task, it is scheduled using the target scheduling method, thus improving the flexibility of task scheduling and ensuring service quality.
[0059] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0060] This invention also provides an electronic device, comprising: It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described task scheduling method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0061] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described task scheduling method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0062] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0063] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0064] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0065] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0066] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0067] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0068] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0069] The above provides a detailed description of a task scheduling method and a task scheduling device provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A task scheduling method, characterized in that, The method includes: Define multiple tasks; the multiple tasks include specific tasks and general tasks; When the scheduling opportunity arises, determine whether the task to be scheduled among the multiple tasks includes a specific task; If the task to be scheduled does not include a specific task, determine the priority of the task to be scheduled among the ordinary tasks; and schedule the task to be scheduled in order according to the priority. If the task to be scheduled contains a specific task, obtain the target scheduling method for the task to be scheduled; and schedule the task to be scheduled according to the target scheduling method.
2. The task scheduling method according to claim 1, characterized in that, The priority of the ordinary task is determined according to the task type; the tasks to be scheduled include tasks of the same priority and tasks of different priorities; scheduling the tasks to be scheduled in sequence according to the priority includes: When the tasks to be scheduled have the same priority, the multiple tasks with the same priority are scheduled in a time-sharing manner using a round-robin approach. If the tasks to be scheduled have different priorities, the tasks to be scheduled shall be scheduled in order of priority.
3. The task scheduling method according to claim 1, characterized in that, The step of obtaining the target scheduling method for the task to be scheduled includes: Obtain the runtime characteristic information of the task to be scheduled; The target scheduling method for the task to be scheduled is determined based on the operational characteristic information; the target scheduling method includes a first target scheduling method, a second target scheduling method, and a third target scheduling method; the first target scheduling method is used to set the priority of the task to be scheduled to the highest; the second target scheduling method is used to allocate resources to the task to be scheduled when the task to be scheduled meets the operational conditions; the third target scheduling method is used to set the priority of the task to be scheduled to the lowest.
4. The task scheduling method according to claim 3, characterized in that, The step of scheduling the task to be scheduled according to the target scheduling method includes: The urgency score of the task to be scheduled is determined based on the operational characteristic information. If the urgency score of the task to be scheduled is greater than the first score threshold, the task to be scheduled is scheduled according to the first target scheduling method; If the urgency score of the task to be scheduled is greater than or less than the second score threshold, the task to be scheduled is scheduled according to the second target scheduling method. If the urgency score of the task to be scheduled is less than or equal to the second score threshold, the task to be scheduled is scheduled according to the third target scheduling method.
5. The task scheduling method according to claim 4, characterized in that, The operational characteristic information includes at least one of historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; determining the urgency score of the task to be scheduled based on the operational characteristic information includes: Obtain the weights corresponding to the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate; The urgency score of the task to be scheduled is determined by multiplying at least one of the historical scheduling delay time, historical resource consumption rate, and historical memory allocation rate with their corresponding weights.
6. The task scheduling method according to claim 1, characterized in that, Before scheduling the tasks to be scheduled in accordance with the said priority, the method further includes: Get the current task's time slice; Determine if the current task's time slice has expired; If the time slice of the current task is not used up, reduce the time slice of the current task; If the time slice of the current task expires, the highest priority task is determined from the tasks to be scheduled. The highest priority task is added to the beginning of the scheduling queue, and the current task is added to the end of the scheduling queue.
7. The task scheduling method according to claim 1, characterized in that, The method further includes: Obtain adjustment instructions; Adjust the scheduling method corresponding to the task according to the adjustment instruction.
8. A task scheduling device, characterized in that, The device includes: A multi-task determination module is used to determine multiple tasks; the multiple tasks include specific tasks and ordinary tasks; The specific task determination module is used to determine, when the scheduling opportunity arrives, whether the task to be scheduled among the multiple tasks includes a specific task; The first scheduling module is used to determine the priority of the task to be scheduled among the ordinary tasks when the task to be scheduled does not include a specific task; and to schedule the task to be scheduled in sequence according to the priority. The second scheduling module is used to obtain the target scheduling method of the task to be scheduled when the task to be scheduled contains a specific task; and to schedule the task to be scheduled according to the target scheduling method.
9. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the task scheduling method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the task scheduling method as described in any one of claims 1-7.