Task adjustment method and device, storage medium, electronic equipment and computer program product
By setting up the first queue and the second queue in the task queue and adjusting the task position according to the waiting time and execution time of the task, the problem of insufficient fairness in task scheduling is solved, the reasonable allocation of resources and fair execution of tasks is achieved, and the system performance and user experience are improved.
Patent Information
- Application Number
- CN202510956618.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-08-08
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing task scheduling technology, task fairness is insufficient, resulting in some tasks being unable to be executed for a long time due to low priority, affecting system efficiency and user experience.
By setting up the first queue and the second queue, it is used for tasks with different priority levels, and adjust the position of the tasks between queues according to the waiting time and execution time of the task, set thresholds to detect abnormal situations, and dynamically adjust the task priority to achieve reasonable allocation of resources.
Effectively prevent unbalanced resource allocation, improve the overall performance of the system and the fairness of task scheduling, ensure that all tasks are executed within a reasonable time, and improve the overall efficiency and user experience of the system.
Smart Images

Figure CN120448078A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a task adjustment method, device, storage medium, electronic device, and computer program product. Background Art
[0002] In today's highly advanced computing systems and network environments, with the rapid development of multi-core processors, distributed architectures, and cloud computing, systems face unprecedentedly complex task scheduling challenges. These systems must not only handle a large number of real-time, interactive, and batch tasks, but also cope with the diverse demands these tasks place on core resources such as CPU, memory, and input / output (I / O). Each task type has distinct resource requirements and priorities.
[0003] Real-time tasks, such as video streaming processing and financial transaction settlement, typically need to be completed within strict deadlines, placing extremely high demands on system response speed and determinism. Interactive tasks, including web browsing and online gaming, prioritize user-perceived latency and immediate system feedback. Batch tasks, such as big data analysis and scientific computing, can consume significant computing resources and last for extended periods, placing high demands on resource efficiency.
[0004] While existing task scheduling algorithms have achieved some success in optimizing system resource utilization and improving overall performance, traditional priority scheduling algorithms tend to prioritize high-priority tasks. While this improves system efficiency, it can also cause low-priority tasks to be indefinitely postponed, creating a "starvation" phenomenon. This unbalanced resource allocation not only impacts user experience but also reduces the overall fairness and efficiency of the system.
[0005] Currently, no effective solution has been proposed to the problem that task scheduling technology in existing technologies is not fair enough, which may result in some tasks not being executed for a long time due to their low priority.
[0006] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the Invention
[0007] The embodiments of the present application provide a task adjustment method, device, storage medium, electronic device, and computer program product to at least solve the problem of insufficient fairness in task scheduling technology in related technologies, which may result in certain tasks not being executed for a long time due to low priority.
[0008] According to one aspect of an embodiment of the present application, according to one embodiment of the present application, a task adjustment method is provided, including: determining the target priority of tasks in a first queue and a second queue, and transferring tasks whose target priority is less than a preset priority into the first queue, and transferring tasks whose target priority is greater than or equal to the preset priority into the second queue; determining a first waiting time for each first task in the first queue, and determining a continuous execution time for each second task in the second queue, wherein the first waiting time is the time from the last time the target device scheduled the first task to the current time; determining a third task among multiple first tasks whose first waiting time is greater than the second preset time, and determining a fourth task among multiple second tasks whose continuous execution time is greater than the preset execution time; transferring the third task into the second queue, and transferring the fourth task into the first queue.
[0009] According to another aspect of an embodiment of the present application, a task adjustment device is provided, including: a first determination module, used to determine the target priority of tasks in a first queue and a second queue, and transfer tasks whose target priority is less than a preset priority to the first queue, and transfer tasks whose target priority is greater than or equal to the preset priority to the second queue; a second determination module, used to determine a first waiting time for each first task in the first queue, and determine a continuous execution time for each second task in the second queue, wherein the first waiting time is the time from the last time the target device scheduled the first task to the current time; a third determination module, used to determine a third task among multiple first tasks whose first waiting time is greater than the second preset time, and to determine a fourth task among multiple second tasks whose continuous execution time is greater than the preset execution time; a transfer module, used to transfer the third task to the second queue, and transfer the fourth task to the first queue.
[0010] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising: a memory for storing a computer program; and a processor for implementing the steps of the adjustment method of any one of the above tasks when executing the computer program.
[0011] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the adjustment method of any of the above tasks are implemented.
[0012] According to another aspect of an embodiment of the present application, a computer program product is further provided, including a computer program, which implements the steps of the adjustment method of any of the above tasks when the computer program is executed by a processor.
[0013] Through the embodiments of the present application, target priorities of tasks in a first queue and a second queue are determined, and tasks with a target priority lower than a preset priority are transferred to the first queue, and tasks with a target priority greater than or equal to the preset priority are transferred to the second queue; a first waiting time for each first task in the first queue is determined, and a continuous execution time for each second task in the second queue is determined, wherein the first waiting time is the time from the last time the target device scheduled the first task to the current time; a third task with a first waiting time greater than a second preset time is determined among multiple first tasks, and a fourth task with a continuous execution time greater than the preset execution time is determined among multiple second tasks; the third task is transferred to the second queue, and the fourth task is transferred to the first queue. That is, by setting a threshold to detect abnormalities in task waiting and execution, and timely adjusting the queue position of the task, the imbalance of resource allocation is effectively prevented, the overall performance of the system and the fairness of task scheduling are improved, and the problem of insufficient fairness in task scheduling technology in the related art, which may cause some tasks to not be executed for a long time due to low priority, is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0015] Figure 1 This is a hardware structure block diagram of a computer device for a task adjustment method according to an embodiment of the present application;
[0016] Figure 2 is a flowchart (1) of a method for adjusting a task according to an embodiment of the present application;
[0017] Figure 3 is a schematic diagram of a task model according to an embodiment of the present application;
[0018] Figure 4 is a flowchart (II) of a method for adjusting a task according to an embodiment of the present application;
[0019] Figure 5 is a schematic diagram of priority transfer according to an embodiment of the present application;
[0020] Figure 6 It is a structural block diagram of a task adjustment device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0022] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0023] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0024] The method embodiments provided in the embodiments of the present application can be executed in a computer device or similar computing device. Taking running on a computer device as an example, Figure 1 This is a hardware structure diagram of a computer device for a task adjustment method according to an embodiment of the present application. Figure 1 As shown, the computer device may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MPU or a programmable logic device FPGA) and a memory 104 for storing data. The computer device may also include a transmission device 106 and an input / output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer device. For example, the computer device may also include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0025] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for adjusting the task in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0026] Transmission device 106 is used to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by a communications provider of the computer device. In one embodiment, transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0027] In this embodiment, a method for adjusting a task is provided. Figure 2 is a flowchart (1) of a method for adjusting a task according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0028] Step S202 , determining target priorities of tasks in the first queue and the second queue, and transferring tasks with target priorities less than a preset priority into the first queue, and transferring tasks with target priorities greater than or equal to the preset priority into the second queue.
[0029] Periodically evaluate the priorities of tasks in the first queue (usually the fair queue) and the second queue (usually the unfair queue) to determine the target priority of each task.
[0030] Step S204, determine the first waiting time of each first task in the first queue, and determine the continuous execution time of each second task in the second queue, wherein the first waiting time is the time from the target device last scheduling the first task to the current time.
[0031] For tasks in the first queue, the waiting time since the last scheduling is calculated, known as the "first waiting time." This helps assess the fairness of task waiting and ensures that all tasks receive an execution opportunity within a reasonable timeframe. For tasks in the second queue, the duration of their continuous execution is recorded, known as the "continuous execution time." This is used to monitor task resource usage within NFQ and prevent tasks from occupying resources for extended periods, forcing other tasks to wait.
[0032] Step S206 , determining a third task having a first waiting time longer than a second preset time among the plurality of first tasks, and determining a fourth task having a continuous execution time longer than a preset execution time among the plurality of second tasks.
[0033] In the first queue, we identify "third tasks" whose waiting time exceeds the second preset duration. This indicates that the task has been waiting too long in the fair queue and may need to be prioritized to prevent starvation. In the second queue, we identify "fourth tasks" whose continuous execution time exceeds the preset execution time. This prevents high-priority tasks from overusing resources and ensures proper resource allocation.
[0034] Step S208: transfer the third task to the second queue, and transfer the fourth task to the first queue.
[0035] Third, tasks that have been waiting in the fair queue for too long are transferred to the unfair queue to receive higher execution priority and faster resource allocation. Fourth, tasks that have been continuously executed for too long in the unfair queue are transferred to the fair queue to ensure fairer resource allocation and prevent resources from being overly concentrated in a few tasks.
[0036] Through the above steps, the target priorities of tasks in the first queue and the second queue are determined, and tasks with target priorities less than the preset priority are transferred to the first queue, and tasks with target priorities greater than or equal to the preset priority are transferred to the second queue; a first waiting time for each first task in the first queue is determined, and a continuous execution time for each second task in the second queue is determined, wherein the first waiting time is the time from the last time the target device scheduled the first task to the current time; a third task with a first waiting time greater than the second preset time is determined from multiple first tasks, and a fourth task with a continuous execution time greater than the preset execution time is determined from multiple second tasks; the third task is transferred to the second queue, and the fourth task is transferred to the first queue. That is, by setting a threshold to detect abnormalities in task waiting and execution, and timely adjusting the queue position of the task, the imbalance of resource allocation is effectively prevented, the overall performance of the system and the fairness of task scheduling are improved, and the problem of insufficient fairness in task scheduling technology in the related art, which may cause some tasks to not be executed for a long time due to low priority, is solved.
[0037] It should be noted that if Figure 3 As shown, in a cloud computing scenario, a tenant often submits multiple tasks, and there is a sequence relationship between these tasks. Only after the previous tasks are completed can the subsequent tasks be run. Therefore, the premise of the application embodiment is to schedule tasks layer by layer, and the following scheduling method is also for tasks at the same layer.
[0038] Optionally, the target priority of the tasks in the first queue and the second queue can be determined in the following manner: obtaining the first task weight, second waiting time, task service quality level, and cumulative execution time of the task; and determining the target priority of the task based on the first task weight, the second waiting time, the task service quality level, and the cumulative execution time.
[0039] Task weight reflects the relative importance or urgency of a task and is typically assigned by the user or the system when the task is created. Tasks with higher weights typically represent service requests that are more important or require a faster response.
[0040] The second waiting time is the waiting time since the last scheduling, which is the length of time the task waits in the queue for execution.
[0041] A service-level agreement defines the quality of service standards for a task, including response time, throughput, reliability, etc. Tasks with high QOS levels usually represent tasks for which users have paid extra or have special service requirements, and should receive resource allocation that is superior to standard QOS.
[0042] The cumulative execution time is the cumulative execution time of the task from the start to the current time point. It is used to evaluate whether the task is close to completion or whether it has consumed too many resources.
[0043] Based on the collected parameters, the system determines the target priority of each task through certain calculation formulas or decision logic.
[0044] In this embodiment of the application, by incorporating task weight, waiting time, service quality level, and cumulative execution time into the calculation, the system can more comprehensively assess task priority, ensuring that not only the attributes of the task itself (such as importance and urgency) are considered, but also the waiting time and resource usage of the task. Compared to traditional priority scheduling algorithms based on a single parameter (such as task weight), this method uses multiple parameters to more carefully reflect the actual needs of the task and the system status, making more accurate and reasonable scheduling decisions.
[0045] Optionally, in the task scheduling system, in order to dynamically adjust the priority of tasks and ensure fairness and efficiency, the embodiment of the present application proposes a target priority calculation formula that comprehensively considers task weight, waiting time, service quality level and cumulative execution time. Specifically: the target priority of the task can be determined by the following formula :
[0046] ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value.
[0047] Task weight and cumulative execution time The ratio can prevent long tasks from excessively occupying resources and ensure that high-weight tasks can reduce their priority even if they are executed for a period of time.
[0048] A logarithmic function is used to quantify the waiting time of a task since its last scheduling, so that shorter waiting times have less impact on priority, while its impact increases nonlinearly with time, which helps to ensure fairness, especially for tasks with longer waiting times.
[0049] The quality of service level of the task is directly added to the priority calculation. Tasks with high QOS levels will receive additional priority, which is a priority guarantee for paid or critical tasks.
[0050] By using the above formula to calculate the target priority of tasks, the system comprehensively considers task urgency, fair waiting, resource utilization efficiency, and user service levels to dynamically adjust the movement of tasks between fair and unfair queues, achieving reasonable resource allocation and improving overall scheduling efficiency and user experience. This calculation method is particularly effective when handling mixed tasks, balancing the demands of different types of tasks and reducing "starvation" while maintaining high system performance and responsiveness.
[0051] Optionally, in task scheduling, not only the various attributes of the task itself, such as task weight, waiting time, quality of service (QOS) and cumulative execution time, need to be considered, but also special attention needs to be paid to the dependencies between tasks, especially the priority of the predecessor task, including: determining whether the task has a predecessor task, wherein the predecessor task is the task on which the task depends; if the task has a predecessor task, obtaining the priority of the predecessor task; determining the target priority of the task based on the priority of the predecessor task, the first task weight, the second waiting time, the task quality of service and the cumulative execution time.
[0052] The system first determines whether each task has predecessors and identifies them. If a task does have predecessors, the system obtains their current priorities. The system then combines the predecessor priorities with factors such as the task's weight, wait time, quality of service level, and accumulated execution time, using a specific calculation formula or logic to determine the task's target priority.
[0053] The embodiment of the present application introduces the priority of the predecessor task as an additional factor, making the task scheduling mechanism more intelligent, effectively processing task sets with complex dependencies, and ensuring the efficient operation of the entire workflow.
[0054] In an exemplary embodiment, determining the target priority of the task based on the priority of the predecessor task, the first task weight, the second waiting time, the task service quality level and the accumulated execution time includes: determining the target priority of the task by the following formula :
[0055] ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value, is the propagation coefficient of the predecessor task, is the priority of the predecessor task, is the out-degree of the predecessor task.
[0056] The target priority of task i is determined by the following formula:
[0057] ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value, is the propagation coefficient of the predecessor task, is the priority of the predecessor task, is the out-degree of the predecessor task.
[0058] is the priority of predecessor task j, and its execution directly affects the resource acquisition of subsequent task i.
[0059] is the out-degree of the predecessor task, that is, how many subsequent tasks depend on it, reflecting the criticality of the task in the overall workflow. It is the propagation coefficient of the predecessor task, which is used to quantify how the priority of the predecessor task is "propagated" to the subsequent tasks. Usually, the value on the critical path is larger.
[0060] For example, imagine a typical workflow in a cloud computing environment, which includes three tasks: A, B, and C, where task B depends on A, and C depends on the completion of B and A.
[0061] Task A has no predecessor task, assuming W A = 8, T A = 5s, = 0s, QOS A = 4, .
[0062] The predecessor task of task B is A, then P B According to the priority P of A A calculate.
[0063] The predecessor tasks of task C are A and B, so P C It will be calculated based on the average priority of A and B, or the priority of A P A and B's priority P B calculate.
[0064] It should be noted that, at the initial stage of the task, the task is first divided into the first queue and a time slice rotation is maintained to ensure that each task gets at least the minimum time slice. Therefore, T i It will not be 0.
[0065] In the embodiments of this application, refined management of task dependencies allows the system to more intelligently schedule dependent tasks by calculating the impact of predecessor task priorities, preventing subsequent tasks from waiting too long due to improper resource allocation for predecessor tasks. The propagation coefficient and out-degree factor in the dynamic balance formula for resource allocation not only reflect the importance of the task's position in the network, but also consider the interactions between tasks, achieving a dynamic and balanced allocation of resources and avoiding excessive concentration of resources on certain tasks.
[0066] In an exemplary embodiment, obtaining the first task weight of the task includes: when the task is a task in the second queue, obtaining the preset task weight of the task; adjusting the preset task weight according to the third waiting time to determine the first task weight of the task, wherein the third waiting time is the time after the task enters the queue.
[0067] When the initial weight W of a task i This weight is preset by the user or the system when a task is submitted. It reflects the importance, urgency, or service level of the task. The system assesses the waiting status of a task by monitoring the length of time the task has been in the queue since it was last scheduled. Long waiting times reduce the task's weight.
[0068] This embodiment of the application effectively balances fairness and efficiency in task scheduling by introducing a wait-time-based task weight adjustment mechanism. This approach is particularly suitable for complex systems handling high-concurrency, multi-type tasks, such as multi-tenant services in cloud computing environments. By dynamically optimizing task priorities, the system can better respond to user needs, improve resource utilization, and ensure service quality and user experience.
[0069] In an exemplary embodiment, adjusting the preset task weight according to the third waiting time to determine the first task weight of the task includes:
[0070] The first task weight is determined by the following formula :
[0071] ,in, is the preset task weight, and t is the third waiting time.
[0072] In this embodiment of the application, an exponential decay adjustment is performed on the preset task weight based on the waiting time of the task in the queue (the third waiting time). Specifically:
[0073] In this formula, This indicates that as the waiting time t increases, the task weight decays exponentially. This model, based on an understanding of fairness and dynamic resource allocation, aims to penalize tasks that remain idle for extended periods of time. Rather than simply depriving them of resources, it gradually reduces their priority relative to other tasks. By using the third waiting time as a weight adjustment parameter, the system automatically adjusts the task's priority based on its real-time status. This means that the longer a task waits, the smaller its weight becomes, reducing its probability of receiving priority in the next scheduling round, unless other mechanisms (e.g., timeout escalation or task feature reassessment) intervene and correct the situation.
[0074] For example, suppose there are two tasks in a non-fair queue (NFQ): Task X and Task Y. Their initial weights are W and Y, respectively. X0 = 10 and W Y0 = 5, and at a certain time point, their second waiting time is t X = 5s and t Y = 10s.
[0075] Calculate the first task weight of task X:
[0076] ;
[0077] Calculate the first task weight of task Y:
[0078] .
[0079] The calculation results show that although Task X has a higher initial weight, its weight decreases significantly after a certain period of waiting. Similarly, Task Y's weight also decays, but given its lower initial weight, its absolute decay may be smaller than that of Task X.
[0080] In the embodiments of this application, through dynamic weight adjustment, long-waiting tasks gradually lose their competitive advantage over new tasks or tasks with shorter wait times, avoiding the unfair "first come first served" phenomenon and promoting fair scheduling among tasks. The exponential decay model encourages the system to execute tasks with high initial weights as quickly as possible because their weights drop rapidly once they have waited too long, thereby incentivizing the scheduling algorithm to prioritize tasks with shorter wait times, improving system responsiveness.
[0081] In an exemplary embodiment, obtaining the first task weight of the task includes: when the task is a task in the first queue, obtaining a preset task weight of the task and determining the preset task weight as the first task weight.
[0082] In a fair queue, the initial weight or priority of each task is primarily preset by the user when submitting the task. This reflects the task's urgency, resource requirements, or the user's payment level. When a task first enters a fair queue or is requeued in a fair queue, its preset task weight will be directly used as the first task weight.
[0083] In a fair queue, the first task weight W of task i is i (t) will remain unchanged until it is scheduled for execution or migrated to an unfair queue. This means that in a fair queue, the priority of a task will not decrease or increase as the waiting time increases, maintaining relative fairness among tasks.
[0084] In an embodiment of the present application, the method for determining the weight of the first task in the fair queue provides a basic but effective mechanism for achieving fairness in task scheduling by retaining the preset weight of the task. It is particularly suitable for processing task scheduling in a multi-tenant environment, ensuring that each tenant's task can obtain reasonable resource allocation, thereby promoting the overall efficiency of the system and user experience.
[0085] In an exemplary embodiment, before transferring the task whose target priority is greater than or equal to the preset priority into the second queue, the method further includes: determining status information of a first resource of the target device; and determining whether to transfer the task whose target priority is greater than or equal to the preset priority into the second queue based on the status information.
[0086] In this embodiment, before transferring a task with a priority higher than or equal to a preset threshold from a fair queue (FQ) to a non-fair queue (NFQ), the system first evaluates the resource status of the target device (i.e., the physical or virtual device executing the task) and makes a decision on whether to transfer the task based on this information.
[0087] That is to say, before deciding whether to transfer a task from the fair queue (FQ) to the non-fair queue (NFQ), it first checks whether the CPU resources are idle when it is pushed into the stack. If they are idle, they are directly preempted. Otherwise, they are put into the queue and then resources are preempted according to priority.
[0088] In an exemplary embodiment, determining whether to transfer the task with a target priority greater than or equal to the preset priority to the second queue is performed based on the status information, including: when the status information indicates that the first resource is in an idle state, executing the task with a target priority greater than or equal to the preset priority through the first resource; when the status information indicates that the first resource is in an occupied state, transferring the task with a target priority greater than or equal to the preset priority to the second queue.
[0089] This embodiment proposes a strategy that monitors the device resource status to determine whether to transfer tasks with a target priority (i.e., tasks that reach or exceed a preset priority threshold) from a fair queue (FQ) to a non-fair queue (NFQ) for execution. Specifically:
[0090] The system evaluates the primary resource status of the target device (the physical or virtual device executing the task) in real time. The primary resource can be any critical resource that limits task execution, such as CPU, memory, or I / O devices. Depending on the resource status, the system takes one of two actions:
[0091] 1. Direct execution when resources are idle: If the status information indicates that the first resource is idle, the system will directly use this resource to execute tasks with a target priority greater than or equal to the preset priority, without transferring them to the NFQ. This reduces task migration between queues, improves scheduling efficiency, and avoids idle resources.
[0092] 2. NFQ Migration When a Resource is In Use: If the status information indicates that the first resource is occupied, the system migrates tasks with a target priority greater than or equal to the preset priority to NFQ. In NFQ, tasks are sorted by priority, and high-priority tasks can preempt resources, resulting in faster response and execution than in a fair queue.
[0093] For example, suppose that on a cloud server, CPU resources are the primary resource. There are two tasks awaiting execution: Task X has a target priority of 8, and Task Y has a target priority of 3, with a preset priority threshold of 5. When evaluating the CPU resource status, the system discovers that the CPU utilization is low and idle. Task X's priority is above the preset threshold, and the CPU is idle, so it can be directly used to execute on the CPU. Task Y's priority is below the preset threshold, so even though the CPU is idle, it remains in the fair queue awaiting scheduling.
[0094] During the execution of task X, CPU resources are occupied. At this time, if another task Z with a priority of 7 appears and also occupies CPU resources, and the priority of task Z is higher than the preset threshold, the system will migrate task Z to NFQ and wait for resources to be released before dynamically preempting the CPU for execution based on the priority.
[0095] In the embodiment of the present application, by real-time monitoring of resource status, the system can quickly respond to resource changes and directly execute high-priority tasks when resources are idle, thereby avoiding unnecessary queue migration and improving resource utilization.
[0096] In an exemplary embodiment, before transferring the third task to the second queue, the method further includes: adjusting the priority of the third task to the first priority, and controlling the third task to preempt the second resource; and determining whether to transfer the third task to the second queue based on the preemption status of the third task.
[0097] In complex computing environments, especially in multi-tenant cloud computing scenarios, task scheduling must not only consider fairness and efficiency but also address dynamic resource allocation and immediate adjustment of task priorities. This embodiment describes a strategy for switching tasks from a fair queue to an unfair queue under specific conditions, including:
[0098] This strategy targets third-tier tasks. When these tasks meet certain conditions (such as increased urgency or urgent resource requirements), they will be adjusted to the first priority (where the first priority is higher than the previous priority of the third-tier tasks). After attempting to seize the second resource (for example, other key resources besides the CPU, such as memory and hard disk space), it will be decided whether to formally migrate them to the unfair queue.
[0099] When the system detects that the urgency or resource requirements of the third task have reached a certain threshold, it immediately raises the priority of that task to the first priority. The system then directs the third task to attempt to preempt the second resource. Resource preemption refers to a task attempting to immediately seize the required system resources, rather than waiting for them to be released according to the regular scheduling plan. Based on the results of the resource preemption and the current system state, the system decides whether to formally migrate the third task to the unfair queue. If the preemption succeeds, the task is executed directly; if the preemption fails, the task is added to the unfair queue.
[0100] For example, in a multi-tenant cloud platform, consider task T3, which originally had a low priority but suddenly becomes a critical data processing task during execution, requiring a large amount of memory to complete data cleaning operations. At this point, the system immediately raises the priority of task T3 to the highest priority, and task T3 attempts to preempt additional memory resources to meet its high-load data processing needs. If the preemption succeeds and the system detects that the current memory usage is within a safe range, task T3 will proceed using the preempted memory resources. Otherwise, task T3 will be migrated to the unfair queue to ensure that it can complete its data processing tasks quickly.
[0101] The embodiments of the present application can significantly speed up the execution of critical tasks and improve the system's responsiveness and processing efficiency by allowing high-priority tasks to directly preempt required resources.
[0102] In an exemplary embodiment, determining whether to transfer the third task to the second queue is based on the preemption status of the third task, including: when the preemption status indicates that the third task successfully preempts the second resource, prohibiting the third task from being transferred to the second queue and executing the third task through the second resource; when the preemption status indicates that the third task fails to preempt the second resource, transferring the third task to the second queue.
[0103] In an embodiment of the present application, when the priority of the third task is raised to the highest level, the system will control the task to attempt to preempt the second resource. If the third task successfully preempts the second resource, the mechanism will prohibit it from being transferred to NFQ and instead execute the task directly through the second resource. This is because under the condition of sufficient resources, direct execution can significantly improve task efficiency and overall system performance. If the third task fails to successfully preempt the second resource, the mechanism will transfer it to NFQ to participate in subsequent priority scheduling. In NFQ, tasks will be dynamically sorted according to their priority and resource requirements, waiting for opportunities to execute when resources are idle or their priorities are adjusted.
[0104] For example, assume that in a multi-tenant cloud computing platform, task T3 is a batch processing task with high memory requirements, and its priority is dynamically adjusted to priority 1. There are two servers in the system: Server 1 has sufficient memory, while Server 2 has a memory utilization rate of 90%.
[0105] 1. Resource preemption attempt: T3 attempts to preempt memory resources on Server1 and Server2.
[0106] 2. Successful preemption processing: T3 successfully preempts sufficient memory resources on Server1. Therefore, according to this mechanism, T3 will be executed directly on Server1 and will not be moved to NFQ.
[0107] 3. Handling Failed Preemption: T3's attempt to preempt memory resources on Server2 fails because Server2's memory is nearly full. Therefore, T3 is moved to NFQ and awaits subsequent dynamic scheduling based on priority and resource availability.
[0108] In the embodiment of the present application, by real-time evaluation of the resource preemption results of the task, it is decided whether to execute it directly or move it to NFQ, thereby achieving a balance between efficient resource utilization and task scheduling fairness, and improving the overall performance of the system and user experience.
[0109] In an exemplary embodiment, after controlling the third task to preempt the second resource, the method further includes: determining the second priority of the task being executed by the second resource; determining whether the first priority is higher than the second priority; if the first priority is higher than the second priority, determining that the third task successfully preempts the second resource; if the first priority is lower than or equal to the second priority, determining that the third task fails to successfully preempt the second resource.
[0110] In an embodiment of the present application, the decision basis for determining whether the third task has successfully preempted the second resource (such as memory, disk I / O, etc.) is a priority comparison between the third task (promoted to the first priority) and the task currently using the second resource (with the second priority).
[0111] First, the system instructs the third task to attempt to preempt the second resource. The system then determines the priority (second priority) of the task currently using the second resource. The system compares the third task's first priority with the current task's second priority to determine the resource preemption outcome.
[0112] If the first priority of the third task is higher than the second priority of the current task, the system will determine that the third task has successfully preempted the resource. If the first priority is lower than or equal to the second priority, the system will determine that the third task has not successfully preempted the resource.
[0113] The third task obtains resource usage rights and executes immediately or waits for resource release without being transferred to the unfair queue. The third task must be transferred to the unfair queue and participate in subsequent priority scheduling, waiting for another opportunity to try to seize resources or execute when resources are idle.
[0114] For example, suppose that in a cloud platform, task T3 (the third task) is promoted to the first priority and attempts to seize memory resources on Server 2. At this time, the memory resources on Server 2 are being used by task T2.
[0115] If T3's first priority is higher than T2's, the system will determine that T3 successfully preempts the memory and execute T3 immediately. If T3's first priority is lower than or equal to T2's, T3 will be transferred to the unfair queue and wait for the next scheduling opportunity.
[0116] In this embodiment of the application, by introducing priority comparison, the system can intelligently determine resource preemption results, accelerate the execution of critical tasks, maintain scheduling fairness, and avoid improper resource allocation. This method is particularly suitable for scenarios with fierce resource competition and dynamically changing task priorities, such as multi-tenant cloud computing platforms, and helps improve overall system performance and user experience.
[0117] In an exemplary embodiment, determining the target priorities of tasks in the first queue and the second queue includes: setting a timer; and determining the target priorities of tasks in the first queue and the second queue when the timer reaches a timing duration.
[0118] When the system is initialized, a timer is set to periodically trigger task priority updates. When the timer reaches the set duration, a priority update event is triggered. The system recalculates the target priorities of all tasks in the first and second queues based on the latest resource status and task execution status. The calculation method may include considering factors such as the task's waiting time, execution time, resource requirements, quality of service (QoS), and dynamic weighting adjustments based on these factors. After recalculation, the new target priority is applied to the corresponding task. In a fair queue, tasks may be reordered based on the new priority; in an unfair queue, the priority adjustment of a task may affect its ability to preempt resources. The timer resets after completing a priority update to ensure that the priority update is triggered again when the next duration is reached, thereby maintaining continuous dynamic adjustment of the priority.
[0119] The embodiments of the present application help optimize resource allocation, improve scheduling efficiency, and maintain scheduling fairness. This method is particularly suitable for multi-tenant environments with frequently changing resource demands and can effectively address the challenges brought by system dynamics and complexity.
[0120] In an exemplary embodiment, after determining the first waiting time of each first task in the first queue, the method further includes: determining the third waiting time of each second task in the second queue; determining a fourth task among multiple second tasks whose third waiting time is greater than the third preset time, adjusting the priority of the fourth task to the third priority, and controlling the fourth task to preempt the third resource; if the fourth task successfully preempts the third resource, executing the fourth task through the third resource.
[0121] The system regularly evaluates the waiting time of all tasks in the first and second queues, including the first waiting time of the first task and the third waiting time of the second task. In the second queue, the system identifies tasks whose third waiting time is greater than the third preset time and marks these tasks as fourth tasks. The priority of the fourth task is raised to the third priority, and its attempts to preempt third resources (such as network bandwidth, specific I / O devices, etc.) are controlled. If the fourth task successfully preempts the third resource, it will immediately use the resource for execution and no longer needs to be transferred to other queues. If the preemption fails, the fourth task may need to continue waiting in the second queue until the resource becomes available or its priority is adjusted again.
[0122] In this embodiment of the application, by increasing priority and preempting resources, the system can directly respond to critical tasks that have been waiting for a long time, reducing their waiting time and speeding up their execution. Long-waiting tasks are given priority, which not only improves the responsiveness of the system but also reflects the fairness of the scheduling mechanism, ensuring that every task has a reasonable chance of execution.
[0123] For example, assuming that in a multi-tenant cloud platform, the second queue has tasks T1, T2, and T3, and their third waiting times are 5 minutes, 10 minutes, and 15 minutes respectively, while the third preset time set by the system is 10 minutes.
[0124] 1. Timeout task identification: After evaluating the waiting time, the system identifies T2 and T3 as timeout tasks and marks them as the fourth task.
[0125] 2. Priority adjustment and resource preemption: The priorities of T2 and T3 are raised to the third priority, and they are controlled to try to preempt the third resource (such as a high-speed network interface).
[0126] Assuming T3 successfully preempts the third resource, the system will immediately execute T3 using that resource without moving it to another queue. If T2 fails to preempt the resource, it may need to continue waiting in the second queue until the resource becomes available or its priority is adjusted again.
[0127] In an exemplary embodiment, after determining the target priority of tasks in the first queue and the second queue, the method further includes: determining a task type for each task in the first queue and the second queue; and determining a preset priority for each task in the first queue and the second queue based on the task type.
[0128] When a task first enters the queue or after each target priority is determined, the system needs to identify the specific type of each task, such as real-time task, interactive task, or batch task. Based on the task type, the system sets a preset priority for each task. For example, a real-time task may be assigned a higher preset priority to meet its strict response time requirements; while a batch task may be assigned a lower preset priority due to its execution characteristics. The target priority of each task is updated regularly through a timer or other mechanism. The priority may be dynamically adjusted based on factors such as the actual execution status of the task, waiting time, and resource requirements. After the target priority is updated, the system will again adjust its preset priority based on the task type, and then combine the two to decide whether to migrate or reposition the task between the two queues.
[0129] Setting preset priorities based on task types helps the system better understand the nature of tasks, thereby making more reasonable resource allocation decisions and avoiding resource waste or uneven distribution.
[0130] This embodiment can optimize resource allocation and improve scheduling efficiency while maintaining scheduling fairness by comprehensively considering task types and actual execution status.
[0131] In order to better understand the process of the adjustment method of the above-mentioned task, the implementation method flow of the adjustment of the above-mentioned task is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of this application.
[0132] The embodiment of the present application provides a task adjustment solution, such as Figure 4 The specific steps are as follows:
[0133] Step S401: constructing a dynamic priority queue structure;
[0134] Specifically:
[0135] Fair Queue (FQ) initialization: When the system starts, all tasks are first assigned to a fair queue (FQ) that rotates by time slice, ensuring that each task has at least the minimum time slice to execute, reflecting the basic principle of fairness.
[0136] Priority stacking for non-fair queues (NFQ): NFQ is built based on weighted metrics such as task historical execution time and user priority, supporting preemptive scheduling of high-priority tasks to optimize resource allocation and improve system efficiency.
[0137] Step S402: Scheduling weight calculation and priority dynamic evaluation;
[0138] Task priority P i The dynamic calculation formula is:
[0139] ,in, Represents the task weight, reflecting the importance and priority preset by the user; Indicates the cumulative execution time of a task, which is intended to prevent long tasks from excessively consuming resources due to continuous running; Refers to the waiting time since the last dispatch, ensuring the fairness of the allocation mechanism; Quality of service levels for tasks, taking into account differences in payment or service levels; , which are the weight values of different characteristics. If you want to give more weight to a certain factor in the priority calculation process, increase the corresponding weight value.
[0140] Step S403: executing the scheduling decision process and priority adjustment;
[0141] The priority P of the periodic update task i , if P iIf the task exceeds the set threshold, it indicates the importance and urgency of the task. The task will be promoted from FQ to NFQ and participate in preemptive scheduling to meet the immediate response of user needs and task importance.
[0142] Dynamic task sorting and resource preemption in NFQ: In NFQ, tasks are dynamically sorted based on a priority stack, with high-priority tasks receiving priority execution and resource preemption. The system checks the CPU resource status when a task is added to the stack. If the resource is idle, the task is preempted and executed. If the resource is occupied, the task is queued according to its priority until resources become available.
[0143] Demotion Mechanism and Timeout Handling: To balance resource allocation, tasks in NFQ that continuously execute for more than a preset duration will be forcibly demoted to FQ to free up resources for other tasks. At the same time, tasks in FQ whose waiting time exceeds a fairness threshold will be temporarily prioritized in NFQ for a resource preemption attempt, preventing task starvation.
[0144] Step S404: Execute a protection mechanism to prevent starvation;
[0145] Fairness threshold setting and temporary priority increase: The system pre-sets a fairness threshold. When the waiting time of a task in FQ exceeds the threshold, its priority is forcibly increased and given a resource preemption opportunity. If the preemption is successful, it is executed immediately; otherwise, it is transferred to NFQ and waits for scheduling.
[0146] Weight decay mechanism: In NFQ, as tasks continue to execute, their initial weights decrease. Will decay exponentially with time t, that is , ensuring that long tasks do not occupy resources indefinitely and promoting dynamic balance between tasks.
[0147] Step S405: executing the priority topology propagation mechanism;
[0148] like Figure 5 As shown in Figure 2, priority transfer rule: When task i is completed, its priority will be transferred to the successor task j that depends on it according to specific rules. The formula is:
[0149] ,in, is the propagation coefficient of task i, which is generally larger on the critical path; is the out-degree of task i, and its value is the number of successor tasks. The significance of this formula is that when a high-priority task is completed, its priority will "infect" the dependent tasks, accelerating the execution of tasks on the critical path. For task j, based on the formula: The calculated priority, is the weight of task j; is the cumulative execution time of task j; is the waiting time since the last scheduling of task j; is the service quality level of task j; , are the weights of different features, Can be based on the formula: The calculated priority can be based on the formula: The calculated priority, where represents the task weight of task i; It represents the cumulative execution time of task i, which is intended to prevent long tasks from excessively consuming resources due to continuous running; Refers to the waiting time since the last scheduling of task i; is the service quality level of task i; , are the weights of different features, is the propagation coefficient of the predecessor task i-1 of task i; is the out-degree of the predecessor task i-1, and its value is the number of successor tasks. is the priority of task i-1, the predecessor of task i.
[0150] The embodiment of the present application, by introducing a hybrid fairness mechanism, comprehensively considers factors such as task priority, waiting time, and resource requirements to ensure fair scheduling between different types of tasks. It avoids the situation where certain tasks occupy resources for a long time and cause other tasks to starve, thereby improving the fairness of the system. The system can dynamically adjust the priority of tasks according to the real-time status of the tasks and changes in system resources. When the execution of a task does not meet expectations, the priority is adjusted in time so that the system can better adapt to changes in task characteristics and resource requirements, thereby improving the dynamic adaptability of the system. In response to the problem of difficulty in scheduling mixed tasks, the present invention adopts a dynamic priority queue and a hybrid fairness mechanism to achieve reasonable scheduling and resource allocation between different types of tasks. It can meet the needs of different types of tasks such as real-time tasks, interactive tasks, and batch tasks, and improve the overall performance and resource utilization of the system.
[0151] Through the description of the above embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0152] This embodiment also provides a task adjustment device for implementing the above-mentioned embodiments and preferred implementations. Details already described will not be repeated here. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0153] Figure 6 is a structural block diagram of a task adjustment device according to an embodiment of the present application, such as Figure 6 As shown, the device includes:
[0154] A first determining module 62 is configured to determine target priorities of tasks in the first queue and the second queue, and transfer tasks whose target priorities are less than a preset priority to the first queue, and transfer tasks whose target priorities are greater than or equal to the preset priority to the second queue;
[0155] a second determining module 64, configured to determine a first waiting duration for each first task in the first queue, and to determine a continuous execution duration for each second task in the second queue, wherein the first waiting duration is a time period from the last time the first task was scheduled on the target device to the current time;
[0156] A third determining module 66 is configured to determine a third task having a first waiting time greater than a second preset time from among the plurality of first tasks, and to determine a fourth task having a continuous execution time greater than a preset execution time from among the plurality of second tasks;
[0157] The transfer module 68 is configured to transfer the third task into the second queue and transfer the fourth task into the first queue.
[0158] The apparatus determines the target priorities of tasks in a first queue and a second queue, transfers tasks with a target priority lower than a preset priority to the first queue, and transfers tasks with a target priority greater than or equal to the preset priority to the second queue; determines a first waiting time for each first task in the first queue, and determines a continuous execution time for each second task in the second queue, wherein the first waiting time is the time from the last time the target device scheduled the first task to the current time; determines a third task among multiple first tasks whose first waiting time is greater than a second preset time, and determines a fourth task among multiple second tasks whose continuous execution time is greater than the preset execution time; transfers the third task to the second queue, and transfers the fourth task to the first queue. This method, i.e., detecting abnormalities in task waiting and execution by setting a threshold and timely adjusting the queue position of the task, effectively prevents imbalance in resource allocation, improves the overall performance of the system and the fairness of task scheduling, and thereby solves the problem in related technologies of insufficient fairness in task scheduling technology, which may result in some tasks not being executed for a long time due to low priority.
[0159] In an exemplary embodiment, the first determination module 62 is used to obtain the first task weight, second waiting time, task service quality level, and cumulative execution time of the task; and determine the target priority of the task based on the first task weight, the second waiting time, the task service quality level, and the cumulative execution time.
[0160] In an exemplary embodiment, the first determining module 62 is configured to determine the target priority of the task by the following formula: :
[0161] ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value.
[0162] In an exemplary embodiment, the first determination module 62 is used to determine whether the task has a predecessor task, wherein the predecessor task is the task on which the task depends; when the task has a predecessor task, obtain the priority of the predecessor task; and determine the target priority of the task based on the priority of the predecessor task, the first task weight, the second waiting time, the task service quality level and the cumulative execution time.
[0163] In an exemplary embodiment, the first determining module 62 is configured to determine the target priority of the task by the following formula: :
[0164] ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value, is the propagation coefficient of the predecessor task, is the priority of the predecessor task, is the out-degree of the predecessor task.
[0165] In an exemplary embodiment, the first determination module 62 is used to obtain the first task weight of the task, including: when the task is a task in the second queue, obtaining the preset task weight of the task; adjusting the preset task weight according to the third waiting time to determine the first task weight of the task, wherein the third waiting time is the time after the task enters the queue.
[0166] In an exemplary embodiment, the first determining module 62 is configured to adjust the preset task weight according to the third waiting time to determine the first task weight of the task, including:
[0167] The first task weight is determined by the following formula :
[0168] ,in, is the preset task weight, and t is the third waiting time.
[0169] In an exemplary embodiment, the first determination module 62 is used to obtain the first task weight of the task, including: when the task is a task in the first queue, obtaining the preset task weight of the task and determining the preset task weight as the first task weight.
[0170] In an exemplary embodiment, the transfer module 68 is used to transfer the task whose target priority is greater than or equal to the preset priority into the second queue, and further includes: determining the status information of the first resource of the target device; and determining whether to transfer the task whose target priority is greater than or equal to the preset priority into the second queue based on the status information.
[0171] In an exemplary embodiment, the transfer module 68 is used to determine whether to transfer the task with a target priority greater than or equal to the preset priority to the second queue based on the status information, including: when the status information indicates that the first resource is in an idle state, executing the task with a target priority greater than or equal to the preset priority through the first resource; when the status information indicates that the first resource is in an occupied state, transferring the task with a target priority greater than or equal to the preset priority to the second queue.
[0172] In an exemplary embodiment, the transfer module 68, before transferring the third task to the second queue, further includes: adjusting the priority of the third task to the first priority, and controlling the third task to preempt the second resource; and determining whether to transfer the third task to the second queue based on the preemption status of the third task.
[0173] In an exemplary embodiment, the transfer module 68 is used to determine whether to transfer the third task to the second queue based on the preemption status of the third task, including: when the preemption status indicates that the third task successfully preempts the second resource, prohibiting the third task from being transferred to the second queue and executing the third task through the second resource; when the preemption status indicates that the third task fails to preempt the second resource, transferring the third task to the second queue.
[0174] In an exemplary embodiment, after entering module 68, which is used to control the third task to preempt the second resource, it also includes: determining the second priority of the task being executed by the second resource; determining whether the first priority is higher than the second priority; if the first priority is higher than the second priority, determining that the third task successfully preempts the second resource; if the first priority is lower than or equal to the second priority, determining that the third task fails to preempt the second resource.
[0175] In an exemplary embodiment, the first determination module 62 is used to determine the target priority of tasks in the first queue and the second queue, including: setting a timer; and determining the target priority of tasks in the first queue and the second queue when the timer reaches the timing duration.
[0176] In an exemplary embodiment, the module 68 is transferred to determine the first waiting time of each first task in the first queue, and further includes: determining the third waiting time of each second task in the second queue; determining a fourth task among multiple second tasks whose third waiting time is greater than the third preset time, adjusting the priority of the fourth task to the third priority, and controlling the fourth task to preempt the third resource; if the fourth task successfully preempts the third resource, executing the fourth task through the third resource.
[0177] In an exemplary embodiment, the first determination module 62, after determining the target priority of tasks in the first queue and the second queue, further includes: determining the task type of each task in the first queue and the second queue; and determining the preset priority of each task in the first queue and the second queue based on the task type.
[0178] It should be noted that, for the description of the features in the embodiment corresponding to the task adjustment device, reference can be made to the relevant description of the embodiment corresponding to the task adjustment method, which will not be repeated here.
[0179] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in the embodiment of the adjustment method for any of the above tasks.
[0180] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of the adjustment method embodiment of any of the above tasks when run.
[0181] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0182] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in the embodiment of the adjustment method for any of the above tasks are implemented.
[0183] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the adjustment method embodiment of any of the above tasks are implemented.
[0184] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0185] The above is a detailed introduction to the task adjustment method, device, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A task adjustment method, characterized in that: include: Determine target priorities of tasks in the first queue and the second queue, and transfer tasks whose target priorities are less than a preset priority to the first queue, and transfer tasks whose target priorities are greater than or equal to the preset priority to the second queue; Determining a first waiting time for each first task in the first queue, and determining a continuous execution time for each second task in the second queue, wherein the first waiting time is the time from the last time the first task was scheduled on the target device to the current time; Determine a third task among the plurality of first tasks whose first waiting time is longer than a second preset time, and determine a fourth task among the plurality of second tasks whose continuous execution time is longer than a preset execution time; The third task is transferred to the second queue, and the fourth task is transferred to the first queue.
2. The method according to claim 1, characterized in that Determine the target priorities for tasks in the first and second queues, including: Obtaining a first task weight, a second waiting time, a task service quality level, and a cumulative execution time of the task; The target priority of the task is determined according to the first task weight, the second waiting time, the task service quality level and the accumulated execution time.
3. The method according to claim 2, characterized in that Determining a target priority of the task according to the first task weight, the second waiting time, the task service quality level, and the accumulated execution time includes: The target priority of the task is determined by the following formula : ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value.
4. The method according to claim 2, characterized in that Determining a target priority of the task according to the first task weight, the second waiting time, the task service quality level, and the accumulated execution time includes: Determine whether the task has a predecessor task, wherein the predecessor task is a task that the task depends on; If there is a predecessor task for the task, obtaining the priority of the predecessor task; The target priority of the task is determined according to the priority of the predecessor task, the first task weight, the second waiting time, the task service quality level and the accumulated execution time.
5. The method according to claim 4, characterized in that Determining a target priority of the task according to the priority of the predecessor task, the first task weight, the second waiting time, the task service quality level, and the accumulated execution time includes: The target priority of the task is determined by the following formula : ,in, is the weight of the first task, is the cumulative execution time, is the second waiting time, the quality of service level for the task in question, 、 、 is the weight value, is the propagation coefficient of the predecessor task, is the priority of the predecessor task, is the out-degree of the predecessor task.
6. The method according to claim 2, characterized in that Obtaining a first task weight of the task includes: If the task is a task in the second queue, obtaining a preset task weight of the task; The preset task weight is adjusted according to the third waiting time to determine the first task weight of the task, wherein the third waiting time is the time after the task enters the queue.
7. The method according to claim 6, characterized in that Adjusting the preset task weight according to the third waiting time to determine the first task weight of the task includes: The first task weight is determined by the following formula : ,in, is the preset task weight, and t is the third waiting time.
8. The method according to claim 2, characterized in that Obtaining a first task weight of the task includes: In a case where the task is a task in the first queue, a preset task weight of the task is obtained and the preset task weight is determined to be the first task weight.
9. The method according to claim 1, characterized in that Before transferring the task whose target priority is greater than or equal to the preset priority into the second queue, the method further includes: Determining status information of a first resource of a target device; Determine whether to transfer the task with the target priority being greater than or equal to the preset priority to the second queue according to the status information.
10. The method according to claim 9, characterized in that Determining, according to the status information, whether to transfer the task whose target priority is greater than or equal to the preset priority into the second queue includes: When the state information indicates that the first resource is in an idle state, executing the task whose target priority is greater than or equal to the preset priority through the first resource; When the status information indicates that the first resource is in an occupied state, the task having the target priority greater than or equal to the preset priority is transferred to the second queue.
11. The method according to claim 1, wherein Before transferring the third task to the second queue, the method further includes: Adjusting the priority of the third task to the first priority, and controlling the third task to preempt the second resource; Determine whether to transfer the third task to the second queue according to the preemption status of the third task.
12. The method according to claim 11, characterized in that Determining whether to transfer the third task to the second queue according to the preemption status of the third task includes: If the preemption condition indicates that the third task successfully preempts the second resource, prohibiting the third task from being transferred to the second queue and executing the third task through the second resource; If the preemption condition indicates that the third task fails to preempt the second resource, the third task is transferred to the second queue.
13. The method according to claim 11, characterized in that After controlling the third task to preempt the second resource, the method further includes: determining a second priority of the task being executed by the second resource; determining whether the first priority is higher than the second priority; In a case where the first priority is higher than the second priority, determining that the third task successfully preempts the second resource; When the first priority is lower than or equal to the second priority, it is determined that the third task fails to preempt the second resource.
14. The method according to claim 1, wherein Determine the target priorities for tasks in the first and second queues, including: Set a timer; When the timer reaches the timing duration, the target priorities of the tasks in the first queue and the second queue are determined.
15. The method according to claim 1, wherein After determining the first waiting duration of each first task in the first queue, the method further includes: determining a third waiting time for each second task in the second queue; Determining a fourth task, among the plurality of second tasks, whose third waiting time is longer than the third preset time, adjusting the priority of the fourth task to the third priority, and controlling the fourth task to preempt the third resource; In a case where the fourth task successfully preempts the third resource, the fourth task is executed through the third resource.
16. The method according to claim 1, wherein After determining the target priorities of the tasks in the first queue and the second queue, the method further includes: determining a task type for each task in the first queue and the second queue; A preset priority of each task in the first queue and the second queue is determined according to the task type.
17. A task adjustment device, characterized in that: include: a first determining module, configured to determine target priorities of tasks in the first queue and the second queue, and transfer tasks whose target priorities are less than a preset priority to the first queue, and transfer tasks whose target priorities are greater than or equal to the preset priority to the second queue; a second determining module, configured to determine a first waiting duration of each first task in the first queue, and determine a continuous execution duration of each second task in the second queue, wherein the first waiting duration is a time period from the last time the first task was scheduled on the target device to the current time; a third determining module, configured to determine, from among the plurality of first tasks, a third task having a first waiting time greater than a second preset time, and to determine, from among the plurality of second tasks, a fourth task having a continuous execution time greater than a preset execution time; The transfer module is configured to transfer the third task into the second queue and transfer the fourth task into the first queue.
18. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method according to any one of claims 1 to 16 when executed by a processor.
19. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 16 are implemented.
20. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 16 are implemented.
Citation Information
Patent Citations
Resource scheduling method and device and electronic equipment
CN111400022A
Task scheduling method, equipment, device and medium
CN115904645A
Data stream role load awareness scheduling method in heterogeneous environment
CN115904746A
Business processing method and device, computer program product and electronic equipment
CN119721612A
Equipment command processing method and device, electronic equipment and readable storage medium
CN120179294A