Task scheduling method and device, equipment and storage medium
By classifying tasks by type and setting priorities, and by adopting a specialized scheduling strategy, the problem of virtual machine task jitter was solved, and efficient and stable task scheduling was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2024-11-20
- Publication Date
- 2026-04-28
AI Technical Summary
Existing task scheduling methods cannot effectively distinguish between virtual machine threads and other user tasks, causing virtual machine tasks to jitter, which affects the stability of cloud services and user experience.
By categorizing tasks into three types—virtual machine threads, system threads, and best-effort threads—and establishing a dedicated scheduling class, priorities are set according to task type. Alternating execution and load balancing strategies are employed to ensure the stable operation of high-priority tasks.
It improves the execution stability of virtual machine tasks, reduces CPU resource contention and conflicts, and enhances task scheduling efficiency and user experience.
Smart Images

Figure CN119645589B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the fields of cloud computing, data processing, and task scheduling. Background Technology
[0002] In traditional cloud computing scenarios, cloud service providers use virtualization technology to divide physical servers into multiple virtual machines for user use. However, to ensure the stability, security, and efficiency of cloud services, a portion of the Central Processing Unit (CPU) resources needs to be reserved for tasks such as network virtualization, storage virtualization, and system monitoring, which increases the overhead of virtualization resources. To reduce this overhead, the industry generally adopts the method of offloading virtualization tasks and unnecessary tasks to smart cards, so that the physical CPU cores on the server can be used entirely to run user virtual machines. However, the host machine still runs some other types of tasks besides the virtual CPU (vCPU) threads running virtual machines (VM tasks), such as kernel tasks and necessary monitoring tasks. Since current task scheduling methods cannot distinguish between VM tasks and other user tasks, VM task jitter may occur. Therefore, how to ensure the stable operation of tasks has gradually become an urgent problem to be solved. Summary of the Invention
[0003] This disclosure provides a task scheduling method, apparatus, device, and storage medium.
[0004] According to one aspect of this disclosure, a task scheduling method is provided, comprising:
[0005] Retrieve at least two tasks from the run queue;
[0006] Based on the task type of each task, at least two tasks are scheduled within the central processing unit of the cloud computing resources.
[0007] The task types include virtual machine thread (VM), system thread (SYS), and best-effort (BE) thread types. The priority of virtual machine thread types is higher than that of system thread types, and the priority of system thread types is higher than that of best-effort thread types.
[0008] According to another aspect of this disclosure, a task scheduling method is provided, comprising:
[0009] Retrieve at least two tasks from the run queue;
[0010] Based on the task type of each task, at least two tasks are scheduled within a multi-core cloud computing resource; wherein, the multi-core cloud computing resource contains multiple central processing units;
[0011] The task types include virtual machine thread type, system thread type, and best-effort thread type; among them, the priority of virtual machine thread type is higher than that of system thread type, and the priority of system thread type is higher than that of best-effort thread type.
[0012] According to another aspect of this disclosure, a task scheduling apparatus is provided, comprising:
[0013] The first acquisition module is used to acquire at least two tasks from the run queue;
[0014] The first scheduling module is used to schedule at least two tasks within the central processing unit of cloud computing resources based on the task type of each task.
[0015] The task types include virtual machine thread type, system thread type, and best-effort thread type; among them, the priority of virtual machine thread type is higher than that of system thread type, and the priority of system thread type is higher than that of best-effort thread type.
[0016] According to another aspect of this disclosure, a task scheduling apparatus is provided, comprising:
[0017] The second acquisition module is used to acquire at least two tasks from the run queue;
[0018] The second scheduling module is used to schedule at least two tasks within a multi-core cloud computing resource based on the task type of each task; wherein the multi-core cloud computing resource contains multiple central processing units.
[0019] The task types include virtual machine thread type, system thread type, and best-effort thread type; among them, the priority of virtual machine thread type is higher than that of system thread type, and the priority of system thread type is higher than that of best-effort thread type.
[0020] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0021] At least one processor; and
[0022] The memory is communicatively connected to the at least one processor; wherein,
[0023] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform any of the methods described in the present disclosure.
[0024] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform any of the methods according to embodiments of this disclosure.
[0025] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements any of the methods according to embodiments of this disclosure.
[0026] This disclosure categorizes tasks on the host machine into different types based on their characteristics and sets corresponding execution priorities for each type. By utilizing preset task scheduling strategies to schedule different types of tasks on the CPU, the execution of VM tasks can be prioritized and optimized, thereby improving the execution stability of VM tasks.
[0027] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0028] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0029] Figure 1 This is a schematic diagram illustrating an application scenario according to an embodiment of this disclosure;
[0030] Figure 2 This is a flowchart illustrating the implementation of a task scheduling method according to an embodiment of the present disclosure;
[0031] Figure 3A This is a diagram illustrating the storage method for VM-type tasks;
[0032] Figure 3B This is a diagram illustrating the storage method for SYS type tasks;
[0033] Figure 3C This is a schematic diagram of the storage method for BE type tasks;
[0034] Figure 4 This is a scheduling diagram of VM type tasks and SYS type tasks according to an embodiment of the present disclosure;
[0035] Figure 5 This is a scheduling diagram of VM type tasks and BE type tasks according to an embodiment of the present disclosure;
[0036] Figure 6 This is a scheduling diagram of three types of tasks according to an embodiment of the present disclosure;
[0037] Figure 7This is a diagram illustrating the migration of SYS type tasks and BE type tasks to an idle CPU;
[0038] Figure 8 This is a diagram illustrating the migration of multiple BE type tasks to multiple CPUs;
[0039] Figure 9 This is a flowchart illustrating the implementation of a task scheduling method according to an embodiment of the present disclosure;
[0040] Figure 10 This is a schematic diagram of the structure of a task scheduling device 1000 according to an embodiment of the present disclosure;
[0041] Figure 11 This is a schematic diagram of the structure of a task scheduling device 1100 according to an embodiment of the present disclosure;
[0042] Figure 12 A schematic block diagram of an example electronic device 1200 that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0043] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0044] The term "and / or" in this disclosure indicates that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. The term "at least one" in this document means any combination of at least two of a plurality of options, such as including at least one of A, B, and C, which can mean including any one or more elements selected from the set of A, B, and C. The terms "first" and "second" in this document refer to and distinguish multiple similar technical terms, and do not imply a specific order or a limitation to only two. For example, "first feature" and "second feature" refer to two types / two features; the first feature can be one or more, and the second feature can also be one or more.
[0045] In traditional cloud computing scenarios, cloud service providers use virtualization technology to divide a single physical server into multiple virtual machines for user use. In this virtualization scenario, not all the physical CPUs on the server can be fully allocated to the user's virtual machines. This is because cloud service providers must reserve some CPU resources to support critical tasks such as network virtualization, storage virtualization, and system monitoring. These tasks are crucial for ensuring the stability, security, and efficiency of cloud services, but this also results in additional consumption of virtualization resources.
[0046] In recent years, the industry has explored a strategy to reduce virtualization resource overhead: migrating virtualization tasks and some non-core tasks to smart cards. The smart card handles network virtualization, storage management, and monitoring, while the host machine focuses on running the tasks necessary to maintain the virtual machines. This shift allows all physical CPU cores on the server to be fully utilized and directly allocated to virtual machines.
[0047] Nevertheless, the host machine still retains some tasks besides the virtual machine's (VM) tasks, such as kernel tasks and necessary monitoring tasks. If the Linux kernel's default Completely Fair Scheduler (CFS) continues to schedule these tasks, VM tasks may experience performance fluctuations, or "jitter," due to improper scheduling, thus affecting the user experience. This is because, from the Linux kernel's perspective, VM tasks are not fundamentally different from other user tasks, and CFS does not give them any special treatment. Even by adjusting the priority of VM tasks or limiting the CPU usage of other user tasks, it is difficult to completely eliminate the risk of jitter.
[0048] Therefore, current task scheduling methods cannot reliably schedule and execute vCPU tasks.
[0049] To address the aforementioned issues, this disclosure proposes a task scheduling method. Figure 1 This is a schematic diagram illustrating an application scenario according to an embodiment of this disclosure, such as... Figure 1As shown in the illustration, the application scenario diagram of this disclosure may include, but is not limited to, terminal device 110 and server 120. The terminal device 110 and server 120 can communicate via any type of wired or wireless network. Specifically, the terminal device 110 can be used to upload configuration information to the server 120; the server 120 can classify tasks according to the configuration information, set the priority of each task, and schedule different types of tasks using a preset scheduling strategy. The terminal device 110 proposed in this disclosure includes, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, in-vehicle terminals, game consoles, e-book readers, multimedia playback devices, wearable devices, and other electronic devices. The server 120 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Furthermore, this disclosure does not impose a specific limitation on the number of terminal devices 110. For example, the application scenario diagram of this disclosure may include one or more terminal devices 110.
[0050] Figure 2 This is a flowchart illustrating the implementation of a task scheduling method according to an embodiment of the present disclosure, including:
[0051] S210. Obtain at least two tasks from the run queue;
[0052] S220. Based on the task type of each task, schedule at least two tasks within the CPU of the cloud computing resources.
[0053] The task types include Virtual Machine thread (VM), System thread (SYS), and Best Effort thread (BE). The priority of the Virtual Machine thread type is higher than that of the System thread type, and the priority of the System thread type is higher than that of the Best Effort thread type.
[0054] In some examples, the system can establish a new scheduling class specifically responsible for scheduling these three types of tasks before scheduling them. The current Linux kernel has five scheduling classes: halt scheduling, time-limited scheduling, real-time scheduling, fair scheduling, and idle scheduling, with their priorities decreasing in that order. This disclosure sets the new scheduling class between the fair scheduling and idle scheduling classes; that is, the new scheduling class has a priority lower than the fair scheduling class but higher than the idle scheduling class. In some examples, different data structures are used to store different types of tasks. For example, Figure 3A This is a diagram illustrating the storage method for VM-type tasks. Figure 3B This is a diagram illustrating the storage method for SYS type tasks. Figure 3C This is a diagram illustrating the storage method for BE type tasks. For example... Figures 3A-3C As shown, tasks of type VM and type SYS can each be stored using a red-black tree, where the leftmost task in each red-black tree is the task to be executed. Tasks of type BE can be stored using a linked list, where BE type tasks follow the First-In-First-Out (FIFO) principle.
[0055] By adopting the above task scheduling method and setting up a dedicated scheduling class to schedule VM type tasks, SYS type tasks and BE type tasks, CPU resources can be intelligently allocated according to the characteristics and requirements of different tasks, ensuring that high-priority tasks (such as VM type tasks) have the opportunity to be executed first, thus improving the execution stability of high-priority tasks.
[0056] In some implementations, VM-type tasks include: vCPU threads that run virtual machines;
[0057] Tasks of type SYS include at least one of the kernel threads in the operating system and virtualization emulation threads;
[0058] BE thread type tasks include: user processes.
[0059] By clearly classifying and prioritizing different types of tasks, it is helpful to avoid competition and conflicts for CPU resources, thereby improving the efficiency of task scheduling.
[0060] In some implementations, at least two tasks are scheduled within the CPU of the cloud computing resource based on the task type of each task, including:
[0061] In cases where at least two tasks include VM-type tasks and SYS-type tasks, the VM-type tasks and SYS-type tasks are scheduled to be executed alternately on the CPU, and the runtime of the SYS-type tasks is limited.
[0062] In some implementations, VM-type tasks and SYS-type tasks are scheduled to run alternately on the CPU, and the runtime of SYS-type tasks is limited, including:
[0063] When the runtime of a VM-type task reaches its allocated time slice, the VM-type task is scheduled to exit the CPU.
[0064] Furthermore, if the runtime of a SYS type task reaches one or more clock cycles, the SYS type task will be scheduled to exit the CPU.
[0065] Figure 4 This is a schematic diagram illustrating the scheduling of VM-type and SYS-type tasks according to an embodiment of this disclosure. Figure 4 As shown, the dashed box represents the run queue, which contains a task of type SYS. After the VM type task completes its allocated time slice, the CPU is relinquished to the SYS type task in the run queue. SYS type tasks are generally very fast, completing within one clock cycle. After the SYS type task completes one clock cycle, the CPU is relinquished to the VM type task for execution.
[0066] By setting time slice and clock cycle limits for VM-type tasks and SYS-type tasks respectively, it can be ensured that VM-type tasks do not occupy CPU resources for a long time, thus avoiding situations where SYS-type tasks wait for a long time or are delayed in execution.
[0067] In some implementations, at least two tasks are scheduled within the CPU of the cloud computing resource based on the task type of each task, including:
[0068] In cases where at least two tasks include VM-type tasks and BE-type tasks:
[0069] Schedule VM-type tasks so that the tasks running on the CPU are VM-type tasks; and record the waiting time of BE-type tasks.
[0070] If the waiting time of a BE-type task reaches the first threshold, increase the priority of the BE-type task so that the running tasks in the CPU are switched to BE-type tasks.
[0071] In some implementations, when the execution time of a BE-type task reaches a second threshold, the priority of the BE-type task is reduced so that the BE-type task exits the CPU; and the waiting time of the BE-type task is re-recorded.
[0072] Figure 5 This is a scheduling diagram of VM-type tasks and BE-type tasks according to an embodiment of this disclosure. Figure 5 As shown, there is a BE type task in the run queue, while a VM type task is running simultaneously. In this situation, the VM type task must be given priority. Only when the VM type task triggers scheduling to voluntarily yield the CPU can the BE type task acquire the CPU and run. If the VM task does not yield the CPU to the BE type task, the BE type task will not get a chance to run, which can easily lead to the BE type task starving. Therefore, by recording the waiting time of the BE type task, when the waiting time reaches a preset first threshold, the priority of the BE type task is increased, allowing the BE type task to preempt the CPU and run, but the running time must not exceed a preset second threshold, which will not exceed one clock cycle. If the running time of the BE type task exceeds the second threshold, the priority of the BE type task is decreased, and even if the BE type task has not finished running, the CPU must be yielded to the VM type task, and the waiting time of the BE type task is recorded again.
[0073] Using the above methods, we can effectively prevent BE-type tasks from falling into a starvation state due to a continuous inability to obtain execution opportunities.
[0074] The above discussed the corresponding scheduling strategies for the simultaneous presence of VM-type and SYS-type tasks, or VM-type and BE-type tasks. When SYS-type and BE-type tasks coexist, there are no VM-type tasks on the CPU; therefore, no special scheduling strategy is needed for that CPU. For SYS-type tasks, the scheduling strategy can be simplified to a CFS (Completely First-Served) scheduling strategy. For BE-type tasks, the scheduling strategy can be degenerated into a FIFO (First-In, First-Out) time-slice round-robin scheduling strategy. Under this strategy, BE-type tasks obtain CPU time slices in the order they arrive, and after execution, they wait for the next round of time slice allocation.
[0075] In some implementations, at least two tasks are scheduled within the CPU of the cloud computing resource based on the task type of each task, including:
[0076] In the case where at least two tasks include tasks of type VM, type SYS, and type BE:
[0077] If the waiting time of a BE-type task has not reached the first threshold, determine at least two remaining tasks in the run queue;
[0078] If at least two remaining tasks include tasks of type VM and / or type SYS, prioritize the task of a different type from the previously executed task and execute the selected task on the CPU; if at least two remaining tasks include only tasks of type BE, execute the task of type BE on the CPU.
[0079] Figure 6 This is a scheduling diagram of three types of tasks according to an embodiment of the present disclosure. For example... Figure 6 As shown, the specific steps include:
[0080] S601. Determine the relationship between the waiting time of the linked list used to store BE type tasks and the first threshold. If it is greater than or equal to the first threshold, then execute S602; if it is less than the first threshold, then execute S605.
[0081] S602. Determine whether there is a BE type task in the linked list used to store BE type tasks. If there is a BE type task, execute S603; otherwise, execute S604.
[0082] S603. Run the BE type task at the head of the linked list and end the process.
[0083] S604. If there is no BE type task in the linked list, the idle scheduling class is called to handle the idle task, and the process ends.
[0084] S605. If the linked list used to store BE type tasks has not timed out, determine whether the last selected task was a VM type task. If not, execute S606; if so, execute S612.
[0085] S606. If the task selected last time was not a VM type task, prioritize selecting a VM type task. Check if there is a VM type task in the run queue. If not, execute S607; if so, execute S611.
[0086] Because VM-type and SYS-type tasks have an alternating scheduling mechanism, with VM-type tasks having the highest priority, if the previous process ran a VM-type task, the current process will prioritize running a SYS-type task; if the previous process ran a SYS-type or BE-type task, the current process will prioritize running a VM-type task.
[0087] S607. If there is no VM type task to be run in the run queue, it means that VM type task cannot be selected first. Then check if there is a SYS type task in the run queue. If not, execute S608; if so, execute S613.
[0088] S608. If there is no SYS type task to be run in the run queue, determine whether there is a BE type task in the run queue. If there is, execute S609; otherwise, execute S610.
[0089] S609. If there are only BE type tasks in the run queue, run the BE type task at the head of the run queue and end the process.
[0090] S610. If there are no tasks of the above three types in the run queue, the idle scheduler class is called to handle the idle task and the process ends.
[0091] S611. If it is determined in S606 that there is a VM type task in the queue, then run the VM type task with the highest priority and end the process.
[0092] S612. If it is determined in S605 that the last selected task was of type VM, prioritize the selection of type SYS task. Check if there is a type SYS task in the run queue. If there is, execute S613; otherwise, execute S614.
[0093] S613. If it is determined that there is a SYS type task in the run queue, run the highest priority SYS type task and end the process.
[0094] S614. If there is no SYS type task in the run queue, it means that the SYS type task cannot be selected first. Then check if there is a VM type task in the run queue. If there is, run S615; otherwise, run S602.
[0095] S615. If there are VM type tasks in the run queue, run the VM type task with the highest priority and end the process.
[0096] By adopting the above process, and by distinguishing different types of tasks and scheduling them according to their characteristics and priorities, it is possible to ensure the timely and stable operation of high-priority tasks (such as VM-type tasks), thereby improving the efficiency of task scheduling.
[0097] The above examples illustrate a single-core scheduling strategy, which involves task scheduling within a single CPU. The scheduling method proposed in this disclosure may also include a multi-core scheduling strategy, which involves task scheduling across multiple CPUs.
[0098] For example, in some implementations, scheduling at least two tasks within the CPU of a cloud computing resource based on the task type of each task may include at least one of the following:
[0099] In the case where the cloud computing resource includes multiple CPUs, and among the multiple CPUs are idle CPUs, tasks of type SYS and / or tasks of type BE in the run queue will be migrated to idle CPUs.
[0100] In the case where the cloud computing resource includes multiple CPUs, and none of the CPUs are idle, the SYS type tasks and / or BE type tasks in the run queue will be load balanced across the multiple CPUs.
[0101] Figure 7 This is a diagram illustrating the migration of SYS type tasks and BE type tasks to idle CPUs. For example... Figure 7 As shown, cloud computing resources include multiple idle CPUs (such as CPU N-2, CPU N-1, and CPU N). The run queue contains tasks of type SYS and tasks of type BE. Tasks of type SYS and BE can be migrated to these idle CPUs. In some examples, tasks of type SYS can be migrated to CPU N-2, and tasks of type BE can be migrated to CPU N-1.
[0102] When an idle CPU is used by a user, if there are still idle CPUs available in the cloud computing resources, SYS and BE type tasks will be migrated to other idle CPUs. If there are no idle CPUs at this time, but there are SYS or BE type tasks on previously idle CPUs, then the load on each CPU needs to be calculated, and the SYS and BE type tasks will be evenly distributed across each CPU to achieve load balancing.
[0103] By migrating tasks to idle CPUs or load balancing them when no idle CPUs are available, you can reduce the overload of individual processors and lower task wait times.
[0104] Furthermore, multi-core scheduling strategies may also include:
[0105] In the case where the cloud computing resource includes multiple CPUs and one of the CPUs has at least two first tasks among its pending tasks, the at least two first tasks are distributed and scheduled to multiple CPUs, and the at least two first tasks preempt the CPU.
[0106] The first task includes: BE type tasks where the waiting time reaches or exceeds a first threshold.
[0107] Figure 8 This is a diagram illustrating the migration of multiple BE-type tasks to multiple CPUs. For example... Figure 8 As shown, the run queue contains multiple BE type tasks, all of which have wait times that have reached or exceeded a preset first threshold. The BE type task at the head of the linked list occupies the current CPU and distributes other BE type tasks in the linked list to other CPUs for execution. If other types of tasks are running on the target CPU (such as...), ... Figure 8 If a VM-type task is running on CPU 2 and a SYS-type task is running on CPU N-2, then the CPU will be preempted.
[0108] By using the above methods, it can be ensured that multiple BE type tasks in the run queue will not be in a waiting state for a long time due to the inability to obtain CPU resources, thus effectively avoiding the occurrence of their "starvation" phenomenon.
[0109] This disclosure also proposes a task scheduling method applicable to task scheduling among multiple CPUs. Figure 9 This is a flowchart illustrating the implementation of a task scheduling method according to an embodiment of the present disclosure, including:
[0110] S910: Obtain at least two tasks from the run queue;
[0111] S920: Based on the task type of each task, schedule at least two tasks within a multi-core cloud computing resource; wherein, the multi-core cloud computing resource contains multiple CPUs;
[0112] The task types include VM, SYS, and BE; VM has a higher priority than SYS, and SYS has a higher priority than BE.
[0113] By using the above methods, the idleness and waste of cloud computing resources can be avoided. At the same time, reasonable task scheduling can reduce the waiting time of tasks in the queue, which helps to improve the overall task processing efficiency.
[0114] In some implementations, VM-type tasks include: vCPU threads that run virtual machines;
[0115] Tasks of type SYS include at least one of the kernel threads in the operating system and virtualization emulation threads;
[0116] BE type tasks include: user processes.
[0117] By clearly defining the types of tasks and assigning them corresponding priorities, the conflict and contention for CPU resources can be effectively reduced, thereby enhancing the efficiency of task scheduling.
[0118] In some implementations, at least two tasks are scheduled within multi-core cloud computing resources based on the task type of each task, including:
[0119] In cases where multiple CPUs include idle CPUs, migrate SYS type tasks and / or BE type tasks in the run queue to the idle CPU;
[0120] In the case of multiple CPUs excluding idle CPUs, load balance is performed on multiple CPUs for SYS type tasks and / or BE type tasks in the run queue.
[0121] For detailed implementation information and procedures, please refer to [link / reference]. Figure 7 The specific methods and steps are shown and described in the document. By using the above methods to allocate tasks to idle CPUs or to implement load balancing strategies when there are no idle CPUs, the burden on individual CPUs can be effectively reduced, and the waiting time of tasks can be decreased.
[0122] In some implementations, at least two tasks are scheduled within multi-core cloud computing resources based on the task type of each task, including:
[0123] In cases where at least two primary tasks are included in the pending tasks of a CPU in a cloud computing resource, the at least two primary tasks are distributed and scheduled to multiple CPUs, and the at least two primary tasks preempt the CPU.
[0124] The first task includes: BE type tasks where the waiting time reaches or exceeds a first threshold.
[0125] For detailed implementation information and procedures, please refer to [link / reference]. Figure 8 The specific methods and steps shown and described herein. By adopting the above methods, it can be ensured that BE tasks in the run queue can acquire CPU resources in a timely manner, avoiding long-term lingering in the waiting queue and effectively preventing the occurrence of task "starvation".
[0126] This disclosure also proposes a task scheduling device. Figure 10 This is a schematic diagram of the structure of a task scheduling device 1000 according to an embodiment of the present disclosure, including:
[0127] The first acquisition module 1010 is used to acquire at least two tasks in the run queue;
[0128] The first scheduling module 1020 is used to schedule at least two tasks within the CPU of cloud computing resources based on the task type of each task.
[0129] The task types include VM, SYS, and BE; VM has a higher priority than SYS, and SYS has a higher priority than BE.
[0130] In some implementations, VM thread type tasks include: vCPU threads that run virtual machines;
[0131] Tasks of type SYS include at least one of the kernel threads in the operating system and virtualization emulation threads;
[0132] BE type tasks include: user processes.
[0133] In some implementations, the first scheduling module 1020 is used for:
[0134] In cases where at least two tasks include VM-type tasks and SYS-type tasks, the VM-type tasks and SYS-type tasks are scheduled to be executed alternately on the CPU, and the runtime of the SYS-type tasks is limited.
[0135] In some implementations, the first scheduling module 1020 is used for:
[0136] When the runtime of a VM-type task reaches its allocated time slice, the VM-type task is scheduled to exit the CPU.
[0137] Furthermore, if the runtime of a SYS type task reaches one or more clock cycles, the SYS type task will be scheduled to exit the CPU.
[0138] In some implementations, the first scheduling module 1020 is used for:
[0139] In cases where at least two tasks include VM-type tasks and BE-type tasks:
[0140] Schedule VM-type tasks so that the tasks running on the CPU are VM-type tasks; and record the waiting time of BE-type tasks.
[0141] If the waiting time of a BE-type task reaches the first threshold, increase the priority of the BE-type task so that the running tasks in the CPU are switched to BE-type tasks.
[0142] In some implementations, the first scheduling module 1020 is further configured to:
[0143] If the execution time of a BE-type task reaches the second threshold, reduce the priority of the BE-type task so that it exits the CPU; and re-record the waiting time of the BE-type task.
[0144] In some implementations, the first scheduling module 1020 is used for:
[0145] In the case where at least two tasks include tasks of type VM, type SYS, and type BE:
[0146] If the waiting time of a BE-type task has not reached the first threshold, determine at least two remaining tasks in the run queue;
[0147] If at least two remaining tasks include tasks of type VM and / or type SYS, prioritize the task of a different type from the previously executed task and execute the selected task on the CPU; if at least two remaining tasks include only tasks of type BE, execute the task of type BE on the CPU.
[0148] In some implementations, the first scheduling module 1020 is used for at least one of the following:
[0149] In cases where cloud computing resources include multiple CPUs, and these CPUs include idle CPUs, tasks of type SYS and / or type BE in the run queue will be migrated to idle CPUs.
[0150] In cloud computing resources that include multiple CPUs, and where none of the CPUs are idle, load balancing is performed on the multiple CPUs for SYS type tasks and / or BE type tasks in the run queue.
[0151] In some implementations, the first scheduling module 1020 is used for:
[0152] In a cloud computing resource that includes multiple CPUs, and where one of the CPUs has at least two first tasks among its pending tasks, the at least two first tasks are distributed and scheduled to multiple CPUs, and the at least two first tasks preempt the CPU.
[0153] The first task includes: BE type tasks where the waiting time reaches or exceeds a first threshold.
[0154] This disclosure also proposes a task scheduling device. Figure 11 This is a schematic diagram of the structure of a task scheduling device 1100 according to an embodiment of the present disclosure, including:
[0155] The second acquisition module 1110 is used to acquire at least two tasks in the run queue;
[0156] The second scheduling module 1120 schedules at least two tasks within a multi-core cloud computing resource based on the task type of each task; wherein the multi-core cloud computing resource contains multiple CPUs.
[0157] The task types include VM, SYS, and BE; VM has a higher priority than SYS, and SYS has a higher priority than BE.
[0158] In some implementations, VM-type tasks include: vCPU threads that run virtual machines;
[0159] Tasks of type SYS include at least one of the kernel threads in the operating system and virtualization emulation threads;
[0160] BE type tasks include: user processes.
[0161] In some implementations, the second scheduling module 1120 is used for:
[0162] In cases where multiple CPUs include idle CPUs, migrate SYS type tasks and / or BE type tasks in the run queue to the idle CPU;
[0163] In the case of multiple CPUs excluding idle CPUs, load balance is performed on multiple CPUs for SYS type tasks and / or BE type tasks in the run queue.
[0164] In some implementations, the second scheduling module 1120 is used for:
[0165] In cases where at least two primary tasks are included in the pending tasks of a CPU in a cloud computing resource, the at least two primary tasks are distributed and scheduled to multiple CPUs, and the at least two primary tasks preempt the CPU.
[0166] The first task includes: BE type tasks where the waiting time reaches or exceeds a first threshold.
[0167] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0168] The acquisition, storage, and application of personal information by users involved in this technical solution comply with relevant laws and regulations and do not violate public order and good morals.
[0169] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0170] Figure 12A schematic block diagram of an example electronic device 1200 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0171] like Figure 12 As shown, device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1202 or a computer program loaded from storage unit 1208 into random access memory (RAM) 1203. The RAM 1203 may also store various programs and data required for the operation of device 1200. The computing unit 1201, ROM 1202, and RAM 1203 are interconnected via bus 1204. Input / output (I / O) interface 1205 is also connected to bus 1204.
[0172] Multiple components in device 1200 are connected to I / O interface 1205, including: input unit 1206, such as keyboard, mouse, etc.; output unit 1207, such as various types of monitors, speakers, etc.; storage unit 1208, such as disk, optical disk, etc.; and communication unit 1209, such as network card, modem, wireless transceiver, etc. Communication unit 1209 allows device 1200 to exchange / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0173] The computing unit 1201 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1201 performs the various methods and processes described above, such as detection methods. For example, in some embodiments, the detection method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed on device 1200 via ROM 1202 and / or communication unit 1209. When the computer program is loaded into RAM 1203 and executed by the computing unit 1201, one or more steps of the detection method described above may be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured to perform the detection method by any other suitable means (e.g., by means of firmware).
[0174] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0175] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0176] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0177] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0178] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0179] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0180] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0181] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A task scheduling method, comprising: Retrieve at least two tasks from the run queue; Based on the task type of each task, the at least two tasks are scheduled within the central processing unit of the cloud computing resources. The task types include virtual machine thread type, system thread type, and best-effort thread type; wherein, the priority of the virtual machine thread type is higher than the priority of the system thread type, and the priority of the system thread type is higher than the priority of the best-effort thread type. The scheduling includes, in the case where the at least two tasks include a task of the virtual machine thread type, a task of the system thread type, and a task of the best-effort thread type: If the waiting time of the best-effort thread type task does not reach the first threshold, determine at least two remaining tasks in the run queue; If the remaining at least two tasks include tasks of virtual machine thread type and / or tasks of system thread type, a task of a different type from the previously executed task is preferentially selected and executed on the central processing unit; if the remaining at least two tasks include only tasks of the best-effort thread type, the best-effort thread type task is executed on the central processing unit. The priority selection of tasks of a different type from the previously executed task includes: if the previous process ran a task of the virtual machine thread type, then in this process, a task of the system thread type will be prioritized; if the previous process ran a task of the system thread type, then in this process, a task of the virtual machine thread type will be prioritized.
2. The method according to claim 1, wherein, The tasks of the virtual machine thread type include: virtual central processing unit threads that run virtual machines; The system thread type of task includes at least one of: kernel threads in the operating system and virtualization emulation threads; The best-effort thread type of task includes: user processes.
3. The method according to claim 1 or 2, wherein, The scheduling of the at least two tasks within the central processing unit of cloud computing resources based on the task types of each task further includes: When the at least two tasks include a task of the virtual machine thread type and a task of the system thread type, the task of the virtual machine thread type and the task of the system thread type are scheduled to be executed alternately on the central processing unit, and the running time of the task of the system thread type is limited.
4. The method according to claim 3, wherein, The scheduling of tasks of the virtual machine thread type and tasks of the system thread type to run alternately on the central processing unit, and the limitation of the running time of tasks of the system thread type, includes: If the runtime of a task of the virtual machine thread type reaches the allocated time slice, the task of the virtual machine thread type is scheduled to exit the central processing unit. Furthermore, if the runtime of a task of the system thread type reaches one or more clock cycles, the task of the system thread type is scheduled to exit the central processing unit.
5. The method according to claim 1 or 2, wherein, The scheduling of the at least two tasks within the central processing unit of cloud computing resources based on the task types of each task further includes: In the case where the at least two tasks include a task of the virtual machine thread type and a task of the best-effort thread type: Schedule tasks of the virtual machine thread type so that the tasks running in the central processing unit are tasks of the virtual machine thread type; and record the waiting time of the best-effort thread type tasks. If the waiting time of the best-effort thread type task reaches a first threshold, the priority of the best-effort thread type task is increased so that the running task in the central processing unit is switched to the best-effort thread type task.
6. The method according to claim 5, further comprising: If the execution time of the best-effort thread type task reaches the second threshold, the priority of the best-effort thread type task is reduced so that the best-effort thread type task exits the central processing unit; and the waiting time of the best-effort thread type task is re-recorded.
7. The method according to claim 1 or 2, wherein, The scheduling of at least two tasks within the central processing unit of cloud computing resources based on the task type of each task further includes at least one of the following: In the case where the cloud computing resources include multiple central processing units (CPUs), and the multiple CPUs include idle CPUs, tasks of the system thread type and / or best-effort thread type in the run queue are migrated to the idle CPUs. In the case where the cloud computing resources include multiple central processing units (CPUs) and the multiple CPUs do not include idle CPUs, the system thread type tasks and / or best-effort thread type tasks in the run queue are load-balanced across the multiple CPUs.
8. The method according to claim 1 or 2, wherein, The scheduling of the at least two tasks within the central processing unit of cloud computing resources based on the task types of each task further includes: In the case where the cloud computing resources include multiple central processing units (CPUs) and one of the CPUs has at least two first tasks among its pending tasks, the at least two first tasks are distributed and scheduled to the multiple CPUs, and the at least two first tasks preempt the CPUs. The first task includes: a best-effort thread type task whose waiting time reaches or exceeds a first threshold.
9. A task scheduling method, comprising: Retrieve at least two tasks from the run queue; Based on the task type of each of the aforementioned tasks, at least two tasks are scheduled within a multi-core cloud computing resource; wherein, the multi-core cloud computing resource includes multiple central processing units; The task types include virtual machine thread type, system thread type, and best-effort thread type; wherein, the priority of the virtual machine thread type is higher than the priority of the system thread type, and the priority of the system thread type is higher than the priority of the best-effort thread type. The scheduling includes: when there are no idle CPUs among the plurality of CPUs, and there are system thread type tasks or best-effort thread type tasks on previously idle CPUs, calculating the load of each CPU, and distributing the system thread type tasks and / or best-effort thread type tasks in the run queue evenly across each CPU to achieve load balancing.
10. The method according to claim 9, wherein, The tasks of the virtual machine thread type include: virtual central processing unit threads that run virtual machines; The system thread type of task includes at least one of: kernel threads in the operating system and virtualization emulation threads; The best-effort thread type of task includes: user processes.
11. The method according to claim 9 or 10, wherein, The scheduling of at least two tasks within multi-core cloud computing resources based on the task types of each task further includes: In the case where an idle CPU is included among the plurality of CPUs, tasks of the system thread type and / or best-effort thread type in the run queue are migrated to the idle CPU.
12. The method according to claim 9 or 10, wherein, The scheduling of at least two tasks within multi-core cloud computing resources based on the task types of each task further includes: If at least two first tasks are included in the pending tasks of a central processor of the cloud computing resource, the at least two first tasks are distributed and scheduled to the multiple central processors, and the at least two first tasks preempt the central processor. The first task includes: a best-effort thread type task whose waiting time reaches or exceeds a first threshold.
13. A task scheduling device, comprising: The first acquisition module is used to acquire at least two tasks from the run queue; The first scheduling module is used to schedule at least two tasks within the central processing unit of cloud computing resources based on the task type of each task. The task types include virtual machine thread type, system thread type, and best-effort thread type; wherein, the priority of the virtual machine thread type is higher than the priority of the system thread type, and the priority of the system thread type is higher than the priority of the best-effort thread type. The scheduling includes, in the case where the at least two tasks include a task of the virtual machine thread type, a task of the system thread type, and a task of the best-effort thread type: If the waiting time of the best-effort thread type task does not reach the first threshold, determine at least two remaining tasks in the run queue; If the remaining at least two tasks include tasks of virtual machine thread type and / or tasks of system thread type, a task of a different type from the previously executed task is preferentially selected and executed on the central processing unit; if the remaining at least two tasks include only tasks of the best-effort thread type, the best-effort thread type task is executed on the central processing unit. The priority selection of tasks of a different type from the previously executed task includes: if the previous process ran a task of the virtual machine thread type, then in this process, a task of the system thread type will be prioritized; if the previous process ran a task of the system thread type, then in this process, a task of the virtual machine thread type will be prioritized.
14. The apparatus according to claim 13, wherein, The tasks of the virtual machine thread type include: virtual central processing unit threads that run virtual machines; The system thread type of task includes at least one of: kernel threads in the operating system and virtualization emulation threads; The best-effort thread type of task includes: user processes.
15. The apparatus according to claim 13 or 14, wherein, The first scheduling module is also used for: When the at least two tasks include a task of the virtual machine thread type and a task of the system thread type, the task of the virtual machine thread type and the task of the system thread type are scheduled to be executed alternately on the central processing unit, and the running time of the task of the system thread type is limited.
16. The apparatus according to claim 15, wherein, The first scheduling module is used for: If the runtime of a task of the virtual machine thread type reaches the allocated time slice, the task of the virtual machine thread type is scheduled to exit the central processing unit. Furthermore, if the runtime of a task of the system thread type reaches one or more clock cycles, the task of the system thread type is scheduled to exit the central processing unit.
17. The apparatus according to claim 13 or 14, wherein, The first scheduling module is also used for: In the case where the at least two tasks include a task of the virtual machine thread type and a task of the best-effort thread type: Schedule tasks of the virtual machine thread type so that the tasks running in the central processing unit are tasks of the virtual machine thread type; and record the waiting time of the best-effort thread type tasks. If the waiting time of the best-effort thread type task reaches a first threshold, the priority of the best-effort thread type task is increased so that the running task in the central processing unit is switched to the best-effort thread type task.
18. The apparatus according to claim 17, wherein the first scheduling module is further configured to: If the execution time of the best-effort thread type task reaches the second threshold, the priority of the best-effort thread type task is reduced so that the best-effort thread type task exits the central processing unit; and the waiting time of the best-effort thread type task is re-recorded.
19. The apparatus according to claim 13 or 14, wherein, The first scheduling module is also used for at least one of the following: In the case where the cloud computing resources include multiple central processing units (CPUs), and the multiple CPUs include idle CPUs, tasks of the system thread type and / or best-effort thread type in the run queue are migrated to the idle CPUs. In the case where the cloud computing resources include multiple central processing units (CPUs) and the multiple CPUs do not include idle CPUs, the system thread type tasks and / or best-effort thread type tasks in the run queue are load-balanced across the multiple CPUs.
20. The apparatus according to claim 13 or 14, wherein, The first scheduling module is also used for: In the case where the cloud computing resources include multiple central processing units (CPUs) and one of the CPUs has at least two first tasks among its pending tasks, the at least two first tasks are distributed and scheduled to the multiple CPUs, and the at least two first tasks preempt the CPUs. The first task includes: a best-effort thread type task whose waiting time reaches or exceeds a first threshold.
21. A task scheduling device, comprising: The second acquisition module is used to acquire at least two tasks from the run queue; The second scheduling module schedules at least two tasks within a multi-core cloud computing resource based on the task type of each task; wherein the multi-core cloud computing resource includes multiple central processing units. The task types include virtual machine thread type, system thread type, and best-effort thread type; wherein, the priority of the virtual machine thread type is higher than the priority of the system thread type, and the priority of the system thread type is higher than the priority of the best-effort thread type. The scheduling includes: when there are no idle CPUs among the plurality of CPUs, and there are system thread type tasks or best-effort thread type tasks on previously idle CPUs, calculating the load of each CPU, and distributing the system thread type tasks and / or best-effort thread type tasks in the run queue evenly across each CPU to achieve load balancing.
22. The apparatus according to claim 21, wherein, The tasks of the virtual machine thread type include: virtual central processing unit threads that run virtual machines; The system thread type of task includes at least one of: kernel threads in the operating system and virtualization emulation threads; The best-effort thread type of task includes: user processes.
23. The apparatus according to claim 21 or 22, wherein, The second scheduling module is also used for: In the case where an idle CPU is included among the plurality of CPUs, tasks of the system thread type and / or best-effort thread type in the run queue are migrated to the idle CPU.
24. The apparatus according to claim 21 or 22, wherein, The second scheduling module is also used for: If at least two first tasks are included in the pending tasks of a central processor of the cloud computing resource, the at least two first tasks are distributed and scheduled to the multiple central processors, and the at least two first tasks preempt the central processor. The first task includes: a best-effort thread type task whose waiting time reaches or exceeds a first threshold.
25. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-12.
26. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-12.
27. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-12.
Citation Information
Patent Citations
Task scheduling method and device based on cloud computing and computer equipment
CN111488210A