Scheduling method and system, computing device and computer-readable storage medium

By maintaining the kernel virtual runtime of the scheduling entity and updating the kernel virtual runtime using the virtual runtime reference value, the problem of poor fairness of the existing scheduling algorithm is solved, and the priority of fair maintenance of the scheduling entity in the running queues of multiple logical processors is realized.

WO2025039777A1PCT designated stage expired Publication Date: 2025-02-27ALIBABA CLOUD COMPUTING CO LTD

Patent Information

Application Number
PCT/CN2024/104323
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-08-21
Filing Date
2024-07-08
Publication Date
2025-02-27

AI Technical Summary

Technical Problem

The existing scheduling algorithms are poor in finding scheduling entities with more CPU usage rights, resulting in unfairness in the scheduler maintaining the priority of the scheduling entity.

Method used

By maintaining the kernel virtual runtime of the scheduled entity and updating the kernel virtual runtime using the virtual runtime reference value corresponding to the group scheduled entity, ensuring that the virtual runtime reference value is determined based on the minimum kernel virtual runtime value of multiple logical processors, thereby fairly maintaining the priority of the scheduled entity.

Benefits of technology

It realizes the priority of fairly maintaining the scheduling entity in the running queues of multiple logical processors, avoids unfairness caused by the running queues of a single logical processor, and improves the fairness of the scheduling mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024104323_27022025_PF_FP_ABST
    Figure CN2024104323_27022025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present description are a scheduling method and system, a computing device and a computer-readable storage medium. The scheduling method comprises: using a virtual runtime reference value corresponding to a group scheduling entity where any scheduling entity is located to update kernel virtual runtime corresponding to said any scheduling entity; searching a run queue of a first logical processor for a first ancestor of a first scheduling entity, and searching a run queue of a second logical processor for a second ancestor of a second scheduling entity, a search condition comprising: the scheduling levels of the first ancestor and the second ancestor being the same; and comparing the kernel virtual runtime corresponding to the first ancestor with the kernel virtual runtime corresponding to the second ancestor, so as to determine the priorities of the first scheduling entity and the second scheduling entity.
Need to check novelty before this filing date? Find Prior Art

Description

Scheduling method, system, computing device, and computer-readable storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on August 21, 2023, with application number 202311063145.1 and application name “Scheduling Method, System, Computing Device and Computer-readable Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of this specification relate to the field of computer technology, and in particular to a scheduling method. Background Art

[0003] The scheduler, the core of the operating system, can be thought of as a resident program. It continuously scans the run queue and uses scheduling algorithms (such as round-robin, priority scheduling, and multi-level feedback queue scheduling) to identify a scheduling entity with greater CPU usage rights than the current one. It then reclaims the processor and allows the new scheduling entity to occupy it.

[0004] The current scheduling algorithm has poor fairness when searching for a scheduling entity with more CPU usage rights. Therefore, the scheduler urgently needs a scheduling method with better scheduling fairness.

[0005] Summary of the Invention

[0006] In view of this, embodiments of this specification provide a scheduling method. One or more embodiments of this specification also relate to a scheduling system, a computing device, a computer-readable storage medium, and a computer program to address technical deficiencies in the prior art.

[0007] According to a first aspect of an embodiment of this specification, a scheduling method is provided, comprising: updating a kernel virtual runtime corresponding to any scheduling entity by using a virtual runtime reference value corresponding to a group scheduling entity to which any scheduling entity belongs, wherein the virtual runtime reference value is determined based on a minimum value of kernel virtual runtimes of multiple scheduling entities corresponding to a scheduling node corresponding to the group scheduling entity in a run queue of multiple logical processors, wherein the multiple logical processors belong to the same physical processor; for a first scheduling entity of a first logical processor and a second scheduling entity of a second logical processor, searching for a first ancestor of the first scheduling entity in the run queue of the first logical processor and searching for a second ancestor of the second scheduling entity in the run queue of the second logical processor according to a preset search condition, wherein the search condition comprises: the first ancestor and the second ancestor have the same scheduling level, and the first logical processor and the second logical processor are any two logical processors among the multiple logical processors; determining the priority of the first scheduling entity and the second scheduling entity by comparing the kernel virtual runtime corresponding to the first ancestor with the kernel virtual runtime corresponding to the second ancestor.

[0008] According to a second aspect of an embodiment of this specification, a scheduling system is provided, comprising: a scheduler and a physical processor, wherein the physical processor comprises a plurality of logical processors; the scheduler is configured to determine a first scheduling entity and a second scheduling entity to be scheduled, apply a scheduling method as described in any embodiment of this specification to determine the priorities of the first scheduling entity and the second scheduling entity, and allocate the running time of the physical processor to the first scheduling entity and the second scheduling entity according to the priorities.

[0009] According to the third aspect of the embodiments of this specification, a computing device is provided, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the above-mentioned scheduling method.

[0010] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned scheduling method are implemented.

[0011] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned scheduling method.

[0012] One embodiment of the present specification provides a scheduling method. Since the method additionally maintains the kernel virtual runtime corresponding to the scheduling entity, the kernel virtual runtime can be understood as a parameter for evaluating the position of the scheduling entity in the entire run queue of the physical processor. The kernel virtual runtime corresponding to any scheduling entity is updated by using the virtual runtime reference value corresponding to the group scheduling entity to which any scheduling entity belongs. The virtual runtime reference value is determined based on the minimum value of the kernel virtual runtime of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the run queue of multiple logical processors. The multiple logical processors belong to the same physical processor. Therefore, any scheduling entity The kernel virtual runtime corresponding to the entity can be updated accordingly as the virtual runtime is updated. Moreover, the virtual runtime baseline value used as a penalty or compensation during the update is a baseline value obtained by taking the minimum kernel virtual runtime of each scheduling entity across multiple logical processors of the entire physical processor. This baseline value can continuously maintain the priority gap between each scheduling entity on the entire physical processor, so that the updated kernel virtual runtime can, with the help of this baseline value, continuously and fairly maintain the priority that the scheduling entity should have in the run queue of the entire physical processor, thereby avoiding the unfair phenomenon caused by the run queue of a single logical processor determining the minimum virtual runtime based solely on its own scheduling entity. Furthermore, for the first scheduling entity and the second scheduling entity to be scheduled, the first ancestor of the first scheduling entity can be searched in the running queue of the first logical processor, and the second ancestor of the second scheduling entity can be searched in the running queue of the second logical processor according to the preset search conditions. Since the search condition is that the scheduling node corresponding to the first ancestor and the scheduling node corresponding to the second ancestor are at the same scheduling level, the kernel virtual running time corresponding to the first ancestor and the kernel virtual running time corresponding to the second ancestor can be compared. Based on the fairer kernel virtual running time, the priority of the first scheduling entity and the second scheduling entity can be determined more fairly, thereby achieving the purpose of improving the fairness of the scheduling mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] FIG1 is a schematic diagram of a run queue provided by one embodiment of this specification;

[0014] FIG2 is a schematic diagram of an application scenario of a scheduling method provided by an embodiment of this specification;

[0015] FIG3 is a flowchart of a scheduling method provided by one embodiment of this specification;

[0016] FIG4 is a schematic structural diagram of a scheduling device provided by an embodiment of this specification;

[0017] FIG5 is a schematic diagram of the structure of a scheduling system provided by one embodiment of this specification;

[0018] FIG6 is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION

[0019] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0020] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0021] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0022] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0023] First, the terms involved in one or more embodiments of this specification are explained.

[0024] Scheduling entity (SE for short), in order to better schedule tasks, the scheduler abstracts a layer of structure called scheduling entity. The unit of running queue management of the logical processor is the scheduling entity. A scheduling entity can include a task or a task group. A task group includes multiple tasks and / or task groups. A task can be a process or a thread. The scheduling entity corresponding to the task group can be called a group scheduling entity, and the scheduling entity corresponding to a task can be called a task scheduling entity. Therefore, the scheduling entity includes: group scheduling entity and / or task scheduling entity. The group scheduling entity describes a group and is used to manage all scheduling entities within the group.

[0025] The run queue (RQ) is a tree-like data structure maintained by the scheduler. Each logical processor corresponds to a run queue in this tree-like data structure (as shown in Figure 1). Below the root node of this tree-like data structure are group scheduling entities (such as Group A and Group B, as shown in Figure 1) and task scheduling entities (such as Task T1 and Task T2, as shown in Figure 1). As shown in Figure 1, group scheduling entities correspond to non-leaf scheduling nodes in the tree-like data structure, while task scheduling entities correspond to leaf scheduling nodes. A group scheduling entity leads a subqueue, which contains the scheduling entities of the group scheduling entity. As shown in Figure 1, the root node can be considered a group scheduling entity leading the entire run queue, including the scheduling entities Task T1, Task T2, and Group A. The subqueue led by Group A contains all the scheduling entities of Group A, such as Task T3, Task T4, and Group B. The subqueue led by Group B contains all the scheduling entities of Group B, such as Task T5 and Task T6. In the Completely Fair Scheduler, both run queues and subqueues are referred to as "cfs_rq." A group scheduling entity manages all the scheduling entities within the group and is responsible for scheduling details for the entire group, including time slice calculation and job flow control. The scheduler places all tasks to be run on a logical processor on the run queue corresponding to that logical processor. Each active task will only be in one run queue at a time. Because the scheduler supports multiple scheduling algorithms, queues for various scheduling algorithms can be embedded in subqueues of the entire run queue.

[0026] Virtual run time (vruntime) is calculated by combining the actual run time of a scheduled entity with its weight. In the scheduler, a larger weight indicates a higher need for the scheduled entity to run. A larger weight reduces its virtual run time, increasing its chances of being scheduled.

[0027] The kernel virtual runtime can be understood as a parameter used to determine the priority gap between scheduling entities within the entire run queue of a physical processor. The initial value of the kernel virtual runtime can be determined based on the initial value of the virtual runtime. When the virtual runtime is updated, the kernel virtual runtime is updated accordingly. In some cases, the kernel virtual runtime is updated based on the baseline virtual runtime value of the group scheduling entity, while in other cases, it is updated based on the baseline virtual runtime value of the group scheduling entity and the change in virtual runtime.

[0028] Minimum virtual run time (min vruntime) refers to the minimum value of the virtual run time of all scheduling entities in a cfs_rq.

[0029] Simultaneous multithreading (SMT / HT) is a hardware multithreading technology that can execute instructions from multiple threads within one clock cycle of a physical processor.

[0030] The Completely Fair Scheduler (CFS) calculates the virtual runtime, also known as vruntime, for each scheduling entity in the run queue. If a scheduling entity is executed, its vruntime will continue to increase over time, while the vruntime of the scheduling entity that is not executed will remain unchanged. Therefore, the scheduler selects the scheduling entity with the smallest vruntime to execute during scheduling to achieve fairness. For different scheduling entities, the vruntime of the scheduling entity with a high priority increases slowly so that it can get more runtime. Currently, CFS always selects the scheduling entity with the smallest vruntime value to execute in order to achieve the goal of "complete fairness". Specifically, CFS maintains a min_vruntime snapshot for each cfs_rq, and determines the priority between scheduling entities by comparing the difference between the vruntime of the scheduling entity and the min_vruntime snapshot of the cfs_rq. However, since min_vruntime is only the minimum virtual runtime of this queue, determining the priority of a scheduling entity based on the difference between the scheduling entity's vruntime and the min_vruntime snapshot of cfs_rq cannot fairly evaluate the priority gap between the highest priority tasks of each logical processor.

[0031] In view of this, in order to address the problems existing in the above-mentioned scheduling mechanism, this specification provides a scheduling method. Since this scheduling method additionally maintains the kernel virtual runtime corresponding to the scheduling entity, the kernel virtual runtime is compensated or penalized based on the virtual runtime benchmark value of the corresponding group scheduling entity, and the virtual runtime benchmark value is determined based on the minimum kernel virtual runtime of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the running queues of multiple logical processors. Therefore, the benchmark value can continuously maintain the priority gap between each scheduling entity on the entire physical processor, so that the updated kernel virtual runtime can continue to fairly maintain the priority that the scheduling entity should have in the running queue of the entire physical processor with the help of the benchmark value, effectively avoiding the problem that the running queue of a single logical processor in the above-mentioned scheduling mechanism determines the minimum virtual runtime based on its own scheduling entity, and cannot fairly maintain the priority gap between tasks of each logical processor.

[0032] Specifically, in this specification, a scheduling method is provided. This specification also involves a scheduling device, a scheduling system, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

[0033] Refer to Figure 2, which shows a schematic diagram of an application scenario of a scheduling method provided according to an embodiment of this specification. As shown in Figure 2, the scheduling method can be applied to the scheduler 200 of the operating system of any computing node. The physical processor of the computing node may include multiple logical processors, such as logical processor 1 and logical processor 2 as shown in Figure 2. The scheduler 200, which can be understood as the core of the operating system, is a program resident in the memory. It determines the priority of the scheduling entity according to the scheduling method provided in the embodiment of this specification, so that tasks with higher priority occupy the physical processor. In Figure 2, the group scheduling entity is represented as "group se" and the task scheduling entity is represented as "task se".

[0034] Specifically, the objects managed by the scheduler 200 are the scheduling entities in the run queue. The run queue can be expressed as a tree data structure. As shown in Figure 2, logical processor 1 corresponds to the run queue 210 of the tree data structure, and logical processor 2 corresponds to the run queue 220 of the tree data structure. The scheduler 200 uses the virtual run time reference value corresponding to the group scheduling entity to which any scheduling entity belongs to update the kernel virtual run time corresponding to any scheduling entity. For example, when the virtual run time of the scheduling entity 2102 is updated, the kernel virtual run time of the scheduling entity 2102 is updated using the virtual run time reference value corresponding to the group scheduling entity 2104 to which it belongs. Among them, the virtual run time reference value corresponding to the group scheduling entity 2104 is determined by comparing the kernel virtual run time of all scheduling entities in the queue 2106 in logical processor 1 and the queue 2108 in logical processor 2. Therefore, the scheduler 200 can search for the first ancestor of the first scheduling entity and the second scheduling entity to be scheduled in the running queue of the first logical processor and the second ancestor of the second scheduling entity in the running queue of the second logical processor according to the preset search condition. Since the search condition is that the scheduling node corresponding to the first ancestor and the scheduling node corresponding to the second ancestor are at the same scheduling level, the kernel virtual running time corresponding to the first ancestor and the kernel virtual running time corresponding to the second ancestor can be compared. Based on the fairer kernel virtual running time, the priority of the first scheduling entity and the second scheduling entity can be determined more fairly, thereby achieving the purpose of improving the fairness of the scheduling mechanism.

[0035] The computing nodes can be physical servers or cloud servers in the cloud that provide various services. For example, they can be servers that provide communication services, data processing services, computing services, storage services, database services, and other services to multiple clients. It should be noted that computing nodes in the cloud can be implemented as distributed server clusters consisting of multiple servers or as single servers. Servers can also be servers in distributed systems or servers integrated with blockchain. Servers can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), big data and artificial intelligence platforms, or intelligent cloud computing servers or intelligent cloud hosts with artificial intelligence technology.

[0036] It is understood that the above application scenarios are only used to illustrate the methods provided in the embodiments of this specification and do not constitute a limitation on the methods provided in the embodiments of this specification. The methods provided in the embodiments of this specification can schedule processor resources of various computing devices.

[0037] Referring to FIG3 , FIG3 shows a flowchart of a scheduling method provided according to an embodiment of the present specification, which specifically includes the following steps.

[0038] Step 302: Use the virtual runtime benchmark value corresponding to the group scheduling entity to which any scheduling entity belongs to update the kernel virtual runtime corresponding to the any scheduling entity, wherein the virtual runtime benchmark value is determined based on the minimum value of the kernel virtual runtime of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the running queues of multiple logical processors, and the multiple logical processors belong to the same physical processor.

[0039] For example, the kernel virtual runtime can be updated when the virtual runtime of the scheduling entity is updated. The virtual runtime is a runtime calculated by the actual runtime of the scheduling entity and the weight of the scheduling entity.

[0040] The kernel virtual runtime can be understood as a parameter used to maintain the position of a scheduling entity within the entire run queue of a physical processor. The initial value of the kernel virtual runtime can be determined based on the initial value of the virtual runtime. When the virtual runtime is updated, the kernel virtual runtime is updated accordingly. In some cases, the kernel virtual runtime is updated based on the virtual runtime baseline value corresponding to the group scheduling entity, or in other cases, based on the virtual runtime baseline value corresponding to the group scheduling entity and the change in virtual runtime. For example, the kernel virtual runtime can be updated simultaneously with the virtual runtime of the scheduling entity. The increment of the kernel virtual runtime of the scheduling entity is determined based on the increment of its virtual runtime. For example, the kernel virtual runtime can be increased directly based on the increment of the virtual runtime, and the virtual runtime baseline can be used to impose penalties or compensation based on actual circumstances. Specifically, when a scheduling event occurs, a function that calculates time differences can be used to update the virtual runtime of the currently running scheduling entity and the kernel virtual runtime. The function that calculates time differences can calculate the increment of virtual runtime based on actual runtime and weight.

[0041] The virtual runtime benchmark value is the minimum granularity used to penalize or compensate the kernel virtual runtime of a scheduling entity. In the method provided in the embodiments of this specification, since the virtual runtime benchmark value is determined based on the minimum value of the kernel virtual runtime of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the run queues of multiple logical processors, the virtual runtime benchmark value is used as the minimum granularity to penalize or compensate the kernel virtual runtime of the scheduling entity, which can continuously maintain the priority gap between the various scheduling entities on the entire physical processor, so that the updated kernel virtual runtime can, with the help of this benchmark value, continuously and fairly maintain the priority that the scheduling entity should have in the run queue of the entire physical processor.

[0042] It should be noted that the run queues of multiple logical processors of the same physical processor have the same tree data structure, that is, for any group of scheduling entities in the run queue of a logical processor, the group of scheduling entities corresponds to a scheduling node leading a subqueue in this run queue, and the same position in the run queues of other logical processors of the same physical processor is also a scheduling node leading a subqueue. Therefore, the scheduling node corresponding to the group scheduling entity can find the scheduling entities corresponding to the scheduling nodes at the same position in the run queues of multiple logical processors. These scheduling entities are all the scheduling entities corresponding to the scheduling nodes corresponding to the group scheduling entity in the run queues of multiple logical processors. For example, the scheduling node corresponding to the group scheduling entity 2104 shown in Figure 2, in the run queues of logical processor 1 and logical processor 2, includes the scheduling entities in queue 2106 and the scheduling entities in queue 2108.

[0043] Step 304: For the first scheduling entity of the first logical processor and the second scheduling entity of the second logical processor, according to preset search conditions, search for the first ancestor of the first scheduling entity in the run queue of the first logical processor, and search for the second ancestor of the second scheduling entity in the run queue of the second logical processor, wherein the search conditions include: the first ancestor and the second ancestor have the same scheduling level, and the first logical processor and the second logical processor are any two logical processors among the multiple logical processors.

[0044] It is understandable that in the running queue of the tree data structure, starting from the node where the scheduling entity is located and tracing back to the root node according to the parent-child relationship, the scheduling entity corresponding to any node can be regarded as the ancestor of the scheduling entity.

[0045] For example, to compare the priorities of scheduling entity 2102 in logical processor 1 and scheduling entity 2110 in logical processor 2 shown in Figure 2, since the scheduling level of the ancestor of scheduling entity 2102, namely group scheduling entity 2104, is 1, and the scheduling level of the ancestor of scheduling entity 2110, namely group scheduling entity 2112, is 1, the ancestors found according to the preset search conditions include group scheduling entity 2104 and group scheduling entity 2112.

[0046] Step 306: Determine the priorities of the first scheduling entity and the second scheduling entity by comparing the kernel virtual runtime corresponding to the first ancestor and the kernel virtual runtime corresponding to the second ancestor.

[0047] 2 , the kernel virtual runtimes of group scheduling entity 2104 and group scheduling entity 2112 can be compared to determine the priority between scheduling entity 2102 and scheduling entity 2110. Specifically, the smaller the kernel virtual runtime, the higher the priority of the scheduling entity.

[0048] It can be seen that since the kernel virtual runtime corresponding to any scheduling entity in this scheduling method, the virtual runtime benchmark value used as penalty or compensation when updated is a benchmark value obtained by taking the minimum kernel virtual runtime of each scheduling entity under the same scheduling node of multiple logical processors across the entire physical processor, this benchmark value can continuously maintain the priority gap between each scheduling entity at the same scheduling level on the entire physical processor, so that the updated kernel virtual runtime can, with the help of this benchmark value, continuously and fairly maintain the priority that the scheduling entity should have in the running queue of the entire physical processor, thereby avoiding the unfair phenomenon caused by the running queue of a single logical processor determining the minimum virtual runtime based solely on its own scheduling entity. Furthermore, for the first scheduling entity and the second scheduling entity to be scheduled, the first ancestor of the first scheduling entity can be searched in the running queue of the first logical processor, and the second ancestor of the second scheduling entity can be searched in the running queue of the second logical processor according to the preset search conditions. Since the search condition is that the scheduling node corresponding to the first ancestor and the scheduling node corresponding to the second ancestor are at the same scheduling level, the kernel virtual running time corresponding to the first ancestor and the kernel virtual running time corresponding to the second ancestor can be compared, so that the priorities of the first scheduling entity and the second scheduling entity can be determined more fairly based on the fairer kernel virtual running time, thereby achieving the purpose of improving the fairness of the scheduling mechanism.

[0049] In order to more efficiently record and search the kernel virtual runtime of the scheduling entity and improve scheduling efficiency, in one or more embodiments of this specification, the method further includes:

[0050] Selecting a target logical processor from the plurality of logical processors;

[0051] Recording the kernel virtual runtime corresponding to any one of the scheduling entities in the node information of the corresponding scheduling node in the run queue of the target logical processor;

[0052] Setting a pointer to a corresponding scheduling node in a run queue of the target logical processor for any group of scheduling entities;

[0053] When any ancestor is found, the kernel virtual runtime corresponding to any ancestor is obtained according to the pointer set by any ancestor.

[0054] Taking the computing cluster application scenario as an example, the entire set of logical processors in the computing cluster can be divided into several CPU (central processing unit, referred to as processor) groups according to the physical logical processors. A CPU group contains all the logical processors of the same physical processor. For example, as shown in Figure 2, each logical processor corresponds to a run queue. In the run queue, the root scheduling node and the scheduling node corresponding to each group scheduling entity each lead a cfs_rq. The root node of each cfs_rq and the scheduling node corresponding to each scheduling entity have their own node information recording area, which records the relevant scheduling details. For example, the node information of the root node of each cfs_rq can include relevant information about the child nodes in the queue, such as the node order and the number of nodes. For example, the node information of each scheduling entity can include information such as the cfs_rq to which the scheduling entity belongs, the parent node, the scheduling level, etc. A logical processor is selected for each CPU group as the target logical processor. As explained in the previous embodiment, the run queues of multiple logical processors on the same physical processor have the same tree data structure. Each scheduling entity can find the scheduling node at the same location in the run queue of the target logical processor belonging to the same physical processor. This is the scheduling node corresponding to the scheduling entity. As shown in Figure 2, assuming that logical processor 2 is selected as the target logical processor, the kernel virtual runtime core_vruntime of scheduling entity 2102 is recorded in the node information of scheduling entity 2110 of logical processor 2. In addition, since each group scheduling entity has a cfs_rq, it can also be understood that for each cfs_rq in the run queue of each logical processor on the same physical processor, a pointer core is maintained pointing to the corresponding cfs_rq in the run queue of the target logical processor. As shown in FIG2 , assuming that logical processor 2 is selected as the target logical processor, a pointer core pointing to the corresponding cfs_rq in the run queue of the target logical processor is maintained for each cfs_rq in the run queue of logical processor 1. For example, a pointer core is set for the cfs_rq led by group scheduling entity 2104 (i.e., queue 2106 shown in FIG2 ) to point to the corresponding cfs_rq in logical processor 2, i.e., queue 2108.

[0055] In this embodiment, the kernel virtual runtime of all scheduling entities of the entire physical processor is recorded by selecting the run queue of a target logical processor, and the kernel virtual runtime is easily searched by setting a pointer for the scheduling entity to point to the corresponding node of the target logical processor, thereby avoiding the need to perform recording and search operations on multiple run queues. Instead, recording and search operations are performed on one run queue, which effectively reduces the overhead of recording and searching the kernel virtual runtime of the scheduling entity and improves scheduling efficiency.

[0056] In addition, since the run queue of the target logical processor records the kernel virtual runtime of each scheduling entity of the entire physical processor, when updating the virtual runtime baseline value of any group of scheduling entities, the kernel virtual runtime recorded in the run queue of the target logical processor can also be used for comparison to obtain the virtual runtime baseline value, thereby improving the updating efficiency of the virtual runtime baseline value. Specifically, in one or more embodiments of this specification, the method may further include:

[0057] For the group scheduling entity, searching for the kernel virtual runtime recorded by multiple sub-nodes under the scheduling node corresponding to the group scheduling entity from the kernel virtual runtime recorded by the run queue of the target logical processor;

[0058] Comparing the kernel virtual running times recorded by the plurality of child nodes and finding the minimum value therebetween;

[0059] The larger value between the current virtual runtime reference value of the group scheduling entity and the minimum value is used as the updated virtual runtime reference value of the group scheduling entity.

[0060] For example, when cfs_rq on any logical processor in the CPU group updates the virtual runtime of any scheduling entity, the kernel virtual runtime of that scheduling entity is also updated accordingly. When the kernel virtual runtime changes, the virtual runtime baseline value can begin updating at that moment. For example, as shown in FIG2 , assuming logical processor 2 is the target logical processor, the kernel virtual runtime of the corresponding scheduling entities in queues 2106 and 2108 is recorded in the node information of each node in queue 2108. Therefore, when the virtual runtime baseline value of group scheduling entity 2104 needs to be updated, all kernel virtual runtimes that need to be compared can be found from the node information of each node in queue 2108, and the minimum value can be found. It is understood that since group scheduling entity 2104 and group scheduling entity 2112 belong to the same scheduling level in the two run queues, the corresponding virtual runtime baseline value is the baseline for scheduling entities at the same scheduling level across all physical processors. Therefore, the virtual runtime baseline values ​​of group scheduling entity 2104 and group scheduling entity 2112 are the same.

[0061] In this embodiment, by recording the node information in the run queue of the target logical processor, the kernel virtual run time of each scheduling entity corresponding to the scheduling node corresponding to the group scheduling entity in the run queues of multiple logical processors can be quickly found with very little overhead, thereby efficiently finding the minimum value therein. Moreover, by taking the larger value between the current virtual run time baseline value and the minimum value as the updated virtual run time baseline value of the group scheduling entity, it can be ensured that the virtual run time baseline value increases as the scheduling entity runs, thereby continuously maintaining the priority gap between the scheduling entities and avoiding the problem that the virtual run time baseline value becomes smaller and it is difficult to maintain the priority gap.

[0062] In addition, in order to more efficiently find the virtual runtime reference value corresponding to the group scheduling entity when updating the kernel virtual runtime corresponding to any scheduling entity, in one or more embodiments of this specification, the method further includes:

[0063] Recording the virtual runtime reference value updated by the group scheduling entity in the node information of the corresponding scheduling node in the run queue of the target logical processor;

[0064] When the kernel virtual runtime corresponding to any one of the scheduling entities needs to be updated, the virtual runtime reference value corresponding to the group scheduling entity is obtained according to the pointer set by the group scheduling entity.

[0065] For example, as shown in FIG2 , the virtual runtime benchmark values ​​core_min_vruntime corresponding to group scheduling entity 2104 and group scheduling entity 2112 may be recorded in the node information of the root node of the cfs_rq led by group scheduling entity 2112. When the virtual runtime benchmark value of group scheduling entity 2104 is needed, the virtual runtime benchmark value is read from the node information of the root node of the cfs_rq led by group scheduling entity 2112.

[0066] In this embodiment, the virtual runtime benchmark value of the group scheduling entity of the entire physical processor is recorded by selecting the run queue of a target logical processor, thereby avoiding the execution of recording and search operations for multiple run queues. Instead, recording and search operations are performed for one run queue, which effectively reduces the overhead of recording and searching the virtual runtime benchmark value of the scheduling entity and improves scheduling efficiency.

[0067] It should be noted that the above one or more embodiments record and search the kernel virtual runtime and virtual runtime benchmark value by selecting the run queue of the target logical processor. This is merely an implementation method with higher processing efficiency of the scheduling method provided in the embodiments of this specification. In actual applications, any other method can be selected to record and search the kernel virtual runtime and virtual runtime benchmark value according to the needs of the scenario, and this specification does not limit this.

[0068] In the scheduling method provided in the embodiments of this specification, when the virtual runtime of the kernel corresponding to the scheduling entity is updated based on the virtual runtime benchmark value, in order to make the scheduling mechanism more fair, different updating methods can be adopted for different situations. The following are exemplary descriptions of several possible implementation methods:

[0069] In one or more embodiments of this specification, a virtual runtime reference value is used to penalize / compensate the kernel virtual runtime for situations where a scheduling entity enters or exits a run queue. Specifically, updating the kernel virtual runtime corresponding to any scheduling entity using the virtual runtime reference value corresponding to the scheduling entity in the group to which the scheduling entity belongs includes:

[0070] When any of the scheduling entities enters the run queue, the kernel virtual run time currently corresponding to the any of the scheduling entities is added to the virtual run time reference value corresponding to the group scheduling entity to obtain the kernel virtual run time updated by the any of the scheduling entities;

[0071] When any of the scheduling entities exits the run queue, the kernel virtual run time currently corresponding to the any of the scheduling entities is added to the increment of the virtual run time, and then the virtual run time reference value corresponding to the group scheduling entity is subtracted to obtain the updated kernel virtual run time of the any of the scheduling entities.

[0072] For example, a task in the operating system that is in the awake state will enter the run queue and wait to be run.

[0073] When a scheduling entity enters a run queue, a virtual runtime baseline value is added to the kernel virtual runtime of the newly entered scheduling entity, thereby maintaining fairness for other scheduling entities already in the run queue. For example, suppose scheduling entity A, which has just woken up on a logical processor, currently has a kernel virtual runtime of 100, and the virtual runtime baseline value of the group scheduling entity corresponding to the subqueue it is about to join is 50. When scheduling entity A enters the run queue of the logical processor, scheduling entity B, belonging to another logical processor on the same physical processor, is already queued in the run queue with a kernel virtual runtime of 100. At this time, since scheduling entity A's kernel virtual runtime is also 100, if no penalty is applied when it enters the queue, it will cause competition for the physical processor allocation of scheduling entity B. Since scheduling entity B has been in the queue for a long time, if it is not given priority, it will be unfair. Therefore, according to the method provided in the embodiments of this specification, when scheduling entity A enters the running waiting queue, its kernel virtual running time is updated to 150 according to the virtual running time benchmark value, so that the kernel virtual running time of scheduling entity A is less than that of scheduling entity B, ensuring the fairness of priority operation of scheduling entity B, thereby maintaining the priority gap between various scheduling entities on the entire physical processor.

[0074] For example, when a task in the operating system changes from wake-up to sleep state, it is dequeued from the run queue.

[0075] In this embodiment, when a scheduling entity is dequeued, the kernel virtual runtime of the newly dequeued scheduling entity is compensated by adding the virtual runtime increment and subtracting the virtual runtime baseline value, thereby ensuring the fairness of the scheduling entity itself and maintaining the fairness of the scheduling entity itself when it re-enters the queue. For example, assuming that the current kernel virtual runtime of scheduling entity A of a logical processor is 150 and the virtual runtime baseline value of the scheduling entity in its group is 50, when scheduling entity A is dequeued, the kernel virtual runtime of 150 is added to its virtual runtime increment of 100 and then subtracted from the virtual runtime baseline value. The updated kernel virtual runtime of scheduling entity A is 200.

[0076] In one or more embodiments of the present specification, in the case where a scheduling entity creates a new child process / thread task, in order to prevent the scheduling entity corresponding to the newly created child process / thread task from inheriting the kernel virtual runtime of the currently running scheduling entity, causing it to easily obtain running priority, the kernel virtual runtime of the newly created scheduling entity is penalized based on its weight. Moreover, since the currently running scheduling entity itself is a scheduling entity that has been penalized based on the virtual runtime baseline value, and the newly created scheduling entity has not yet been queued, the virtual runtime baseline value is subtracted from the kernel virtual runtime of the newly created scheduling entity to ensure fairness when the newly created scheduling entity is queued. Specifically, the use of the virtual runtime baseline value corresponding to the scheduling entity of the group to which any scheduling entity belongs to update the kernel virtual runtime corresponding to any scheduling entity includes:

[0077] When the currently running scheduling entity creates any new scheduling entity, the kernel virtual runtime of the currently running scheduling entity is used as the kernel virtual runtime corresponding to the any scheduling entity;

[0078] Determining a penalty time for any scheduling entity according to a weight corresponding to any scheduling entity;

[0079] Adding the penalty time to the kernel virtual runtime corresponding to any one of the scheduling entities to obtain the kernel virtual runtime updated by the any one of the scheduling entities;

[0080] The kernel virtual runtime updated by any scheduling entity is obtained by subtracting the virtual runtime reference value corresponding to the group scheduling entity from the kernel virtual runtime updated by any scheduling entity.

[0081] For example, suppose that the currently running scheduling entity C creates a new scheduling entity D. At this time, the kernel virtual running time 100 of the scheduling entity C can be used as the kernel virtual running time of the newly created scheduling entity D, and the penalty time is calculated according to the weight of the newly created scheduling entity D. Assuming the penalty time is 20, the updated kernel virtual running time of the newly created scheduling entity D is 120. Assuming that the virtual running time benchmark value corresponding to the scheduling entity in its group is 50, the updated kernel virtual running time of the newly created scheduling entity D is 120 minus 50, that is, 70.

[0082] It should be noted that when calculating the penalty time according to the weight corresponding to any scheduling entity, the algorithm used is not limited. For example, a general virtual runtime time slice penalty algorithm can be used, which will not be described in detail in this specification.

[0083] In addition, in view of the fact that the newly created scheduling entity may have a flag bit indicating priority operation, in order to ensure that the newly created scheduling entity can be run with priority, in combination with the above embodiment, the method further includes:

[0084] If any of the newly created scheduling entities has a flag indicating priority operation, and the kernel virtual runtime of the currently running scheduling entity is less than the kernel virtual runtime updated by any of the scheduling entities, then the kernel virtual runtime of the currently running scheduling entity is exchanged with that of any of the scheduling entities.

[0085] The flag indicating priority can be expressed in any manner. For example, the flag indicating priority can be recorded in the parameter "sysctl_sched_child_runs_first". When the value of "sysctl_sched_child_runs_first" is true, it indicates that the flag indicating priority exists; when the value is false, it indicates that the flag indicating priority does not exist. By exchanging the kernel virtual runtimes of the two, priority is guaranteed for the child process / thread that requires priority.

[0086] In one or more embodiments of this specification, when a scheduling entity is awakened, a preset sleep time threshold is set to address the situation where a scheduling entity that has slept for too long is difficult to run due to its large kernel virtual runtime. A virtual runtime baseline value is assigned to the scheduling entity that has slept for too long as the kernel virtual runtime. This allows the scheduling entity that has slept for too long to be given a higher priority and run as quickly as possible, thereby ensuring fairness for scheduling entities that have been forced to idle and thus sleep for too long. Specifically, using the virtual runtime baseline value corresponding to a scheduling entity in the group to which any scheduling entity belongs to update the kernel virtual runtime corresponding to any scheduling entity includes:

[0087] When any scheduling entity is awakened, if the sleep time of the any scheduling entity exceeds a preset sleep time threshold, the virtual runtime reference value corresponding to the group of scheduling entities is used as the kernel virtual runtime updated by the any scheduling entity.

[0088] The specific value of the preset sleep time threshold can be set according to the application scenario and is not limited in this specification. For example, the preset sleep time threshold can be 60 seconds. When any scheduling entity is awakened, if the sleep time is greater than 60 seconds, the kernel virtual runtime of the scheduling entity is set to be equal to the virtual runtime baseline value of the scheduling entity in the group to which it belongs.

[0089] For example, suppose the kernel scheduler needs to select the highest-priority task from two or more HTs to run. Due to the nature of the kernel scheduler, tasks with different cookies (a type of cache file) are not allowed to run simultaneously on the same physical processor. Therefore, the kernel scheduler uses a forced idle mechanism to prevent tasks with different cookies (a type of cache file) from running simultaneously on the same physical processor. For example, suppose there are tasks A1, A2, and B. A1 is a short task, and A2 is a long task. Task B is not allowed to run simultaneously with A1 or A2 on two HTs on the same physical processor. Assume that task B has a higher priority and occupies the physical processor. At this time, A1 and A2 are in a forced idle sleep state. When task B is finished, A1 and A2 are awakened. At this time, it is necessary to select the task with a higher priority from A1 and A2 to run. Since A1 is a short task and A2 is a long task, in this case, if the priority is determined based on the difference in the minimum virtual running time, A2 may be in a long sleep state and unable to run. To address this problem, according to the method provided in this embodiment, although A1's running time is extremely short each time, when A2 sleeps for a long time exceeding the preset sleep time threshold, A2's kernel virtual running time will be updated to the virtual running time baseline value, so that A2 can obtain a higher priority based on a smaller kernel virtual running time and occupy the physical processor. It can be seen that the method provided in the embodiment of this specification can make scheduling more fair and reasonable.

[0090] In one or more embodiments of this specification, another unfair situation is addressed by using a virtual runtime benchmark value to update the kernel virtual runtime. Specifically, assuming that the virtual runtime of a dormant process remains unchanged, while the virtual runtime of other running processes continues to advance, then when the dormant process finally wakes up, its virtual runtime is much smaller than that of others, which will give it the advantage of preempting the physical processor, making it difficult for other processes to occupy the physical processor for a long time, resulting in unfairness. Therefore, in order to avoid the imbalance of priority gaps caused by the kernel virtual runtime being too small when the scheduling entity is awakened, which is unfair to other scheduling entities, the method provided in the embodiments of this specification also compares its kernel virtual runtime with the temporary kernel virtual runtime determined using the virtual runtime benchmark value, and takes the larger value as the updated kernel virtual runtime, thereby maintaining a reasonable priority gap between scheduling entities and improving fairness. Specifically, the method of using the virtual runtime benchmark value corresponding to the scheduling entity of the group to which any scheduling entity belongs to update the kernel virtual runtime corresponding to any scheduling entity includes:

[0091] When any scheduling entity is awakened, if the sleep time of any scheduling entity does not exceed a preset sleep time threshold, the virtual runtime reference value corresponding to the group scheduling entity is used as the temporary kernel virtual runtime of the any scheduling entity, and it is determined whether the any scheduling entity is a newly created task;

[0092] If any of the scheduling entities is a newly created task, determining a penalty time for the any of the scheduling entities according to a weight corresponding to the any of the scheduling entities, and adding the penalty time to the temporary kernel virtual runtime of the any of the scheduling entities to obtain an updated temporary kernel virtual runtime;

[0093] If any of the scheduling entities is not a newly created task, determining a compensation time for the any of the scheduling entities according to a weight corresponding to the any of the scheduling entities, and subtracting the compensation time from the temporary kernel virtual runtime of the any of the scheduling entities to obtain an updated temporary kernel virtual runtime;

[0094] If the updated temporary kernel virtual runtime is greater than the kernel virtual runtime currently corresponding to any scheduling entity, the updated temporary kernel virtual runtime is used as the kernel virtual runtime updated by any scheduling entity.

[0095] For example, assuming that when a scheduling entity is awakened, the sleep time does not exceed the preset sleep time threshold, and assuming that the current kernel virtual runtime of the scheduling entity is 50, and the virtual runtime baseline value of the scheduling entity in its group is 50, then the temporary kernel virtual runtime is 50. Since the scheduling entity is not a newly created task, the compensation time determined according to its weight is 20, then the updated temporary kernel virtual runtime after compensation is 30. Since the updated temporary kernel virtual runtime is less than its current kernel virtual runtime, the updated kernel virtual runtime is still 50.

[0096] For another example, suppose that when a scheduling entity is awakened, the sleep time does not exceed the preset sleep time threshold, and suppose that the current kernel virtual runtime of the scheduling entity is 20, and the virtual runtime benchmark value of the scheduling entity in its group is 50, then the temporary kernel virtual runtime is 50. Since the scheduling entity is not a newly created task, the compensation time determined according to its weight is 20, then the updated temporary kernel virtual runtime after compensation is 30. Since the updated temporary kernel virtual runtime is greater than its current kernel virtual runtime, the updated kernel virtual runtime is 30.

[0097] It can be seen that in this embodiment, the temporary kernel virtual runtime of the scheduling entity is determined based on the virtual runtime benchmark value, and depending on whether it is a new task, a certain penalty or compensation is imposed on the temporary kernel virtual runtime to improve fairness. Then, its own kernel virtual runtime is compared with the temporary kernel virtual runtime determined using the virtual runtime benchmark value, and the larger value is taken as the updated kernel virtual runtime, thereby ensuring a reasonable gap in priority between scheduling entities and further ensuring fairness.

[0098] Corresponding to the above method embodiment, this specification also provides a scheduling device embodiment. Figure 4 shows a schematic diagram of the structure of a scheduling device provided by one embodiment of this specification. As shown in Figure 4, the device includes:

[0099] The update module 402 is configured to update the kernel virtual runtime corresponding to any scheduling entity using the virtual runtime benchmark value corresponding to the group scheduling entity to which any scheduling entity belongs, wherein the virtual runtime benchmark value is determined based on the minimum value of the kernel virtual runtime of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the running queues of multiple logical processors, and the multiple logical processors belong to the same physical processor.

[0100] Ancestor search module 404 is configured to search for a first ancestor of a first scheduling entity of a first logical processor and a second scheduling entity of a second logical processor in a run queue of the first logical processor according to preset search conditions, wherein the search conditions include: the first ancestor and the second ancestor have the same scheduling level, and the first logical processor and the second logical processor are any two logical processors among the multiple logical processors.

[0101] The comparison module 406 is configured to determine the priority of the first scheduling entity and the second scheduling entity by comparing the kernel virtual runtime corresponding to the first ancestor and the kernel virtual runtime corresponding to the second ancestor.

[0102] In one or more embodiments of this specification, the update module includes:

[0103] an enqueue update submodule configured to, when any of the scheduling entities enters the run queue, add the kernel virtual run time currently corresponding to the any of the scheduling entities and the virtual run time reference value corresponding to the group scheduling entity to obtain an updated kernel virtual run time of the any of the scheduling entities;

[0104] The dequeue update submodule is configured to add the kernel virtual runtime time currently corresponding to any scheduling entity to the increment of the virtual runtime time, and then subtract the virtual runtime reference value corresponding to the group scheduling entity, when any scheduling entity is out of the running queue, to obtain the kernel virtual runtime time updated by any scheduling entity.

[0105] In one or more embodiments of this specification, the update module includes:

[0106] a new creation and updating submodule configured to, when a currently running scheduling entity creates any new scheduling entity, use the kernel virtual runtime of the currently running scheduling entity as the kernel virtual runtime corresponding to the any scheduling entity;

[0107] A new penalty submodule is configured to determine a penalty time for any scheduling entity according to a weight corresponding to any scheduling entity, and add the penalty time to the kernel virtual runtime corresponding to any scheduling entity to obtain an updated kernel virtual runtime of any scheduling entity;

[0108] A new compensation submodule is created, configured to subtract the virtual runtime reference value corresponding to the group scheduling entity from the kernel virtual runtime updated by any scheduling entity to obtain the kernel virtual runtime updated by any scheduling entity.

[0109] In one or more embodiments of this specification, the update module further includes:

[0110] The exchange submodule is configured to exchange the kernel virtual runtime of the currently running scheduling entity with that of any scheduling entity if any of the newly created scheduling entities has a flag indicating priority operation and the kernel virtual runtime of the currently running scheduling entity is less than the kernel virtual runtime updated by any of the scheduling entities.

[0111] In one or more embodiments of this specification, the update module includes:

[0112] The wake-up compensation submodule is configured to use the virtual runtime reference value corresponding to the group scheduling entity as the kernel virtual runtime updated by any scheduling entity when any scheduling entity is awakened if the sleep time of the any scheduling entity exceeds a preset sleep time threshold.

[0113] In one or more embodiments of this specification, the update module includes:

[0114] a wake-up temporary setting submodule, configured to, when any scheduling entity is woken up, use the virtual runtime reference value corresponding to the group scheduling entity as the temporary kernel virtual runtime of the any scheduling entity if the sleep time of the any scheduling entity does not exceed a preset sleep time threshold, and determine whether the any scheduling entity is a newly created task;

[0115] a new penalty submodule configured to, if any of the scheduling entities is a newly created task, determine a penalty time for the any of the scheduling entities according to a weight corresponding to the any of the scheduling entities, and add the penalty time to the temporary kernel virtual runtime of the any of the scheduling entities to obtain an updated temporary kernel virtual runtime;

[0116] A wake-up temporary compensation submodule is configured to, if any of the scheduling entities is not a newly created task, determine a compensation time for the any of the scheduling entities according to a weight corresponding to the any of the scheduling entities, and subtract the compensation time from the temporary kernel virtual runtime of the any of the scheduling entities to obtain an updated temporary kernel virtual runtime;

[0117] The temporary comparison submodule is configured to use the updated temporary kernel virtual runtime as the updated kernel virtual runtime of any scheduling entity if the updated temporary kernel virtual runtime is greater than the kernel virtual runtime currently corresponding to any scheduling entity.

[0118] In one or more embodiments of this specification, the device further includes:

[0119] a processor selection module configured to select a target logical processor from the plurality of logical processors;

[0120] a runtime recording module configured to record the kernel virtual runtime corresponding to any scheduling entity in the node information of the corresponding scheduling node in the run queue of the target logical processor;

[0121] a pointer setting module configured to set a pointer pointing to a corresponding scheduling node in the run queue of the target logical processor for any group of scheduling entities;

[0122] The time acquisition module is configured to, when any ancestor is found, acquire the kernel virtual running time corresponding to any ancestor according to the pointer set by any ancestor.

[0123] In one or more embodiments of this specification, the device further includes:

[0124] a runtime search module configured to search, for the group scheduling entity, from the kernel virtual runtime recorded in the run queue of the target logical processor, for the kernel virtual runtime recorded by multiple child nodes under the scheduling node corresponding to the group scheduling entity;

[0125] a minimum value search module configured to compare the kernel virtual runtimes recorded by the plurality of child nodes and find the minimum value therein;

[0126] The reference value determination module is configured to use the larger value between the current virtual runtime reference value of the group scheduling entity and the minimum value as the updated virtual runtime reference value of the group scheduling entity.

[0127] In one or more embodiments of this specification, the device further includes:

[0128] a benchmark value recording module configured to record the virtual runtime benchmark value updated by the group scheduling entity in the node information of the corresponding scheduling node in the run queue of the target logical processor;

[0129] The reference value acquisition module is configured to acquire the virtual runtime reference value corresponding to the group scheduling entity according to the pointer set by the group scheduling entity when the kernel virtual runtime corresponding to any scheduling entity needs to be updated.

[0130] The above is a schematic scheme of a scheduling device of this embodiment. It should be noted that the technical scheme of the scheduling device and the technical scheme of the scheduling method described above are of the same concept. For details not described in detail in the technical scheme of the scheduling device, please refer to the description of the technical scheme of the scheduling method described above.

[0131] Corresponding to the above method embodiment, this specification also provides a scheduling system embodiment. Figure 5 shows a schematic diagram of the structure of a scheduling system provided by one embodiment of this specification. As shown in Figure 5, the scheduling system includes:

[0132] A scheduler 520 and a physical processor 540 , wherein the physical processor 540 includes a plurality of logical processors;

[0133] The scheduler 520 is configured to determine a first scheduling entity and a second scheduling entity to be scheduled, apply a scheduling method as described in any embodiment of this specification to determine the priority of the first scheduling entity and the second scheduling entity, and allocate the running time of the physical processor to the first scheduling entity and the second scheduling entity according to the priority.

[0134] The above is a schematic scheme of a scheduling system of this embodiment. It should be noted that the technical scheme of the scheduling system and the technical scheme of the scheduling method described above are of the same concept. For details not described in detail in the technical scheme of the scheduling system, please refer to the description of the technical scheme of the scheduling method described above.

[0135] Figure 6 shows a block diagram of a computing device 600 according to one embodiment of this specification. Components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and a database 650 is used to store data.

[0136] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, or a near field communication (NFC) interface.

[0137] In one embodiment of the present disclosure, the aforementioned components of computing device 600 and other components not shown in FIG6 may also be connected to each other, for example, via a bus. It should be understood that the block diagram of the computing device structure shown in FIG6 is for illustrative purposes only and does not limit the scope of this disclosure. Those skilled in the art may add or replace other components as needed.

[0138] Computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 600 may also be a mobile or stationary server.

[0139] The processor 620 is configured to execute the following computer-executable instructions, which implement the steps of the above-mentioned scheduling method when executed by the processor.

[0140] The above is a schematic solution of a computing device of this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned scheduling method belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned scheduling method.

[0141] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which implement the steps of the above-mentioned scheduling method when executed by a processor.

[0142] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the scheduling method described above are of the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the scheduling method described above.

[0143] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned scheduling method.

[0144] The above is an illustrative solution of a computer program of this embodiment. It should be noted that the technical solution of the computer program and the technical solution of the scheduling method described above are of the same concept. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solution of the scheduling method described above.

[0145] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0146] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.

[0147] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0148] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0149] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A scheduling method, comprising: Using a virtual runtime reference value corresponding to a group scheduling entity to which any scheduling entity belongs, updating a kernel virtual runtime corresponding to any scheduling entity, wherein the virtual runtime reference value is determined based on a minimum value of kernel virtual runtimes of a plurality of scheduling entities corresponding to a scheduling node corresponding to the group scheduling entity in a running queue of a plurality of logical processors, wherein the plurality of logical processors belong to the same physical processor; For a first scheduling entity of a first logical processor and a second scheduling entity of a second logical processor, according to a preset search condition, searching for a first ancestor of the first scheduling entity in a run queue of the first logical processor, and searching for a second ancestor of the second scheduling entity in a run queue of the second logical processor, wherein the search condition includes: the first ancestor and the second ancestor have the same scheduling level, and the first logical processor and the second logical processor are any two logical processors among the multiple logical processors; The priorities of the first scheduling entity and the second scheduling entity are determined by comparing the kernel virtual runtime corresponding to the first ancestor and the kernel virtual runtime corresponding to the second ancestor.

2. The method according to claim 1, wherein the updating of the kernel virtual runtime corresponding to any scheduling entity by using the virtual runtime reference value corresponding to the scheduling entity of the group to which any scheduling entity belongs comprises: When any of the scheduling entities enters the run queue, the kernel virtual run time currently corresponding to the any of the scheduling entities and the virtual run time reference value corresponding to the group scheduling entity are added to obtain the kernel virtual run time updated by the any of the scheduling entities; When any of the scheduling entities exits the run queue, the kernel virtual run time currently corresponding to the any of the scheduling entities is added to the increment of the virtual run time, and then the virtual run time reference value corresponding to the group scheduling entity is subtracted to obtain the kernel virtual run time updated by the any of the scheduling entities.

3. The method according to claim 1, wherein the updating of the kernel virtual runtime corresponding to any scheduling entity by using the virtual runtime reference value corresponding to the scheduling entity in the group to which any scheduling entity belongs comprises: When the currently running scheduling entity creates any new scheduling entity, the kernel virtual running time of the currently running scheduling entity is used as the kernel virtual running time corresponding to the any scheduling entity; Determining a penalty time for any scheduling entity according to a weight corresponding to any scheduling entity; Adding the penalty time to the kernel virtual runtime corresponding to any one of the scheduling entities to obtain the kernel virtual runtime updated by any one of the scheduling entities; The virtual runtime of the kernel updated by any scheduling entity is obtained by subtracting the virtual runtime reference value corresponding to the group scheduling entity from the virtual runtime of the kernel updated by any scheduling entity.

4. The method according to claim 3, further comprising: If any of the newly created scheduling entities has a flag indicating priority operation, and the kernel virtual running time of the currently running scheduling entity is less than the kernel virtual running time updated by any of the scheduling entities, then the kernel virtual running time of the currently running scheduling entity is exchanged with that of any of the scheduling entities.

5. The method according to claim 1, wherein the updating of the kernel virtual runtime corresponding to any scheduling entity by using the virtual runtime reference value corresponding to the scheduling entity of the group to which any scheduling entity belongs comprises: When any scheduling entity is awakened, if the sleep time of any scheduling entity exceeds a preset sleep time threshold, the virtual runtime reference value corresponding to the group of scheduling entities is used as the kernel virtual runtime updated by any scheduling entity.

6. The method according to claim 1, wherein the updating the kernel virtual runtime corresponding to any scheduling entity by using the virtual runtime reference value corresponding to the scheduling entity in the group to which any scheduling entity belongs comprises: When any scheduling entity is awakened, if the sleep time of any scheduling entity does not exceed the preset sleep time threshold, the virtual runtime reference value corresponding to the group scheduling entity is used as the temporary kernel virtual runtime of any scheduling entity, and it is determined whether any scheduling entity is a newly created task; If any of the scheduling entities is a newly created task, determining a penalty time for the any of the scheduling entities according to a weight corresponding to the any of the scheduling entities, and adding the penalty time to a temporary kernel virtual runtime of the any of the scheduling entities to obtain an updated temporary kernel virtual runtime; If any of the scheduling entities is not a newly created task, determining a compensation time for any of the scheduling entities according to a weight corresponding to any of the scheduling entities, and subtracting the compensation time from the temporary kernel virtual runtime of any of the scheduling entities to obtain an updated temporary kernel virtual runtime; If the updated temporary kernel virtual runtime is greater than the kernel virtual runtime currently corresponding to any scheduling entity, the updated temporary kernel virtual runtime is used as the kernel virtual runtime updated by any scheduling entity.

7. The method according to claim 1, further comprising: Selecting a target logical processor from the plurality of logical processors; Recording the kernel virtual running time corresponding to any one of the scheduling entities in the node information of the corresponding scheduling node in the running queue of the target logical processor; Setting a pointer to a corresponding scheduling node in a run queue of the target logical processor for any group of scheduling entities; When any ancestor is found, the kernel virtual runtime corresponding to any ancestor is obtained according to the pointer set by any ancestor.

8. The method according to claim 7, further comprising: For the group scheduling entity, searching for the kernel virtual runtime recorded by a plurality of sub-nodes under the scheduling node corresponding to the group scheduling entity from the kernel virtual runtime recorded by the run queue of the target logical processor; Compare the kernel virtual running times recorded by the multiple child nodes to find the minimum value therein; The larger value between the current virtual runtime reference value of the group scheduling entity and the minimum value is used as the updated virtual runtime reference value of the group scheduling entity.

9. The method according to claim 8, further comprising: Recording the virtual runtime reference value updated by the group scheduling entity in the node information of the corresponding scheduling node in the run queue of the target logical processor; When it is necessary to update the kernel virtual runtime corresponding to any one of the scheduling entities, the virtual runtime reference value corresponding to the group scheduling entity is obtained according to the pointer set by the group scheduling entity.

10. A scheduling system, comprising: A scheduler and a physical processor, wherein the physical processor includes a plurality of logical processors; The scheduler is configured to determine a first scheduling entity and a second scheduling entity to be scheduled, apply the scheduling method as described in any one of claims 1 to 9 to determine the priorities of the first scheduling entity and the second scheduling entity, and allocate the running time of the physical processor to the first scheduling entity and the second scheduling entity according to the priorities.

11. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the scheduling method described in any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the scheduling method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Task scheduling method and device, storage medium and electronic equipment

    CN113495780A

  • Task scheduling method and device based on CFS, equipment and storage medium

    CN113886038A

  • Task scheduling method and device, equipment and storage medium

    CN113961348A

  • Task scheduling method and device

    CN114327843A

  • Thread scheduling method and device and electronic equipment

    CN115543551A

Cited By

  • Database connection control method and device based on dynamic threshold value and medium

    CN122388024A