Task scheduling method and device
By determining the task execution CPU in each CPU of the physical machine and assigning tasks in virtual and physical scheduling queues, the problem of inefficient task scheduling in the prior art is solved, and efficient task execution and system performance improvement is achieved.
Patent Information
- Application Number
- CN202411886916.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-19
AI Technical Summary
The prior art is difficult to effectively schedule various tasks processed by the physical machine CPU, resulting in inefficient task execution.
By determining the CPU that executes the wake-up task in each CPU of the physical machine, and storing tasks in the virtual scheduling queue and the physical scheduling queue, the reasonable allocation and scheduling of tasks are achieved. When the local scheduling queue of a certain CPU is empty, the task is obtained from the virtual scheduling queue or the physical scheduling queue and the CPU is called to execute.
It realizes efficient scheduling of tasks pending with the physical machine CPU, improving task execution efficiency and overall system performance.
Smart Images

Figure CN119829242A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to the field of cloud computing technology, and more particularly to a task scheduling method and device. Background Art
[0002] A virtual machine is a computer system with complete hardware system functions that is simulated by software. Based on the resources of a physical machine, multiple virtual machines can be simulated. Each virtual machine is isolated from each other and does not affect each other. Each virtual machine can provide services to users independently. Since the virtual machine is simulated by software and does not have real hardware resources, the tasks generated by the virtual CPU of the virtual machine still need to rely on the CPU of the physical machine to process.
[0003] In addition to the tasks generated by the virtual CPU of the virtual machine, the CPU of the physical machine also needs to process other tasks. Therefore, it is necessary to provide a task scheduling solution to schedule various tasks to be processed by the CPU of the physical machine. Summary of the invention
[0004] The present disclosure provides a task scheduling method and device.
[0005] In a first aspect, an embodiment of the present disclosure provides a task scheduling method, including:
[0006] In response to a task being awakened, determining a CPU in each CPU of the physical machine that executes the awakened task, wherein the awakened task carries a task identifier indicating a source of the task;
[0007] Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store tasks of different types;
[0008] In response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, determining a target queue from a virtual scheduling queue and a physical scheduling queue of a target CPU, wherein the target CPU is a CPU corresponding to the detected empty queue;
[0009] Obtain the to-be-executed tasks from the target queue, and call the target CPU to execute the to-be-executed tasks.
[0010] In a second aspect, an embodiment of the present disclosure provides a task scheduling device, including:
[0011] A first response module, configured to determine, in response to a task being awakened, a CPU in each CPU of the physical machine that executes the awakened task, wherein the awakened task carries a task identifier indicating a source of the task;
[0012] A queue determination module is used to determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and 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] A second response module is used to determine a target queue from a virtual scheduling queue and a physical scheduling queue of a target CPU in response to an empty queue appearing in a local scheduling queue of each CPU of the physical machine, wherein the target CPU is a CPU corresponding to the detected empty queue;
[0014] The task execution module is used to obtain the tasks to be executed from the target queue and call the target CPU to execute the tasks to be executed.
[0015] In a third aspect, an embodiment of the present disclosure provides 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, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0019] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method described in the first aspect.
[0020] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0021] As can be seen from the above, when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, whenever a task is awakened, a CPU will be assigned to it and stored in the virtual scheduling queue or physical scheduling queue of the assigned CPU. When the local scheduling queue of a CPU is an empty queue, tasks can be obtained from the virtual scheduling queue or physical scheduling queue of the CPU, and the CPU can be called to execute the task. Since the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling of multiple different types of tasks.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0024] Figure 1 A flowchart of a first task scheduling method provided in an embodiment of the present disclosure;
[0025] Figure 2 A flowchart of a second task scheduling method provided in an embodiment of the present disclosure;
[0026] Figure 3 A flowchart of a third task scheduling method provided in an embodiment of the present disclosure;
[0027] Figure 4 A flowchart of a fourth task scheduling method provided in an embodiment of the present disclosure;
[0028] Figure 5 A flowchart of a fifth task scheduling method provided in an embodiment of the present disclosure;
[0029] Figure 6 A schematic diagram of the structure of a first task scheduling device provided in an embodiment of the present disclosure;
[0030] Figure 7 It is a block diagram of an electronic device used to implement the task scheduling method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0032] First, some concepts involved in the embodiments of the present disclosure are introduced.
[0033] 1. SCX (extensible scheduler class)
[0034] SCX, also known as sched_ext, is a scheduling framework in the Linux kernel that allows custom schedulers to be implemented and dynamically loaded in BPF, with strong flexibility and scalability. In addition, SCX also has the ability to quickly experiment and customize scheduling, which can simplify scheduling strategy development and promote 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 without timer ticks and scheduling overhead, allowing other cores to run in unlimited time slices.
[0036] The SCX architecture is divided into 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 the loading of custom schedulers; the third layer is the specific BPF (Berkeley Packet Filter) scheduler, based on which developers can implement their own scheduling logic; the top layer is the BPF scheduler user end that interacts with user controls, which communicates with the kernel scheduler and coordinates task scheduling.
[0037] The four layers in the SCX architecture interact with each other through specific interfaces, and there are some specific details of the interaction between the layers. First, the kernel scheduler provides basic task management functions, and defines the interface for scheduling tasks through struct sched_class, such as enqueue_task, dequeue_task and other functions for the upper layer to call. The SCX framework extends the functions on this basis 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. As the core of the scheduling strategy, the BPF scheduler can manage tasks in the scheduling queue according to different scheduling strategies. Through scx_bpf_dispatch, the BPF scheduler can distribute tasks in the order of FIFO (First Input First Output) or virtual time (vtime). It can also call scx_bpf_consume to take tasks out of the scheduling queue and hand them over to the CPU for execution. In addition, the BPF scheduler is also responsible for selecting the appropriate CPU to execute the task, and scx_bpf_select_cpu_dfl helps it select the optimal CPU according to the default policy. In user space, the scheduler's supporting program can interact with the BPF map and use APIs such as bpf_map_lookup_elem to read and modify data in BPF. This mechanism allows users to flexibly manage scheduling policies, such as optimizing task allocation by adjusting scheduling parameters or reading the status of scheduling queues. The entire process realizes the close collaboration of the scheduler from the kernel to the user space, allowing the scheduler to dynamically adjust according to actual needs, providing powerful flexibility.
[0038] Secondly, the execution subject of the task scheduling solution provided by the embodiment of the present disclosure is explained.
[0039] The executor of the task scheduling solution provided in the embodiment of the present disclosure is a scheduler, which is used to schedule various tasks to be executed by each CPU in the physical machine, wherein the various tasks include tasks generated by the virtual CPU of the virtual machine. The virtual machine is a computer system obtained by software simulation based on the resources of the physical machine.
[0040] The task scheduling method and device provided by the embodiments of the present disclosure are described one by one below.
[0041] See also Figure 1 , Figure 1 The present invention provides a flowchart of a first task scheduling method according to an embodiment of the present invention. In this embodiment, the method includes the following steps S101-S104.
[0042] Step S101: In response to a task being awakened, a CPU that executes the awakened task is determined among the CPUs of the physical machine.
[0043] The awakened task carries a task identifier indicating the source of the task.
[0044] When creating a task, different created objects can add a task identifier representing the source of the task to the task. For example, when the system kernel creates a task, it can add an identifier representing the system kernel to the task. When the virtual CPU (i.e., vCPU) of the virtual machine creates a task, it can add an identifier representing the virtual CPU to the task. Other created objects can also add identifiers representing themselves to the task.
[0045] When adding a task ID to a task, you can add an ID bit to the task in advance and fill in the field in the ID 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 in the task ID bit.
[0046] Specifically, a task may be in an unawakened state due to interruption, execution prohibition, etc. When the physical machine meets the conditions for executing the task in the unawakened state, the task in the unawakened state will be awakened. At this time, the scheduler can respond to the task being awakened and determine the CPU that executes the awakened task among the CPUs of the physical machine.
[0047] The specific implementation method of determining the CPU can be found in the subsequent embodiments and will not be described in detail here.
[0048] Step S102: Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue.
[0049] Among them, the physical machine may have one or more CPU chips, each CPU chip can be considered as a CPU of the physical machine, and each CPU has a virtual scheduling queue and a physical scheduling queue for storing tasks to be executed by the CPU, and the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks.
[0050] In one embodiment of the present disclosure, 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.
[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 solution can implement task scheduling including tasks generated by the virtual CPU of the virtual machine.
[0052] Specifically, after the CPU that executes the awakened task is determined, the awakened task can be stored in the scheduling queue corresponding to the task identifier carried in the awakened task. For example, if the awakened task carries task identifier 10, it means that the awakened task comes from the vCPU, then the virtual scheduling queue of the CPU can be determined as the queue for storing the awakened task, and the awakened task is stored in the determined virtual scheduling queue of the CPU.
[0053] Step S103: in response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, a target queue is determined from the virtual scheduling queue and the physical scheduling queue of the target CPU.
[0054] In addition to the virtual scheduling queue and the physical scheduling queue, each CPU also has a local scheduling queue for storing the tasks to be executed next or being executed.
[0055] The target CPU is the CPU corresponding to the detected empty queue.
[0056] Specifically, for each CPU of the physical machine, the virtual scheduling queue and physical scheduling queue of the CPU store the tasks to be executed by the CPU. After the CPU completes executing the tasks in the local scheduling queue, it can notify the scheduler that its local scheduling queue is an empty queue. The scheduler can determine the target queue from the virtual scheduling queue and physical scheduling queue of the CPU in response to the local scheduling queue of the CPU being an empty queue.
[0057] The specific implementation method of determining the target queue from the virtual scheduling queue and the physical scheduling queue of the CPU can be found in the subsequent embodiments, which will not be described in detail here.
[0058] Step S104: Obtain the to-be-executed tasks from the target queue, and call the target CPU to execute the to-be-executed tasks.
[0059] Specifically, tasks in the virtual scheduling queue or physical scheduling queue of the CPU can be arranged according to preset rules. After determining the target queue, the scheduler can obtain the first task arranged 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 calling can be performed in the manner mentioned in the following embodiments, so that the target CPU executes the task to be executed, or the target CPU can be called to execute the task to be executed using existing calling functions, models, algorithms, etc.
[0061] In one embodiment of the present disclosure, the above preset rules may be arranged in order of virtual execution time from small to large, or may be arranged according to a first-in-first-out principle.
[0062] In the case of arranging in ascending order of virtual execution time, when a task is stored in a certain scheduling queue, the virtual execution time of the task can be calculated according to the actual execution time of the task at this time, the weight of the task and the priority nice value of the task, so as to determine the position of the task according to the virtual execution time of the task and the virtual execution time of the tasks stored in the above-mentioned scheduling queue, thereby realizing the storage of the task, wherein the priority nice value of the task is the value set for the task in advance, the weight of the task is inversely proportional to the virtual execution time of the task, the larger the weight, the smaller the virtual execution time, the earlier the task is executed, and the actual execution time of the task is directly proportional to the virtual execution time, the longer the actual execution time, the larger the virtual execution time, and the later the task is executed.
[0063] When a task is placed in a scheduling queue and arranged according to the first-in-first-out principle, it can be placed directly at the end of the queue.
[0064] In one embodiment of the present application, the tasks in the above virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task.
[0065] The virtual execution time is used to measure the execution status of a task on the virtual timeline. The smaller the virtual execution time, the more the task needs to be executed. Therefore, the tasks in the virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task. In each scheduling, the tasks that need to be scheduled and executed the most can be accurately obtained, thereby improving the accuracy of task scheduling.
[0066] As can be seen from the above, when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, whenever a task is awakened, a CPU will be assigned to it and stored in the virtual scheduling queue or physical scheduling queue of the assigned CPU. When the local scheduling queue of a CPU is an empty queue, tasks can be obtained from the virtual scheduling queue or physical scheduling queue of the CPU, and the CPU can be called to execute the task. Since the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling of multiple different types of tasks.
[0067] In one embodiment of the present disclosure, when calling the target CPU to execute the task to be executed in the above step S104, 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, and the target CPU is called to execute the task to be executed stored in the local scheduling queue according to the obtained time slice.
[0068] The time slice is the execution time of the task. For example, if the time slice is 10 ms, it means that the task can be executed for 10 ms when the CPU executes the task.
[0069] Specifically, when obtaining the time slice of the task to be executed, the time slice of the task to be executed may be determined according to 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, according to 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 as the time slice of the task to be executed.
[0071] When dispatching the task to be executed to the local dispatch queue of the target CPU, the task to be executed may be dispatched to the local dispatch queue of the target CPU through a dispatch function.
[0072] For example, the task to be executed can be dispatched to the local dispatch queue of the target CPU through the ops.dispatch function.
[0073] After obtaining the time slice of the task to be executed, the time slice can be written into the task to be executed. In this way, when the task to be executed is dispatched to the local scheduling queue of the target CPU, the target CPU can directly obtain the task to be executed from the local scheduling queue and parse the time slice from the task, so as to execute the task to be executed according to the time slice.
[0074] Alternatively, a time slice is sent to the target CPU, so that the target CPU can obtain the task to be executed from the local scheduling queue on the one hand, and receive the time slice on the other hand, so that the target CPU can execute the task to be executed according to the received time slice.
[0075] When the duration of the target CPU executing the task to be executed reaches the duration represented by the time slice, if the task to be executed has not been completed, the task to be executed can be re-considered as a woken-up task and return to step S101 to wait for the next round of scheduling until the task to be executed is completed.
[0076] It can be seen from the above that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, 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, thereby calling the target CPU 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 realizing accurate scheduling of the task. Therefore, through the above scheme, the accuracy of task scheduling can be improved.
[0077] In one embodiment of the present disclosure, the task identifier carried in the task may also be processed in the manner mentioned in the following embodiments.
[0078] In one embodiment of the present disclosure, in response to a user's instruction to switch an identifier of the awakened task, the task identifier carried in the awakened task is switched.
[0079] Specifically, the user may issue the flag switching instruction before the awakened task is stored in the scheduling queue, or may issue the flag switching instruction after the awakened task is stored in the scheduling queue.
[0080] When the user issues an identifier switching instruction before the awakened task is stored in the scheduling queue, the scheduler may switch the task identifier carried in the awakened task in response to the instruction.
[0081] During the switching, if the identification switching instruction indicates the identification of the task after the task is switched, the task identification carried in the task may be switched to the identification indicated by the identification switching instruction.
[0082] If the identification switching instruction does not indicate the identification of the task after switching, the task identification carried by the task can be switched to its next identification according to the sequence of the identifications set in advance.
[0083] For example, if there are three identifiers, the order is identifier 1, identifier 2 and identifier 3 respectively, if the task carries identifier 2, then during the switching, identifier 2 can be switched to identifier 3.
[0084] When the user issues an identity switching instruction after the awakened task is stored in the scheduling queue, the scheduler can not only switch the task identity carried by the awakened task, but also move the awakened task to the queue corresponding to the switched task identity after switching the task identity of the awakened task. In this way, the task identity and the queue where the task is located correspond to each other, avoiding unexpected problems caused by the mismatch between the task identity and the queue where the task is located.
[0085] From the above, it can be seen that when applying the scheme provided by the embodiment of the present disclosure to schedule tasks, the user can switch the task identifier carried in the awakened task through the identifier switching instruction. This enables the user to flexibly control the queue where the task is located according to their own needs, and then control the scheduling of the task. Therefore, applying the task scheduling scheme provided by the embodiment of the present disclosure can improve the flexibility of task scheduling.
[0086] The following describes four implementation methods of determining the CPU mentioned in step S101.
[0087] In a first implementation manner, a CPU in an idle state may be searched among the CPUs to be used as the CPU for executing the awakened task.
[0088] Specifically, each CPU can maintain its own status. For example, when the CPU is executing a task, the CPU status can be a busy status. When the CPU is online and not executing a task, the CPU status can be an idle status. When the CPU is offline, the CPU status can be an offline status. When the CPU fails, the CPU status can be a faulty status. In this way, when a task is awakened, the CPU in an idle state can be searched according to the status of each CPU, and the CPU is determined to be the CPU that executes the awakened task. Since the CPU is in an idle state, it means that the CPU is not currently executing a task. Therefore, determining that the CPU is the CPU that executes the awakened task can enable the awakened task to be executed quickly, thereby improving the execution efficiency of the task and further improving the user experience.
[0089] In the second implementation, 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, the third CPU is determined as the CPU that executes the awakened task.
[0090] Specifically, each CPU has a load limit when executing tasks. If the tasks assigned to the CPU exceed the load limit, the CPU may fail due to overload. Therefore, when the tasks assigned to the CPU reach the load limit, it can be considered that the CPU is saturated and no more tasks can be assigned to the CPU; when the tasks assigned to the CPU do not reach the load limit, it can be considered that the CPU is not saturated. In this case, tasks can continue to be assigned to the CPU.
[0091] In view of this, when determining the CPU that executes the awakened task, if the awakened task is a subtask type, the parent task of the awakened task can be determined, and the CPU corresponding to the queue storing the parent task can be determined, which is the third CPU, and it is determined whether the task assigned to the third CPU has reached the load limit of the third CPU. If not, it can be determined that the third CPU is not saturated. At this time, the third CPU can be determined to be the CPU that executes the awakened task. If the task assigned to the third CPU reaches the load limit of the third CPU, it can be determined that the third CPU is saturated. At this time, it is necessary to determine the CPU that executes the awakened task from other CPUs.
[0092] In this implementation, since the parent task and the child task usually share the cache, when the third CPU corresponding to the queue storing the awakened parent task is not saturated, the third CPU can be preferentially determined as the CPU that executes the awakened task. This makes it easier for the awakened task and its parent task to share the same cache, thereby improving the affinity of the cache and further improving the task scheduling performance.
[0093] In a third implementation manner, a CPU that executes the awakened task is determined among the CPUs pre-designated to execute the awakened task.
[0094] Specifically, when some tasks are created, the CPUs that are allowed to execute the task can be specified. In this case, when the task is awakened, the CPUs specified by the task can be obtained, and a CPU that executes the awakened task can be determined from them. In this way, the CPU that executes the awakened task can be accurately determined, thereby improving the accuracy of task scheduling.
[0095] In a fourth implementation manner, if a CPU is not determined according to any of the first three implementation manners, a CPU that has previously executed the awakened task may be determined as the CPU that executes the awakened task this time.
[0096] In the full-core sales scenario, cloud vendors hope to give all the core computing power of the physical machine to the virtual machine to ensure the service quality of the virtual machine, avoid jitter in the virtual machine, and thus improve the user experience of using the virtual machine. In this scenario, it is necessary to require the scheduler to prioritize the tasks generated by the virtual CPU.
[0097] In the above scenario, an embodiment of the present disclosure provides another task scheduling method. In this embodiment, the above-mentioned physical scheduling queue includes a system scheduling queue and other scheduling queues. The system scheduling queue is used to store the second category of tasks generated by the system kernel of the CPU, and the other scheduling queues are used to store the third category of tasks except the first category of tasks and the second category of tasks.
[0098] When determining the target queue in the above step S103, the determination may be performed according to the following steps 1 and 2.
[0099] Step 1: When there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and no tasks in other scheduling queues, if the task last executed by the target CPU belongs to the first category of tasks, then the system scheduling queue of the target CPU is determined as the target queue; if the task last executed by the target CPU belongs to the second category of tasks, then the virtual scheduling queue of the target CPU is determined as the target queue.
[0100] Specifically, when determining the target queue, it is possible to respectively detect whether there are tasks in the virtual scheduling queue, system scheduling queue and other scheduling queues of the target CPU. When it is detected that there are tasks in the virtual scheduling queue and the system scheduling queue, but no tasks in other scheduling queues, it is possible to determine the type of task last executed by the target CPU. If the last executed task belongs to the first type of task, the system scheduling queue of the target CPU is determined as the target queue, so that task execution can be obtained from the system scheduling queue subsequently; if the last executed task belongs to the second type of task, the virtual scheduling queue of the target CPU is determined as the target queue, so that task execution can be obtained from the virtual scheduling queue subsequently.
[0101] It can be seen that in this case, the scheduler can alternately schedule tasks in the virtual scheduling queue and the system scheduling queue, so that the target CPU alternately executes the first type of tasks and the second type of tasks. In addition, when obtaining the time slice of the task to be executed in the subsequent step S104, if the task to be executed belongs to the second type of task, the time slice of the task to be executed can be limited, or if the task to be executed belongs to the first type of task, the time slice of the task to be executed can be increased, so that the first type of task can be executed as soon as possible, thereby improving the operating performance of the virtual machine, and then improving the service quality of the virtual machine.
[0102] In addition, in this case, if the task last executed by the target CPU belongs to the third category of tasks, 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 preferentially.
[0103] Step 2: When there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the virtual scheduling queue of the target CPU is determined as the target queue.
[0104] When it is detected that there are tasks in the virtual scheduling queue of the target CPU and other scheduling queues, but no tasks in the system scheduling queue, the virtual scheduling queue of the target CPU can be determined as the target queue, so that tasks in the virtual scheduling queue can be scheduled preferentially.
[0105] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and no tasks in other scheduling queues, the first category of tasks and the second category of tasks can be scheduled alternately. When there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and no tasks in the system scheduling queue, the first category of tasks in the virtual scheduling queue can be scheduled preferentially. This can ensure that the first category of tasks have a higher scheduling priority, that is, the tasks generated by the virtual CPU can be scheduled preferentially, reducing the computing core jitter caused by other tasks when the virtual machine is running, so that the scheduling scheme can meet the needs of the full-core selling scenario. It can be seen that the scheduling scheme provided by the embodiment of the present disclosure is suitable for the full-core selling scenario, thereby broadening the scope of application of task scheduling.
[0106] In one embodiment of the present disclosure, the task scheduling solution provided in the above embodiment can be implemented based on the SCX framework.
[0107] The SCX framework provides the ability to customize scheduling queues and task scaling strategies. Based on this capability of the SCX framework, users can customize three types of DSQ (Distributed Scheduled Queue) for each CPU of the physical machine, namely the virtual scheduling queue, system scheduling queue and other scheduling queues mentioned in the aforementioned embodiments, and define that the tasks in the virtual scheduling queue and the system scheduling queue are arranged in ascending order of virtual execution time, and the tasks in other scheduling queues are arranged according to the first-in-first-out principle.
[0108] See also Figure 2 , provides a flow chart of the second task scheduling method. Figure 2 In the figure, 11 is the task identifier of the first type of task, 01 is the task identifier of the second type of task, and 00 is the task identifier of the third type of task.
[0109] exist Figure 2In the process shown, when a task is awakened and the CPU to execute the task is determined, the ops.enqueue function is used to determine the scheduling queue where the task is to be stored. In this function, the tag field (task identifier) in the task structure task_struct is used to determine which type of task it belongs to and put it into the DSQ of the corresponding category, and calculate the time slice size of its scheduled execution. Subsequently, when the local scheduling queue local DSQ of the CPU determined above is empty, the scheduler can use the ops.dispatch function in balance_one to consume task scheduling entities from the above three types of DSQ, that is, to obtain tasks and task time slices in the three custom DSQs, and dispatch the obtained tasks to the local scheduling queue of the CPU, so that the CPU runs the tasks in the local scheduling queue.
[0110] Compared with other scheduling solutions, the scheduling solution implemented based on the SCX framework also has the characteristics of SCX, that is, it can realize hot-swappable replacement and iterative update without replacing the kernel, and online operation and maintenance and fault handling are more efficient and convenient.
[0111] On the basis of the above embodiment, the scheduler may further limit the maximum number of tasks stored in the local scheduling queue of each CPU to 1. That is, at most only one task can be stored in the local scheduling queue of each CPU.
[0112] In this way, each time a task to be executed is obtained through the aforementioned step one or step two, and the aforementioned step S104, the task to be executed is dispatched to the local scheduling queue of the target CPU, and the target CPU can immediately execute the task to be executed, thereby ensuring the scheduling timeliness of the scheduling strategy composed of the aforementioned step one, step two and the aforementioned step S104, that is, the tasks executed by the target CPU can be accurately controlled through the aforementioned step one, step two and the aforementioned step S104, avoiding the situation where it is difficult to prioritize the first type of tasks 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 tasks are obtained through the aforementioned step one, step two and the aforementioned step S104 and need to be prioritized, it is necessary to wait for the tasks in the local scheduling queue to be completed before the acquired first type of tasks can be executed. Limiting the local scheduling queue to store a maximum of one task can solve this problem, thereby ensuring that the first type of tasks can be prioritized, and thus enabling the scheduling scheme to meet the needs of the full-core sales scenario and broaden the scope of application of task scheduling.
[0113] In one embodiment of the present disclosure, the tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task.
[0114] Similar to the virtual scheduling queue, the tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task. It can also accurately obtain the tasks that need to be scheduled and executed most in each scheduling, thereby improving the accuracy of task scheduling.
[0115] In another embodiment of the present disclosure, the tasks in the other scheduling queues are arranged according to the storage time of each task.
[0116] In the full-core sales scenario, the first type of task has the highest scheduling priority, the second type of task has the second highest scheduling priority, and the third type of task has the lowest scheduling priority. Therefore, for other scheduling queues storing the third type of tasks, it is only necessary to arrange the tasks in sequence according to the storage time of each task, without calculating the virtual execution time of each task. This can reduce the amount of scheduling tasks of the scheduler and improve scheduling efficiency.
[0117] In the 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 other scheduling queues, the target queue may also be determined by the method mentioned in the following embodiments.
[0118] In one embodiment of the present disclosure, see Figure 3 , a flow chart of a third task scheduling method is provided. In this embodiment, the method includes the following steps S301-S306.
[0119] Step S301: In response to a task being awakened, a CPU that executes the awakened task is determined among the CPUs of the physical machine.
[0120] Step S302: Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue.
[0121] The above steps S301 and S302 are respectively the same as the above steps S101 and S102, 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, determine whether the duration of the target CPU processing the second type of task exceeds the first duration threshold within the most recent first preset number of clock cycles. If so, execute step S304; if not, execute step S305.
[0123] The first situation mentioned above is a situation where there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU, but there are no tasks in other scheduling queues.
[0124] The first preset number mentioned above is a pre-set number.
[0125] The 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 in the most recent first preset number of clock cycles can be counted. If the duration exceeds the first duration threshold, it means that the execution duration of the second type of task in the recent period is relatively long, affecting the priority scheduling of the first type of task. Therefore, in the case where the above-stated 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 subsequently select the first type of task in the virtual scheduling queue as the task to be executed, thereby limiting 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 means that the execution duration of the second type of task in the recent period is relatively short, and does not affect the priority scheduling of the first type of task, or the impact on the priority scheduling of the first type of task is relatively small. At this time, 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 last executed by the target CPU belongs to the first category of tasks, the system scheduling queue of the target CPU is determined as the target queue; if the task last executed by the target CPU belongs to the second category of tasks, the virtual scheduling queue of the target CPU is determined as the target queue.
[0129] The description of this step can be found in the above-mentioned embodiment and will not be repeated here.
[0130] Step S306: Obtain the to-be-executed tasks from the target queue, and call the target CPU to execute the to-be-executed tasks.
[0131] This step is the same as the above step S104 and will not be repeated here.
[0132] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when the duration of the target CPU processing the second type of tasks within the most recent first preset number of clock cycles exceeds the first duration threshold, the virtual scheduling queue of the target CPU can be directly determined as the target queue, which can further ensure that the first type of tasks stored in the virtual scheduling queue can be scheduled first, thereby making this scheduling scheme more suitable for the full-core sales scenario, meeting the expectations of cloud manufacturers in this scenario, and improving the user experience.
[0133] In the case where there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the target queue may also be determined by the method mentioned in the following embodiments.
[0134] In one embodiment of the present disclosure, see Figure 4 , a flow chart of a fourth task scheduling method is provided. In this embodiment, the method includes the following steps S401-S406.
[0135] Step S401: In response to a task being awakened, a CPU that executes the awakened task is determined among the CPUs of the physical machine.
[0136] Step S402: Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue.
[0137] The above steps S401 and S402 are respectively the same as the above steps S101 and S102, 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, determine whether the target CPU has processed the third type of task within the last second preset number of clock cycles. If not, execute step S404; if yes, execute step S405.
[0139] The second situation mentioned above is a situation where there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU, but there are no tasks in the system scheduling queue.
[0140] The second preset number is a pre-set number, and the second preset number may be the same as or different from the first preset number.
[0141] Specifically, each time in response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, when there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and no tasks in the system scheduling queue, it can be detected whether the target CPU has processed the third type of tasks within the last second preset number of clock cycles. If not, step S404 is executed to directly determine the other scheduling queues of the target CPU as the target queue. This can avoid the tasks in other scheduling queues from being unscheduled for a long time, thereby causing task starvation.
[0142] If the target CPU has processed the third type of tasks within the last second preset number of clock cycles, step S405 may be executed to determine the virtual scheduling queue of the target CPU as the target queue to ensure that the first type of tasks in the virtual scheduling queue are scheduled preferentially.
[0143] Step S404: Determine other scheduling queues of the target CPU as target queues.
[0144] Step S405: Determine the virtual scheduling queue of the target CPU as the target queue.
[0145] Step S406: Obtain the to-be-executed tasks from the target queue, and call the target CPU to execute the to-be-executed tasks.
[0146] This step is the same as the above step S104 and will not be repeated here.
[0147] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, if the target CPU has not processed the third type of tasks within the last second preset number of clock cycles, the other scheduling queues of the target CPU can be directly determined as the target queue. This can avoid starvation of tasks in other scheduling queues, resulting in unbalanced task scheduling within the physical machine system and affecting the operating performance of the physical machine. Therefore, the task scheduling scheme provided by the embodiment of the present disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.
[0148] During the task scheduling process, the tasks to be executed may also be obtained by executing the method provided in the following embodiments.
[0149] In one embodiment of the present disclosure, during the process of the first CPU executing 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 is interrupted from executing the current task, and the 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 of 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, and there are tasks in other scheduling queues, it can obtain a task from the other scheduling queues, which belongs to the third category of tasks, and dispatch the third category of tasks to the local scheduling queue of the first CPU, so that the first CPU executes the third category of tasks.
[0152] During the process of the first CPU executing the third category of tasks, if a first category task is awakened and the scheduler stores the first category task in the virtual scheduling queue of the first CPU, the scheduler can detect the existence of tasks in the virtual scheduling queue of the first CPU. At this time, the first CPU can interrupt the execution of the current task and obtain the task to be executed from the virtual scheduling queue of the first CPU, so that the first CPU subsequently processes the first category of tasks, thereby achieving the purpose of giving priority to the tasks generated by the virtual CPU. This can make this scheduling solution more suitable for the full-core sales scenario, meet the expectations of cloud manufacturers in this scenario, and improve the user experience.
[0153] When the task scheduling solution provided by the embodiment of the present disclosure is implemented based on the SCX framework, when the task is stored in the virtual scheduling queue or in other scheduling queues, the scx_bpf_dispatch function or the scx_bpf_dispatch_vtime function can be used to store the task.
[0154] In addition to the above-mentioned method for determining the tasks to be executed, the tasks to be executed may also be determined by the method provided in the following embodiments.
[0155] In one embodiment of the present disclosure, see Figure 5 , a flow chart of a fifth task scheduling method is provided. In this embodiment, the method includes the following steps S501-S506.
[0156] Step S501: In response to a task being awakened, a CPU that executes the awakened task is determined among the CPUs of the physical machine.
[0157] Step S502: Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue.
[0158] Step S503: in response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, a target queue is determined from the virtual scheduling queue and the physical scheduling queue of the target CPU.
[0159] The above steps S501-S503 are respectively the same as the above steps S101-S103, and will not be repeated here.
[0160] Step S504: Obtain 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, the task is determined to be a task to be executed.
[0162] Step S506: calling the target CPU to execute the task to be executed.
[0163] For the description of steps S504 and S506, reference may be made to the description of step S104, which will not be repeated here.
[0164] The above step S505 is described below.
[0165] The second duration threshold is a preset duration.
[0166] Specifically, after the scheduler stores the task in a scheduling queue of the CPU, it can time the task. When the timing reaches the second time threshold and the task is still not executed, the task can be directly determined as a pending task. This can avoid the phenomenon of task starvation caused by the task not being executed for a long time, which makes the task scheduling inside the physical machine system unbalanced and affects the operating performance of the physical machine. Therefore, the task scheduling scheme provided by the embodiment of the present disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.
[0167] During the task scheduling process, the solutions provided in the following embodiments may also be executed.
[0168] In one embodiment of the present disclosure, for any second CPU among 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 the task switching condition. If so, the time slice of the current task executed by the second CPU is cleared, and the task is stored again in the scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue.
[0169] A clock may be provided in the physical machine, and the above detection may be performed once every clock cycle. For example, the above clock cycle may be 10 ms, so the above detection is performed once every 10 ms.
[0170] The above task switching conditions are pre-defined conditions and are used to switch the task currently being processed by the CPU.
[0171] Specifically, when each clock cycle is reached, it can be detected whether the current task executed by each second CPU meets the task switching condition. If so, the time slice of the current task executed by the second CPU can be cleared, and the task can be stored again 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 local scheduling queue of the second CPU becoming an empty queue, and again determine the target queue from the scheduling queues of the second CPU, 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, thereby realizing task switching.
[0172] When the task scheduling scheme provided by the embodiment of the present disclosure is implemented based on the SCX framework, the resched_curr function can be used to perform a rescheduling operation, that is, to perform the above-mentioned time slice clearing and re-storing of tasks. In addition, when the second CPU is called to execute the to-be-executed tasks stored in the local scheduling queue according to the acquired time slice, the pick_next_task function can be used to obtain the tasks from the local scheduling queue and hand them over to the CPU for execution.
[0173] If the current task executed by the second CPU does not meet the task switching condition, the task processing is not performed, and the second CPU continues 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 detect whether the current task of each second CPU needs to be preempted, that is, to detect whether the current task executed by each second CPU meets the task switching conditions. If the task switching conditions are met, the above-mentioned preemption operations such as clearing the time slice and re-storing the task are performed.
[0175] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when it is detected that the current task executed by the second CPU meets the task switching conditions, operations such as time slice clearing and task re-storage 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 executed by the second CPU to avoid the task occupying the CPU for a long time, resulting in difficulty in timely scheduling of subsequent tasks, thereby improving the accuracy and reliability of task scheduling.
[0176] In one embodiment of the present 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 case, every time a clock cycle is reached, for each second CPU, the scheduler can calculate the ideal execution time of the task based on the task information of the current task executed by the second CPU, and count the actual execution time of the task to determine whether the actual execution time of the task exceeds the ideal execution time. If it exceeds, it means that the task meets the task switching conditions. At this time, continue to execute the subsequent time slice clearing operation; if it does not exceed, it means that the task does not meet the task switching conditions. At this time, no operation is performed.
[0178] When the task scheduling solution provided in the embodiment of the present disclosure is implemented based on the SCX framework, the above-mentioned ideal execution time can use the sched_slice function to calculate the ideal execution time of the task.
[0179] In this way, by comparing the ideal execution time and the actual execution time of the task, it is possible to accurately determine whether to switch tasks, thereby ensuring that the execution of the task is within a controllable range, avoiding the task occupying the CPU for a long time, making it difficult to schedule subsequent tasks in a timely manner, and thus improving the accuracy and reliability of task scheduling.
[0180] In one embodiment of the present disclosure, when the task scheduling scheme provided in the aforementioned embodiment 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 the embodiment of the present disclosure can be achieved by relying on the load balancing mechanism of SCX itself. Compared with CFS achieving load balancing by periodically tick balancing to pull tasks, this scheme uses a custom DSQ as a cache, and obtains tasks to the CPU in the custom DSQ, which is simpler and more efficient.
[0181] Specifically, the scheduler can use the balance_scx function under the SCX framework to optimize system performance by effectively scheduling CPU tasks. This strategy first attempts to balance the run queue (rq) of the current CPU, that is, by calling the balance_one function to process tasks in the local scheduling queue. If the system has SMT (Simulate MultiThreading) turned on, the balance_scx function will further balance the logical CPUs (SMT brother CPUs) that share the same physical core, traverse the rq of these brother CPUs, and update their run queue clocks through the update_rq_clock function, and then call balance_one to try to balance the load of these queues.
[0182] When balance_one enters the scheduling loop, it will first call the BPF hook function dispatch to execute the custom scheduling policy and refresh the scheduling rq buffer. If there are tasks in the local queue, the system will return directly and run the tasks; if there are consumable tasks in the global queue, it will also return directly. In this process, the balance_one function uses a loop counter nr_loops to prevent the system from falling into an infinite loop. If the counter is reduced to 0, the system will arrange a delayed schedule to avoid continuously scheduling unqualified tasks, thereby ensuring that the system's watchdog can work normally and prevent the system from being unresponsive for a long time.
[0183] Corresponding to the aforementioned task scheduling method, the embodiment of the present disclosure also provides a task scheduling device.
[0184] In one embodiment of the present disclosure, see Figure 6, a structural schematic diagram of a task scheduling device is provided, the device comprising:
[0185] A first response module 601 is used for determining, in response to a task being awakened, a CPU in each CPU of the physical machine that executes the awakened task, wherein the awakened task carries a task identifier indicating a 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 the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue, wherein 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] A second response module 603 is used to determine a target queue from a virtual scheduling queue and a physical scheduling queue of a target CPU in response to an empty queue appearing in a local scheduling queue of each CPU of the physical machine, wherein the target CPU is a CPU corresponding to the detected empty queue;
[0188] The task execution module 604 is used to obtain the to-be-executed tasks from the target queue and call the target CPU to execute the to-be-executed tasks.
[0189] As can be seen from the above, when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, whenever a task is awakened, a CPU will be assigned to it and stored in the virtual scheduling queue or physical scheduling queue of the assigned CPU. When the local scheduling queue of a CPU is an empty queue, tasks can be obtained from the virtual scheduling queue or physical scheduling queue of the CPU, and the CPU can be called to execute the task. Since the virtual scheduling queue and the physical scheduling queue are used to store different types of tasks, the above scheme can realize task scheduling of multiple different types of tasks.
[0190] In one embodiment of the present disclosure, 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.
[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 solution can implement task scheduling including tasks generated by the virtual CPU of the virtual machine.
[0192] In one embodiment of the present disclosure, the physical scheduling queue includes a system scheduling queue and other scheduling queues, the system scheduling queue is used to store the second type of tasks generated by the system kernel of the CPU, and the other scheduling queue is used to store the third type of tasks except the first type of tasks and the second type of tasks;
[0193] The queue determination module 602 includes:
[0194] A first determination submodule is used for, when there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and there are no tasks in other scheduling queues, if the task last executed by the target CPU belongs to the first category of tasks, determining the system scheduling queue of the target CPU as the target queue; if the task last executed by the target CPU belongs to the second category of tasks, determining the virtual scheduling queue of the target CPU 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 of the target CPU and other scheduling queues and there are no tasks in the system scheduling queue.
[0196] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and no tasks in other scheduling queues, the first category of tasks and the second category of tasks can be scheduled alternately. When there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and no tasks in the system scheduling queue, the first category of tasks in the virtual scheduling queue can be scheduled preferentially. This can ensure that the first category of tasks have a higher scheduling priority, that is, the tasks generated by the virtual CPU can be scheduled preferentially, reducing the computing core jitter caused by other tasks when the virtual machine is running, so that the scheduling scheme can meet the needs of the full-core selling scenario. It can be seen that the scheduling scheme provided by the embodiment of the present disclosure is suitable for the full-core selling scenario, thereby broadening the scope of application of task scheduling.
[0197] In one embodiment of the present disclosure, when there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU, and there are no tasks in other scheduling queues, the device further includes:
[0198] A third determination submodule is used to determine that the virtual scheduling queue of the target CPU is the target queue if the duration of the target CPU processing the second type of task exceeds a first duration threshold within the latest first preset number of clock cycles;
[0199] Otherwise, the first determining submodule is triggered.
[0200] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when the duration of the target CPU processing the second type of tasks within the most recent first preset number of clock cycles exceeds the first duration threshold, the virtual scheduling queue of the target CPU can be directly determined as the target queue, which can further ensure that the first type of tasks stored in the virtual scheduling queue can be scheduled first, thereby making this scheduling scheme more suitable for the full-core sales scenario, meeting the expectations of cloud manufacturers in this scenario, and improving the user experience.
[0201] In one embodiment of the present disclosure, when there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the device further includes:
[0202] a fourth determination submodule, configured to determine other scheduling queues of the target CPU as target queues if the target CPU has not processed any third-category tasks within the latest second preset number of clock cycles;
[0203] Otherwise, the second determining submodule is triggered.
[0204] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, if the target CPU has not processed the third type of tasks within the last second preset number of clock cycles, the other scheduling queues of the target CPU can be directly determined as the target queue. This can avoid starvation of tasks in other scheduling queues, resulting in unbalanced task scheduling within the physical machine system and affecting the operating performance of the physical machine. Therefore, the task scheduling scheme provided by the embodiment of the present disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.
[0205] In one embodiment of the present disclosure, the device further includes:
[0206] The first acquisition module is used to interrupt the first CPU from executing the current task and acquire the task to be executed from the virtual scheduling queue of the first CPU if it is detected that there is a task in the virtual scheduling queue of the first CPU during the process of the first CPU executing the third category of tasks, wherein the first CPU is any one of the CPUs of the physical machine.
[0207] This solution is more suitable for the full-core sales scenario, meeting the expectations of cloud manufacturers in this scenario and improving the user experience.
[0208] In one embodiment of the present disclosure, the maximum number of tasks stored in the local scheduling queue of each CPU is 1.
[0209] This solution ensures the scheduling timeliness of the scheduling strategy and avoids the situation where it is difficult to prioritize the first-category tasks 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-category tasks are obtained through the aforementioned steps one, two and S104 and need to be prioritized, it is necessary to wait for the tasks in the local scheduling queue to be completed before the acquired first-category tasks can be executed. Limiting the local scheduling queue to store a maximum of one task can solve this problem, thereby ensuring that the first-category tasks can be prioritized, and thus enabling this scheduling solution to meet the needs of full-core sales scenarios and broaden the scope of application of task scheduling.
[0210] In one embodiment of the present disclosure, the tasks in the virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task.
[0211] The virtual execution time is used to measure the execution status of a task on the virtual timeline. The smaller the virtual execution time, the more the task needs to be executed. Therefore, the tasks in the virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task. In each scheduling, the tasks that need to be scheduled and executed the most can be accurately obtained, thereby improving the accuracy of task scheduling.
[0212] In one embodiment of the present disclosure, the tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task.
[0213] Similar to the virtual scheduling queue, the tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task. It can also accurately obtain the tasks that need to be scheduled and executed most in each scheduling, thereby improving the accuracy of task scheduling.
[0214] In one embodiment of the present disclosure, the tasks in the other scheduling queues are arranged according to the storage time of each task.
[0215] In the full-core sales scenario, the first type of task has the highest scheduling priority, the second type of task has the second highest scheduling priority, and the third type of task has the lowest scheduling priority. Therefore, for other scheduling queues storing the third type of tasks, it is only necessary to arrange the tasks in sequence according to the storage time of each task, without calculating the virtual execution time of each task. This can reduce the amount of scheduling tasks of the scheduler and improve scheduling efficiency.
[0216] In one embodiment of the present disclosure, the device further includes:
[0217] The task determination module is used to determine, for each task stored in each scheduling queue of the target CPU, if the waiting time of the task reaches a second time threshold, that the task is the task to be executed.
[0218] This solution can avoid the phenomenon of task starvation caused by long-term non-execution of tasks, which makes the task scheduling inside the physical machine system unbalanced and affects the operating performance of the physical machine. Therefore, the task scheduling solution provided by the embodiment of the present disclosure can ensure the normal operation of the physical machine and improve the reliability of task scheduling.
[0219] In one embodiment of the present disclosure, the device further includes:
[0220] The task switching module is used to detect whether the current task executed by any second CPU among the CPUs of the physical machine meets the task switching condition every time a clock cycle is reached. If so, 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.
[0221] From the above, it can be seen that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, when it is detected that the current task executed by the second CPU meets the task switching conditions, operations such as time slice clearing and task re-storage 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 executed by the second CPU to avoid the task occupying the CPU for a long time, resulting in difficulty in timely scheduling of subsequent tasks, thereby improving the accuracy and reliability of task scheduling.
[0222] In one embodiment of the present disclosure, the task switching condition is: the actual execution time of the task exceeds the ideal execution time of the task.
[0223] In this way, by comparing the ideal execution time and the actual execution time of the task, it is possible to accurately determine whether to switch tasks, thereby ensuring that the execution of the task is within a controllable range, avoiding the task occupying the CPU for a long time, making it difficult to schedule subsequent tasks in a timely manner, and thus improving the accuracy and reliability of task scheduling.
[0224] In one embodiment of the present disclosure, the first response module 601 is specifically configured to:
[0225] A CPU in an idle state is searched among the CPUs to be used as a CPU to execute the awakened task.
[0226] Determining a CPU in an idle state as a CPU for executing a task to be awakened can enable the awakened task to be executed quickly, thereby improving the execution efficiency of the task and further improving the user experience.
[0227] In one embodiment of the present disclosure, the first response module 601 is specifically configured to:
[0228] If the awakened task belongs to a subtask type and the third CPU corresponding to the queue storing the parent task of the awakened task is not saturated, the third CPU is determined to be the CPU executing the awakened task.
[0229] In this scheme, since the parent task and the child task usually share the cache, when the third CPU corresponding to the queue storing the awakened parent task is not saturated, the third CPU can be preferentially determined as the CPU that executes the awakened task. This makes it easier for the awakened task and its parent task to share the same cache, thereby improving the affinity of the cache and further improving the task scheduling performance.
[0230] In one embodiment of the present disclosure, the first response module 601 is specifically configured to:
[0231] Among the CPUs pre-specified for executing the awakened task, a CPU that executes the awakened task is determined.
[0232] This solution can accurately determine the CPU that executes the awakened task, thereby improving the accuracy of task scheduling.
[0233] In one embodiment of the present disclosure, the device further includes:
[0234] The identification switching module is used to switch the task identification carried in the awakened task in response to the identification switching instruction of the user for the awakened task.
[0235] From the above, it can be seen that when applying the scheme provided by the embodiment of the present disclosure to schedule tasks, the user can switch the task identifier carried in the awakened task through the identifier switching instruction. This enables the user to flexibly control the queue where the task is located according to their own needs, and then control the scheduling of the task. Therefore, applying the task scheduling scheme provided by the embodiment of the present disclosure can improve the flexibility of task scheduling.
[0236] In one embodiment of the present disclosure, the device 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 of the awakened task if the awakened task has been stored in the scheduling queue of the CPU.
[0238] This solution can avoid unexpected problems caused by the mismatch between the task identifier and the queue where the task is located.
[0239] In one embodiment of the present disclosure, the task execution module 604 is specifically used to:
[0240] Obtaining the time slice of the task to be executed;
[0241] Dispatching the task to be executed to the local scheduling queue of the target CPU;
[0242] The target CPU is called to execute the tasks to be executed stored in the local scheduling queue according to the acquired time slice.
[0243] It can be seen from the above that when the scheme provided by the embodiment of the present disclosure is applied to schedule tasks, 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, thereby calling the target CPU 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 realizing accurate scheduling of the task. Therefore, through the above scheme, the accuracy of task scheduling can be improved.
[0244] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance 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 come from a public data set.
[0247] According to an embodiment of the present disclosure, the present 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 an embodiment 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 can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0249] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0250] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0251] The computing unit 701 may be a variety of general and / or special 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 dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the task scheduling method. For example, in some embodiments, the task scheduling method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the 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 in any other appropriate manner (e.g., by means of firmware).
[0252] Various implementations 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 chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0253] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0254] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, 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 (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the 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 acoustic input, voice input, or tactile input).
[0256] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0257] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0258] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0259] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A task scheduling method, comprising: In response to the task being awakened, determining a CPU in each CPU of the physical machine that executes the awakened task, wherein the awakened task carries a task identifier indicating a source of the task; Determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and store the awakened task in the determined queue, wherein the virtual scheduling queue and the physical scheduling queue are used to store tasks of different types; In response to an empty queue appearing in the local scheduling queue of each CPU of the physical machine, determining a target queue from a virtual scheduling queue and a physical scheduling queue of a target CPU, wherein the target CPU is a CPU corresponding to the detected empty queue; Obtain the to-be-executed tasks from the target queue, and call the target CPU to execute the to-be-executed tasks.
2. The method according to claim 1, wherein: 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.
3. The method according to claim 2, wherein: The physical scheduling queue includes a system scheduling queue and other scheduling queues, the system scheduling queue is used to store the second type of tasks generated by the system kernel of the CPU, and the other scheduling queue is used to store the third type of tasks except the first type of tasks and the second type of tasks; Determining the target queue from the virtual scheduling queue and the physical scheduling queue of the target CPU includes: In the 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 other scheduling queues, if the task last executed by the target CPU belongs to the first category of tasks, then the system scheduling queue of the target CPU is determined as the target queue; if the task last executed by the target CPU belongs to the second category of tasks, then the virtual scheduling queue of the target CPU is determined as the target queue; When there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the virtual scheduling queue of the target CPU is determined as the target queue.
4. The method according to claim 3, wherein: In the 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 other scheduling queues, the method further includes: 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, determining the virtual scheduling queue of the target CPU as the target queue; Otherwise, the step of determining the system scheduling queue of the target CPU as the target queue if the task last executed by the target CPU belongs to the first category of tasks; and determining the virtual scheduling queue of the target CPU as the target queue if the task last executed by the target CPU belongs to the second category of tasks is performed.
5. The method according to claim 3, wherein: In the case where there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU and there are no tasks in the system scheduling queue, the method further includes: If the target CPU has not processed any third-category task within the latest second preset number of clock cycles, determining another scheduling queue of the target CPU as the target queue; Otherwise, the step of determining the virtual scheduling queue of the target CPU as the target queue is executed.
6. The method according to claim 3, wherein: The method further comprises: During the process of the first CPU executing the third type of task, if it is detected that there is a task in the virtual scheduling queue of the first CPU, the execution of the current task by the first CPU is interrupted, and the task to be executed is obtained from the virtual scheduling queue of the first CPU, wherein the first CPU is any CPU among the CPUs of the physical machine.
7. The method according to claim 3, wherein: The maximum number of tasks stored in the local scheduling queue of each CPU is 1.
8. The method according to claim 3, wherein: The tasks in the virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task; and / or The tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task; and / or The tasks in the other scheduling queues are arranged according to the storage time of each task.
9. The method according to any one of claims 1 to 8, wherein: 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 task to be executed.
10. The method according to any one of claims 1 to 8, wherein: The method further comprises: For any second CPU among 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 the task switching condition. If so, the time slice of the current task executed by the second CPU is cleared and the task is stored again in the scheduling queue of the second CPU, so that the local scheduling queue of the second CPU becomes an empty queue.
11. The method according to claim 10, wherein: The task switching condition is: the actual execution time of the task exceeds the ideal execution time of the task.
12. The method according to any one of claims 1 to 8, wherein: The step of determining a CPU that executes the awakened task among the CPUs of the physical machine includes: Searching for a CPU in an idle state among the CPUs as a CPU to execute the awakened task; or If the awakened task belongs to a subtask type and the third CPU corresponding to the queue storing the parent task of the awakened task is not saturated, determining the third CPU as the CPU executing the awakened task; or Among the CPUs pre-specified for executing the awakened task, a CPU that executes the awakened task is determined.
13. The method according to any one of claims 1 to 8, wherein: The method further comprises: In response to a user's identifier switching instruction for the awakened task, the task identifier carried in the awakened task is switched.
14. The method according to claim 13, wherein: The method further comprises: If the awakened task has been stored in the scheduling queue of the CPU, after the task identifier of the awakened task is switched, the awakened task is moved to the queue corresponding to the switched task identifier.
15. The method according to any one of claims 1 to 8, wherein: The calling the target CPU to execute the task to be executed includes: Obtaining the time slice of the task to be executed; Dispatching the task to be executed to the local scheduling queue of the target CPU; The target CPU is called to execute the tasks to be executed stored in the local scheduling queue according to the acquired time slice.
16. A task scheduling device, comprising: A first response module, configured to determine, in response to a task being awakened, a CPU in each CPU of the physical machine that executes the awakened task, wherein the awakened task carries a task identifier indicating a source of the task; A queue determination module is used to determine the queue corresponding to the task identifier in the virtual scheduling queue and the physical scheduling queue of the determined CPU, and 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; A second response module is used to determine a target queue from a virtual scheduling queue and a physical scheduling queue of a target CPU in response to an empty queue appearing in a local scheduling queue of each CPU of the physical machine, wherein the target CPU is a CPU corresponding to the detected empty queue; The task execution module is used to obtain the tasks to be executed from the target queue and call the target CPU to execute the tasks to be executed.
17. The device according to claim 16, wherein: 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.
18. The device according to claim 17, wherein: The physical scheduling queue includes a system scheduling queue and other scheduling queues, the system scheduling queue is used to store the second type of tasks generated by the system kernel of the CPU, and the other scheduling queue is used to store the third type of tasks except the first type of tasks and the second type of tasks; The queue determination module comprises: A first determination submodule is used for, when there are tasks in the virtual scheduling queue and the system scheduling queue of the target CPU and there are no tasks in other scheduling queues, if the task last executed by the target CPU belongs to the first category of tasks, determining the system scheduling queue of the target CPU as the target queue; if the task last executed by the target CPU belongs to the second category of tasks, determining the virtual scheduling queue of the target CPU as the target queue; 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 of the target CPU and other scheduling queues and there are no tasks in the system scheduling queue.
19. The device according to claim 18, wherein: In the 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 other scheduling queues, the device further includes: A third determination submodule is used to determine that the virtual scheduling queue of the target CPU is the target queue if the duration of the target CPU processing the second type of task exceeds a first duration threshold within the latest first preset number of clock cycles; Otherwise, the first determining submodule is triggered.
20. The device according to claim 18, wherein In the case where there are tasks in the virtual scheduling queue and other scheduling queues of the target CPU, and there are no tasks in the system scheduling queue, the device further includes: a fourth determination submodule, configured to determine other scheduling queues of the target CPU as target queues if the target CPU has not processed any third-category tasks within the latest second preset number of clock cycles; Otherwise, the second determining submodule is triggered.
21. The device according to claim 18, wherein The device also includes: The first acquisition module is used to interrupt the first CPU from executing the current task and acquire the task to be executed from the virtual scheduling queue of the first CPU if it is detected that there is a task in the virtual scheduling queue of the first CPU during the process of the first CPU executing the third category of tasks, wherein the first CPU is any one of the CPUs of the physical machine.
22. The device according to claim 18, wherein The maximum number of tasks stored in the local scheduling queue of each CPU is 1.
23. The device according to claim 18, wherein The tasks in the virtual scheduling queue are arranged in ascending order according to the virtual execution time of each task; and / or The tasks in the system scheduling queue are arranged in ascending order according to the virtual execution time of each task; and / or The tasks in the other scheduling queues are arranged according to the storage time of each task.
24. The device according to any one of claims 16 to 23, wherein: The device also includes: The task determination module is used to determine, for each task stored in each scheduling queue of the target CPU, if the waiting time of the task reaches a second time threshold, that the task is the task to be executed.
25. The device according to any one of claims 16 to 23, wherein: The device also includes: The task switching module is used to detect whether the current task executed by any second CPU among the CPUs of the physical machine meets the task switching condition every time a clock cycle is reached. If so, 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.
26. The device according to claim 25, wherein The task switching condition is: the actual execution time of the task exceeds the ideal execution time of the task.
27. The device according to any one of claims 16 to 23, wherein: The first response module is specifically used to: Searching for a CPU in an idle state among the CPUs as a CPU to execute the awakened task; or If the awakened task belongs to a subtask type and the third CPU corresponding to the queue storing the parent task of the awakened task is not saturated, determining the third CPU as the CPU executing the awakened task; or Among the CPUs pre-specified for executing the awakened task, a CPU that executes the awakened task is determined.
28. The device according to any one of claims 16 to 23, wherein: The device also includes: The identification switching module is used to switch the task identification carried in the awakened task in response to the identification switching instruction of the user for the awakened task.
29. The device according to claim 28, wherein The device also includes: 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 of the awakened task if the awakened task has been stored in the scheduling queue of the CPU.
30. The device according to any one of claims 16 to 23, wherein: The task execution module is specifically used for: Obtaining the time slice of the task to be executed; Dispatching the task to be executed to the local scheduling queue of the target CPU; The target CPU is called to execute the tasks to be executed stored in the local scheduling queue according to the acquired time slice.
31. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 15.
32. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-15.
33. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Task processing method and device
CN110688229A
Task scheduling method and system
CN113360254A
Task list allocation method and device, electronic equipment, medium and program product
CN113449994A
Task scheduling method and device, equipment and storage medium
CN113961348A
Task processing method and device, equipment and storage medium
CN114020429A
Cited By
Implementation method and device of programmable I / O scheduler, medium and product
CN120066619A
Implementation Method, Device, Medium and Product of a Programmable I / O Scheduler
CN120066619B
Task execution method, system and device, storage medium and program product
CN120295798A
Task scheduling method and device of processor and storage medium
CN121029372A