Scheduling method and system, computing equipment and computer readable storage medium

By maintaining the kernel virtual runtime of the scheduling entity and updating 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 queue of multiple logical processors is realized. Improve the fairness of the scheduling mechanism.

CN119493643APending Publication Date: 2025-02-21ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311063145.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-21
Publication Date
2025-02-21

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 entities.

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 value of multiple logical processors, thereby maintaining scheduling fairly Priority of entities.

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 CN119493643A_ABST
    Figure CN119493643A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a scheduling method and system, computing equipment and a computer readable storage medium, and the scheduling method comprises the steps: updating kernel virtual running time corresponding to any scheduling entity by using a virtual running time reference value corresponding to a group scheduling entity where any scheduling entity is located; a first ancestor of the first scheduling entity is searched in a running queue of a first logic processor, a second ancestor of the second scheduling entity is searched in a running queue of a second logic processor, and the searching condition includes that the scheduling hierarchy of the first ancestor is the same as that of the second ancestor; and comparing the kernel virtual running time corresponding to the first ancestor with the kernel virtual running time corresponding to the second ancestor, and determining the priorities of the first scheduling entity and the second scheduling entity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] The scheduler is the core of the operating system and can be understood as a resident program. The scheduler continuously scans the run queue and uses some scheduling algorithms (such as time slice round-robin, priority scheduling, multi-level feedback queue scheduling, etc.) to find a scheduling entity that has more CPU usage rights than the current scheduling entity that occupies the CPU, reclaim the processor, and then let the scheduling entity with more CPU usage rights occupy the processor.

[0003] 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. Summary of the invention

[0004] In view of this, an embodiment of this specification provides 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 solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of the present 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 scheduling entity in a group 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 running 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 running queue of the first logical processor and searching for a second ancestor of the second scheduling entity in the running queue of the second logical processor according to a preset search condition, wherein the search condition comprises: the scheduling level of the first ancestor is the same as that of the second ancestor, 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.

[0006] According to a second aspect of an embodiment of this specification, a scheduling system is provided, including: a scheduler and a physical processor, the physical processor including multiple 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 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.

[0007] According to the third aspect of the embodiments of this specification, a computing device is provided, including: 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.

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

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

[0010] An 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 used to evaluate 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, and the virtual runtime benchmark value used as penalty or compensation during the update is a benchmark value obtained by taking the minimum kernel virtual runtime of each scheduling entity of multiple logical processors across the entire physical processor. 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 continuously and 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, thereby avoiding the unfairness caused by the running queue of a single logical processor determining the minimum virtual runtime based 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 according to the preset search condition, and the second ancestor of the second scheduling entity can be searched in the running queue of the second logical processor. 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 more fair 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

[0011] Figure 1 is a schematic diagram of a running queue provided by an embodiment of this specification;

[0012] Figure 2 This is a schematic diagram of an application scenario of a scheduling method provided by an embodiment of this specification;

[0013] Figure 3 is a flowchart of a scheduling method provided by an embodiment of this specification;

[0014] Figure 4 It is a structural schematic diagram of a scheduling device provided by an embodiment of this specification;

[0015] Figure 5 It is a structural diagram of a scheduling system provided by an embodiment of this specification;

[0016] Figure 6 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0017] Many specific details are described in the following description to facilitate a full 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 connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0018] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" 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 other meanings. 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.

[0019] 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, this 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".

[0020] 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 the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

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

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

[0023] Run queue (rq for short) is a tree data structure maintained by the scheduler. One logical processor corresponds to one run queue of the tree data structure (e.g. Figure 1 The running queue of the tree data structure includes, under the root node, group scheduling entities (such as Figure 1 Group A, Group B, etc.) and task scheduling entities (such as Figure 1 task T1, task T2, etc. as shown in FIG. Figure 1 As shown in , the group scheduling entity corresponds to the non-leaf scheduling node in the tree data structure, and the task scheduling entity corresponds to the leaf scheduling node in the tree data structure. A group scheduling entity leads a sub-queue, and the sub-queue contains the scheduling entities of the group scheduling entity. Figure 1 As shown in the figure, the root node can be regarded as a group scheduling entity that leads the entire run queue, which includes the scheduling entities task T1, task T2 and Group A; the subqueue led by the group scheduling entity Group A includes all the scheduling entities of Group A, such as task T3, task T4 and Group B; the subqueue led by the group scheduling entity Group B includes all the scheduling entities of Group B, such as task T5 and task T6. In the completely fair scheduler, both the run queue and the subqueue can be called "cfs_rq". The group scheduling entity is used to manage all the scheduling entities contained in the group scheduling entity and is responsible for the scheduling details of the entire group, including time slice calculation, job flow control, etc. The scheduler puts all tasks that will be run on a logical processor on the run queue corresponding to the logical processor. Each active task will only be in one run queue at a time. For the scheduler, since it supports multiple scheduling algorithms, the queues of various scheduling algorithms can be embedded in the subqueues of the entire run queue.

[0024] Virtual runtime (vruntime) is the runtime calculated by the actual runtime of the scheduling entity and the weight of the scheduling entity. In the scheduler, the greater the weight of a scheduling entity, the more it needs to run. The greater the weight, the smaller its virtual runtime, so the greater the chance of being scheduled.

[0025] The kernel virtual runtime can be understood as a parameter used to determine the priority gap between various scheduling entities in the entire run queue of the 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. When the kernel virtual runtime is updated, it is updated based on the virtual runtime baseline value corresponding to the group scheduling entity in some cases, and based on the virtual runtime baseline value corresponding to the group scheduling entity and the change amount of the virtual runtime in other cases.

[0026] Minimum virtual runtime (min vruntime for short) refers to the minimum value of the virtual runtime of all scheduled entities in a cfs_rq.

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

[0028] The Completely Fair Scheduler (CFS) calculates the virtual runtime, also called 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 has not been executed will remain unchanged. Therefore, the scheduler selects the scheduling entity with the smallest vruntime to execute in order to achieve a fair state. For different scheduling entities, the vruntime of a 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 vruntime of the scheduling entity and the min_vruntime snapshot of cfs_rq cannot fairly evaluate the priority gap between the highest priority tasks of each logical processor.

[0029] In view of this, in order to address the problems existing in the above-mentioned scheduling mechanism, the present specification provides a scheduling method. Since the 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 value of the kernel virtual runtimes of multiple scheduling entities corresponding to the scheduling node corresponding to the group scheduling entity in the running queues of multiple logical processors, so that 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 value of the virtual runtime based on its own scheduling entity, and cannot fairly maintain the priority gap between tasks of each logical processor.

[0030] Specifically, in this specification, a scheduling method is provided. This specification also relates to 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.

[0031] See also Figure 2 , Figure 2FIG. 1 is a schematic diagram showing an application scenario of a scheduling method provided according to an embodiment of this specification. Figure 2 As shown, 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 Figure 2 The logical processor 1 and the logical processor 2 are shown. The scheduler 200 can be understood as the core of the operating system, which is a resident program in the memory. The scheduling method provided in the embodiment of this specification determines the priority of the scheduling entity so that tasks with higher priority occupy the physical processor. Figure 2 In the example, the group scheduling entity is represented as “group se” and the task scheduling entity is represented as “task se”.

[0032] Specifically, the object managed by the scheduler 200 is the scheduling entity in the running queue. The running queue can be represented as a tree data structure. Figure 2 As shown, logical processor 1 corresponds to the operation queue 210 of the tree data structure, and logical processor 2 corresponds to the operation queue 220 of the tree data structure. The scheduler 200 uses the virtual operation time reference value corresponding to the group scheduling entity to which any scheduling entity belongs to update the kernel virtual operation time corresponding to any scheduling entity. For example, when the virtual operation time of the scheduling entity 2102 is updated, the kernel virtual operation time of the scheduling entity 2102 is updated using the virtual operation time reference value corresponding to the group scheduling entity 2104 to which it belongs. Among them, the virtual operation time reference value corresponding to the group scheduling entity 2104 is determined by comparing the kernel virtual operation 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 according to the preset search condition, and search for the second ancestor of the second scheduling entity in the running queue of the second logical processor. 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, and based on the more fair kernel virtual running time, the priority of the first scheduling entity and the second scheduling entity can be more fairly determined, thereby achieving the purpose of improving the fairness of the scheduling mechanism.

[0033] The computing node may be a physical server or cloud server that provides various services in the cloud. For example, it may be a server that provides communication services, data processing services, computing services, storage services, database services and other services to multiple clients. It should be noted that the computing node in the cloud can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server may also be a server of a distributed system, or a server combined with a blockchain. The server may also be a cloud server for 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 distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

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

[0035] See also Figure 3 , Figure 3 A flowchart of a scheduling method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0036] Step 302: Use the virtual runtime baseline 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 baseline 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.

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

[0038] The kernel virtual runtime can be understood as a parameter for maintaining the position of the scheduling entity in the entire run queue of the 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. When the kernel virtual runtime is updated, it is updated based on the virtual runtime reference value corresponding to the group scheduling entity in some cases, and based on the virtual runtime reference value corresponding to the group scheduling entity and the change amount of the virtual runtime in other cases. For example, the kernel virtual runtime can be updated at the same time as the virtual runtime of the scheduling entity is updated. The increment of the kernel virtual runtime of the scheduling entity is determined according to the increment of its virtual runtime, such as directly increasing according to the increment of the virtual runtime, and using the virtual runtime reference value to punish or compensate according to the actual situation. Specifically, when a scheduling event occurs, some functions for calculating time differences can be used to update the virtual runtime of the currently running scheduling entity and update the kernel virtual runtime, wherein the function for calculating time differences can calculate the increment of virtual runtime based on actual runtime and weight.

[0039] The virtual runtime benchmark value is the minimum granularity for punishing or compensating the kernel virtual runtime of a scheduling entity. In the method provided in the embodiment 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 running queue of multiple logical processors, the virtual runtime benchmark value is used as the minimum granularity to punish or compensate the kernel virtual runtime of the scheduling entity, and can continuously maintain the priority gap between the various scheduling entities 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.

[0040] It should be noted that the running 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 running queue of a logical processor, the group of scheduling entities corresponds to a scheduling node leading a subqueue in the current running queue, and the same position in the running queues of other logical processors of the same physical processor is also a scheduling node leading a subqueue. Therefore, the scheduling nodes corresponding to the group scheduling entity can find the scheduling entities corresponding to the scheduling nodes at the same position in the running queues of multiple logical processors, and these scheduling entities are all the scheduling entities corresponding to the scheduling nodes corresponding to the group scheduling entity in the running queues of multiple logical processors. For example, Figure 2The scheduling node corresponding to the group scheduling entity 2104 shown, and the corresponding scheduling entities in the running queues of logical processor 1 and logical processor 2 include each scheduling entity in queue 2106 and each scheduling entity in queue 2108 .

[0041] Step 304: For the first scheduling entity of the first logical processor and the second scheduling entity of the second logical processor, according to a preset search condition, search for a first ancestor of the first scheduling entity in the running queue of the first logical processor, and search for a second ancestor of the second scheduling entity in the running 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.

[0042] It can be understood 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.

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

[0044] Step 306: 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.

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

[0046] It can be seen that since the kernel virtual runtime corresponding to any scheduling entity in the scheduling method, the virtual runtime benchmark value used as penalty or compensation when updated is a benchmark value obtained by taking the minimum value of the kernel virtual runtime of each scheduling entity under the same scheduling node of multiple logical processors across the entire physical processor, the 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 use the benchmark value to continuously and fairly maintain the priority that the scheduling entity should have in the running queue of the entire physical processor, thereby avoiding the unfairness caused by the running queue of a single logical processor determining the minimum value of the virtual runtime based 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 according to the preset search condition, and the second ancestor of the second scheduling entity can be searched in the running queue of the second logical processor. 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.

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

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

[0049] 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;

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

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

[0052] 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 logical processors of the same physical processor. Figure 2As shown, 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 all lead a cfs_rq. Each cfs_rq's own root node and each scheduling entity's corresponding scheduling node have their own node information recording area, which records the relevant scheduling detail information. For example, the node information of the root node of each cfs_rq may include relevant information of the child nodes in the queue, such as the node order, the number of nodes, etc. For example, the node information of each scheduling entity may 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 of the same physical processor have the same tree data structure. Each scheduling entity can find a scheduling node in the same position 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 Figure 2 As shown, 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 leads a cfs_rq, it can also be understood that for the logical processors of the same physical processor, for each cfs_rq in the run queue of each logical processor, a pointer core pointing to the corresponding cfs_rq in the run queue of the target logical processor is maintained. Figure 2 As shown, assuming that logical processor 2 is selected as the target logical processor, for each cfs_rq in the run queue of logical processor 1, a pointer core pointing to the corresponding cfs_rq in the run queue of the target logical processor is maintained, such as the cfs_rq (i.e., the cfs_rq led by group scheduling entity 2104) Figure 2 The queue 2106 shown sets the pointer core to point to the corresponding cfs_rq in logical processor 2, that is, queue 2108.

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

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

[0055] 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;

[0056] Compare the kernel virtual running times recorded by the multiple child nodes to find the minimum value therein;

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

[0058] 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 the scheduling entity will be updated accordingly. If the kernel virtual runtime changes, the virtual runtime benchmark value can start the update process at that time. Figure 2 As shown, assuming that logical processor 2 is the target logical processor, the kernel virtual runtime of the scheduling entities corresponding to queues 2106 and 2108 is recorded in the node information of each queue 2108. Therefore, when the virtual runtime benchmark value of the group scheduling entity 2104 needs to be updated, all the kernel virtual runtimes that need to be compared can be found from the node information of each node of queue 2108, and the minimum value can be found. It can be understood that since group scheduling entity 2104 and group scheduling entity 2112 belong to the same scheduling level in the two running queues, the corresponding virtual runtime benchmark value is the benchmark of the scheduling entity under the same scheduling level across the entire physical processor, and therefore, the virtual runtime benchmark values ​​of group scheduling entity 2104 and group scheduling entity 2112 are the same.

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

[0060] 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:

[0061] 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;

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

[0063] For example, Figure 2 As shown, the virtual runtime benchmark values ​​core_min_vruntime corresponding to the group scheduling entity 2104 and the group scheduling entity 2112 may be recorded in the node information of the root node of the cfs_rq led by the group scheduling entity 2112. When the virtual runtime benchmark value of the group scheduling entity 2104 needs to be obtained, the virtual runtime benchmark value is read from the node information of the root node of the cfs_rq led by the group scheduling entity 2112.

[0064] In this embodiment, the virtual runtime baseline 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 on multiple run queues. Only one run queue is required to execute recording and search, which effectively reduces the overhead of recording and searching the virtual runtime baseline value of the scheduling entity and improves the scheduling efficiency.

[0065] It should be noted that the above one or more embodiments record and search for the kernel virtual running time and the virtual running time baseline value by selecting the running queue of the target logical processor. This is only 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 for the kernel virtual running time and the virtual running time baseline value according to the needs of the scenario, and this specification does not limit this.

[0066] The scheduling method provided in the embodiment of this specification updates the kernel virtual runtime corresponding to the scheduling entity based on the virtual runtime reference value, and in order to make the scheduling mechanism more fair, different updating methods can be adopted for different situations. The following is an exemplary description of several possible implementation methods:

[0067] In one or more embodiments of the present specification, for the situation where a scheduling entity enters and exits a running queue, a virtual running time reference value is used to punish / compensate the kernel virtual running time. Specifically, using the virtual running time reference value corresponding to a scheduling entity in the group to which any scheduling entity belongs to update the kernel virtual running time corresponding to any scheduling entity, includes:

[0068] 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;

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

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

[0071] When a scheduling entity enters the run queue, by adding the virtual run time reference value, the kernel virtual run time of the scheduling entity that has just entered the queue is penalized, thereby maintaining the fairness of other scheduling entities that are already queued in the run queue. For example, suppose that the current kernel virtual run time of the A scheduling entity that has just been awakened in a logical processor is 100, and the virtual run time reference value of the group scheduling entity corresponding to the subqueue to be added is 50. When the A scheduling entity enters the run queue of the logical processor, the B scheduling entity of another logical processor belonging to the same physical processor is already queued in the run queue, and the kernel virtual run time is 100. At this time, since the kernel virtual run time of the A scheduling entity is also 100, if no penalty is imposed when entering the queue, it will cause competition for the physical processor allocated to the B scheduling entity. If the B scheduling entity cannot run first when it has been queued for a long time, there will be a certain degree of unfairness. 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 baseline value, so that the kernel virtual running time of scheduling entity A is less than that of scheduling entity B, thereby ensuring the fairness of priority operation of scheduling entity B, thereby maintaining the priority gap between the various scheduling entities on the entire physical processor.

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

[0073] In this embodiment, when the scheduling entity leaves the running queue, the kernel virtual running time of the scheduling entity that has just left the queue is compensated by adding the increment of the virtual running time and subtracting the virtual running time reference value, thereby ensuring the fairness of the scheduling entity itself and maintaining the fairness of the scheduling entity itself when the scheduling entity re-enters the queue. For example, assuming that the current kernel virtual running time of the A scheduling entity of a logical processor is 150, and the virtual running time reference value of the scheduling entity in its group is 50, when the A scheduling entity leaves the running queue, the kernel virtual running time 150 is added to the increment of its virtual running time 100 and then subtracted from the virtual running time reference value, then the kernel virtual running time updated by the A scheduling entity is 200.

[0074] In one or more embodiments of the present specification, in the case where a scheduling entity creates a new subprocess / thread task, in order to prevent the scheduling entity corresponding to the newly created subprocess / thread task from inheriting the kernel virtual runtime of the currently running scheduling entity, causing it to easily obtain the 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 benchmark value, and the newly created scheduling entity has not yet entered the queue, the virtual runtime benchmark value is subtracted from the kernel virtual runtime of the newly created scheduling entity to ensure fairness when the newly created scheduling entity enters the queue. Specifically, the use of 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:

[0075] 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;

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

[0077] 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;

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

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

[0080] 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, and this specification will not go into details here.

[0081] In addition, in view of the fact that the newly created scheduling entity may have a flag bit for 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:

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

[0083] The flag indicating the priority operation can be indicated in any manner, for example, the flag indicating the priority operation 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 there is a flag indicating the priority operation, and when the value is false, it indicates that there is no flag indicating the priority operation. By exchanging the kernel virtual running time of the two through this embodiment, the priority running right of the child process / thread that needs to be run first is guaranteed.

[0084] In one or more embodiments of the present specification, when a scheduling entity is awakened, there is a scheduling entity that has been sleeping for too long, and it is difficult to run due to its large kernel virtual running time. A preset sleep time threshold is set, and a virtual running time reference value is assigned to the scheduling entity that has been sleeping for too long as the kernel virtual running time, so that the scheduling entity that has been sleeping for too long can obtain a higher priority and run as soon as possible, thereby ensuring fairness for the scheduling entity that has been forced to idle and has been sleeping for too long. Specifically, the use of the virtual running time reference value corresponding to the scheduling entity of the group to which any scheduling entity belongs to, to update the kernel virtual running time corresponding to any scheduling entity, includes:

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

[0086] The specific value of the preset sleep time threshold can be set according to the application scenario, and this specification does not limit this. 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 benchmark value of the scheduling entity in the group.

[0087] For example, suppose the kernel scheduler needs to select the task with the highest priority from two or more HTs to run. Due to the characteristics of the kernel scheduler itself, tasks with different cookies (a cache file) are not allowed to run on the same physical processor at the same time. Therefore, the kernel scheduler uses a forced idle mechanism to prevent tasks with different cookies (a cache file) from running on the same physical processor at the same time. 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 on the two HTs of the same physical processor at the same time as A1 or A2. Assuming that task B has a higher priority and occupies the physical processor to run, 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 a 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-term sleep state and cannot run. To address this problem, according to the method provided in this embodiment, although A1 runs for a very short time each time, when A2 sleeps for a long time exceeding the preset sleep time threshold, the kernel virtual running time of A2 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.

[0088] In one or more embodiments of this specification, another unfair situation is solved by updating the kernel virtual runtime using the virtual runtime benchmark value. Specifically, assuming that the virtual runtime of a dormant process remains unchanged, while the virtual runtime of other running processes is constantly advancing, then when the dormant process finally wakes up, its virtual runtime is much smaller than 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 embodiment 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 use of 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, including:

[0089] 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;

[0090] 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;

[0091] 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;

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

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

[0094] For another 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 20, 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 greater than its current kernel virtual runtime, the updated kernel virtual runtime is 30.

[0095] 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 priority gap between scheduling entities and further ensuring fairness.

[0096] Corresponding to the above method embodiment, this specification also provides a scheduling device embodiment, Figure 4 FIG. 1 shows a schematic diagram of a scheduling device provided by an embodiment of the present specification. Figure 4 As shown, the device comprises:

[0097] The update module 402 is configured to update the kernel virtual runtime corresponding to any scheduling entity by 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.

[0098] The ancestor search module 404 is configured to search for a first ancestor of the first scheduling entity in the running queue of the first logical processor and a second scheduling entity of the second 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.

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

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

[0101] The queue update submodule is configured to add the kernel virtual runtime currently corresponding to any scheduling entity and the virtual runtime reference value corresponding to the group scheduling entity when any scheduling entity enters the running queue, so as to obtain the kernel virtual runtime updated by any scheduling entity;

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

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

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

[0105] 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 running time corresponding to any scheduling entity to obtain an updated kernel virtual running time of any scheduling entity;

[0106] A new compensation submodule is created, which is 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.

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

[0108] The exchange submodule is configured to exchange the kernel virtual running time 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 running time of the currently running scheduling entity is less than the kernel virtual running time updated by any of the scheduling entities.

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

[0110] The wake-up compensation submodule is configured to use the virtual runtime reference value corresponding to the group of scheduling entities 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.

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

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

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

[0114] A wake-up temporary compensation submodule is configured to determine, if any of the scheduling entities is not a newly created task, 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 running time of the any of the scheduling entities to obtain an updated temporary kernel virtual running time;

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

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

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

[0118] 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;

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

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

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

[0122] A runtime search module is configured to search, for the group scheduling entity, for the kernel virtual runtime recorded in the run queue of the target logical processor, for the kernel virtual runtime recorded in multiple sub-nodes under the scheduling node corresponding to the group scheduling entity;

[0123] A minimum value search module is configured to compare the kernel virtual running times recorded by the plurality of child nodes to find the minimum value therein;

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

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

[0126] a reference value recording module configured to record 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;

[0127] 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 it is necessary to update the kernel virtual runtime corresponding to any scheduling entity.

[0128] 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, and the details not described in detail in the technical scheme of the scheduling device can be found in the description of the technical scheme of the scheduling method described above.

[0129] Corresponding to the above method embodiment, this specification also provides a scheduling system embodiment. Figure 5 FIG. 1 shows a schematic diagram of a scheduling system provided by an embodiment of the present specification. Figure 5 As shown, the scheduling system includes:

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

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

[0132] 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, and the details not described in detail in the technical scheme of the scheduling system can be found in the description of the technical scheme of the scheduling method described above.

[0133] Figure 6 The block diagram of a computing device 600 according to an embodiment of the present specification is shown. The 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 the database 650 is used to store data.

[0134] 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 these 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)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0135] In one embodiment of the present specification, the above components of the computing device 600 and Figure 6 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 6 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0136] The 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, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 600 may also be a mobile or stationary server.

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

[0138] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above scheduling method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above scheduling method.

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

[0140] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above scheduling method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above scheduling method.

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

[0142] 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, and the details not described in detail in the technical solution of the computer program can be found in the description of the technical solution of the scheduling method described above.

[0143] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0144] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. 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, etc. 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 do not include electric carrier signals and telecommunication signals.

[0145] It should be noted that, for the above-mentioned 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, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

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

[0147] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to 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 technicians in the relevant technical field can well understand and use this specification. This specification is only limited 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.