A task scheduling method and device

By determining the CPU in the physical machine to execute a task and storing the task in a virtual or physical scheduling queue, the scheduling problem between virtual machine tasks and physical machine tasks is solved, achieving efficient and accurate task scheduling, meeting the needs of all-core sales scenarios, and improving the service quality of virtual machines.

CN119829242BActive Publication Date: 2026-03-31BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In the existing technology, the tasks generated by the virtual CPU of the virtual machine need to be processed by the CPU of the physical machine, but the CPU of the physical machine also needs to process other tasks. There is a lack of effective task scheduling schemes to achieve efficient scheduling of tasks to be processed by the CPU of the physical machine.

Method used

A task scheduling method and apparatus are provided, which determines the CPU that will execute the task in the CPU of the physical machine and stores the task in a virtual scheduling queue or a physical scheduling queue. The task is allocated and scheduled according to the task identifier and the queue status to ensure efficient scheduling of different types of tasks.

Benefits of technology

It enables efficient scheduling of various types of tasks, improves the accuracy and flexibility of task scheduling, meets the needs of all-core sales scenarios, and improves the service quality and user experience of virtual machines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829242B_ABST
    Figure CN119829242B_ABST
Patent Text Reader

Abstract

The present disclosure provides a task scheduling method and device, relates to the technical field of computers, and particularly relates to the technical field of cloud computing. The specific implementation scheme is: in response to a task being woken up, determining a CPU in a physical machine that executes the woken-up task; in a virtual scheduling queue and a physical scheduling queue of the determined CPU, determining a queue corresponding to a task identifier, and storing the woken-up task in the determined queue; in response to an empty queue appearing in a local scheduling queue of each CPU of the physical machine, determining a target queue from the virtual scheduling queue and the physical scheduling queue of a target CPU; obtaining a task to be executed from the target queue, and calling the target CPU to execute the task to be executed. The task scheduling scheme provided by the embodiment of the present disclosure can implement scheduling of various tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, particularly to the field of cloud computing technology, and especially to a task scheduling method and apparatus. Background Technology

[0002] A virtual machine (VM) is a computer system simulated by software, possessing complete hardware system functionality. Multiple VMs can be simulated based on the resources of a single physical machine. Each VM is isolated from the others and does not affect the others, providing services independently to the user. Because VMs are simulated by software and do not possess real hardware resources, tasks generated by the VM's virtual CPU still require processing by the physical machine's CPU.

[0003] In addition to the tasks generated by the virtual CPU of the virtual machine, the physical machine's CPU also needs to handle other tasks. Therefore, a task scheduling scheme is needed to schedule the various tasks to be processed by the physical machine's CPU. Summary of the Invention

[0004] This disclosure provides a task scheduling method and apparatus.

[0005] In a first aspect, embodiments of this disclosure provide a task scheduling method, including:

[0006] In response to a task being woken up, the CPU that executes the woken-up task is determined among the CPUs of the physical machine, wherein the woken-up task carries a task identifier indicating the source of the task.

[0007] In the determined CPU's virtual scheduling queue and physical scheduling queue, the queue corresponding to the task identifier is determined, and the awakened task is stored in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks;

[0008] In response to the occurrence of an empty queue in the local scheduling queue of each CPU of the physical machine, a target queue is determined from the virtual scheduling queue and physical scheduling queue of the target CPU, wherein the target CPU is the CPU corresponding to the detected empty queue.

[0009] Obtain the task to be executed from the target queue and call the target CPU to execute the task.

[0010] Secondly, embodiments of this disclosure provide a task scheduling apparatus, including:

[0011] The first response module is used to determine the CPU that executes the awakened task among the CPUs of the physical machine in response to the task being awakened, wherein the awakened task carries a task identifier indicating the source of the task.

[0012] The queue determination module is used to determine the queue corresponding to the task identifier in the virtual scheduling queue and physical scheduling queue of the determined CPU, and to store the awakened task in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks;

[0013] The second response module is used to determine the target queue from the virtual scheduling queue and physical scheduling queue of the target CPU in response to the occurrence of an empty queue in the local scheduling queue of each CPU of the physical machine, wherein the target CPU is the CPU corresponding to the detected empty queue.

[0014] The task execution module is used to retrieve tasks to be executed from the target queue and call the target CPU to execute the tasks to be executed.

[0015] Thirdly, embodiments of this disclosure provide an electronic device, including:

[0016] At least one processor; and

[0017] A memory communicatively connected to the at least one processor; wherein,

[0018] 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 described in the first aspect.

[0019] Fourthly, embodiments of this disclosure provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described in the first aspect.

[0020] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0021] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, whenever a task is awakened, a CPU is allocated to it, and the task is stored in the virtual scheduling queue or physical scheduling queue of the allocated CPU. When the local scheduling queue of a CPU is empty, a task can be retrieved from the virtual scheduling queue or physical scheduling queue of that CPU, and the CPU can be invoked to execute the task. Since the virtual scheduling queue and physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling for various different types of tasks.

[0022] 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

[0023] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0024] Figure 1 A flowchart illustrating the first task scheduling method provided in this embodiment of the disclosure;

[0025] Figure 2 A flowchart illustrating a second task scheduling method provided in an embodiment of this disclosure;

[0026] Figure 3 A flowchart illustrating the third task scheduling method provided in this embodiment of the disclosure;

[0027] Figure 4 A flowchart illustrating the fourth task scheduling method provided in this embodiment of the disclosure;

[0028] Figure 5 A flowchart illustrating the fifth task scheduling method provided in this embodiment of the disclosure;

[0029] Figure 6 This is a schematic diagram of the structure of a first task scheduling device provided in an embodiment of the present disclosure;

[0030] Figure 7 This is a block diagram of an electronic device used to implement the task scheduling method of the embodiments of this disclosure. Detailed Implementation

[0031] 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 and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0032] First, some concepts involved in the embodiments of this disclosure will be introduced.

[0033] 1. SCX (extensible scheduler class)

[0034] SCX, also known as sched_ext, is a scheduling framework in the Linux kernel. It allows for the implementation and dynamic loading of custom schedulers within BPF, offering strong flexibility and scalability. Furthermore, SCX enables rapid experimentation and customized scheduling, simplifying scheduling policy development and promoting experimental innovation.

[0035] The core idea of ​​this scheduler is to make scheduling decisions through a single central CPU and distribute scheduling tasks to other cores. It implements a mechanism that eliminates the need for timer ticks and scheduling overhead, allowing other cores to run with unlimited time slices.

[0036] The SCX architecture consists of four layers. The bottom layer is the core kernel scheduler, which defines the common behavior of all scheduler classes. The second layer is the SCX framework, which provides an interface for interacting with the kernel and supports loading custom schedulers. The third layer is the specific BPF (Berkeley Packet Filter) scheduler, upon which developers can implement their own scheduling logic. The top layer is the BPF scheduler client, which interacts with the user control and communicates with the kernel scheduler to coordinate task scheduling.

[0037] The four layers in the SCX architecture interact with each other through specific interfaces, and the interactions between these layers have some specific details. First, the kernel scheduler provides basic task management functionality, defining interfaces for scheduling tasks through `struct sched_class`, such as `enqueue_task` and `dequeue_task` functions, for upper layers to call. The SCX framework extends this functionality and connects to the BPF scheduler through interfaces such as `enqueue_task_scx` and `pick_next_task_scx`. Whenever a task enters the queue, the SCX framework calls the corresponding BPF scheduler callback function, such as `scx_ops.enqueue`, to handle the specific scheduling logic. The BPF scheduler, as the core of the scheduling policy, manages the tasks in the scheduling queue according to different scheduling policies. Through `scx_bpf_dispatch`, the BPF scheduler can distribute tasks in FIFO (First Input First Output) or virtual time (vtime) order. It can also call `scx_bpf_consume` to retrieve tasks from the scheduling queue and hand them over to the CPU for execution. Furthermore, the BPF scheduler is also responsible for selecting the appropriate CPU to execute tasks, with `scx_bpf_select_cpu_dfl` helping it choose the optimal CPU based on the default policy. In user space, the scheduler's accompanying programs can interact with the BPF mapping, using APIs such as `bpf_map_lookup_elem` to read and modify data in the BPF. This mechanism allows users to flexibly manage scheduling policies, such as optimizing task allocation by adjusting scheduling parameters or reading the status of the scheduling queue. This entire process achieves tight collaboration between the scheduler and user space, enabling the scheduler to dynamically adjust according to actual needs and providing powerful flexibility.

[0038] Secondly, the executing entity of the task scheduling scheme provided in the embodiments of this disclosure will be described.

[0039] The task scheduling scheme provided in this embodiment is executed by a scheduler, which is used to schedule various tasks to be executed by each CPU in a physical machine. Among these tasks are tasks generated by the virtual CPU of a virtual machine, which is a computer system simulated by software based on the resources of the physical machine.

[0040] The task scheduling method and apparatus provided in the embodiments of this disclosure will be described one by one below.

[0041] See Figure 1 , Figure 1 This is a flowchart illustrating a first task scheduling method provided in an embodiment of the present disclosure. In this embodiment, the method includes the following steps S101-S104.

[0042] Step S101: In response to the task being woken up, determine the CPU among the CPUs of the physical machine that will execute the woken-up task.

[0043] The awakened task carries a task identifier indicating the source of the task.

[0044] When creating a task, different objects can add a task identifier to the task to indicate the source of the task. For example, when the system kernel creates a task, it can add an identifier to the task to indicate that it is the system kernel. When the virtual machine's virtual CPU (i.e., vCPU) creates a task, it can add an identifier to the task to indicate that it is the virtual CPU. Other objects can also add an identifier to the task to indicate themselves.

[0045] When adding a task identifier, you can pre-add an identifier bit to the task and fill in fields on the identifier bit. For example, you can use 10 to represent the vCPU and 01 to represent the system kernel. When the vCPU creates a task, you can fill in 10 on the task's identifier bit.

[0046] Specifically, a task may be in an unwakeable state due to interruption, execution restriction, or other reasons. When the physical machine meets the conditions for executing an unwakeable task, the unwakeable task will be woken up. At this time, the scheduler can respond to the task being woken up by determining the CPU among the CPUs of the physical machine to execute the woken-up task.

[0047] The specific implementation method of the CPU can be found in the subsequent embodiments, which will not be described in detail here.

[0048] Step S102: In the virtual scheduling queue and physical scheduling queue of the determined CPU, determine the queue corresponding to the task identifier, and store the wake-up task in the determined queue.

[0049] The physical machine may have one or more CPU chips. Each CPU chip can be considered as a CPU of the physical machine. Each CPU has a virtual scheduling queue and a physical scheduling queue to store the tasks to be executed by that CPU. The virtual scheduling queue and the physical scheduling queue are used to store different types of tasks.

[0050] In one embodiment of this disclosure, a virtual scheduling queue is used to store first-type tasks generated by the virtual CPU of a virtual machine. A physical scheduling queue is used to store tasks other than the first-type tasks.

[0051] Since the virtual scheduling queue is used to store the first type of tasks generated by the virtual CPU of the virtual machine, the above scheme can realize task scheduling that includes tasks generated by the virtual CPU of the virtual machine.

[0052] Specifically, once the CPU executing the wake-up task is determined, the wake-up task can be stored in the scheduling queue corresponding to the task identifier carried in the wake-up task. For example, if the wake-up task carries task identifier 10, it means that the wake-up task comes from vCPU. Then the virtual scheduling queue of the CPU can be determined as the queue for storing the wake-up task, and thus the wake-up task is stored in the virtual scheduling queue of the determined CPU.

[0053] Step S103: In response to the occurrence of an empty queue in the local scheduling queue of each CPU of the physical machine, determine the target queue from the virtual scheduling queue and physical scheduling queue of the target CPU.

[0054] In addition to virtual scheduling queues and physical scheduling queues, each CPU also has a local scheduling queue, which is used to store tasks to be executed next or currently being executed.

[0055] The target CPU mentioned above is the CPU corresponding to the detected empty queue.

[0056] Specifically, for each CPU of a physical machine, the CPU's virtual scheduling queue and physical scheduling queue contain the tasks that the CPU will execute. When the CPU finishes executing the tasks in its local scheduling queue, it can notify the scheduler that its local scheduling queue is empty. The scheduler can respond to the fact that the CPU's local scheduling queue is empty by determining the target queue from the CPU's virtual scheduling queue and physical scheduling queue.

[0057] The specific implementation of determining the target queue from the CPU's virtual scheduling queue and physical scheduling queue can be found in subsequent embodiments, and will not be detailed here.

[0058] Step S104: Obtain the task to be executed from the target queue and call the target CPU to execute the task.

[0059] Specifically, tasks in the CPU's virtual or physical scheduling queue can be arranged according to preset rules. After determining the target queue, the scheduler can obtain the first task in the target queue as the task to be executed and call the target CPU to execute the task to be executed.

[0060] When calling the target CPU to execute the task to be executed, the call can be made in the manner mentioned in the following embodiments, so that the target CPU can execute the task to be executed, or existing calling functions, models, algorithms, etc. can be used to call the target CPU to execute the task to be executed.

[0061] In one embodiment of this disclosure, the aforementioned preset rules may be arranged in ascending order of virtual execution time, or they may be arranged according to the first-in, first-out principle.

[0062] When tasks are arranged in ascending order of virtual execution time, once a task is stored in a scheduling queue, its virtual execution time can be calculated based on its current actual execution time, weight, and priority (nice) value. This virtual execution time, along with the virtual execution times of other tasks already stored in the queue, determines the task's location, thus enabling task storage. The priority (nice) value is a pre-defined value for the task. The task's weight is inversely proportional to its virtual execution time; a higher weight results in a shorter virtual execution time and earlier execution. Conversely, the actual execution time is directly proportional to the virtual execution time; a longer actual execution time results in a longer virtual execution time and later execution.

[0063] When tasks are arranged according to the first-in, first-out (FIFO) principle, once a task is stored in a scheduling queue, it can be placed directly at the end of the queue.

[0064] In one embodiment of this application, the tasks in the virtual scheduling queue are arranged in ascending order of their virtual execution times.

[0065] Virtual execution time is used to measure the execution status of a task on a virtual timeline. The smaller the virtual execution time, the more necessary the task is to be executed. Therefore, the tasks in the virtual scheduling queue are arranged in ascending order of their virtual execution times. This allows for the accurate identification of the most needed tasks to be scheduled and executed during each scheduling process, thereby improving the accuracy of task scheduling.

[0066] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, whenever a task is awakened, a CPU is allocated to it, and the task is stored in the virtual scheduling queue or physical scheduling queue of the allocated CPU. When the local scheduling queue of a CPU is empty, a task can be retrieved from the virtual scheduling queue or physical scheduling queue of that CPU, and the CPU can be invoked to execute the task. Since the virtual scheduling queue and physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling for various different types of tasks.

[0067] In one embodiment of this disclosure, when the target CPU is invoked to execute the task to be executed in step S104 above, the time slice of the task to be executed can be obtained, and the task to be executed can be dispatched to the local scheduling queue of the target CPU. The target CPU is then invoked to execute the task to be executed stored in the local scheduling queue according to the obtained time slice.

[0068] The time slice mentioned above refers to the execution duration of the task. For example, if the time slice is 10ms, it means that the CPU can execute the task for 10ms.

[0069] Specifically, when obtaining the time slice of a task to be executed, the time slice of the task to be executed can be determined based on the weight of the task to be executed, the weight of each task in the target queue, and the preset scheduling cycle of the target CPU.

[0070] For example, based on the weight of the task to be executed and the weight of each task in the target queue, the weight ratio of the task to be executed is calculated, and then the weight ratio is multiplied by the preset scheduling period to obtain the calculation result, which is used as the time slice of the task to be executed.

[0071] When dispatching a task to be executed to the local scheduling queue of the target CPU, the dispatch function can be used to dispatch the task to the local scheduling queue of the target CPU.

[0072] For example, the ops.dispatch function can be used to dispatch tasks to the local scheduling queue of the target CPU.

[0073] After obtaining the time slice of the task to be executed, the time slice can be written into the task. When the task is dispatched to the local scheduling queue of the target CPU, the target CPU can directly obtain the task from the local scheduling queue, parse the time slice from the task, and then execute the task according to the time slice.

[0074] Alternatively, a time slice can be sent to the target CPU. In this way, the target CPU can obtain the task to be executed from the local scheduling queue and receive the time slice, so that the target CPU can execute the task to be executed according to the received time slice.

[0075] When the time slice for the target CPU to execute the task reaches the specified duration, if the task has not yet been completed, it can be treated as a wake-up task again and returned to step S101 to wait for the next round of scheduling until the task is completed.

[0076] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, after obtaining the task to be executed, the time slice of the task to be executed is obtained, and the task to be executed is dispatched to the local scheduling queue of the target CPU. The target CPU is then invoked to execute the task to be executed stored in the local scheduling queue according to the obtained time slice. In this way, the time slice can be used to control the time when the CPU executes the task, thereby achieving precise scheduling of tasks. Therefore, the above scheme can improve the accuracy of task scheduling.

[0077] In one embodiment of this disclosure, the task identifier carried in the task can also be processed in the manner mentioned in the following embodiments.

[0078] In one embodiment of this disclosure, in response to a user's instruction to switch the identifier of the awakened task, the task identifier carried in the awakened task is switched.

[0079] Specifically, the user may issue the identifier switching command before the woken task is stored in the scheduling queue, or the user may issue the identifier switching command after the woken task is stored in the scheduling queue.

[0080] If a user issues an identifier switching command before the woken task is stored in the scheduling queue, the scheduler can respond to the command and switch the task identifier carried in the woken task.

[0081] During the switch, if the identifier switching command indicates the identifier after the task switch, the task identifier carried in the task can be switched to the identifier indicated by the identifier switching command.

[0082] If the identifier switching command does not indicate the identifier after the task switching, the task identifier carried by the task can be switched to its next identifier according to the pre-set order of the identifiers.

[0083] For example, if there are three identifiers, in the order of identifier 1, identifier 2 and identifier 3, if the task carries identifier 2, then identifier 2 can be switched to identifier 3 during the switching process.

[0084] When a user issues a switch command after the awakened task has been stored in the scheduling queue, the scheduler, in addition to switching the task identifier carried in the awakened task, can also move the awakened task to the queue corresponding to the new task identifier after switching the task identifier. This ensures that the task identifier and the task's queue correspond to each other, avoiding unpredictable problems caused by a mismatch between the task identifier and the task's queue.

[0085] As can be seen from the above, when scheduling tasks using the scheme provided in the embodiments of this disclosure, users can switch the task identifier carried in the awakened task through the identifier switching command. This allows users to flexibly control the task queue according to their own needs, and thus control the task scheduling. Therefore, the task scheduling scheme provided in the embodiments of this disclosure can improve the flexibility of task scheduling.

[0086] The following explains the four implementation methods for determining the CPU mentioned in step S101 above.

[0087] In the first implementation, an idle CPU can be searched among the CPUs to execute the wake-up task.

[0088] Specifically, each CPU can maintain its own state. For example, when a CPU is executing a task, its state can be "busy"; when a CPU is online but not executing a task, its state can be "idle"; when a CPU is offline, its state can be "offline"; and when a CPU fails, its state can be "faulty". When a task is woken up, the CPU can be searched for in an idle state based on its state, and this CPU can be identified as the one to execute the woken task. Since the CPU is in an idle state, it means that it is not currently executing a task. Therefore, identifying this CPU as the one to execute the woken task allows the woken task to be executed quickly, thereby improving task execution efficiency and ultimately enhancing the user experience.

[0089] In the second implementation, if the task being woken up is a subtask and the third CPU corresponding to the queue storing the parent task of the task being woken up is not saturated, then the third CPU is determined to be the CPU that executes the task being woken up.

[0090] Specifically, each CPU has a load limit when executing tasks. If the number of tasks assigned to a CPU exceeds this load limit, the CPU may fail due to overload. Therefore, when the number of tasks assigned to a CPU reaches its load limit, the CPU can be considered saturated and no more tasks should be assigned to it. When the number of tasks assigned to a CPU does not reach its load limit, the CPU can be considered unsaturated, and tasks can continue to be assigned to it.

[0091] Therefore, when determining the CPU to execute the woken-up task, if the woken-up task is a subtask, its parent task can be identified, and the CPU corresponding to the queue storing that parent task can be determined. This CPU is the third CPU. It is then determined whether the tasks allocated to the third CPU have reached its load limit. If not, the third CPU is not saturated, and it can be identified as the CPU to execute the woken-up task. If the tasks allocated to the third CPU have reached its load limit, the third CPU is saturated, and in this case, the CPU to execute the woken-up task needs to be determined from among the other CPUs.

[0092] In this implementation, since parent and child tasks usually share a cache, if the third CPU corresponding to the queue storing the woken-up parent task is not saturated, the third CPU can be preferentially determined as the CPU to execute the woken-up task. This makes it easier for the woken-up task and its parent task to share the same cache, thereby improving cache affinity and thus improving task scheduling performance.

[0093] In the third implementation, the CPU that will execute the wake-up task is determined from among the pre-specified CPUs used to execute the wake-up task.

[0094] Specifically, some tasks can specify which CPUs are allowed to execute the task when they are created. In this case, when the task is woken up, the CPUs specified by the task can be obtained, and one of them can be selected to execute the woken task. This can accurately determine the CPU to execute the woken task, thereby improving the accuracy of task scheduling.

[0095] In the fourth implementation method, if the CPU cannot be determined according to any of the first three implementation methods, then the CPU that previously executed the wake-up task can be determined as the CPU that will execute the wake-up task this time.

[0096] In scenarios where all cores are sold, cloud providers aim to offload all core computing power of physical machines to virtual machines, thereby ensuring the quality of service (QoS) of virtual machines, avoiding virtual machine jitter, and ultimately improving the user experience. In this scenario, the scheduler needs to prioritize tasks generated by virtual CPUs.

[0097] In the above scenario, one embodiment of this disclosure provides another task scheduling method. In this embodiment, the physical scheduling queue includes a system scheduling queue and other scheduling queues. The system scheduling queue is used to store second-type tasks generated by the CPU's system kernel, and the other scheduling queues are used to store third-type tasks other than first-type and second-type tasks.

[0098] When determining the target queue in step S103 above, the determination can be carried out according to the following steps one and two.

[0099] Step 1: If there are tasks in the target CPU's virtual scheduling queue and system scheduling queue, but no tasks in other scheduling queues, then if the task previously executed by the target CPU belongs to the first type of task, the target CPU's system scheduling queue is determined as the target queue; if the task previously executed by the target CPU belongs to the second type of task, the target CPU's virtual scheduling queue is determined as the target queue.

[0100] Specifically, when determining the target queue, the system can check whether there are tasks in the target CPU's virtual scheduling queue, system scheduling queue, and other scheduling queues. If tasks are detected in the virtual scheduling queue and system scheduling queue, but not in other scheduling queues, the type of the task last executed by the target CPU can be determined. If the last executed task belonged to the first type of task, the system scheduling queue of the target CPU is determined as the target queue, so that tasks can be obtained from the system scheduling queue for execution later. If the last executed task belonged to the second type of task, the virtual scheduling queue of the target CPU is determined as the target queue, so that tasks can be obtained from the virtual scheduling queue for execution later.

[0101] As can be seen, in this scenario, the scheduler can alternately schedule tasks in the virtual scheduling queue and the system scheduling queue, allowing the target CPU to alternately execute tasks of type I and type II. Furthermore, in the subsequent step S104, when obtaining the time slice of a task to be executed, if the task belongs to type II, its time slice can be limited; or, if the task belongs to type I, its time slice can be increased, so that type I tasks can be completed as quickly as possible, thereby improving the virtual machine's performance and ultimately enhancing its service quality.

[0102] In addition, in this case, if the task previously executed by the target CPU belongs to the third type of task, the virtual scheduling queue of the target CPU can be determined as the target queue, so that the tasks in the virtual scheduling queue can be executed first.

[0103] Step 2: If there are tasks in the target CPU's virtual scheduling queue and other scheduling queues, but no tasks in the system scheduling queue, determine the target CPU's virtual scheduling queue as the target queue.

[0104] When it is detected that there are tasks in the target CPU's virtual scheduling queue and other scheduling queues, but no tasks in the system scheduling queue, the target CPU's virtual scheduling queue can be identified as the target queue, thus enabling priority scheduling of tasks in the virtual scheduling queue.

[0105] As can be seen from the above, when scheduling tasks using the scheme provided in this disclosure, if tasks exist in the virtual scheduling queue and system scheduling queue of the target CPU but not in other scheduling queues, the first type of tasks and the second type of tasks can be scheduled alternately. If tasks exist in the virtual scheduling queue and other scheduling queues of the target CPU but not in the system scheduling queue, the first type of tasks in the virtual scheduling queue can be scheduled first. This ensures that the first type of tasks have a higher scheduling priority, that is, tasks generated by the virtual CPU can be scheduled first, reducing the computing core jitter caused by other tasks during virtual machine operation. Thus, this scheduling scheme can meet the needs of the full-core sales scenario. It is evident that the scheduling scheme provided in this disclosure is applicable to the full-core sales scenario, thereby broadening the scope of application of task scheduling.

[0106] In one embodiment of this disclosure, the task scheduling scheme provided in the above embodiments can be implemented based on the SCX framework.

[0107] The SCX framework provides the ability to customize scheduling queues and custom task scaling policies. Based on this capability of the SCX framework, users can customize three types of DSQs (Distributed Scheduled Queues) for each CPU of a physical machine, namely the virtual scheduling queue, system scheduling queue, and other scheduling queues mentioned in the previous embodiments. Furthermore, tasks in the virtual scheduling queue and system scheduling queue are arranged in ascending order of virtual execution time, while tasks in other scheduling queues are arranged according to the first-in, first-out principle.

[0108] See Figure 2 A flowchart illustrating the second task scheduling method is provided. Figure 2 In the diagram, 11 is the task identifier for the first type of task, 01 is the task identifier for the second type of task, and 00 is the task identifier for the third type of task.

[0109] exist Figure 2In the illustrated process, when a task is awakened and a CPU is assigned to execute it, the `ops.enqueue` function is used to determine the scheduling queue where the task will be stored. Within this function, the `tag` field (task identifier) ​​in the `task_struct` structure is used to determine the task's category and it is placed into the corresponding DSQ. The scheduled time slice size is also calculated. Subsequently, when the CPU's local scheduling queue (`local DSQ`) is empty, the scheduler can use the `ops.dispatch` function in `balance_one` to consume task scheduling entities from the three types of DSQs. This means retrieving tasks and their time slices from the three custom DSQs and dispatching the retrieved tasks to the CPU's local scheduling queue, allowing the CPU to execute the tasks in the local scheduling queue.

[0110] Compared to other scheduling schemes, the scheduling scheme based on the SCX framework also has the characteristics of SCX, namely, it can realize hot-swappable replacement and iterative updates without replacing the kernel, and online operation and maintenance and fault handling are more efficient and convenient.

[0111] Based on the above embodiments, the scheduler can also limit the maximum number of tasks that can be stored in the local scheduling queue of each CPU to 1. That is, each CPU's local scheduling queue can only hold a maximum of 1 task.

[0112] In this way, each time a task to be executed is obtained through the aforementioned step one or two, and step S104, the task to be executed is dispatched to the local scheduling queue of the target CPU. The target CPU can immediately execute the task to be executed, thereby ensuring the scheduling timeliness of the scheduling strategy consisting of the aforementioned steps one, two, and S104. That is, the task executed by the target CPU can be accurately controlled through the aforementioned steps one, two, and S104, avoiding the situation where it is difficult to prioritize the scheduling of the first type of task when there are multiple tasks in the local scheduling queue. For example, if there are multiple tasks in the local scheduling queue, and the first type of task that needs to be prioritized is obtained through the aforementioned steps one, two, and S104, it is necessary to wait for the tasks in the local scheduling queue to be completed before the obtained first type of task can be executed. Limiting the local scheduling queue to a maximum of one task can solve this problem, thereby ensuring that the first type of task can be prioritized for scheduling. This allows the scheduling scheme to meet the needs of the all-core sales scenario and broadens the applicability of task scheduling.

[0113] In one embodiment of this disclosure, the tasks in the system scheduling queue are arranged in ascending order of their virtual execution times.

[0114] Similar to the virtual scheduling queue, the tasks in the system scheduling queue are arranged in ascending order of their virtual execution time. This allows the system to accurately identify the most needed tasks for scheduling and execution during each scheduling process, thereby improving the accuracy of task scheduling.

[0115] In another embodiment of this disclosure, the tasks in the other scheduling queues described above are arranged according to the storage time of each task.

[0116] In a full-core sales scenario, the scheduling priority of the first type of task is the highest, followed by the second type, and the scheduling priority of the third type is the lowest. Therefore, for other scheduling queues that store the third type of task, it is only necessary to arrange the tasks in order according to their storage time, without having to calculate the virtual execution time of each task. This can reduce the scheduling workload of the scheduler and improve scheduling efficiency.

[0117] If there are tasks in the virtual scheduling queue and system scheduling queue of the target CPU, but no tasks in other scheduling queues, the target queue can also be determined using the methods mentioned in the following embodiments.

[0118] In one embodiment of this disclosure, see [link to embodiment]. Figure 3 The present invention provides a flowchart of a third task scheduling method. In this embodiment, the above method includes the following steps S301-S306.

[0119] Step S301: In response to the task being woken up, determine the CPU among the CPUs of the physical machine that will execute the woken-up task.

[0120] Step S302: In the determined CPU's virtual scheduling queue and physical scheduling queue, determine the queue corresponding to the task identifier, and store the wake-up task in the determined queue.

[0121] The steps S301 and S302 described above are the same as steps S101 and S102 described above, and will not be repeated here.

[0122] Step S303: In response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, in the first case, it is determined whether the time taken for the target CPU to process the second type of task in the most recent first preset number of clock cycles exceeds the first time threshold. If it exceeds, then step S304 is executed; if it does not exceed, then step S305 is executed.

[0123] The first scenario mentioned above refers to a situation where there are tasks in the target CPU's virtual scheduling queue and system scheduling queue, but no tasks in other scheduling queues.

[0124] The first preset quantity mentioned above is a pre-set quantity.

[0125] The aforementioned first duration threshold is a preset duration.

[0126] Specifically, each time an empty queue appears in the local scheduling queue of each CPU of the physical machine, the duration of the target CPU processing the second type of task within the most recent first preset number of clock cycles can be counted. If this duration exceeds a first duration threshold, it indicates that the execution time of the second type of task has been relatively long in the recent period, affecting the priority scheduling of the first type of task. Therefore, if the counted duration exceeds the first duration threshold, step S304 can be executed to select the virtual scheduling queue of the target CPU as the target queue, and then select the first type of task in the virtual scheduling queue as the task to be executed, thereby restricting the execution of the second type of task and ensuring the priority scheduling of the first type of task. If the duration does not exceed the first duration threshold, it indicates that the execution time of the second type of task has been relatively short in the recent period, and has not affected the priority scheduling of the first type of task, or has a small impact on the priority scheduling of the first type of task. In this case, step S305 can be executed to select the target queue in the manner shown in step S305.

[0127] Step S304: Determine the virtual scheduling queue of the target CPU as the target queue.

[0128] Step S305: If the task previously executed by the target CPU belongs to the first type of task, then the system scheduling queue of the target CPU is determined as the target queue; if the task previously executed by the target CPU belongs to the second type of task, then the virtual scheduling queue of the target CPU is determined as the target queue.

[0129] For a description of this step, please refer to the foregoing embodiments, which will not be repeated here.

[0130] Step S306: Obtain the task to be executed from the target queue and call the target CPU to execute the task.

[0131] This step is the same as step S104 above, and will not be repeated here.

[0132] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, if the time taken for the target CPU to process the second type of task exceeds the first time threshold within the most recent first preset number of clock cycles, the virtual scheduling queue of the target CPU can be directly determined as the target queue. This can further ensure that the first type of task stored in the virtual scheduling queue can be scheduled with priority, thereby making this scheduling scheme more suitable for the all-core sales scenario, meeting the expectations of cloud vendors in this scenario, and improving the user experience.

[0133] If there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU, but no tasks are in the system scheduling queue, the target queue can also be determined using the methods mentioned in the following embodiments.

[0134] In one embodiment of this disclosure, see [link to embodiment]. Figure 4 The present invention provides a flowchart of a fourth task scheduling method. In this embodiment, the above method includes the following steps S401-S406.

[0135] Step S401: In response to the task being woken up, determine the CPU among the CPUs of the physical machine that will execute the woken-up task.

[0136] Step S402: In the determined CPU's virtual scheduling queue and physical scheduling queue, determine the queue corresponding to the task identifier, and store the wake-up task in the determined queue.

[0137] The steps S401 and S402 described above are the same as steps S101 and S102 described above, and will not be repeated here.

[0138] Step S403: In response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, in the second case, it is determined whether the target CPU has processed the third type of task within the most recent second preset number of clock cycles. If not, step S404 is executed; if yes, step S405 is executed.

[0139] The second scenario mentioned above refers to a situation where there are tasks in the target CPU's virtual scheduling queue and other scheduling queues, but no tasks in the system scheduling queue.

[0140] The second preset quantity is a pre-set quantity, which may be the same as or different from the first preset quantity.

[0141] Specifically, each time an empty queue appears in the local scheduling queue of each CPU of the physical machine, if there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU, but no tasks in the system scheduling queue, it can be checked whether the target CPU has processed the third type of task within the last second preset number of clock cycles. If it has not been processed, step S404 is executed to directly determine the other scheduling queues of the target CPU as the target queue. This can avoid tasks in other scheduling queues from not being scheduled for a long time, which would lead to task starvation.

[0142] If the target CPU has processed a third type of task within the most recent second preset number of clock cycles, then step S405 can be executed to determine the virtual scheduling queue of the target CPU as the target queue, so as to ensure that the first type of task in the virtual scheduling queue is scheduled first.

[0143] Step S404: Determine other scheduling queues of the target CPU as the target queue.

[0144] Step S405: Determine the virtual scheduling queue of the target CPU as the target queue.

[0145] Step S406: Obtain the task to be executed from the target queue and call the target CPU to execute the task.

[0146] This step is the same as step S104 above, and will not be repeated here.

[0147] As can be seen from the above, when scheduling tasks using the scheme provided in the embodiments of this disclosure, if the target CPU has not processed any third-type tasks within the most recent second preset number of clock cycles, other scheduling queues of the target CPU can be directly identified as the target queue. This can avoid task starvation in other scheduling queues, which would lead to unbalanced task scheduling within the physical machine system and affect the operating performance of the physical machine. Therefore, the task scheduling scheme provided in the embodiments of this disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.

[0148] During task scheduling, tasks to be executed can also be obtained by following the methods provided in the embodiments below.

[0149] In one embodiment of this disclosure, if a task is detected in the virtual scheduling queue of the first CPU while the first CPU is executing a third type of task, the execution of the current task by the first CPU is interrupted, and a task to be executed is obtained from the virtual scheduling queue of the first CPU.

[0150] The first CPU is any one of the CPUs in the physical machine.

[0151] Specifically, when the local scheduling queue of the first CPU is empty, the scheduler can determine the target queue from the virtual, system and other scheduling queues of the first CPU. When the scheduler detects that there are no tasks in the virtual scheduling queue and the system scheduling queue of the first CPU, but there are tasks in other scheduling queues, it can obtain a task from other scheduling queues. This task belongs to the third type of task, and dispatches the third type of task to the local scheduling queue of the first CPU, so that the first CPU can execute the third type of task.

[0152] If a first-type task is awakened while the first CPU is executing a third-type task, and the scheduler stores the first-type task in the first CPU's virtual scheduling queue, the scheduler can detect that there is a task in the first CPU's virtual scheduling queue. At this time, the scheduler can interrupt the first CPU from executing the current task and retrieve the task to be executed from the first CPU's virtual scheduling queue, so that the first CPU will subsequently process first-type tasks. This achieves the goal of prioritizing the processing of tasks generated by the virtual CPU, making this scheduling scheme more suitable for all-core sales scenarios, meeting the expectations of cloud vendors in this scenario, and improving the user experience.

[0153] When the task scheduling scheme provided in this embodiment is implemented based on the SCX framework, the task can be stored in a virtual scheduling queue or in other scheduling queues using the scx_bpf_dispatch function or the scx_bpf_dispatch_vtime function.

[0154] In addition to the methods described above for determining tasks to be executed, tasks can also be determined using the methods provided in the following embodiments.

[0155] In one embodiment of this disclosure, see [link to embodiment]. Figure 5 The present invention provides a flowchart of the fifth task scheduling method. In this embodiment, the above method includes the following steps S501-S506.

[0156] Step S501: In response to the task being woken up, determine the CPU among the CPUs of the physical machine that will execute the woken-up task.

[0157] Step S502: In the determined CPU's virtual scheduling queue and physical scheduling queue, determine the queue corresponding to the task identifier, and store the wake-up task in the determined queue.

[0158] Step S503: In response to the occurrence of an empty queue in the local scheduling queue of each CPU of the physical machine, determine the target queue from the virtual scheduling queue and physical scheduling queue of the target CPU.

[0159] The steps S501-S503 are the same as the steps S101-S103 above, and will not be repeated here.

[0160] Step S504: Obtain the tasks to be executed from the target queue.

[0161] Step S505: For each task stored in each scheduling queue of the target CPU, if the waiting time of the task reaches the second time threshold, then the task is determined to be a task to be executed.

[0162] Step S506: Call the target CPU to execute the task to be executed.

[0163] For a description of steps S504 and S506, please refer to the description of step S104 above, which will not be repeated here.

[0164] The following is an explanation of step S505 above.

[0165] The aforementioned second duration threshold is a preset duration.

[0166] Specifically, after the scheduler stores a task in a scheduling queue of the CPU, it can start timing the task. If the task is still not executed when the timer reaches a second time threshold, it can be directly determined as a task to be executed. This can avoid the task starvation caused by the task not being executed for a long time, which would lead to unbalanced task scheduling within the physical machine system and affect the running performance of the physical machine. Therefore, the task scheduling scheme provided by the embodiments of this disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.

[0167] During task scheduling, the schemes provided in the following embodiments can also be executed.

[0168] In one embodiment of this disclosure, for any second CPU among the CPUs of the physical machine, at each clock cycle, it is detected whether the current task being executed by the second CPU meets the task switching conditions. If it does, the time slice of the current task being executed by the second CPU is cleared to zero, and the task is re-stored in the scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue.

[0169] The physical machine can be configured with a clock, which executes the above detection once every clock cycle. For example, the clock cycle could be 10ms, in which case the detection would be executed once every 10ms.

[0170] The above task switching conditions are predefined conditions used to switch the task that the CPU is currently processing.

[0171] Specifically, at the end of each clock cycle, it can be checked whether the current task being executed by each second CPU meets the task switching conditions. If it does, the time slice of the current task being executed by the second CPU can be cleared and the task can be stored back in the scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue. In this way, the scheduler can respond to the fact that the local scheduling queue of the second CPU becomes an empty queue, determine the target queue from the scheduling queues of the second CPU again, obtain the task to be executed, obtain the time slice of the task to be executed, dispatch the task to be executed to the local scheduling queue of the second CPU, and call the second CPU to execute the task to be executed stored in the local scheduling queue according to the obtained time slice. This achieves task switching.

[0172] When the task scheduling scheme provided in this embodiment is implemented based on the SCX framework, the resched_curr function can be used for rescheduling operations, namely, clearing the time slices and restoring the tasks as mentioned above. Furthermore, when the second CPU is invoked to execute the tasks stored in the local scheduling queue according to the acquired time slice, the pick_next_task function can be used to retrieve the tasks from the local scheduling queue and hand them over to the CPU for execution.

[0173] If the current task being executed by the second CPU does not meet the task switching conditions, then no task processing will be performed, and the second CPU will continue to execute the current task.

[0174] exist Figure 2 In the process shown, for each CPU, every time a tick clock cycle is reached, the scheduler can call the check preempt tick function to check whether the current task of each second CPU needs to be preempted, that is, to check whether the current task being executed by each second CPU meets the task switching conditions. If the task switching conditions are met, the preemption operations such as clearing the time slice and restoring the task are performed.

[0175] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, if the current task being executed by the second CPU meets the task switching conditions, operations such as clearing the time slice and restoring the task are performed, so that the local scheduling queue of the second CPU becomes an empty queue. In this way, the scheduler can reschedule the task being executed by the second CPU, avoiding the task occupying the CPU for a long time and making it difficult to schedule subsequent tasks in a timely manner, thereby improving the accuracy and reliability of task scheduling.

[0176] In one embodiment of this disclosure, the task switching condition is: the actual execution time of the task exceeds the ideal execution time of the task.

[0177] Specifically, in this scenario, at the beginning of each clock cycle, for each second CPU, the scheduler can calculate the ideal execution time of the task based on the task information of the current task being executed by that second CPU, and then calculate the actual execution time of the task. The scheduler will then determine whether the actual execution time of the task exceeds the ideal execution time. If it does, it means that the task meets the task switching conditions, and the subsequent time slice clearing operation will continue. If it does not exceed the ideal execution time, it means that the task does not meet the task switching conditions, and no operation will be performed.

[0178] In the case where the task scheduling scheme provided in this embodiment is implemented based on the SCX framework, the ideal execution time can be calculated using the sched_slice function.

[0179] By comparing the ideal execution time of a task with its actual execution time, it is possible to accurately determine whether a task switch is necessary. This ensures that task execution remains within a controllable range, preventing tasks from occupying the CPU for extended periods and making it difficult to schedule subsequent tasks in a timely manner. Consequently, the accuracy and reliability of task scheduling can be improved.

[0180] In one embodiment of this disclosure, when the task scheduling scheme provided in the foregoing embodiments is implemented based on the SCX framework, if the CPU of the physical machine has multiple cores, the load balancing of the task scheduling scheme provided in this disclosure can be achieved by relying on the load balancing mechanism of the SCX itself. Compared with CFS achieving load balancing by periodically pulling tasks through tick balance, this scheme uses a custom DSQ as a cache to obtain tasks to the CPU, which is simpler and more efficient.

[0181] Specifically, the scheduler can utilize the `balance_scx` function within the SCX framework to optimize system performance by effectively scheduling CPU tasks. This strategy first attempts to balance the current CPU's run queue (rq), that is, by calling the `balance_one` function to process tasks in the local scheduling queue. If the system has SMT (Simulate MultiThreading) enabled, the `balance_scx` function will further balance logical CPUs sharing the same physical core (SMT sibling CPUs), iterating through the rqs of these sibling CPUs and updating their run queue clocks using the `update_rq_clock` function, before calling `balance_one` again to attempt to balance the load across these queues.

[0182] When `balance_one` enters the scheduling loop, it first calls the BPF hook function `dispatch` to execute the custom scheduling strategy and flushes the scheduling queue buffer. If there are tasks in the local queue, the system returns immediately and runs the tasks; if there are consumable tasks in the global queue, it also returns immediately. During this process, the `balance_one` function uses a loop counter `nr_loops` to prevent the system from entering an infinite loop. If the counter decrements to 0, the system will schedule a delayed task to avoid continuously scheduling unqualified tasks, thereby ensuring that the system watchdog timer can function properly and preventing the system from becoming unresponsive for extended periods.

[0183] Corresponding to the aforementioned task scheduling method, this disclosure also provides a task scheduling device.

[0184] In one embodiment of this disclosure, see [link to embodiment]. Figure 6A schematic diagram of a task scheduling device is provided, the device comprising:

[0185] The first response module 601 is used to determine the CPU that executes the awakened task among the CPUs of the physical machine in response to the task being awakened, wherein the awakened task carries a task identifier indicating the source of the task.

[0186] The queue determination module 602 is used to determine the queue corresponding to the task identifier in the virtual scheduling queue and physical scheduling queue of the determined CPU, and store the awakened task in the determined queue. The virtual scheduling queue is used to store the first type of tasks generated by the virtual CPU of the virtual machine, and the physical scheduling queue is used to store tasks other than the first type of tasks.

[0187] The second response module 603 is used to determine the target queue from the virtual scheduling queue and physical scheduling queue of the target CPU in response to the occurrence of an empty queue in the local scheduling queue of each CPU of the physical machine, wherein the target CPU is the CPU corresponding to the detected empty queue.

[0188] The task execution module 604 is used to obtain the task to be executed from the target queue and call the target CPU to execute the task to be executed.

[0189] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, whenever a task is awakened, a CPU is allocated to it, and the task is stored in the virtual scheduling queue or physical scheduling queue of the allocated CPU. When the local scheduling queue of a CPU is empty, a task can be retrieved from the virtual scheduling queue or physical scheduling queue of that CPU, and the CPU can be invoked to execute the task. Since the virtual scheduling queue and physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling for various different types of tasks.

[0190] In one embodiment of this disclosure, the virtual scheduling queue is used to store first-type tasks generated by the virtual CPU of the virtual machine, and the physical scheduling queue is used to store tasks other than the first-type tasks.

[0191] Since the virtual scheduling queue is used to store the first type of tasks generated by the virtual CPU of the virtual machine, the above scheme can realize task scheduling that includes tasks generated by the virtual CPU of the virtual machine.

[0192] In one embodiment of this disclosure, the physical scheduling queue includes a system scheduling queue and other scheduling queues. The system scheduling queue is used to store second-type tasks generated by the CPU's system kernel, and the other scheduling queues are used to store third-type tasks other than the first-type and second-type tasks.

[0193] The queue determination module 602 includes:

[0194] The first determining submodule is used to determine the system scheduling queue of the target CPU as the target queue when there are tasks in the virtual scheduling queue and system scheduling queue of the target CPU and no tasks in other scheduling queues; if the task previously executed by the target CPU belongs to the first type of task, then the virtual scheduling queue of the target CPU is determined as the target queue; if the task previously executed by the target CPU belongs to the second type of task, then the virtual scheduling queue of the target CPU is determined as the target queue.

[0195] The second determining submodule is used to determine the virtual scheduling queue of the target CPU as the target queue when there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU, but no tasks in the system scheduling queue.

[0196] As can be seen from the above, when scheduling tasks using the scheme provided in this disclosure, if tasks exist in the virtual scheduling queue and system scheduling queue of the target CPU but not in other scheduling queues, the first type of tasks and the second type of tasks can be scheduled alternately. If tasks exist in the virtual scheduling queue and other scheduling queues of the target CPU but not in the system scheduling queue, the first type of tasks in the virtual scheduling queue can be scheduled first. This ensures that the first type of tasks have a higher scheduling priority, that is, tasks generated by the virtual CPU can be scheduled first, reducing the computing core jitter caused by other tasks during virtual machine operation. Thus, this scheduling scheme can meet the needs of the full-core sales scenario. It is evident that the scheduling scheme provided in this disclosure is applicable to the full-core sales scenario, thereby broadening the scope of application of task scheduling.

[0197] In one embodiment of this disclosure, when tasks exist in the virtual scheduling queue and system scheduling queue of the target CPU, but no tasks exist in other scheduling queues, the apparatus further includes:

[0198] The third determining submodule is used to determine the virtual scheduling queue of the target CPU as the target queue if the duration of the target CPU processing the second type of task exceeds a first duration threshold within the most recent first preset number of clock cycles.

[0199] Otherwise, the first determination submodule is triggered.

[0200] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, if the time taken for the target CPU to process the second type of task exceeds the first time threshold within the most recent first preset number of clock cycles, the virtual scheduling queue of the target CPU can be directly determined as the target queue. This can further ensure that the first type of task stored in the virtual scheduling queue can be scheduled with priority, thereby making this scheduling scheme more suitable for the all-core sales scenario, meeting the expectations of cloud vendors in this scenario, and improving the user experience.

[0201] In one embodiment of this disclosure, when tasks exist in the virtual scheduling queue and other scheduling queues of the target CPU, but no tasks exist in the system scheduling queue, the apparatus further includes:

[0202] The fourth determining submodule is used to determine other scheduling queues of the target CPU as target queues if the target CPU has not processed any third-type tasks within the most recent second preset number of clock cycles.

[0203] Otherwise, the second determination submodule is triggered.

[0204] As can be seen from the above, when scheduling tasks using the scheme provided in the embodiments of this disclosure, if the target CPU has not processed any third-type tasks within the most recent second preset number of clock cycles, other scheduling queues of the target CPU can be directly identified as the target queue. This can avoid task starvation in other scheduling queues, which would lead to unbalanced task scheduling within the physical machine system and affect the operating performance of the physical machine. Therefore, the task scheduling scheme provided in the embodiments of this disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.

[0205] In one embodiment of this disclosure, the apparatus further includes:

[0206] The first acquisition module is used to interrupt the execution of the current task by the first CPU and acquire the task to be executed from the virtual scheduling queue of the first CPU if a task is detected in the virtual scheduling queue of the first CPU during the execution of the third type of task by the first CPU. The first CPU is any CPU among the CPUs of the physical machine.

[0207] This solution is more suitable for all-core sales scenarios, meeting the expectations of cloud vendors in this scenario and improving the user experience.

[0208] In one embodiment of this disclosure, the maximum number of tasks stored in the local scheduling queue of each CPU is 1.

[0209] This solution ensures the timeliness of the scheduling strategy and avoids situations where it is difficult to prioritize the scheduling of the first type of task when there are multiple tasks in the local scheduling queue. For example, if there are multiple tasks in the local scheduling queue, and the first type of task that needs to be prioritized is obtained through the aforementioned steps one, two, and S104, the first type of task can only be executed after the tasks in the local scheduling queue have been completed. Limiting the local scheduling queue to a maximum of one task can solve this problem, thereby ensuring that the first type of task can be scheduled first. This allows the scheduling solution to meet the needs of the full-core sales scenario and broadens the applicability of task scheduling.

[0210] In one embodiment of this disclosure, the tasks in the virtual scheduling queue are arranged in ascending order of their virtual execution times.

[0211] Virtual execution time is used to measure the execution status of a task on a virtual timeline. The smaller the virtual execution time, the more necessary the task is to be executed. Therefore, the tasks in the virtual scheduling queue are arranged in ascending order of their virtual execution times. This allows for the accurate identification of the most needed tasks to be scheduled and executed during each scheduling process, thereby improving the accuracy of task scheduling.

[0212] In one embodiment of this disclosure, the tasks in the system scheduling queue are arranged in ascending order of their virtual execution times.

[0213] Similar to the virtual scheduling queue, the tasks in the system scheduling queue are arranged in ascending order of their virtual execution time. This allows the system to accurately identify the most needed tasks for scheduling and execution during each scheduling process, thereby improving the accuracy of task scheduling.

[0214] In one embodiment of this disclosure, the tasks in the other scheduling queues are arranged according to the storage time of each task.

[0215] In a full-core sales scenario, the scheduling priority of the first type of task is the highest, followed by the second type, and the scheduling priority of the third type is the lowest. Therefore, for other scheduling queues that store the third type of task, it is only necessary to arrange the tasks in order according to their storage time, without having to calculate the virtual execution time of each task. This can reduce the scheduling workload of the scheduler and improve scheduling efficiency.

[0216] In one embodiment of this disclosure, the apparatus further includes:

[0217] The task determination module is used to determine the task to be executed if the waiting time of each task stored in each scheduling queue of the target CPU reaches a second time threshold.

[0218] This solution can prevent task starvation caused by prolonged inactivity, which leads to unbalanced task scheduling within the physical machine system and affects the physical machine's operating performance. Therefore, applying the task scheduling scheme provided in this disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.

[0219] In one embodiment of this disclosure, the apparatus further includes:

[0220] The task switching module is used to detect whether the current task being executed by any second CPU among the CPUs of the physical machine meets the task switching conditions at the end of each clock cycle. If it does, the time slice of the current task being executed by the second CPU is cleared to zero, and the task is stored back in the scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue.

[0221] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, if the current task being executed by the second CPU meets the task switching conditions, operations such as clearing the time slice and restoring the task are performed, so that the local scheduling queue of the second CPU becomes an empty queue. In this way, the scheduler can reschedule the task being executed by the second CPU, avoiding the task occupying the CPU for a long time and making it difficult to schedule subsequent tasks in a timely manner, thereby improving the accuracy and reliability of task scheduling.

[0222] In one embodiment of this disclosure, the task switching condition is: the actual execution time of the task exceeds the ideal execution time of the task.

[0223] By comparing the ideal execution time of a task with its actual execution time, it is possible to accurately determine whether a task switch is necessary. This ensures that task execution remains within a controllable range, preventing tasks from occupying the CPU for extended periods and making it difficult to schedule subsequent tasks in a timely manner. Consequently, the accuracy and reliability of task scheduling can be improved.

[0224] In one embodiment of this disclosure, the first response module 601 is specifically used for:

[0225] The CPU is searched for in an idle state to execute the wake-up task.

[0226] Identifying the CPU in an idle state as the CPU to execute the woken-up task allows the woken-up task to be executed quickly, thereby improving task execution efficiency and thus enhancing the user experience.

[0227] In one embodiment of this disclosure, the first response module 601 is specifically used for:

[0228] If the awakened task is a subtask type and the third CPU corresponding to the queue storing the parent task of the awakened task is not saturated, then the third CPU is determined to be the CPU that executes the awakened task.

[0229] In this scheme, since parent and child tasks usually share a cache, if the third CPU corresponding to the queue storing the woken-up parent task is not saturated, the third CPU can be preferentially determined as the CPU to execute the woken-up task. This makes it easier for the woken-up task and its parent task to share the same cache, thereby improving cache affinity and thus improving task scheduling performance.

[0230] In one embodiment of this disclosure, the first response module 601 is specifically used for:

[0231] Among the pre-specified CPUs used to execute the woke-up task, the CPU that will execute the woke-up task is determined.

[0232] This solution can accurately identify the CPU that is executing the woken-up task, thereby improving the accuracy of task scheduling.

[0233] In one embodiment of this disclosure, the apparatus further includes:

[0234] The identifier switching module is used to switch the task identifier carried in the awakened task in response to the user's identifier switching command for the awakened task.

[0235] As can be seen from the above, when scheduling tasks using the scheme provided in the embodiments of this disclosure, users can switch the task identifier carried in the awakened task through the identifier switching command. This allows users to flexibly control the task queue according to their own needs, and thus control the task scheduling. Therefore, the task scheduling scheme provided in the embodiments of this disclosure can improve the flexibility of task scheduling.

[0236] In one embodiment of this disclosure, the apparatus further includes:

[0237] The queue switching module is used to move the awakened task to the queue corresponding to the switched task identifier after switching the task identifier if the awakened task has been stored in the CPU's scheduling queue.

[0238] This solution can avoid unpredictable problems caused by the mismatch between the task identifier and the queue in which the task belongs.

[0239] In one embodiment of this disclosure, the task execution module 604 is specifically used for:

[0240] Obtain the time slice of the task to be executed;

[0241] The task to be executed is dispatched to the local scheduling queue of the target CPU;

[0242] The target CPU is invoked to execute the tasks stored in the local scheduling queue according to the acquired time slice.

[0243] As can be seen from the above, when scheduling tasks using the scheme provided in this embodiment, after obtaining the task to be executed, the time slice of the task to be executed is obtained, and the task to be executed is dispatched to the local scheduling queue of the target CPU. The target CPU is then invoked to execute the task to be executed stored in the local scheduling queue according to the obtained time slice. In this way, the time slice can be used to control the time when the CPU executes the task, thereby achieving precise scheduling of tasks. Therefore, the above scheme can improve the accuracy of task scheduling.

[0244] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0245] It should be noted that the head model in this embodiment is not a head model for a specific user and cannot reflect the personal information of a specific user.

[0246] It should be noted that the two-dimensional face images in this embodiment are from a publicly available dataset.

[0247] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0248] Figure 7 A schematic block diagram of an example electronic device 700 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 processors, 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.

[0249] like Figure 7As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 702 or a computer program loaded into random access memory (RAM) 703 from storage unit 708. The RAM 703 may also store various programs and data required for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.

[0250] Multiple components in device 700 are connected to I / O interface 705, including: input unit 706, such as keyboard, mouse, etc.; output unit 707, such as various types of monitors, speakers, etc.; storage unit 708, such as disk, optical disk, etc.; and communication unit 709, such as network card, modem, wireless transceiver, etc. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0251] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 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 701 performs the various methods and processes described above, such as task scheduling methods. For example, in some embodiments, the task scheduling method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the task scheduling method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the task scheduling method by any other suitable means (e.g., by means of firmware).

[0252] 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), complex 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.

[0253] 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.

[0254] 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. A machine-readable medium 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.

[0255] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information 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).

[0256] 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 implementations 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.

[0257] 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.

[0258] 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.

[0259] 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 spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A task scheduling method, comprising: in response to a task being woken up, determining a CPU to execute the woken-up task among CPUs of a physical machine, wherein the woken-up task carries a task identifier indicating a task source; determining a queue corresponding to the task identifier among a virtual scheduling queue and a physical scheduling queue of the determined CPU, and storing the woken-up task in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks, the virtual scheduling queue is used to store a first type of task generated by a virtual CPU of a virtual machine, the physical scheduling queue is used to store a task other than the first type of task, the physical scheduling queue comprises a system scheduling queue and other scheduling queues, the system scheduling queue is used to store a second type of task generated by a system kernel of a CPU, and the other scheduling queues are used to store a third type of task other than the first type of task and the second type of task; in response to an empty queue appearing in a local scheduling queue of each CPU of the physical machine, in a case where there is a task in the virtual scheduling queue and the system scheduling queue of a target CPU and there is no task in the other scheduling queues, if a last task executed on the target CPU belongs to the first type of task, determining the system scheduling queue of the target CPU as a target queue; if the last task executed on the target CPU belongs to the second type of task, determining the virtual scheduling queue of the target CPU as the target queue; in a case where there is a task in the virtual scheduling queue and the other scheduling queues of the target CPU and there is no task in the system scheduling queue, determining the virtual scheduling queue of the target CPU as the target queue, wherein the target CPU is a CPU corresponding to the detected empty queue; obtaining a to-be-executed task from the target queue, and invoking the target CPU to execute the to-be-executed task.

2. The method of claim 1, wherein, in a case where there is a task in the virtual scheduling queue and the system scheduling queue of the target CPU and there is no task in the other scheduling queues, the method further comprises: if a length of time for which the target CPU processes the second type of task exceeds a first time threshold within a latest first preset number of clock cycles, determining the virtual scheduling queue of the target CPU as the target queue; otherwise, performing the step of determining the system scheduling queue of the target CPU as the target queue if the last task executed on the target CPU belongs to the first type of task, or determining the virtual scheduling queue of the target CPU as the target queue if the last task executed on the target CPU belongs to the second type of task.

3. The method of claim 1, wherein, in a case where there is a task in the virtual scheduling queue and the other scheduling queues of the target CPU and there is no task in the system scheduling queue, the method further comprises: if the target CPU does not process the third type of task within a latest second preset number of clock cycles, determining the other scheduling queue of the target CPU as the target queue; otherwise, performing the step of determining the virtual scheduling queue of the target CPU as the target queue.

4. The method of claim 1, wherein, the method further comprises: In a process that the first CPU executes the third type of task, if it is detected that there is a task in the virtual scheduling queue of the first CPU, the first CPU interrupts the execution of the current task and acquires the to-be-executed task from the virtual scheduling queue of the first CPU, wherein the first CPU is any one of the CPUs of the physical machine.

5. The method of claim 1, wherein, The maximum number of tasks stored in the local scheduling queue of each CPU is 1.

6. The method of claim 1, wherein, The tasks in the virtual scheduling queue are arranged in an order from small to large according to the virtual execution time of each task. The tasks in the system scheduling queue are arranged in an order from small to large according to the virtual execution time of each task. The tasks in the other scheduling queue are arranged in an order according to the storage time of each task. The method further comprises: For each task stored in each scheduling queue of the target CPU, if the waiting time of the task reaches a second time threshold, the task is determined to be the to-be-executed task.

7. The method of any one of claims 1-6, wherein, The method further comprises: For any second CPU of the CPUs of the physical machine, every time a clock cycle is reached, it is detected whether the current task executed by the second CPU meets a task switching condition, if yes, the time slice of the current task executed by the second CPU is cleared, and the task is stored in the scheduling queue of the second CPU again, so that the local scheduling queue of the second CPU becomes an empty queue.

8. The method of any one of claims 1-6, wherein, The task switching condition is that the actual execution time of the task exceeds the ideal execution time of the task. The method further comprises:

9. The method of claim 8, wherein, searching for a CPU in an idle state in each CPU to be the CPU for executing the woken-up task; 10. The method of any one of claims 1-6, wherein, or if the woken-up task belongs to a sub-task type and a third CPU corresponding to the queue in which the parent task of the woken-up task is stored is not saturated, the third CPU is determined to be the CPU for executing the woken-up task; or in each CPU designated in advance to execute the woken-up task, the CPU for executing the woken-up task is determined. The method further comprises: in response to a user switching instruction for the identifier of the woken-up task, switching the task identifier carried in the woken-up task.

11. The method of any one of claims 1-6, wherein, The method further comprises: if the woken-up task has been stored in the scheduling queue of the CPU, after the task identifier of the woken-up task is switched, the woken-up task is moved to the queue corresponding to the switched task identifier.

12. The method of claim 11, wherein, The method further comprises: acquiring the time slice of the to-be-executed task; 13. The method of any one of claims 1-6, wherein, dispatching the to-be-executed task to the local scheduling queue of the target CPU; calling the target CPU to execute the to-be-executed task stored in the local scheduling queue according to the acquired time slice.

14. A task scheduling apparatus, comprising: a first response module configured to, in response to a task being woken up, determine a CPU for executing the woken-up task in each CPU of a physical machine, wherein the woken-up task carries a task identifier indicating a task source. ​ ​ The queue determining module is configured to determine a queue corresponding to the task identifier from among the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the woken-up task in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store tasks of different types, the virtual scheduling queue is used to store first-type tasks generated by a virtual CPU of a virtual machine, the physical scheduling queue is used to store tasks other than the first-type tasks, the physical scheduling queue includes a system scheduling queue and other scheduling queues, the system scheduling queue is used to store second-type tasks generated by a system kernel of the CPU, and the other scheduling queues are used to store third-type tasks other than the first-type tasks and the second-type tasks. The second response module includes: a first determining submodule configured to, in response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, and in a case where there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and there are no tasks in the other scheduling queues, determine the system scheduling queue of the target CPU as the target queue if the last executed task of the target CPU belongs to the first type; and determine the virtual scheduling queue of the target CPU as the target queue if the last executed task of the target CPU belongs to the second type; and a second determining submodule configured to, in response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, and in a case where there are tasks in the virtual scheduling queue and the other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, determine the virtual scheduling queue of the target CPU as the target queue, wherein the target CPU is the CPU corresponding to the detected empty queue. The task execution module is configured to acquire a task to be executed from the target queue, and invoke the target CPU to execute the task to be executed.

15. The apparatus of claim 14, wherein, In a case where there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and there are no tasks in the other scheduling queues, the apparatus further includes: The third determining submodule is configured to, if the target CPU processes the second-type tasks for a time period longer than a first time threshold in a latest first preset number of clock periods, determine the virtual scheduling queue of the target CPU as the target queue. Otherwise, the first determining submodule is triggered.

16. The apparatus of claim 14, wherein, In a case where there are tasks in the virtual scheduling queue and the other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the apparatus further includes: The fourth determining submodule is configured to, if the target CPU does not process the third-type tasks in a latest second preset number of clock periods, determine the other scheduling queue of the target CPU as the target queue. Otherwise, the second determining submodule is triggered.

17. The apparatus of claim 14, wherein, The apparatus further includes: The first acquiring module is configured to, in a process in which a first CPU executes a third-type task, if it is detected that there is a task in the virtual scheduling queue of the first CPU, interrupt the first CPU from executing the current task, and acquire a task to be executed from the virtual scheduling queue of the first CPU, wherein the first CPU is any one of the CPUs of the physical machine.

18. The apparatus of claim 14, wherein, The maximum number of tasks stored in the local scheduling queue of each CPU is 1.

19. The apparatus of claim 14, wherein, The tasks in the virtual scheduling queue are arranged in ascending order of virtual execution time of each task; and / or The tasks in the system scheduling queue are arranged in ascending order of virtual execution time of each task; and / or The tasks in the other scheduling queues are arranged in order of storage time of each task.

20. The apparatus of any of claims 14-19, wherein, The apparatus further comprises: The task determination module is configured to, for each task stored in each scheduling queue of the target CPU, determine the task as the to-be-executed task if a waiting duration of the task reaches a second duration threshold.

21. The apparatus of any of claims 14-19, wherein, The apparatus further comprises: The task switching module is configured to, for any second CPU of each CPU of the physical machine, detect whether a current task executed by the second CPU meets a task switching condition every time a clock cycle arrives, and if so, clear a time slice of the current task executed by the second CPU, and re-store the task in a scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue.

22. The apparatus of claim 21, wherein, The task switching condition is that an actual execution time of a task exceeds an ideal execution time of the task.

23. The apparatus of any one of claims 14-19, wherein, The first response module is specifically configured to: search for a CPU in idle state among the CPUs as the CPU for executing the woken-up task; or if the woken-up task belongs to a sub-task type and a third CPU corresponding to a queue in which a parent task of the woken-up task is stored is not saturated, determine the third CPU as the CPU for executing the woken-up task; or among the CPUs designated in advance for executing the woken-up task, determine the CPU for executing the woken-up task.

24. The apparatus of any one of claims 14-19, wherein, The apparatus further comprises: The identification switching module is configured to, in response to a user's identification switching instruction for the woken-up task, switch a task identification carried in the woken-up task.

25. The apparatus of claim 24, wherein, The apparatus further comprises: The queue switching module is configured to, if the woken-up task has been stored in a scheduling queue of a CPU, after switching the task identification of the woken-up task, move the woken-up task to a queue corresponding to the switched task identification.

26. The apparatus of any one of claims 14-19, wherein, The task execution module is specifically configured to: obtain a time slice of the to-be-executed task; dispatch the to-be-executed task to the local scheduling queue of the target CPU; invoke the target CPU to execute the to-be-executed task stored in the local scheduling queue according to the obtained time slice.

27. An electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-13.

28. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to make the computer execute the method according to any one of claims 1-13.

29. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-13.

Citation Information

Patent Citations

  • Task processing method and device

    CN110688229A

  • Task scheduling method and system

    CN113360254A