WO2022068697A1 - 任务调度方法及装置 - Google Patents
任务调度方法及装置 Download PDFInfo
- Publication number
- WO2022068697A1 WO2022068697A1 PCT/CN2021/120360 CN2021120360W WO2022068697A1 WO 2022068697 A1 WO2022068697 A1 WO 2022068697A1 CN 2021120360 W CN2021120360 W CN 2021120360W WO 2022068697 A1 WO2022068697 A1 WO 2022068697A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- task
- priority
- virtual machine
- scheduler
- tasks
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5019—Workload prediction
Definitions
- the present application relates to the field of computer technology, and in particular, to a task scheduling method and device.
- virtual machine technology allows a server to execute multiple operating systems at the same time, and each operating system can be used as a virtual machine to execute in an independent environment without affecting each other. Therefore, more and more service providers provide virtual machine services, and users can use the computing services provided by the virtual machines of the service providers.
- the service provider since the virtual machines used by different users can be executed on the same server, the utilization rate of the server deployed by the service provider is greatly improved.
- a user uses a virtual machine provided by a service provider, he or she usually applies for virtual machine resources according to the peak of the required calculation amount, and the service provider will also divide the server resources to different virtual machines according to the peak of the calculation amount.
- the user usually does not use all the virtual machine resources applied for by the user, resulting in a low utilization rate of the virtual machine resources allocated by the server to each user.
- a scheduler can be set in the server to uniformly manage and schedule the tasks that need to be executed in the virtual machine resources. 1.
- the scheduler manages the tasks executed in the virtual machine through a completely fair scheduling policy, wherein the scheduler assigns different tasks to all tasks executed in the virtual machine according to the priority weight value of each task Execution time to ensure that all tasks are executed.
- this kind of scheduler can only ensure that tasks with higher priorities are allocated more execution time, but cannot guarantee that tasks with higher priorities are scheduled first, and cannot guarantee that tasks with higher priorities preempt the execution of tasks with lower priorities.
- the scheduler manages the tasks executed in the virtual through the real-time scheduler strategy, wherein the scheduler executes the one of the highest priority tasks that enters the queue first according to the priorities of all tasks. , or take turns executing multiple tasks of the highest priority.
- this kind of scheduler can only execute tasks with lower priorities after tasks with higher priorities are executed, so it cannot guarantee the fairness of task scheduling with the same priority, and cannot solve the problem of starvation of tasks with lower priorities caused by scheduling. .
- both the completely fair scheduling strategy and the real-time scheduler strategy have their own shortcomings.
- a virtual machine When a virtual machine can execute different types of tasks, it cannot simultaneously satisfy the priority of scheduling high-priority tasks and guarantees. Low priority tasks are also scheduled fairly. Therefore, how to design a scheduler so that when the scheduler can be used to schedule tasks of different priorities executed on a virtual machine, can also satisfy the fairness of the scheduling, is a technical problem that needs to be solved urgently in the art.
- the present application provides a task scheduling method and device, so that when scheduling tasks to be executed of a virtual machine, the scheduler can not only ensure that tasks with high priority are scheduled preferentially, but also satisfy the fairness of tasks with the same priority. .
- a first aspect of the present application provides a task scheduling method, which is used when a scheduler schedules a task to be executed by a first target virtual machine, while meeting the priority requirement of the scheduled task and at the same time ensuring fair scheduling of the task .
- the scheduler when scheduling the task to be executed by the first target virtual machine, the scheduler first obtains at least one task with the highest priority in the task queue to be executed by the first target virtual machine, so as to ensure that the task with the highest priority is executed first, and then In at least one task with the highest priority, the first task with the smallest virtual running time is further determined, and finally the first target virtual machine is controlled to execute the first task, so as to ensure the fair scheduling of tasks in at least one task with the same priority, and also That is to say, this embodiment can realize that when the scheduler can schedule tasks on the first target virtual machine, it can not only ensure that tasks with high priority are scheduled preferentially, but also satisfy the fairness when scheduling tasks of the same priority.
- the scheduler serving as the execution body can schedule multiple virtual machines at the same time, and when scheduling the task executed by the first target virtual machine in the multiple virtual machines, the scheduler can pass A first scheduler implementation that controls the first target virtual machine.
- the scheduler may determine the priorities of multiple tasks to be executed by the first target virtual machine through the queue of tasks to be executed stored in the first scheduler.
- the scheduler is controlling the first target virtual machine to execute the first task.
- the first task can be adjusted to the front of the to-be-executed task queue by adjusting the order of the to-be-executed task queue in the first scheduler.
- the present application provides at least the following three specific implementations:
- the scheduler may After acquiring all tasks in the task queue to be executed from the first scheduler, the priorities corresponding to all tasks are determined, and at least one task with the highest priority is finally determined.
- the first scheduler when the first scheduler schedules tasks to be executed on the first target virtual machine, in addition to storing all tasks to be executed, it also stores all tasks in the queue.
- the priority is recorded, for example, in a table. Then, when determining the priority of the task to be executed by the first target virtual machine, the scheduler can directly obtain the priority corresponding to all the tasks from the table instead of obtaining each task itself, thereby reducing the amount of calculation and improving the efficiency.
- the scheduler when the first scheduler schedules tasks to be executed on the first target virtual machine, different multiple queues may be set to store tasks, and each Queues are stored in queues with different priorities. Then, when the scheduler determines at least one task with the highest priority among the tasks to be executed by the first target virtual machine, it can directly obtain the at least one task from the queue with the highest priority stored in the first scheduler without processing other tasks. Tasks with other priorities on the queue can also reduce the amount of calculation and improve efficiency.
- a second aspect of the present application provides a task scheduling method.
- the scheduler schedules a first target virtual machine to execute a task
- the scheduler will The priority of the task after the priority adjustment is adjusted, and the virtual running time of the task is adjusted to realize the preemption of the currently executed task of the first target virtual machine by the high-priority task, so as to meet the dynamic performance of the task execution of the first target virtual machine. schedule.
- the first target virtual machine is executing the third task
- the priority of the second task is adjusted among the tasks to be executed by the first target virtual machine at this time, for example, the second priority is adjusted to the first priority
- the virtual running time of the second task is adjusted according to the minimum virtual machine running time of at least one task to be executed by the first target virtual machine with the same priority as the first, for example, from the first virtual running time to the first virtual running time Second virtual running time
- the scheduler immediately controls the first target virtual machine to execute the second task, thereby realizing the effect of the second task on the first target virtual machine
- the preemptive execution of the currently executing task realizes the dynamic scheduling of the task.
- the adjustment target is to adjust the adjusted second virtual running time to be greater than all the pending virtual machines of the first target virtual machine.
- the virtual running time of the at least one task corresponding to the first priority is the smallest virtual running time. That is to say, the virtual running time of the second task is adjusted so that the virtual running time of the second task is as small as possible, but cannot be smaller than the smallest virtual running time in the same priority.
- the scheduler specifically determines that the priority of the second task needs to be adjusted according to the instruction information sent by the user, so that after the user adjusts the task to be executed on the first target virtual machine through the scheduler,
- the scheduler can adjust the virtual running time of the task, realize the dynamic adjustment of the task by the user, enrich the application scenarios, and improve the user experience.
- the scheduler when the scheduler adjusts the virtual running time of the second task, the scheduler specifically adds the first virtual running time Ta before the adjustment of the second task to the smallest among the same priorities.
- the virtual running time is adjusted to the second virtual running time, so that the adjusted second virtual running time is slightly larger than the minimum value of the virtual running time in at least one task of the first priority in the task corresponding to the first priority.
- a third aspect of the present application provides a task scheduling method, which is applied to when a scheduler schedules tasks in a first target virtual machine, when there are low-priority tasks in the to-be-running task queue of the first target virtual machine, the In the case of execution, low-priority tasks can be actively migrated to other virtual machines (referred to as the second target virtual machine) for execution, thereby preventing the first target virtual machine from executing tasks with multiple priorities, prioritizing high-priority scheduling. high-priority tasks in turn lead to starvation of low-priority tasks.
- the scheduler when the first target virtual machine executes the fourth task, the scheduler simultaneously obtains the time record information of the fourth task in the first scheduler of the first target virtual machine, and according to the time record information It is determined whether there is a starvation problem in the five tasks. After the time record information meets the preset conditions, the first scheduler that controls the first target virtual machine sends the fifth task to the second scheduler of the second target virtual machine, so that the second target virtual machine The virtual machine executes the fifth task, thereby realizing the scheduling of the fifth task among different virtual machines, so that the fifth task will not stay in the pending execution queue of the first scheduler because of its low priority, preventing starvation problem occurs.
- time record information may include at least the following two possible implementations:
- a possible implementation of the time recording information is: it can be used to record the execution time when the first target virtual machine has executed the fourth task, and the preset condition may be the execution time of the fourth task less than the first threshold. Among them, it can prevent that because the priority of the fourth task is higher, the fifth task at a lower priority cannot be executed all the time, which will lead to the starvation problem of the fifth task. Therefore, the scheduler can determine that the execution time of the fourth task is greater than After the first threshold is met and the preset condition is satisfied, the second target virtual machine is scheduled to execute the fifth task.
- time recording information for recording the waiting time of the fifth task in the to-be-executed task queue of the first scheduler, the preset condition may be The waiting time of the fifth task is greater than the second threshold. Also in order to prevent the starvation problem of the fifth task, the scheduler may schedule the second target virtual machine to execute the fifth task after determining that the waiting time of the fifth task is greater than the second threshold and satisfying the preset condition.
- the second target virtual machine may be selected with reference to a certain standard.
- the second target virtual machine may be determined in the following order: first select the virtual machine in the idle state in the cloud server, and secondly select the task priority on the scheduling queue of the virtual machine in the cloud server Lower and lightly loaded virtual machines, again select a task on the scheduling queue of a virtual machine in a cloud server with a lower priority but a heavier load / a task on the scheduling queue of a virtual machine in a server with a higher priority but Lightly loaded virtual machines.
- the second target virtual machine may also be a virtual machine specially set in the cloud server, and the virtual machine is specially used to execute the scheduler from other A task scheduled by a virtual machine, and when not scheduled by the scheduler, the virtual machine will not perform other tasks.
- a fourth aspect of the present application provides a task scheduling apparatus, which can be used to execute the task scheduling method of the first aspect of the present application.
- the apparatus includes an acquisition module, a priority determination module, a virtual runtime determination module, and a control module.
- the obtaining module is used to obtain the priorities of multiple tasks to be executed by the first target virtual machine;
- the priority determination module is used to determine at least one task with the highest priority among the multiple tasks;
- the virtual runtime determination module is used to start from at least one task In one task, the first task with the smallest virtual running time is determined;
- the control module is used to control the first target virtual machine to execute the first task.
- the obtaining module is specifically configured to, according to the queue of tasks to be executed stored by the first scheduler in the first target virtual machine, determine the number of tasks to be executed by the first target virtual machine. priority.
- the obtaining module is specifically configured to traverse the priorities of all tasks on the queue of tasks to be executed stored by the first scheduler, and determine at least one task with the highest priority from the queue of tasks to be executed Task.
- the acquisition module is specifically configured to determine at least one task with the highest priority among the multiple tasks by using the priority record information stored in the first scheduler; wherein, the priority record information is used for It is used to record the priorities of all tasks on the queue of tasks to be executed by the first scheduler.
- the obtaining module is specifically configured to determine at least one task with the highest priority according to the tasks in the queue corresponding to the highest priority stored in the first scheduler; wherein, the first scheduler Tasks to be executed are stored in multiple queues, and each queue corresponds to a different priority.
- a fifth aspect of the present application provides an apparatus for adjusting task priority, which can be used to execute the task scheduling method provided in the second aspect of the present application.
- the apparatus includes an acquisition module, a virtual runtime adjustment module, and a control module.
- the obtaining module is configured to obtain at least one task to be executed by the first target virtual machine that is the same as the first priority when the priority of the second task to be executed by the first target virtual machine is adjusted from the second priority to the first priority.
- the minimum virtual running time corresponding to at least one task is configured to adjust the first virtual running time corresponding to the second task to the second virtual running time according to the minimum virtual running time; the control module is used to control the first target virtual machine to execute the second task when the first priority is higher than the priority of the third task being executed by the first target virtual machine.
- the second virtual running time is greater than the minimum virtual running time of at least one task corresponding to the first priority in the queue of tasks to be executed stored by the first scheduler of the first target virtual machine. virtual runtime.
- the task scheduling apparatus further includes: a receiving module, configured to receive indication information, and according to the indication information, determine that the priority of the second task is adjusted from the second priority to the first priority class.
- the virtual time adjustment module is specifically configured to add the first virtual running time to the minimum virtual running time, and then subtract at least one corresponding first priority in the queue of tasks to be executed.
- the smallest virtual running time among the virtual running times of the task is to obtain the second virtual running time.
- a sixth aspect of the present application provides a task scheduling apparatus, which can be used to execute the task scheduling method provided in the third aspect of the present application, and the apparatus includes: an acquisition module and a control module.
- the obtaining module is used to obtain the time record information stored by the first scheduler of the first target virtual machine; wherein, the time record information is used to record the execution time of the fourth task, the fourth task corresponds to the third priority, or the time The record information is used to record the waiting time of the fifth task in the to-be-executed task queue stored by the first scheduler, and the priority corresponding to the fifth task is lower than the third priority;
- the control module is used for when the time record information satisfies the preset condition , controlling the first scheduler of the first target virtual machine to send the fifth task to the second scheduler of the second target virtual machine, so that the second target virtual machine executes the fifth task.
- the preset condition when the time recording information is used to record the execution time of the fourth task, the preset condition includes: the execution time of the fourth task is greater than the first threshold.
- the preset condition when the time record information records the waiting time of the fifth task in the to-be-executed task queue of the first scheduler, includes: the waiting time is greater than the second threshold.
- the second target virtual machine is a virtual machine in an idle state among multiple virtual machines deployed by the host where the first target virtual machine is located; or, the second target virtual machine is a multiple virtual machine deployed by the host.
- the virtual machines a virtual machine whose load is less than the third threshold; or, the second target virtual machine is a scheduler used to execute a task with a fourth priority among multiple virtual machines deployed by the host, where the fourth priority is lower than third priority.
- the second target virtual machine is a scheduler dedicated to executing the fifth task when the time record information satisfies a preset condition.
- a seventh aspect of the present application provides an electronic device, including: a processor and a communication interface.
- the communication interface is used to realize the connection communication between the communication device and the peripheral device.
- the processor is configured to implement the method described in any one of the first aspect, the second aspect or the third aspect.
- the above communication device further includes: a memory.
- the memory is used to store a computer program, and the processor executes the computer program stored in the memory, so that the apparatus executes the method of any one of the first aspect, the second aspect or the third aspect.
- An eighth aspect of the present application provides a chip, including: a processor and a communication interface;
- the communication interface is used to communicate with other devices
- the processor is configured to read instructions to implement the method according to any of the above first, second or third aspects.
- a ninth aspect of the present application provides a computer program product, the computer program product includes computer program code, and when the computer program code is executed by a computer, causes the computer to execute the above-mentioned first aspect, second aspect or third aspect The method of any of the aspects.
- 1 is a schematic diagram of an application scenario of the application
- FIG. 2 is a schematic structural diagram of a cloud server using a virtual machine structure
- FIG. 3 is a schematic diagram of a module in which a cloud server schedules a virtual machine
- Figure 4 is a schematic diagram of the working principle of the completely fair scheduler
- Figure 5 is a schematic diagram of the working principle of the real-time scheduler
- FIG. 6 is a schematic structural diagram of a cloud server to which a task scheduling method provided by the present application is applied;
- FIG. 7 is a schematic diagram of the deployment of a cloud server cluster provided by the present application.
- FIG. 8 is a schematic flowchart of an embodiment of a task scheduling method provided by the present application.
- FIG. 9 is a schematic diagram of a scheduling process in the task scheduling method provided by the present application.
- FIG. 10 is a schematic flowchart of an embodiment of a task scheduling method provided by the present application.
- FIG. 11 is a schematic diagram of a scheduling process in the task scheduling method provided by the present application.
- FIG. 12 is a schematic flowchart of an embodiment of a task scheduling method provided by the present application.
- FIG. 13 is a schematic flowchart of an embodiment of a task scheduling method provided by the present application.
- FIG. 14 is a schematic diagram of a scheduling process in the task scheduling method provided by the present application.
- 15 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the application.
- 16 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the present application.
- FIG. 17 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the present application.
- FIG. 18 is a schematic structural diagram of an embodiment of an electronic device provided by the present application.
- FIG. 1 is a schematic diagram of an application scenario of the application, wherein the application is applied in the field of hybrid deployment of data centers.
- a provider of cloud computing services can set up multiple cloud servers in the Internet 2 3.
- the cloud server 3 provides computing services.
- the cloud computing service provided by the cloud server 3 can be obtained by directly using it, or applying to the supplier, or paying a certain fee to the supplier.
- the terminal device 1 used by the user performs computational tasks such as gene sequencing
- the computing power provided by the CPU of the terminal device 1 alone may take several days to calculate, which is inefficient.
- the user can use the cloud server 3 computing resources (such as CPU) to perform the computing task of gene sequencing, so that the terminal device 1 can obtain the computing result of gene sequencing in a few minutes or less, so that the user can obtain higher computing efficiency, and at the same time,
- the server 3 set in the Internet 2 for computing can also allow users to use more computing resources without the need to specially install and upgrade the terminal equipment 1 they use, and also reduce the economics of computing for users cost. Since the computing resources used by the user are provided by the cloud server 3 provided by the supplier on the network side, this scenario of using network resources for computing can also be referred to as "cloud computing".
- FIG. 2 is a schematic structural diagram of a cloud server using a virtual machine structure.
- the supplier Taking the cloud server 3 in the scenario shown in FIG. 1 as an example, the supplier’s system resources (for example, CPU, memory, An operating system (the operating system may also be called a host operating system (host OS), such as Linux, etc.) is installed on the basis of a hard disk, etc.), and different virtual machines can be executed in the operating system.
- system resources for example, CPU, memory
- An operating system the operating system may also be called a host operating system (host OS), such as Linux, etc.
- host OS host operating system
- different virtual machines can be executed in the operating system.
- the computing resources requested by the terminal device 11 may account for 30% of the CPU computing capacity in the system resources of the cloud server 3, and the terminal device 12 requests to use
- the computing resources of the cloud server 3 can account for 50% of the CPU computing power in the cloud server 3 system resources
- the computing resources requested by the terminal device 13 can account for 20% of the CPU computing power in the cloud server 3 system resources.
- the calculation amount required by the three terminal devices it is divided into three parts according to the proportion, and a virtual machine is executed in each of the three parts of system resources, which is denoted as virtual machine 1-3.
- the terminal device 11 can use the virtual machine 1 provided by the cloud server 3 for computing
- the terminal device 12 can use the virtual machine 2 provided by the cloud server 3 for computing
- the terminal device 13 can use the virtual machine 3 provided by the cloud server 3 for computing
- each user can operate the corresponding virtual machine as if using a physical machine, and each virtual machine uses part of its corresponding system resources to execute without affecting each other.
- the utilization rate of the resource is usually not considered, and the computing resource is applied according to the maximum peak value of the required computing amount.
- the cloud server 3 shown in Figure 2 most of the system resources allocated to the virtual machine are not used, and are often in an idle state.
- the utilization rate is less than 20%, and the cost of the CPU accounts for more than 40% of the hardware cost of the single board of the cloud server 3. Therefore, the provider of the cloud server 3, in order to improve the utilization rate of the system resources of the cloud server 3, save on the Internet 2
- the number of cloud servers 3 set in can be used to provide services to other users when the resources that have been allocated to users are idle.
- the cloud server shown in Figure 2 when 50% of the system resources applied for by virtual machine 2 are idle, they can be allocated to virtual machine 4 for use. For users using virtual machine 2 and virtual machine 4, Each of them applies to the provider for 50% of the system resources of the cloud server 3, and the provider can understand that the same system resources are used to satisfy the system resources applied for by the virtual machine 2 and the virtual machine 4 at the same time.
- the shared method improves the utilization efficiency of the system resources of the cloud server 3 .
- FIG. 3 is a schematic diagram of a module for a cloud server to schedule virtual machines
- FIG. 3 shows a scheduler set in the cloud server, wherein the cloud server may include a main scheduler and a periodic scheduler, The main scheduler is used to directly schedule tasks, and the periodic scheduler is used to execute tasks at a fixed frequency, which is used to periodically schedule tasks.
- the combination of the two can form the core scheduler of the cloud server, also known as the core scheduler.
- the core scheduler of the cloud server schedules any virtual machine set in the cloud server as an example.
- the task to be executed is task 1 - Task N.
- the core scheduler first calls scheduler classes such as completely fair scheduler (CFS), RRS (round-robin) or first in, first out (FIFO) through step 1.
- CFS completely fair scheduler
- RRS round-robin
- FIFO first in, first out
- Each scheduler class can schedule tasks according to different scheduling rules.
- the core scheduler instructs the virtual machine by context switching through step 3.
- the target task that should be executed in step 4 so as to realize the scheduling of the execution sequence of the tasks executed by the virtual machine.
- the existing scheduler classes can be divided into at least two different types, a completely fair scheduler (CFS) and a real-time scheduler (RR, FIFO, or Deadline, etc.), which will be described separately below.
- CFS completely fair scheduler
- RR real-time scheduler
- FIG 4 is a schematic diagram of the working principle of the completely fair scheduler.
- the CFS scheduler class When the core scheduler calls the CFS scheduler class to schedule the tasks 1, 2 and 3 to be executed by the virtual machine, the CFS scheduler class first assigns the virtual machine The execution time is divided into different continuous time slices according to the time axis, such as time slice 1, time slice 2 in Figure 4... Then, in each time slice, the execution time of the three tasks is allocated according to the weight of each task , to ensure that each task will be executed in the time period composed of consecutive time slices, ensuring the fairness of scheduling. For example, the CFS scheduler class can calculate the time allocated for each task in the time slice through the formula "time slice length * task weight/sum of all task weights in the scheduling queue where the task is located".
- Figure 5 is a schematic diagram of the working principle of the real-time scheduler.
- the core scheduler calls the real-time scheduler class to schedule tasks to be executed by the virtual machine
- all tasks can be added to a linked list in priority order, for example, Figure 5
- the priority of the downward direction is higher, and the priority of the upward direction is lower.
- the FIFIO scheduler class will use the first priority when scheduling the above tasks.
- a task that enters the execution state first obtains computing resources such as the CPU of the virtual machine, and keeps occupying the resources until the task enters the sleep state. For example, task A has been executed after entering the queue, and tasks B1, B2, C1 and C2 may not be executed. Time, the problem that this low priority task cannot get execution time is also known as the "starvation problem".
- the RR scheduler class schedules the above tasks, it can schedule tasks with the same priority to share the resources of the virtual machine by executing it in turn. For example, the RR scheduler can schedule the virtual machine to execute the priority in the virtual machine's scheduler in turn. tasks B1 and B2 to ensure fair execution of tasks with the same priority, but may also cause starvation problems for tasks with lower priority.
- the real-time scheduler class is based on priority, and prioritizes the execution of tasks with higher priorities to ensure the requirements of task priority, but when scheduling high-priority tasks, it will lead to low-priority tasks.
- the problem of starvation of tasks cannot guarantee the fair execution of low-priority needs.
- the completely fair scheduler can only guarantee fairness, but cannot schedule tasks with different priorities; the real-time scheduler only schedules tasks with different priorities but cannot schedule fairly, resulting in Starvation of low priority tasks. Therefore, in the application scenario of hybrid deployment of virtual machines in which different virtual machines share system resources as shown in FIG. 2, it is impossible to simply use the existing scheduler class to ensure that tasks with high priority are preferentially scheduled, and Ensures that low-priority tasks are fairly scheduled. Therefore, how to design a scheduler so that when the scheduler can be used to schedule tasks of different priorities executed on virtual machines in mixed deployment, can also satisfy the fairness of scheduling is a technical problem that needs to be solved urgently in the art.
- the present application provides a task scheduling method and device, so that the scheduler can not only ensure that high-priority tasks are preferentially scheduled to be executed by the virtual machine when scheduling tasks to be executed by the virtual machine, but also meet the requirements of the virtual machine. Fairness when scheduling tasks of the same priority.
- FIG. 6 is a schematic structural diagram of a cloud server to which a task scheduling method provided by the present application is applied, wherein the method provided by the present application may be executed by the scheduler in the cloud server shown in FIG. 6 .
- the types of the virtual machines at least include: on-demand virtual machines (on-demand virtual machines, OVM for short) and elastic virtual machines ( elastic virtual machine, referred to as EVM).
- OVM can also be called a non-oversold virtual machine.
- the computing power of the vCPU of OVM is basically the same as that of the CPU of the physical machine, and it is suitable for processing tasks that are sensitive to computation and delay; EVM can also be called an oversold virtual machine. It belongs to a preemptible computing instance and is suitable for processing tasks in batch processing and business scenarios with fault tolerance mechanisms.
- an operating system may be installed on the system resources of the host of the cloud server, and a scheduler executed in the operating system may be used to schedule tasks executed by each virtual machine.
- the operating system of the cloud server is also provided with a virtual machine identification module, which is used to mark the priority of tasks to be executed by each virtual machine.
- a scheduler may be set in each virtual machine for scheduling tasks to be executed by each virtual machine.
- an OVM virtual machine and an EVM virtual machine are used as examples to illustrate that different types of virtual machines are deployed in the cloud server. It can be understood that in the cloud server shown in Figure 6, It is also possible to deploy multiple OVM virtual machines and multiple EVM virtual machines, not shown in the figure. And for each virtual machine, no matter its type is OVM or EVM, it is equivalent to a computer that executes independently.
- the system resources of the cloud server used by the virtual machine such as CPU, can be executed in an independent form. Some of the CPU resources in can also be referred to as vCPU.
- FIG. 7 is a schematic diagram of the deployment of a cloud server cluster provided by the present application, wherein the supplier manages the cloud server clusters in different regions through the cluster unified scheduling platform, and among the multiple cloud servers included in each region, each Different types of virtual machines can be deployed on each server, thus realizing the deployment of cloud server clusters through more flexible deployment methods, instead of deploying only one type of virtual machine in each cloud server.
- a dynamic resource agent can be set on each cloud server to count the resource usage of each cloud server, so that the resource information of each cloud server is fed back to the unified scheduler of the cluster.
- the task scheduling method provided by this application can be executed by the scheduler in each cloud server in FIG. 6 or FIG. 7, although each cloud server is deployed with different types of virtual machines, and each virtual machine has It has its own scheduler, but when the scheduler set on the cloud server schedules tasks executed by each virtual machine, OVM can be implemented on the premise of ensuring the commonality of tasks executed by each OVM virtual machine or EVM virtual machine. on-demand allocation.
- the scheduler in each virtual machine stores and schedules the queue of tasks to be executed of the virtual machine, and the scheduler on the cloud server can adjust the queue of tasks to be executed in the scheduler in the virtual machine to realize the task queue of the virtual machine. Scheduling of tasks to be executed.
- the task scheduling method provided by the present application is described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same executive body can implement all or part of them at the same time. For the same or similar concepts Or the process may not be repeated in some embodiments.
- the task scheduling method provided by the present application may be executed by the scheduler in the cloud server as shown in FIG. 6 or FIG. 7 , or may also be executed by other devices in the cloud server other than those shown in FIG. 6 or FIG. 7 . Only using the scheduler in the cloud server shown in FIG. 6 as an execution subject as an example, the flow of the task scheduling method will be described, rather than limiting the structure of the cloud server.
- the task scheduling method provided in the first embodiment of the present application can be used for the scheduler to achieve fair scheduling of tasks while meeting the task priority requirements when scheduling tasks in a virtual machine, that is, on the basis of the CFS scheduler.
- the scheduling of tasks with different priorities can be understood as an enhanced CFS scheduling method.
- FIG. 8 is a schematic flowchart of an embodiment of a task scheduling method provided by the present application.
- the task scheduling method shown in FIG. 8 can be executed by a scheduler in the operating system of a host in a cloud server as shown in FIG. 6 , and is applied in scheduling
- the server schedules the task to be executed by the first target virtual machine in the cloud server
- the first target virtual machine may be any OVM virtual machine or any EVM virtual machine deployed in the cloud server
- the first target virtual machine can be any OVM virtual machine or any EVM virtual machine deployed in the cloud server.
- the scheduler in a target virtual machine is denoted as the first scheduler.
- the first scheduler stores and schedules tasks to be executed by the first target virtual machine through the task queue.
- the scheduler as the execution subject can be connected to the first scheduler. Acquire the task queue stored in the first scheduler, and adjust the tasks to be executed in the first scheduler, so as to adjust the tasks to be executed by the first target virtual machine.
- the task scheduling method provided by this embodiment includes:
- the scheduler obtains priorities of all tasks to be executed by the first target virtual machine.
- the scheduler first obtains all tasks currently to be executed by the first target virtual machine and the priorities of all tasks from the first scheduler of the first target virtual machine through S101 .
- the priorities may be divided in advance, or may be divided by the scheduler according to the types of tasks. For example, services that are not sensitive to computing delay, such as gene sequencing and batch services, correspond to a lower priority; and services that are sensitive to computing delay, such as online video content real-time rendering, correspond to a higher priority.
- the priorities of all tasks can also be uniformly managed by the virtual machine identification module set on the host.
- the scheduler on the cloud server as the execution body may first obtain the N tasks from the first scheduler of the first target virtual machine, and each The priority of the task.
- the tasks of the first priority include task 1, task 2 and task 3; the tasks of the second priority include task 4 and task 5 . . .
- the embodiment of the present application does not limit the number of priorities of the tasks to be executed by the first target virtual machine, and takes the priority from high to low in the order of the first priority, the second priority . . . as an example for description.
- the scheduler determines at least one task with the highest priority among all tasks.
- the scheduler determines at least one task with the highest priority from all the N tasks acquired in S101. For example, in the example shown in FIG. 9 , the scheduler determines that the tasks corresponding to the first priority with the highest priority are: task 1 , task 2 and task 3 .
- the scheduler may determine the priorities of all tasks from the queue of tasks to be executed by traversing the priorities of all tasks on the queue of tasks to be executed stored by the first scheduler. , and identify at least one task with the highest priority among all tasks.
- the queue can be a linked list, an array, a tree-like structure, etc.
- the scheduler can traverse the entire red-black tree and obtain the information in the red-black tree. At least one task with the highest priority.
- the scheduler may also store priority record information in a special storage space, and use the priority record information to perform a task for each task queue added to the first scheduler to be executed.
- the priority of the task is recorded.
- the scheduler can record the correspondence between different tasks and priorities through an array, which can be in the form of "task 1-first priority, task 2-first priority" and so on.
- the scheduler may determine at least one task with the highest priority in the task queue to be executed of the first scheduler by using the priority record information recorded in the storage space.
- a plurality of task queues to be executed may also be set in the first scheduler, each task queue to be executed corresponds to a priority, and the queues may also be linked lists, arrays, A tree-like structure, etc.
- the scheduler can use different red-black trees to represent to-be-executed task queues corresponding to different priorities. For example, in the example shown in FIG. 9 , task 1, task 2 and task 3 corresponding to the first priority can be recorded through the first red-black tree, and task 4 corresponding to the second priority can be recorded through the second red-black tree and task 5.
- the scheduler can directly obtain at least one task with the highest priority from the first red-black tree corresponding to the first priority with the highest priority, thereby improving the efficiency of obtaining the at least one task with the highest priority in S102.
- the scheduler determines the task with the smallest virtual running time among the at least one task, which is recorded as the first task.
- the scheduler further determines the first task with the smallest virtual running time among the at least one task acquired in S102.
- the scheduler measures which task is most worthy to be scheduled by the virtual running time of each task.
- all tasks to be executed can be represented by a red-black tree with virtual running time as the key value, then the virtual running time The smaller the time is, the closer the process is to the leftmost end of the entire red-black tree.
- the first scheduler controls the first target virtual machine each time to execute the task at the leftmost end of the red-black tree, and the virtual running time of the process is the smallest. Therefore, in this embodiment, after the scheduler determines at least one task with the highest priority through S102, the first task with the smallest virtual running time may be determined in the at least one task with the highest priority. For example, in the example shown in FIG.
- S104 The scheduler controls the first scheduler to schedule the first target virtual machine to execute the first task.
- the scheduler controls the first scheduler so that the first scheduler adjusts its task queue, so that the first scheduler schedules the first target virtual machine to execute the first task determined in S103.
- the scheduler can adjust the order of tasks in the task queue to be executed of the first scheduler by means of context switching, so that the first scheduler that controls the first target virtual machine first obtains the first task from the task queue to be executed.
- the task is executed by the processor (vCPU) of the first target virtual machine.
- the scheduler will repeatedly execute the task scheduling method S101 shown in FIG. 8 , and continue to schedule the first target virtual machine to execute the tasks in its queue to be executed through the first scheduler.
- the task with the shortest virtual execution time is executed, thereby ensuring that the current first target virtual machine executes the task with the highest priority, and tasks with the same priority can be fairly scheduled. Therefore, in the example shown in FIG. 9, in this order, the first target virtual machine will execute the tasks of the first priority, the second priority...
- the selection of virtual running time is equivalent to adopting the completely fair scheduling strategy of the CFS scheduler, and the CFS scheduling strategy is realized.
- the scheduler when scheduling the first target virtual machine to execute a task, the scheduler first determines at least one task with the highest priority in the task queue to be executed by the first target virtual machine, ensuring the priority The highest task is executed first; then, for at least one task with the highest priority, the first task with the smallest virtual running time is selected for execution, which ensures fairness in scheduling tasks of the same priority. Therefore, compared with the completely fair scheduler in the prior art shown in FIG. 4 , the task scheduling method provided in this embodiment can schedule tasks with high priority to be executed first; compared with the real-time scheduler shown in FIG.
- the task scheduling method provided in the second embodiment of the present application can be used when the scheduler schedules tasks.
- the first The scheduler currently schedules the tasks executed by the first target virtual machine for preemption, that is, the scheduler dynamically schedules the tasks of the first target virtual machine to meet the scheduling requirements of the scheduler for various types of tasks.
- FIG. 10 is a schematic flowchart of an embodiment of the task scheduling method provided by the application.
- the task scheduling method shown in FIG. 10 can be executed by the scheduler in the operating system of the host in the cloud server as shown in FIG.
- the first target virtual machine may be any OVM virtual machine or any EVM virtual machine deployed in the cloud server
- the first target virtual machine can be any OVM virtual machine or any EVM virtual machine deployed in the cloud server.
- a scheduler in a target virtual machine is denoted as a first scheduler, and the first scheduler stores and schedules tasks to be executed by the first target virtual machine through a task queue, and the method includes:
- the scheduler determines through S201 that the first target virtual machine is to be executed The priority of the second task is changed, and the minimum virtual running time of at least one task with the same priority as the first is determined.
- S202 The scheduler adjusts the first virtual running time corresponding to the second task to the second virtual running time according to the minimum virtual running time determined in S201.
- FIG. 11 which is a schematic diagram of the scheduling process in the task scheduling method provided by the present application, wherein, it is assumed that the N tasks currently to be executed that the first scheduler schedules the first target virtual machine are respectively task 1 , task 2... task N, N>1. Then in S201, the scheduler as the execution body first obtains the task whose priority is adjusted from the second priority to the first priority, which is recorded as the second task, or can also obtain the newly added N+1 task record. for the second task. and further determine the first priority corresponding to the second task and the first virtual running time corresponding to the second task.
- the second task can also be a task added to the task queue to be executed by the first scheduler after switching from the sleep state to the wake-up state, and the scheduler can directly obtain the newly added task queue from the to-be-executed task queue.
- the second virtual runtime of the second task can also be a task added to the task queue to be executed by the first scheduler after switching from the sleep state to the wake-up state, and the scheduler can directly obtain the newly added task queue from the to-be-executed task queue.
- the scheduler adjusts the first virtual running time of the second task obtained in S201 to the second virtual running time, wherein the purpose of adjusting the virtual running time of the second task is to enable the second task to obtain the execution time, Therefore, the adjustment of the virtual running time of the second task should be related to the currently executed third task or a task with the same priority as the second task.
- FIG. 12 is a schematic flowchart of an embodiment of the task scheduling method provided by the present application, and the method shown in FIG. Based on the method shown in FIG. 11 , after acquiring the second task, the scheduler determines whether there are other tasks with the same priority as the second task and corresponding to the first priority in the queue of tasks to be executed of the first scheduler through S2021 task. If there are no other tasks of the first priority in the to-be-executed task queue of the first scheduler, execute S2022; if there are other tasks of the first priority in the to-be-executed task queue of the first scheduler, execute S2023.
- the scheduler refers to the virtual running time of the third task that the first scheduler is scheduling the first target virtual machine to execute
- An adjustment is made to the first virtual runtime of the second task.
- the adjustment principle may make the second virtual running time after the adjustment of the first virtual running time slightly larger than the virtual running time of the third task. For example, when the first virtual running time is less than the virtual running time of the third task, the scheduler After adding a first variable to the first virtual running time, a second virtual running time is obtained, so that the second virtual running time is greater than the virtual running time of the third task.
- the variable can be adjusted in real time according to the actual situation.
- the scheduler After adding a first variable to the first virtual running time, a second virtual running time is obtained, so that the second virtual running time is greater than the smallest virtual running time among the virtual running times of task 1 to task 3 .
- the first variable can be adjusted according to the actual situation.
- the first scheduler can be controlled so that the first scheduler schedules the first target virtual machine to execute the second task.
- a comparison between the priority of the task currently being executed by the first scheduler and the priority of the second task is also added, so that the first priority of the second task is higher than the priority of the third task being executed.
- the second task preempts the third task.
- the second task may also be originally stored in the task queue to be executed by the first scheduler, and the scheduler is in After the second task is acquired in S201, it is further determined to adjust the priority corresponding to the second task from the second priority to the first priority according to the instruction information sent by the user. Subsequently, in S202, the scheduler specifically adjusts the first virtual running time to the first virtual running time according to the minimum virtual running time among the virtual running times of at least one task corresponding to the second priority in the task queue to be executed of the first scheduler 2. Virtual runtime.
- the task scheduling method when the first target virtual machine executes the third task, if the scheduler obtains the second task corresponding to the first priority In the execution task queue, the virtual running time of the at least one task corresponding to the first priority is the smallest virtual running time, or the first virtual running time of the second task is adjusted to the second virtual running time according to the virtual running time of the third task. operation hours. Finally, when the first priority of the second task is higher than the priority of the third task, the first target virtual machine is controlled to execute the second task, thereby realizing the second task queue newly added to the first target virtual machine to be executed. Preemptive execution of tasks. Therefore, the task scheduling method provided in this embodiment overcomes the deficiency that the completely fair scheduler shown in FIG.
- the task scheduling method provided in the third embodiment of the present application can be used when the scheduler schedules tasks in the first target virtual machine, when there is a low priority task queue stored in the first scheduler of the first target virtual machine to be executed.
- tasks with high priority cannot be executed all the time
- tasks with low priority can be actively migrated to other virtual machines (referred to as the second target virtual machine) for execution, thereby preventing the first virtual machine from executing tasks with multiple priorities.
- priority scheduling of high-priority tasks leads to starvation of low-priority tasks.
- FIG. 13 is a schematic flowchart of an embodiment of the task scheduling method provided by the application.
- the task scheduling method shown in FIG. 13 can be executed by the scheduler in the operating system of the host in the cloud server as shown in FIG.
- the first target virtual machine may be any OVM virtual machine or any EVM virtual machine deployed in the cloud server
- the first target virtual machine can be any OVM virtual machine or any EVM virtual machine deployed in the cloud server.
- a scheduler in a target virtual machine is denoted as a first scheduler, and the first scheduler stores and schedules tasks to be executed by the first target virtual machine through a task queue, and the method includes:
- the scheduler acquires time record information of the first scheduler when the first target virtual machine executes the fourth task.
- the scheduler when the first target virtual machine executes the task (denoting the task being executed by the first virtual machine as the fourth task), the scheduler also records the time record information for the task of the first scheduler of the first target virtual machine at the same time.
- the tasks in the queue are logged.
- the S301 may be performed by the scheduler when the clock is interrupted, or performed when the scheduler schedules switching, or performed by the scheduler setting a timer.
- the fourth task corresponds to the third priority, and at the same time, in the first scheduler of the first target virtual machine, the stored task queue to be executed at least also includes a fifth task, and the priority corresponding to the fifth task is lower than the third priority.
- the time record information may be stored in a storage space in the scheduler, or in a storage space in the first target virtual machine.
- the time recording information is used to record the execution time of the fourth task, or, in another possible implementation, the time recording information is used to record the execution time of the fifth task Time to wait in the task queue.
- FIG. 14 is a schematic diagram of the scheduling process in the task scheduling method provided by the application, wherein, it is assumed that the N tasks currently to be executed by the first scheduler are respectively task 1, task 2...task N , N>1, and at this time, the first target virtual machine executes the fourth task among the N tasks in the task queue to be executed. Then, for the scheduler, in S301, the time record information of the current moment can be obtained.
- the scheduler determines to schedule the fifth task to be executed by the second target virtual machine according to the time record information.
- the preset condition may be that the execution time of the fourth task is less than the first threshold (1s).
- the scheduler After it is determined that the execution time of the fourth task is greater than the first threshold and the preset condition is satisfied, the second target virtual machine is scheduled to execute the fifth task.
- the preset condition may be that the waiting time of the fifth task is greater than the second threshold.
- the scheduler may schedule the second target virtual machine to execute the fifth task after determining that the waiting time of the fifth task is greater than the second threshold and satisfying the preset condition.
- the second target virtual machine may be any virtual machine in the cloud server, and before the scheduler controls the second target virtual machine to perform the fifth task in S302, the second target virtual machine may also be determined in the cloud server. machine.
- the second target virtual machine may be a virtual machine currently in an idle state in the cloud server, so that when the scheduler controls the second target virtual machine to perform the fifth task, it will not affect other tasks run by the second target virtual machine;
- the second target virtual machine may be a virtual machine whose current load is less than the third threshold in the cloud server; when the scheduler controls the second target virtual machine to perform the fifth task, the impact on other tasks run by the second target virtual machine is reduced.
- the second target virtual machine may also be a virtual machine deployed by the cloud server dedicated to executing the priority corresponding to the fifth task, that is, tasks with different priorities are assigned to different virtual machines in the cloud server for execution, and then the scheduling When scheduling the fifth task in S302, the controller selects a virtual machine corresponding to the fourth priority of the fifth task as the second target virtual machine.
- the scheduler may also determine the second target virtual machine in the following order: first select the virtual machine in the idle state in the cloud server, and secondly select the task on the scheduling queue of the virtual machine in the cloud server first.
- a lower-level and lighter-loaded virtual machine again select a task on the scheduling queue of a virtual machine in a cloud server with a lower priority but a heavier load / a higher-priority task on the scheduling queue of a virtual machine in the server But lightly loaded virtual machines.
- the second target virtual machine may also be a specially set virtual machine in the cloud server, and the virtual machine is dedicated to executing the scheduler from other virtual machines in the scenario of preventing the starvation problem as shown in FIG. 14 . task, then in S302, the scheduler may directly control the second target virtual machine to execute the fifth task.
- the scheduler when the first target virtual machine executes the fourth task, the scheduler also obtains time record information, which is used to judge whether the fifth task with a lower priority has a starvation problem. , and after the time record information satisfies the preset condition, the second target virtual machine in the cloud server is controlled to execute the fifth task, thereby realizing the scheduling of the fifth task among different target virtual machines, so that the fifth task will not be The priority is low and stays in the pending execution queue of the first target virtual machine to prevent the occurrence of starvation problems.
- the task scheduling method provided by the embodiments of the present application is introduced, and in order to implement the functions in the task scheduling method provided by the above embodiments of the present application, the scheduler as the execution body may include a hardware structure and/or
- the software module implements the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above functions is performed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
- FIG. 15 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the present application.
- the task scheduling apparatus shown in FIG. 15 can be used to execute the task scheduling method shown in FIG. Class determination module 1502 , virtual runtime determination module 1503 , and control module 1504 .
- the obtaining module 1501 is used for obtaining the priorities of multiple tasks to be executed by the first target virtual machine;
- the priority determining module 1502 is used for determining at least one task with the highest priority among the multiple tasks;
- the virtual running time determining module 1503 uses From the at least one task, determine the first task with the smallest virtual running time;
- the control module 1504 is configured to control the first target virtual machine to execute the first task.
- the obtaining module 1501 is specifically configured to, according to the task queue to be executed stored by the first scheduler in the first target virtual machine, determine the priorities of multiple tasks to be executed by the first target virtual machine.
- the obtaining module 1501 is specifically configured to traverse the priorities of all tasks on the queue of tasks to be executed stored by the first scheduler, and determine at least one task with the highest priority from the queue of tasks to be executed.
- the obtaining module 1501 is specifically configured to, through the priority record information stored in the first scheduler, determine at least one task with the highest priority among the multiple tasks; wherein, the priority record information is used to record the first scheduler The priority of all tasks on the queue of pending tasks.
- the obtaining module 1501 is specifically configured to, according to the tasks in the queue corresponding to the highest priority stored in the first scheduler, determine at least one task with the highest priority; wherein, the task to be executed by the first scheduler passes through multiple tasks. Queues store tasks to be executed, and each queue corresponds to a different priority.
- FIG. 16 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the present application.
- the task scheduling apparatus shown in FIG. 16 can be used to execute the task scheduling method shown in FIG. 10 .
- the apparatus includes: an acquisition module 1601, a virtual running time Adjustment module 1602 and control module 1603.
- the obtaining module 1601 is configured to obtain, when the priority of the second task to be executed by the first target virtual machine is adjusted from the second priority to the first priority, obtain the task to be executed by the first target virtual machine that is the same as the first priority
- the minimum virtual running time corresponding to at least one task the virtual running time adjustment module 1602 is configured to adjust the first virtual running time corresponding to the second task to the second virtual running time according to the minimum virtual running time
- the control module 1603 is configured to, when the first priority is higher than the priority of the third task being executed by the first target virtual machine, control the first target virtual machine to execute the second task.
- the second virtual running time is greater than the smallest virtual running time among the virtual running times of at least one task corresponding to the first priority in the queue of tasks to be executed stored by the first scheduler of the first target virtual machine.
- the task scheduling apparatus further includes: a receiving module 1604, configured to receive indication information, and according to the indication information, determine that the priority of the second task is adjusted from the second priority to the first priority.
- a receiving module 1604 configured to receive indication information, and according to the indication information, determine that the priority of the second task is adjusted from the second priority to the first priority.
- the virtual time adjustment module 1602 is specifically configured to add the first virtual running time to the minimum virtual running time, and then subtract the virtual running time of at least one task corresponding to the first priority in the task queue to be executed. The smallest virtual running time, the second virtual running time is obtained.
- FIG. 17 is a schematic structural diagram of an embodiment of a task scheduling apparatus provided by the application.
- the task scheduling apparatus shown in FIG. 17 can be used to execute the task scheduling method shown in FIG. 13 .
- the apparatus includes: an acquisition module 1701 and a control module 1702 .
- the obtaining module 1701 is used to obtain the time record information stored by the first scheduler of the first target virtual machine; wherein, the time record information is used to record the execution time of the fourth task, and the fourth task corresponds to the third priority, or, The time record information is used to record the waiting time of the fifth task in the to-be-executed task queue stored by the first scheduler, and the priority corresponding to the fifth task is lower than the third priority; the control module 1702 is used for when the time record information meets the predetermined Setting a condition, the first scheduler that controls the first target virtual machine sends the fifth task to the second scheduler of the second target virtual machine, so that the second target virtual machine executes the fifth task.
- the preset condition includes: the execution time of the fourth task is greater than the first threshold.
- the preset condition includes: the waiting time is greater than the second threshold.
- the second target virtual machine is a virtual machine in an idle state among multiple virtual machines deployed by the host where the first target virtual machine is located; A virtual machine with three thresholds; or, the second target virtual machine is a scheduler for executing a task of a fourth priority among multiple virtual machines deployed by the host, where the fourth priority is lower than the third priority.
- the second target virtual machine is a scheduler dedicated to executing the fifth task when the time record information satisfies a preset condition.
- each module of the above apparatus is only a division of logical functions, and may be fully or partially integrated into a physical entity in actual implementation, or may be physically separated.
- these modules can all be implemented in the form of software calling through processing elements; they can also all be implemented in hardware; some modules can also be implemented in the form of calling software through processing elements, and some modules can be implemented in hardware.
- the determination module may be a separately established processing element, or may be integrated into a certain chip of the above-mentioned device to be implemented, in addition, it may also be stored in the memory of the above-mentioned device in the form of program code, and a certain processing element of the above-mentioned device may Call and execute the function of the above determined module.
- the implementation of other modules is similar. In addition, all or part of these modules can be integrated together, and can also be implemented independently.
- the processing element described here may be an integrated circuit with signal processing capability. In the implementation process, each step of the above-mentioned method or each of the above-mentioned modules can be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.
- the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital) signal processor, DSP), or, one or more field programmable gate arrays (field programmable gate array, FPGA), etc.
- ASIC application specific integrated circuits
- DSP digital signal processor
- FPGA field programmable gate array
- the processing element may be a general-purpose processor, such as a central processing unit (central processing unit, CPU) or other processors that can call program codes.
- these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
- SOC system-on-a-chip
- the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware or any combination thereof.
- software it can be implemented in whole or in part in the form of a computer program product.
- the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated.
- the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
- the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center is by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
- the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes an integration of one or more available media.
- the usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state disks (SSDs)), and the like.
- FIG. 18 is a schematic structural diagram of an embodiment of an electronic device provided by the present application.
- the electronic device can serve as the scheduler described in any of the foregoing embodiments of the present application, and execute the task scheduling method executed by the scheduler.
- the communication apparatus 1100 may include: a processor 111 (eg, a CPU) and a transceiver 113 ; wherein the transceiver 113 is coupled to the processor 111 , and the processor 111 controls the transceiver 113 to transmit and receive.
- the communication apparatus 1100 further includes a memory 112, and various instructions may be stored in the memory 112, so as to perform various processing functions and implement the method steps performed by the scheduler in this embodiment of the present application.
- the electronic device involved in the embodiment of the present application may further include: a power supply 114 , a system bus 115 , and a communication interface 116 .
- the transceiver 113 may be integrated in the transceiver of the electronic device, or may be an independent transceiver antenna on the electronic device.
- the system bus 115 is used to implement communication connections between elements.
- the above-mentioned communication interface 116 is used to implement connection and communication between the electronic device and other peripheral devices.
- the above-mentioned processor 111 is configured to be coupled with the memory 112 to read and execute the instructions in the memory 112, so as to implement the method steps performed by the scheduler in the above-mentioned method embodiments.
- the transceiver 113 is coupled with the processor 111 , and the processor 111 controls the transceiver 113 to send and receive messages. The implementation principle and technical effect thereof are similar, and are not repeated here.
- the system bus mentioned in FIG. 18 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus or the like.
- PCI peripheral component interconnect
- EISA extended industry standard architecture
- the system bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
- the communication interface is used to realize the communication between the database access device and other devices (eg client, read-write library and read-only library).
- the memory may include RAM and may also include non-volatile memory, such as at least one disk storage.
- the processor mentioned in FIG. 18 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate Array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
- a general-purpose processor including a central processing unit CPU, a network processor (NP), etc.
- DSP digital signal processor
- ASIC application-specific integrated circuit
- FPGA field programmable gate Array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
- this embodiment of the present application further provides a readable storage medium, where an instruction is stored in the storage medium, and when the storage medium runs on a computer, the computer executes the program executed by the scheduler as in any of the foregoing embodiments of the present application. method of execution.
- an embodiment of the present application further provides a chip for running an instruction, where the chip is configured to execute the method executed by the scheduler in any of the foregoing embodiments of the present application.
- An embodiment of the present application further provides a program product, where the program product includes a computer program, and the computer program is stored in a storage medium, and at least one processor can read the computer program from the storage medium, and the at least one processor can read the computer program from the storage medium.
- the processor executes the computer program, the method executed by the scheduler in any of the foregoing embodiments of the present application may be implemented.
- “at least one” refers to one or more, and "a plurality” refers to two or more.
- “And/or”, which describes the association relationship of the associated objects, indicates that there can be three kinds of relationships, for example, A and/or B, which can indicate: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A, B can be singular or plural.
- the character “/” generally indicates that the related objects before and after are an “or” relationship; in the formula, the character “/” indicates that the related objects are a “division” relationship.
- “At least one item(s) below” or similar expressions thereof refer to any combination of these items, including any combination of single item(s) or plural items(s).
- At least one item (number) of a, b, or c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple indivual.
- various numbers and numbers involved in the embodiments of the present application are only for the convenience of description, and are not used to limit the scope of the embodiments of the present application.
- the size of the sequence numbers of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, rather than the implementation process of the embodiments of the present application. constitute any limitation.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本申请提供一种任务调度方法及装置,调度器在调度第一目标虚拟机待执行的任务时,首先获取第一目标虚拟机待执行任务队列中优先级最高的至少一个任务,以首先保证最高优先级的任务优先执行,随后还在优先级最高的至少一个任务中进一步确定虚拟运行时间最小的第一任务,并最终控制第一目标虚拟机执行第一任务,保证了相同优先级的至少一个任务中对任务的公平调度,因此,本申请能够实现调度器能够在调度第一目标虚拟机上的任务时,既能够保证高优先级的任务被优先调度、又能够满足相同优先级任务调度时的公平。
Description
本申请要求于2020年09月29日提交中国专利局、申请号为202011053405.3、申请名称为《任务调度方法及装置》的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,尤其涉及一种任务调度方法及装置。
在计算机领域,虚拟机技术允许一个服务器同时执行多个操作系统,每个操作系统可以作为一个虚拟机,在彼此独立的环境中执行而互不影响。因此,越来越多的服务商提供了虚拟机服务,用户可以使用服务商的虚拟机提供的计算服务。而对于服务商,由于不同用户所使用的虚拟机可以执行在同一个服务器上,极大地提高了服务商所部署的服务器的使用率。同时,用户在使用服务商提供的虚拟机时,通常按照所需计算量的峰值申请虚拟机的资源,服务商也会将服务器的资源按照计算量的峰值划分给不同的虚拟机使用。但是在实际使用过程中,用户通常不会使用其所申请的全部的虚拟机资源,造成服务器向每个用户分配的虚拟机资源的利用率不高。
因此为了对服务器上有限的资源进行更加合理的使用,现有技术中服务商可以在同一个向用户分配的虚拟机资源中,执行不同用户的任务,由于不同用户的任务类型不同、优先级不同,因此可以在服务器中设置调度器,对虚拟机资源中需要执行的任务进行统一的管理与调度。①、在一种实现中,调度器通过完全公平调度策略对虚拟机中执行的任务进行管理,其中,调度器为虚拟机中执行的所有任务按照每个任务的优先权权重值,分配不同的执行时间,保证所有任务都得到执行。但是,这种调度器只能够保证优先级较高的任务分配更多的执行时间,而无法保证优先调度优先级较高的任务,也无法保证高优先级任务抢占低优先级任务的执行。②、在另一种实现中,调度器通过实时调度器策略对虚拟中执行的任务进行管理,其中,调度器按照所有任务的优先级,首先执行最高优先级的任务中最先进入队列的一个、或者轮流执行最高优先级的多个任务。但是,这种调度器在优先级较高的任务执行完之后才能够执行优先级较低的任务,因此无法保证相同优先级任务调度的公平性,同时无法解决调度引起的低优先级任务饥饿问题。
综上,在现有技术中,完全公平调度策略和实时调度器策略都各自存在着不足,当一个虚拟机上可以执行不同类型的任务时,无法同时满足调度优先调度高优先级的任务和保证低优先级任务也得到调度的公平。因此,如何设计一种调度器,使得调度器能够用于调度虚拟机上执行的不同优先级的任务时,还能够满足调度的公平,是本领域亟需解决的技术问题。
发明内容
本申请提供一种任务调度方法及装置,以使调度器能够在调度虚拟机的待执行的任务时,既能够保证高优先级的任务被优先调度、又能够满足相同优先级任务调度时的公平。
本申请第一方面提供一种任务调度方法,用于调度器在调度第一目标虚拟机待执行的任务时,可以满足对所调度的任务优先级的要求的同时,还能够保证任务的公平调度。
其中,调度器在调度第一目标虚拟机待执行的任务时,首先获取第一目标虚拟机待执行任务队列中优先级最高的至少一个任务,以首先保证最高优先级的任务优先执行,随后还在优先级最高的至少一个任务中进一步确定虚拟运行时间最小的第一任务,并最终控制第一目标虚拟机执行第一任务,保证了相同优先级的至少一个任务中对任务的公平调度,也就是说,本实施例能够实现了调度器能够在调度第一目标虚拟机上的任务时,既能够保证高优先级的任务被优先调度、又能够满足相同优先级任务调度时的公平。
在本申请第一方面一实施例中,作为执行主体的调度器可以同时对多个虚拟机进行调度,并且调度器在调度多个虚拟机中的第一目标虚拟机执行的任务时,可以通过控制第一目标虚拟机的第一调度器实现。例如,调度器可以通过第一调度器中存储的待执行任务队列,确定第一目标虚拟机待执行的多个任务的优先级,又例如,调度器在控制第一目标虚拟机执行第一任务时,具体可以通过调整第一调度器中待执行任务队列的顺序,将第一任务调整到待执行任务队列的最前实现。
对于调度器确定第一目标虚拟机待执行的任务中,优先级最高的至少一个任务,本申请提供至少以下三种方式具体实现:
在本申请第一方面一实施例提供的第一种方式中,基于第一调度器中存储了第一目标虚拟机待执行任务队列,则调度器在确定优先级最高的至少一个任务时,可以从第一调度器中获取待执行任务队列中所有的任务后,再确定所有任务对应的优先级,并最终确定出优先级最高的至少一个任务。
在本申请第一方面一实施例提供的第二种方式中,第一调度器在对第一目标虚拟机的待执行任务进行调度时,除了存储所有待执行的任务,还对队列中所有任务的优先级进行记录,例如都记录在一个表格中。则调度器在确定第一目标虚拟机待执行任务的优先级时,可以直接从表格中获取所有任务对应的优先级,而不用获取每个任务本身,从而减少计算量、提高效率。
在本申请第一方面一实施例提供的第三种方式中,第一调度器在对第一目标虚拟机的待执行任务进行调度时,可以设置不同的多个队列来存储任务,并且每个队列所存储的队列的优先级不同。则调度器在确定第一目标虚拟机待执行任务中优先级最高的至少一个任务时,可以从第一调度器中存储的优先级最高的队列中,直接获取这至少一个任务,而不用处理其他队列上其他优先级的任务,同样能够减少计算量、提高效率。
本申请第二方面提供一种任务调度方法,用于调度器在调度第一目标虚拟机执行任务时,当第一目标虚拟机待执行任务队列中任务的优先级发生了调整,则调度器根 据优先级调整后的任务的优先级,对该任务的虚拟运行时间进行调整,来实现高优先级任务对第一目标虚拟机当前执行任务的抢占,以满足对第一目标虚拟机执行任务的动态调度。
其中,假设第一目标虚拟机正在执行第三任务,若此时第一目标虚拟机的待执行任务中,第二任务的优先级发生了调整,例如由第二优先级调整为第一优先级,则根据第一目标虚拟机待执行的与第一优先级相同的至少一个任务中的最小虚拟机运行时间,对第二任务的虚拟运行时间进行调整,例如由第一虚拟运行时间调整为第二虚拟运行时间,最终,在第二任务的优先级高于第三任务的优先级时,调度器随即控制第一目标虚拟机执行第二任务,从而实现了第二任务对第一目标虚拟机当前执行任务的抢占执行,实现了对任务的动态调度。
在本申请第二方面一实施例中,在调度器对第二任务的虚拟运行时间进行调整时,调整的目标是将调整后的第二虚拟运行时间,调整为大于第一目标虚拟机所有待执行任务中,第一优先级对应的至少一个任务的虚拟运行时间中最小的虚拟运行时间。也就是说,对第二任务的虚拟运行时间进行调整,使得其虚拟运行时间尽可能的小,但是不能小于同优先级中最小的虚拟运行时间。
在本申请第二方面一实施例中,调度器具体根据用户发送的指示信息,确定第二任务的优先级需要调整,使得用户通过调度器对第一目标虚拟机的待执行任务进行调整后,调度器即可调整任务的虚拟运行时间,实现用户对任务的动态调整,能够丰富应用场景,以及提高用户体验。
在本申请第二方面一实施例中,调度器在对于第二任务的虚拟运行时间进行调整时,具体将该第二任务调整前的第一虚拟运行时间Ta,加上同优先级中最小的虚拟运行时间minB之后,再减去第二优先级对应的至少一个任务中虚拟运行时间的最小值记为minA,即通过公式第二虚拟运行时间=(Ta-minA)+minB,来将第一虚拟运行时间调整为第二虚拟运行时间,使得调整后的第二虚拟运行时间在第一优先级对应的任务中,略大于第一优先级的至少一个任务中虚拟运行时间的最小值。
本申请第三方面提供一种任务调度方法,应用于调度器在调度第一目标虚拟机中的任务时,当第一目标虚拟机的待运行任务队列中存在低优先级的任务一直得不到执行的情况,可以将低优先级的任务主动迁移到其他虚拟机(记为第二目标虚拟机)上执行,从而防止由于第一目标虚拟机执行多种优先级的任务时,优先调度高优先级的任务进而导致的低优先级任务的饥饿问题。
其中,调度器在第一目标虚拟机执行第四任务时,同时获取第一目标虚拟机的第一调度器中对于第四任务的时间记录信息,并根据时间记录信息对优先级较低的第五任务是否出现饥饿问题进行判断,在时间记录信息满足预设条件之后,控制第一目标虚拟机的第一调度器将第五任务发送给第二目标虚拟机的第二调度,使得第二目标虚拟机执行第五任务,从而实现了对第五任务在不同虚拟机之间的调度,使得第五任务不会由于优先级较低而一直停留在第一调度器的待执行队列中,防止饥饿问题的发生。
更为具体地,本申请提供的时间记录信息可以至少包括如下两种可能的实现方式:
在本申请第三方面一实施例中,时间记录信息一种可能的实现是:可用于记录第一目标虚拟机已经执行第四任务的执行时间,则预设条件可以是第四任务的执行时间 小于第一阈值。其中,能够防止由于第四任务的优先级较高,处于较低优先级的第五任务一直得不到执行,会导致第五任务的饥饿问题,因此,调度器可以确定第四任务执行时间大于第一阈值而满足预设条件后,调度由第二目标虚拟机执行第五任务。
在本申请第三方面一实施例中,时间记录信息的另一种可能的实现是:用于记录第五任务在第一调度器的待执行任务队列中的等待时间,则预设条件可以是第五任务的等待时间大于第二阈值。同样为了防止第五任务的饥饿问题,调度器可以确定第五任务的等待时间大于第二阈值而满足预设条件后,调度由第二目标虚拟机执行第五任务。
可选地,在调度器调度第二目标虚拟机执行第五任务时,可以参照一定的标准来选择第二目标虚拟机。
例如,在本申请第三方面一实施例中,可以按照如下顺序确定第二目标虚拟机:优先选择云服务器中空闲态的虚拟机、其次选择云服务器中虚拟机的调度队列上的任务优先级较低且负载较轻的虚拟机、再次选择云服务器中虚拟机的调度队列上的任务优先级较低但负载较重的虚拟机/服务器中虚拟机的调度队列上的任务优先级较高但负载较轻的虚拟机。
又例如,在本申请第三方面另一实施例中,第二目标虚拟机还可以是云服务器中专门设置的虚拟机,该虚拟机专用于在防止饥饿问题的场景中,执行调度器从其他虚拟机调度的任务,并且在没有被调度器调度时,该虚拟机不会执行其他任务。
本申请第四方面提供一种任务调度装置,可用于执行如本申请第一方面的任务调度方法,该装置包括:获取模块、优先级确定模块、虚拟运行时间确定模块和控制模块。其中,获取模块用于获取第一目标虚拟机待执行的多个任务的优先级;优先级确定模块用于确定多个任务中优先级最高的至少一个任务;虚拟运行时间确定模块用于从至少一个任务中,确定虚拟运行时间最小的第一任务;控制模块用于控制第一目标虚拟机执行第一任务。
在本申请第四方面一实施例中,获取模块具体用于,根据第一目标虚拟机中,第一调度器所存储的待执行任务队列,确定第一目标虚拟机待执行的多个任务的优先级。
在本申请第四方面一实施例中,获取模块具体用于,遍历第一调度器所存储的待执行任务队列上所有任务的优先级,从待执行任务的队列中确定优先级最高的至少一个任务。
在本申请第四方面一实施例中,获取模块具体用于,通过第一调度器中存储的优先级记录信息,确定多个任务中优先级最高的至少一个任务;其中,优先级记录信息用于记录第一调度器待的执行任务的队列上所有任务的优先级。
在本申请第四方面一实施例中,获取模块具体用于,根据第一调度器中存储的最高优先级对应的队列中的任务,确定优先级最高的至少一个任务;其中,第一调度器待执行任务通过多个队列存储待执行的任务,每个队列对应不同的优先级。
本申请第五方面提供一种任务优先级调整装置,可用于执行如本申请第二方面提供的任务调度方法,该装置包括:获取模块、虚拟运行时间调整模块和控制模块。其中,获取模块用于当第一目标虚拟机待执行的第二任务的优先级由第二优先级调整为第一优先级,获取第一目标虚拟机待执行的与第一优先级相同的至少一个任务中,至 少一个任务对应的最小的虚拟运行时间;虚拟运行时间调整模块用于根据最小的虚拟运行时间,将第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间;控制模块用于,当第一优先级高于第一目标虚拟机正在执行的第三任务的优先级,控制第一目标虚拟机执行第二任务。
在本申请第五方面一实施例中,第二虚拟运行时间大于第一目标虚拟机的第一调度器存储的待执行任务队列中,对应第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间。
在本申请第五方面一实施例中,所述任务调度装置还包括:接收模块,用于接收指示信息,并根据指示信息,确定第二任务的优先级由第二优先级调整为第一优先级。
在本申请第五方面一实施例中,虚拟时间调整模块具体用于,将第一虚拟运行时间加上最小的虚拟运行时间后,再减去待执行任务队列中对应第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间,得到第二虚拟运行时间。
本申请第六方面提供一种任务调度装置,可用于执行如本申请第三方面提供的任务调度方法,该装置包括:获取模块和控制模块。其中,获取模块用于获取第一目标虚拟机的第一调度器存储的时间记录信息;其中,时间记录信息用于记录第四任务执行的时间,第四任务对应第三优先级,或者,时间记录信息用于记录第五任务在第一调度器存储的待执行任务队列中的等待时间,第五任务对应的优先级低于第三优先级;控制模块用于当时间记录信息满足预设条件,控制第一目标虚拟机的第一调度器将第五任务发送到第二目标虚拟机的第二调度器,使第二目标虚拟机执行第五任务。
在本申请第六方面一实施例中,当时间记录信息用于记录第四任务执行的时间,预设条件包括:第四任务执行的时间大于第一阈值。
在本申请第六方面一实施例中,当时间记录信息记录第五任务在第一调度器的待执行任务队列中的等待时间,预设条件包括:等待时间大于第二阈值。
在本申请第六方面一实施例中,第二目标虚拟机为第一目标虚拟机所在主机部署的多个虚拟机中处于空闲态的虚拟机;或者,第二目标虚拟机为主机部署的多个虚拟机中负载小于第三阈值的虚拟机;或者,第二目标虚拟机为主机部署的多个虚拟机中用于执行第四优先级的任务的调度器,其中,第四优先级低于第三优先级。
在本申请第六方面一实施例中,第二目标虚拟机是专用于当时间记录信息满足预设条件时执行第五任务的调度器。
本申请第七方面提供一种电子设备,包括:处理器和通信接口。
所述通信接口用于实现所述通信装置与外设的连接通信。
所述处理器用于实现上述第一方面、第二方面或者第三方面任一项所述的方法。
作为一种可能的设计,上述通信装置还包括:存储器。
所述存储器用于存储计算机程序,所述处理器执行所述存储器中存储的计算机程序,以使得所述装置执行上述第一方面、第二方面或者第三方面任一项所述的方法。
本申请第八方面提供一种芯片,包括:处理器和通信接口;
所述通信接口用于实现与其他设备通信;
所述处理器用于读取指令以实现如上述第一方面、第二方面或者第三方面任一项所述的方法。
本申请第九方面提供一种计算机程序产品,所述计算机程序产品包括计算机程序代码,当所述计算机程序代码被计算机执行时,使得所述计算机执行如上述第一方面、第二方面或者第三方面任一项所述的方法。
图1为本申请应用场景的示意图;
图2为一种使用虚拟机结构的云服务器的结构示意图;
图3为一种云服务器对虚拟机进行调度的模块示意图;
图4为完全公平调度器的工作原理示意图;
图5为实时调度器的工作原理示意图;
图6为本申请提供的一种任务调度方法所应用的云服务器的结构示意图;
图7为本申请提供的一种云服务器集群的部署示意图;
图8为本申请提供的任务调度方法一实施例的流程示意图;
图9为本申请提供的任务调度方法中调度流程的示意图;
图10为本申请提供的任务调度方法一实施例的流程示意图;
图11为本申请提供的任务调度方法中调度流程的示意图;
图12为本申请提供的任务调度方法一实施例的流程示意图;
图13为本申请提供的任务调度方法一实施例的流程示意图;
图14为本申请提供的任务调度方法中调度流程的示意图;
图15为本申请提供的任务调度装置一实施例的结构示意图;
图16为本申请提供的任务调度装置一实施例的结构示意图;
图17为本申请提供的任务调度装置一实施例的结构示意图;
图18为本申请提供的电子设备一实施例的结构示意图。
图1为本申请应用场景的示意图,其中,本申请应用在数据中心的混合部署领域,例如,在图1所示的场景中,云计算服务的供应商可以在互联网2内设置多个云服务器3,由云服务器3提供计算服务。当用户所使用的终端设备1需要一定的计算资源时,可以直接使用、或者向供应商申请、或者向供应商支付一定费用来获得由云服务器3提供的云计算服务。例如,用户使用的终端设备1在进行基因测序等计算量较大的计算任务时,仅仅依靠终端设备1的CPU提供的计算能力可能要计算几天时间效率较低,此时用户可以使用云服务器3的计算资源(例如CPU),进行基因测序的计算任务,使得终端设备1能够在几分钟或者更短的时间内得到基因测序的计算结果,从而使用户获得了更高的计算效率,同时,使用设置在互联网2内的服务器3进行计算,还能够让用户在不需要专门安装、升级其使用的终端设备1的情况下,就能够使用更多的计算资源,还减少了用户进行计算的经济成本。由于用户使用的计算资源是由供应商设置在网络侧的云服务器3来提供,故这种使用网络资源进行计算的场景又可被称为“云计算”。
而作为云服务器3的供应商,同样为了节约资源、减少成本,可以通过虚拟机技 术,在一个云服务器3上设置多台虚拟机,分别向不同的用户提供计算资源。其中,虚拟机技术是指通过软件模拟的具有完整硬件系统功能的、执行在各自独立环境中执行的完整计算机系统。例如,图2为一种使用虚拟机结构的云服务器的结构示意图,以如图1所示的场景中的云服务器3为例,供应商在云服务器3的系统资源(例如,CPU、内存、硬盘等)的基础上安装操作系统(所述操作系统又可被称为主机操作系统(host OS),例如:Linux等),在操作系统中可以执行不同的虚拟机。当云服务器3向如图1所示的三个终端设备11-13提供计算服务,终端设备11请求使用的计算资源可以占云服务器3系统资源中CPU计算能力的30%、终端设备12请求使用的计算资源可以占云服务器3系统资源中CPU计算能力的50%、终端设备13请求使用的计算资源可以占云服务器3系统资源中CPU计算能力的20%,供应商将云服务器3的系统资源按照三个终端设备所需要的计算量按照比例划分为三部分,在这三部分系统资源中各自执行一个虚拟机,记为虚拟机1-3。最终,终端设备11可以使用云服务器3提供的虚拟机1进行计算、终端设备12可以使用云服务器3提供的虚拟机2进行计算、终端设备13可以使用云服务器3提供的虚拟机3进行计算,而在云服务器3中,每个用户可以像使用实体机一样对各自对应的虚拟机进行操作,每个虚拟机使用其所对应的部分系统资源执行,互不影响。
然而,在实际的使用过程中,由于用户在通过终端设备1使用云服务器3提供的虚拟机时,通常不会考虑对资源的使用率,是根据所需计算量的最大峰值来申请计算资源,造成了在如图2所示的云服务器3中,为虚拟机所分配的系统资源中的大部分并不会使用,而经常处于闲置状态,一些业界的研究数据表明,对系统资源中CPU的利用率在20%以下,而CPU的成本占据了云服务器3单板硬件成本的40%以上,因此云服务器3的提供商,为了提高对云服务器3的系统资源的利用率、节省在互联网2中设置的云服务器3的数量,可以将向用户已经分配的资源空闲时,用于向其他用户提供服务。例如,在如图2所示的云服务器中,在虚拟机2所申请的50%的系统资源空闲时,可以分配给虚拟机4使用,对于使用虚拟机2和虚拟机4的用户而言,各自都向提供商申请了云服务器3的50%的系统资源,而对于提供商一侧可以理解为使用相同的系统资源同时满足了虚拟机2和虚拟机4所申请的系统资源,从而通过资源共用的方式,提高对云服务器3的系统资源的利用效率。
同时,云服务器还可以对执行在各个虚拟机中任务进行调度,从而实现虚拟机资源更加合理的利用。示例性地,图3为一种云服务器对虚拟机进行调度的模块示意图,如图3示出了在云服务器中设置的调度器,其中,云服务器中可以包括主调度器和周期调度器,主调度器用于对任务进行直接的调度、周期调度器以固定的频率执行,用于对任务进行周期性的调度,二者结合可组成云服务器的核心调度器(core scheduler),又可被称为通用调度器(generic scheduler)。图3所示的场景中,以云服务器的核心调度器对云服务器中设置的任一虚拟机进行调度为例,其中,假设核心调度器正在调度的虚拟机中,待执行的任务有任务1-任务N。则核心调度器首先通过步骤①调用完全公平调度器(completely fair scheduler,简称:CFS)、RRS(round-robin)或者先入先出(first in,first out,简称:FIFO)等调度器类,每个调度器类可根据不同的调度规则对任务进行调度。则调度器类通过步骤②获取虚 拟机待执行的N个任务后,按照对应的调度规则确定调度虚拟机执行某个目标任务后,由核心调度器通过步骤③以上下文切换方式指示虚拟机,在步骤④中应执行的目标任务,从而实现对虚拟机执行的任务进行执行先后顺序的调度。
更为具体地,现有的调度器类至少可以划分为完全公平调度器(CFS)和实时调度器(RR、FIFO或者Deadline等)两种不同的类型,下面分别进行说明。
图4为完全公平调度器的工作原理示意图,其中,当核心调度器调用CFS调度器类,对虚拟机待执行的任务1、任务2和任务3进行调度时,CFS调度器类首先将虚拟机的执行时间按照时间轴划分为不同的连续时间片,例如图4中的时间片1、时间片2…随后,在每个时间片中,将三个任务按照每个任务的权重分配执行的时间,以保证在连续的时间片组成的时间段内,每个任务都会被执行,保证调度的公平性。例如,CFS调度器类可以通过公式“时间片长度*任务权重/该任务所在调度队列中所有任务权重之和”计算每个任务在时间片内分配的时间。
从图4可以看出,完全公平调度器类在对虚拟机执行的多个任务进行调度时,以公平为原则,保证每个任务都可以被执行,但是只能够保证权重较高的任务比权重较低的任务获得更多的时间执行,在调度的不同任务属于不同的优先级(优先级越高对应权重越高、优先级越低对应权重越低)时,无法调度高优先级的任务优先执行、也无法保证高优先级任务能够抢占正在执行的低优先级任务的执行时间。
图5为实时调度器的工作原理示意图,其中,当核心调度器调用实时调度器类,对虚拟机待执行的任务进行调度时,可以将所有任务按照优先级顺序加入一个链表中,例如图5所示的上下方向排列的链表,向下方向的优先级更高,向上方向的优先级更低。假设此时虚拟机待执行的任务有高优先级的任务A、中优先级的任务B1和B2、低优先级的任务C1和C2,则FIFIO调度器类在调度上述任务时,将采用最先进入执行状态的任务首先获取虚拟机的CPU等计算资源,并一直占用该资源直到这个任务进入睡眠状态,例如,任务A进入队列后一直执行,任务B1、B2、C1和C2可能都不能获得执行时间,这种低优先级的任务不能获得执行时间的问题又被称为“饥饿问题”。而RR调度器类在调度上述任务时,可以通过轮流执行的方式,调度具有相同优先级的任务共享虚拟机的资源,例如,RR调度器可以调度虚拟机轮流执行虚拟机的调度器中优先级的任务B1和B2的任务,来保证具有相同优先级任务的公平执行,但是同样可能会导致更低优先级的任务的饥饿问题。
从图5可以看出,实时调度器类以优先级为基础,优先调度优先级较高的任务执行,以保证任务优先级的要求,但是在调度高优先级任务的同时,会导致低优先级任务的饥饿问题,无法保障低优先级的公平执行需求。
综上,现有的调度器类中,完全公平调度器仅能够保证公平,而不能对不同优先级的任务进行区别调度;实时调度器仅对不同优先级的任务进行调度而不能公平调度,导致低优先级任务的饥饿问题。因此,在如图2所示的不同虚拟机共用系统资源的虚拟机混合部署的应用场景中,无法简单地使用现有的调度器类在既能够保证优先级高的任务被优先调度、又能够保证低优先级的任务得到公平的调度。因此,如何设计一种调度器,使得调度器能够用于调度混合部署的虚拟机上执行的不同优先级的任务时,还能够满足调度的公平,是本领域亟需解决的技术问题。
因此,本申请提供一种任务调度方法及装置,以使调度器能够在调度虚拟机的待执行的任务时,既能够保证高优先级的任务被优先调度由虚拟机执行、又能够满足虚拟机在执行相同优先级任务调度时的公平。下面以具体地实施例对本申请的技术方案进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。
图6为本申请提供的一种任务调度方法所应用的云服务器的结构示意图,其中,本申请所提供的方法可以由图6所示的云服务器中的调度器来执行。具体地,如图6所示的云服务器中,可以部署不同类型的虚拟机,所述虚拟机的类型至少包括:按需虚拟机(on-demand virtual machine,简称:OVM)和弹性虚拟机(elastic virtual machine,简称:EVM)。其中,OVM又可被称为非超卖虚拟机,OVM的vCPU计算能力与物理机CPU计算能力基本保持一致,适合处理对计算和时延都敏感的任务;EVM又可被称为超卖虚拟机或者共享型虚拟机,属于一种可以被抢占的计算实例,适合用于处理批处理和有容错机制的业务场景中的任务。则在如图6所示的云服务器中,在云服务器的主机的系统资源上可以安装操作系统,操作系统中执行的调度器可用于对每个虚拟机执行的任务进行调度。同时,为了对不同优先级的任务进行调度,云服务器的操作系统中还设置有虚拟机标识模块,用于对每个虚拟机待执行的任务的优先级进行标注。并且每个虚拟机中还可以各自设置调度器,用于对每个虚拟机待执行的任务进行调度。如图6所示的云服务器中以一个OVM虚拟机和一个EVM虚拟机为例,用以说明云服务器中部署有不同类型的虚拟机,可以理解的是,如图6所示的云服务器中还可以部署多个OVM虚拟机和多个EVM虚拟机,未在图中绘出。而对于每一个虚拟机,不论其类型是OVM还是EVM,都相当于独立执行的计算机,此时虚拟机所使用的云服务器的系统资源例如CPU,能够以独立的形式执行,在每个虚拟机中的部分CPU资源又可被称为vCPU。
云服务器经过如图6所示的部署方式后,由于每个云服务器内可以同时部署OVM虚拟机和EVM虚拟机,则对于云服务器的供应商,就可以不用在集群中通过不同的云服务器部署不同类型的虚拟机,而是可以实现如图7所示的综合部署方式。图7为本申请提供的一种云服务器集群的部署示意图,其中,供应商通过集群统一调度平台,对不同区域的云服务器集群进行管理,而每个区域内包括的多个云服务器中,每个服务器上都可以部署不同类型的虚拟机,从而通过更加灵活的部署方式,实现了云服务器集群的部署,不用每个云服务器内仅部署一种类型的虚拟机。此外,每个云服务器上还可以设置动态资源代理,用于统计每个云服务器的资源使用情况,使得向集群统一调度器反馈每个云服务器的资源信息。
特别地,本申请提供的任务调度方法,可以由图6或图7中每个云服务器内的调度器来执行,虽然每个云服务器内部署有不同类型的虚拟机、每个虚拟机内有自己的调度器,但是由云服务器上设置的调度器对每个虚拟机执行的任务的调度时,可以实现对每个OVM虚拟机或者EVM虚拟机所执行的任务保证公性的前提下实现OVM的按需分配。其中,每个虚拟机内的调度器存储并调度该虚拟机的待执行任务队列,云服务器上的调度器可以通过对虚拟机内调度器的待执行任务队列进行调整的方式,实现对虚拟机待执行任务的调度。
下面以具体的实施例,详细介绍本申请提供的任务调度方法,下面这几个具体的实施例可以相互结合,并由同一个执行主体来同时实现其中的全部或部分,对于相同或相似的概念或过程可能在某些实施例不再赘述。本申请提供的任务调度方法可以由如图6或图7所示的云服务器中的调度器执行,或者,也可以由除图6或图7中其他的云服务器中的其他装置执行,本申请仅使用图6所示的云服务器中的调度器作为执行主体作为示例,对任务调度方法的流程进行说明,而非对云服务器结构进行限定。
实施例一
本申请实施例一提供的任务调度方法,可用于调度器在调度虚拟机中的任务时,在满足任务优先级要求的同时,实现任务的公平调度,也就是在CFS调度器的基础上实现了不同优先级任务的调度,可以理解为一种增强的CFS调度方法。
图8为本申请提供的任务调度方法一实施例的流程示意图,如图8所示的任务调度方法可以由如图6所示的云服务器中主机的操作系统内的调度器执行,应用在调度器对云服务器中第一目标虚拟机待执行的任务进行调度的场景,所述第一目标虚拟机可以是云服务器中部署的任一OVM虚拟机或者任一EVM虚拟机,并将所述第一目标虚拟机中的调度器记为第一调度器,第一调度器通过任务队列,存储并调度第一目标虚拟机待执行的任务,作为执行主体的调度器可以与第一调度器连接,获取第一调度器中存储的任务队列,以及调整第一调度器中的任务待执行任务,实现调整第一目标虚拟机待执行的任务。具体地,则本实施例提供的任务调度方法包括:
S101:调度器获取第一目标虚拟机待执行的所有任务的优先级。
具体地,调度器首先通过S101从第一目标虚拟机的第一调度器中,获取第一目标虚拟机当前待执行的所有任务,以及所有任务的优先级。其中,所述优先级可以是提前划分好的、也可以是由调度器根据任务的类型划分的。例如,对于基因测序、batch业务等对计算时延不敏感的业务,对应较低的优先级;对于在线视频内容实时渲染等对计算时延敏感的业务,对应较高的优先级。在如图6所示的云服务器中,所有任务的优先级还可以由主机上设置的虚拟机标识模块进行统一管理。
下面结合图9的示例进行说明,图9为本申请提供的任务调度方法中调度流程的示意图,其中,假设第一调度器在调度的第一目标虚拟机时,第一调度器的任务队列中,存储有第一目标虚拟机当前待执行的N个任务分别为任务1、任务2……任务N,N>1。则在S101中,作为执行主体的云服务器上的调度器为了确定第一目标虚拟机的待执行任务,可以首先从第一目标虚拟机的第一调度器中获取这N个任务,以及每个任务对应的优先级。例如,在N个任务中,第一优先级的任务有任务1、任务2和任务3;第二优先级的任务有任务4和任务5……。本申请实施例对第一目标虚拟机待执行任务的优先级的数量不做限定,并以第一优先级、第二优先级……的排列顺序中优先级由高至低为例进行说明。
S102:调度器确定所有任务中优先级最高的至少一个任务。
随后,调度器从S101中获取的所有N个任务中,确定优先级最高的至少一个任务。例如,在如图9所示的示例中,调度器确定优先级最高的第一优先级对应的任务有:任务1、任务2和任务3。
可选地,在S102第一种可能的实现方式中,调度器可以通过遍历第一调度器存储 的待执行任务队列上所有任务优先级的方式,从待执行任务队列上确定所有任务的优先级,并确定出所有任务中优先级最高的至少一个任务。可选地,所述队列可以是链表、数组、树类结构等,当所述待执行任务队列为树类结构中的红黑树时,调度器可以遍历整个红黑树,获取红黑树中优先级最高的至少一个任务。
或者,在S102第二种可能的实现方式中,调度器还可以在专门的存储空间中,存储优先级记录信息,通过优先级记录信息对加入第一调度器的待执行任务队列中的每个任务的优先级进行记录,例如,调度器可通过数组记录不同任务与优先级之间的对应关系,其形式可以为“任务1-第一优先级、任务2-第一优先级…”等。则在S102中调度器可以通过存储空间中所记录的优先级记录信息,确定第一调度器的待执行任务队列中优先级最高的至少一个任务。
又或者,在S102第三种可能的实现方式中,第一调度器中还可以设置多个待执行任务队列,每个待执行任务队列对应一个优先级,所述队列同样可以是链表、数组、树类结构等,当所述待执行任务队列为树类结构中的红黑树时,调度器可以通过不同的红黑树表示不同优先级对应的待执行任务队列。例如,在如图9所示的示例中,可以通过第一红黑树记录第一优先级对应的任务1、任务2和任务3,通过第二红黑树记录第二优先级对应的任务4和任务5。则调度器在S102中可以直接从优先级最高的第一优先级对应的第一红黑树中,获取优先级最高的至少一个任务,从而S102中提高获取优先级最高的至少一个任务的效率。
S103:调度器确定至少一个任务中虚拟运行时间最小的任务,记为第一任务。
随后,在S103中,调度器进一步确定S102中所获取的至少一个任务中,虚拟运行时间最小的第一任务。其中,所述虚拟运行之间又可被称为“vruntime”,其中,每个任务的虚拟运行时间=任务的实际执行时间*1024/待执行的所有任务的权重之和,例如,对于第一调度器中待执行的任务1、任务2和任务3,权重分别为1、2和3,则待执行所有任务的权重之和为1+2+3=6。调度器通过每个任务的虚拟运行时间来衡量哪个任务最值得被调度,其中,在CFS调度器中,所有待执行任务可以通过一棵虚拟运行时间为键值的红黑树表示,则虚拟运行时间越小的进程越靠近整个红黑树的最左端,第一调度器每次控制第一目标虚拟机执行位于红黑树最左端的任务,该进程的虚拟运行时间最小。因此,在本实施例中,当调度器通过S102确定出优先级最高的至少一个任务之后,可以在优先级最高的至少一个任务中确定虚拟运行时间最小的第一任务。例如,在如图9所示的示例中,调度器确定出第一优先级的任务1、任务2和任务3之后,从任务1的第一虚拟运行时间、任务2的第二虚拟运行时间和任务3的第三vruntime中确定任务2对应的第二虚拟运行时间最小,则将任务2作为第一任务。
S104:调度器控制第一调度器调度第一目标虚拟机执行第一任务。
最终,在S104中,调度器通过控制第一调度器的方式,使得第一调度器调整其任务队列,从而使得第一调度器调度第一目标虚拟机执行S103中所确定的第一任务。可选地,调度器可以通过上下文切换的方式,调整第一调度器的待执行任务队列中任务的顺序,实现控制第一目标虚拟机的第一调度器从待执行任务队列中首先获取第一任务并由第一目标虚拟机的处理器(vCPU)执行。
可以理解的是,如图8-9所示的实施例中,以第一调度器的待执行任务队列上有 多个优先级的任务为例,若第一调度器的待执行任务队列上只有一个优先级的任务,则在S101之后,调度器可以直接执行S103,即,从所获取的所有任务中确定虚拟运行时间最小的第一任务,并通过S104控制第一目标虚拟机执行第一任务。
此外,本实施例中调度器在第一任务执行完之后,将重复执行如图8所示的任务调度方法S101,并继续通过第一调度器调度第一目标虚拟机执行其待执行任务队列中优先级最高的至少一个任务中虚拟执行执行时间最小的任务,从而保证了当前第一目标虚拟机执行的是优先级最高的任务,并且对于相同优先级的任务能够得到公平的调度。因此在如图9所示的示例中,按照这个顺序,第一目标虚拟机将依次执行第一优先级、第二优先级……的任务,并且在调度每个优先级对应的相同任务时,通过虚拟运行时间的选择相当于采用了CFS调度器的完全公平的调度策略,实现了CFS调度策略。
综上,本实施例提供的任务调度方法中,调度器在调度第一目标虚拟机执行任务时,首先确定第一目标虚拟机待执行任务队列中优先级最高的至少一个任务,保证了优先级最高的任务优先执行;随后对于最高优先级的至少一个任务选择其中虚拟运行时间最小的第一任务执行,保证了相同优先级任务在调度时的公平。因此,本实施例提供的任务调度方法与图4所示的现有技术中完全公平调度器相比,能够调度高优先级的任务优先执行;与图5所示的实时调度器相比,还能够保证相同优先级的任务得到公平的调度,从而实现了调度器能够在调度第一目标虚拟机上的任务时,既能够保证高优先级的任务被优先调度、又能够满足相同优先级任务调度时的公平,能够应用与如图6或者图7所示的虚拟机混合部署调度的场景中。
实施例二
本申请实施例二提供的任务调度方法,可用于调度器在调度任务时,当第一目标虚拟机的第一调度器中,待执行任务队列中任务的优先级发生了调整,可以对第一调度器当前调度第一目标虚拟机执行的任务进行抢占,也就是实现调度器对第一目标虚拟机的任务进行动态的调度,以满足调度器对多种不同类型的任务的调度需求。
图10为本申请提供的任务调度方法一实施例的流程示意图,如图10所示的任务调度方法可以由如图6所示的云服务器中主机的操作系统内的调度器执行,应用在调度器对云服务器中第一目标虚拟机待执行的任务进行调度的场景,所述第一目标虚拟机可以是云服务器中部署的任一OVM虚拟机或者任一EVM虚拟机,并将所述第一目标虚拟机中的调度器记为第一调度器,第一调度器通过任务队列,存储并调度第一目标虚拟机待执行的任务,则该方法包括:
S201:当调度器确定第一目标虚拟机的待执行任务队列中的第二任务由第二优先级调整为第一优先级,获取第一目标虚拟机待执行的与第一优先级相同的至少一个任务中,最小的虚拟运行时间。
具体地,当第一调度器调度第一目标虚拟机执行任务(将第一虚拟机正在执行的任务记为第三任务)时,若此时第一目标虚拟机在第一调度器的待执行任务队列中,第二任务由第二优先级调整为第一优先级,或者在第一调度器的待执行任务队列中加入了第二任务,则调度器通过S201确定第一目标虚拟机待执行的第二任务的优先级发生了变化,并确定与第一优先级相同的至少一个任务中最小的虚拟运行时间。
S202:调度器根据S201中确定的最小虚拟运行时间,将第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间。
下面结合图11的示例进行说明,图11为本申请提供的任务调度方法中调度流程的示意图,其中,假设第一调度器调度第一目标虚拟机的当前待执行的N个任务分别为任务1、任务2……任务N,N>1。则在S201中,作为执行主体的调度器首先获取其中优先级由第二优先级调整为第一优先级的任务,记为第二任务,或者还可以获取新加入的第N+1个任务记为第二任务。并进一步确定第二任务对应的第一优先级,以及第二任务对应的第一虚拟运行时间。或者,可选地,所述第二任务还可以是从睡眠状态切换到唤醒状态后,加入第一调度器待执行任务队列的任务,则调度器可以直接从待执行任务队列中获取新加入的第二任务的第二虚拟运行时间。
随后,调度器将S201中获取的第二任务的第一虚拟运行时间调整为第二虚拟运行时间,其中,对第二任务的虚拟运行时间进行调整的目的是使得第二任务能够得到执行时间,故第二任务的虚拟运行时间的调整应与当前执行的第三任务或者与第二任务优先级相同的任务有关。
具体地,本实施例的具体实现方式可以参照如图12所示的S2021-S2023,其中,图12为本申请提供的任务调度方法一实施例的流程示意图,如图12所示的方法在如图11所示方法的基础上,调度器在获取第二任务后,通过S2021确定第一调度器的待执行任务队列中是否存在其他与第二任务优先级相同的、同对应于第一优先级的任务。若第一调度器的待执行任务队列中没有其他第一优先级的任务,则执行S2022;若第一调度器的待执行任务队列中有其他第一优先级的任务,则执行S2023。
在S2022中,若待执行任务队列中,所有的N个任务都不是第一优先级的任务,则调度器参考第一调度器正在调度第一目标虚拟机执行的第三任务的虚拟运行时间,对第二任务的第一虚拟运行时间进行调整。具体地,调整原则可以使得第一虚拟运行时间调整后的第二虚拟运行时间略大于第三任务的虚拟运行时间,例如,当第一虚拟运行时间小于第三任务的虚拟运行时间,则调度器将第一虚拟运行时间加上一个第一变量后,得到第二虚拟运行时间,使得第二虚拟运行时间大于第三任务的虚拟运行时间。所述变量可以根据实际情况实时进行调整。
在S2023中,若第一调度器的待执行任务队列中存在其他第一优先级的任务,示例性地,在图11所示的场景中,当确定第一调度器调度目标虚拟机所运行的任务1、任务2和任务3与第二任务的优先级相同,都对应第一优先级,则调度器具体根据所确定的任务1-任务3的虚拟运行时间中最小的虚拟运行时间对第二虚拟运行时间进行调整。具体地,调整原则可以使得第一虚拟运行时间调整后的第二虚拟运行时间略大于第三任务的虚拟运行时间,例如,当第一虚拟运行时间小于第三任务的虚拟运行时间,则调度器将第一虚拟运行时间加上一个第一变量后,得到第二虚拟运行时间,使得第二虚拟运行时间大于任务1-任务3的虚拟运行时间中最小的虚拟运行时间。所述第一变量可以根据实际情况进行调整。
S203:当第一优先级高于第一目标虚拟机正在执行的第三任务的优先级,调度器控制第一目标虚拟机执行第二任务,此时,第二任务对应于第二虚拟运行时间。
最终,当调度器通过S202对新加入待执行任务队列的第二任务的虚拟运行时间进 行调整后,可以控制第一调度器,使得第一调度器调度第一目标虚拟机执行第二任务。特别地,在本步骤中,还加入了调度器对第一调度器当前正在执行任务与第二任务优先级的比对,使得第二任务的第一优先级高于正在执行的第三任务的优先级时,实现第二任务对第三任务的抢占。
或者,可选地,在如图10所示的实施例中,S201另一种可能的实现方式中,第二任务还可以是原本就存在第一调度器待执行任务队列中,则调度器在S201中获取第二任务后,进一步根据用户发出的指示信息,确定将第二任务对应的优先级由第二优先级调整为第一优先级。随后,在S202中,调度器具体根据第一调度器的待执行任务队列中对应第二优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间,对第一虚拟运行时间进行调整为第二虚拟运行时间。其中,假设第二任务在调整优先级之前,第二优先级对应的至少一个任务中,对应的第一虚拟运行时间为Ta,而第二优先级对应的至少一个任务中虚拟运行时间的最小值记为minA;第二任务在调整优先级之后,第一优先级对应的至少一个任务中虚拟运行时间的最小值记为minB,则调度器通过公式:第二虚拟运行时间=(Ta-minA)+minB,来将第一虚拟运行时间调整为第二虚拟运行时间,并使得调整后的第二虚拟运行时间在第一优先级对应的任务中,略大于第一优先级的至少一个任务中虚拟运行时间的最小值。需要说明的是,上述公式仅为示例性的说明,在实际调整过程中调度器并不限于使用这一种方式进行调整。
综上,本实施例提供的任务调度方法中,调度器在第一目标虚拟机执行第三任务的同时,若获取了对应第一优先级的第二任务,则根据第一目标虚拟机的待执行任务队列中,对应第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间或者根据第三任务的虚拟运行时间,对第二任务的第一虚拟运行时间进行调整为第二虚拟运行时间。最终,在第二任务的第一优先级高于第三任务的优先级时,控制第一目标虚拟机执行第二任务,从而实现了新加入第一目标虚拟机的待执行任务队列的第二任务的抢占执行。因此,本实施例提供的任务调度方法克服了如图4所示的完全公平调度器以及图5所示的实时调度器无法提供抢占的不足,使得调度器能够在第一目标虚拟机上运行多种优先级的任务时,能够实现高优先级的任务对低优先级任务的抢占运行,能够应用与如图6或者图7所示的虚拟机混合部署调度的场景中。
实施例三
本申请实施例三提供的任务调度方法,可用于调度器在调度第一目标虚拟机中的任务时,当第一目标虚拟机的第一调度器所存储的待运行任务队列中,存在低优先级的任务一直得不到执行的情况,可以将低优先级的任务主动迁移到其他虚拟机(记为第二目标虚拟机)上执行,从而防止由于第一虚拟机执行多种优先级的任务时,优先调度高优先级的任务进而导致的低优先级任务的饥饿问题。
图13为本申请提供的任务调度方法一实施例的流程示意图,如图13所示的任务调度方法可以由如图6所示的云服务器中主机的操作系统内的调度器执行,应用在调度器对云服务器中第一目标虚拟机待执行的任务进行调度的场景,所述第一目标虚拟机可以是云服务器中部署的任一OVM虚拟机或者任一EVM虚拟机,并将所述第一目标虚拟机中的调度器记为第一调度器,第一调度器通过任务队列,存储并调度第一目标虚拟机待执行的任务,则该方法包括:
S301:调度器获取第一目标虚拟机执行第四任务时,第一调度器的时间记录信息。
具体地,当第一目标虚拟机执行任务(将第一虚拟机正在执行的任务记为第四任务)时,调度器还同时通过时间记录信息对第一目标虚拟机的第一调度器的任务队列中的任务进行记录。所述S301可以由调度器在时钟中断时执行,或者在调度器调度切换时执行,又或者通过调度器设置定时器的方式执行。其中,记第四任务对应第三优先级,同时,在第一目标虚拟机的第一调度器中,存储的待运行任务队列中至少还包括第五任务,第五任务对应的优先级低于所述第三优先级。
可选地,所述时间记录信息可以存储在调度器内的存储空间中,或者,存储在第一目标虚拟机内的存储空间中。在一种可能的实现方式中,所述时间记录信息用于记录第四任务的执行时间,或者,在另一种可能的实现方式中,所述时间记录信息用于记录第五任务在待执行任务队列中等待的时间。
下面结合图14的示例进行说明,图14为本申请提供的任务调度方法中调度流程的示意图,其中,假设第一调度器当前待执行的N个任务分别为任务1、任务2……任务N,N>1,并且此时,第一目标虚拟机执行待执行任务队列的N个任务中的第四任务。则对于调度器在S301中,可以获取当前时刻的时间记录信息。
S302:当时间记录信息满足预设条件,则调度器控制第一目标虚拟机的第一调度器,将第一调度器中存储的第五任务发送给第二目标虚拟机的第二调度器,使得第二调度器控制第二目标虚拟机执行第五任务。
具体地,调度器在通过S301获取时间记录信息之后,根据时间记录信息确定调度第五任务到第二目标虚拟机执行,例如,当所述时间记录信息用于记录第一目标虚拟机已经执行第四任务的执行时间,则预设条件可以是第四任务的执行时间小于第一阈值(1s)。例如,当第四任务已经执行了1秒,由于第四任务的优先级较高,处于较低优先级的第五任务一直得不到执行,会导致第五任务的饥饿问题,因此,调度器可以确定第四任务执行时间大于第一阈值而满足预设条件后,调度由第二目标虚拟机执行第五任务。
又例如,当所述时间记录信息用于记录第五任务在第一目标虚拟机的待执行任务队列中的等待时间,则预设条件可以是第五任务的等待时间大于第二阈值。同样为了防止第五任务的饥饿问题,调度器可以确定第五任务的等待时间大于第二阈值而满足预设条件后,调度由第二目标虚拟机执行第五任务。
进一步地,所述第二目标虚拟机可以是云服务器中的任一个虚拟机,则调度器在S302中控制第二目标虚拟机执行第五任务之前,还可以在云服务器中确定第二目标虚拟机。例如,所述第二目标虚拟机可以是云服务器中当前处于空闲态的虚拟机,使得调度器控制第二目标虚拟机执行第五任务时,不会影响第二目标虚拟机运行的其他任务;或者,第二目标虚拟机可以是云服务器中当前负载小于第三阈值的虚拟机;使得调度器控制第二目标虚拟机执行第五任务时,减少对第二目标虚拟机运行的其他任务的影响;或者,第二目标虚拟机还可以是云服务器部署的专用于执行第五任务对应的优先级的虚拟机,也就是云服务器中将不同优先级的任务分配给不同的虚拟机执行,则调度器在S302中调度第五任务时,选择与第五任务的第四优先级对应的虚拟机作为所述第二目标虚拟机。
可选地,调度器在调度第五任务时,还可以按照如下顺序确定第二目标虚拟机:优先选择云服务器中空闲态的虚拟机、其次选择云服务器中虚拟机的调度队列上的任务优先级较低且负载较轻的虚拟机、再次选择云服务器中虚拟机的调度队列上的任务优先级较低但负载较重的虚拟机/服务器中虚拟机的调度队列上的任务优先级较高但负载较轻的虚拟机。
可选地,第二的目标虚拟机还可以是云服务器中专门设置的虚拟机,该虚拟机专用于在如图14所示的防止饥饿问题的场景中,执行调度器从其他虚拟机调度的任务,则在S302中,调度器可以直接控制第二目标虚拟机执行第五任务。
综上,本实施例提供的任务调度方法中,调度器在第一目标虚拟机执行第四任务时,还获取时间记录信息,用于对优先级较低的第五任务是否出现饥饿问题进行判断,并在时间记录信息满足预设条件之后,控制云服务器中第二目标虚拟机执行第五任务,从而实现了对第五任务在不同目标虚拟机之间的调度,使得第五任务不会由于优先级较低而一直停留在第一目标虚拟机的待执行队列中,防止饥饿问题的发生。
在前述实施例中,对本申请实施例提供的任务调度方法进行了介绍,而为了实现上述本申请实施例提供的任务调度方法中的各功能,作为执行主体的调度器可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。
例如,图15为本申请提供的任务调度装置一实施例的结构示意图,如图15所示的任务调度装置可用于执行如图8所示的任务调度方法,该装置包括:获取模块1501、优先级确定模块1502、虚拟运行时间确定模块1503和控制模块1504。其中,获取模块1501用于获取第一目标虚拟机待执行的多个任务的优先级;优先级确定模块1502用于确定多个任务中优先级最高的至少一个任务;虚拟运行时间确定模块1503用于从至少一个任务中,确定虚拟运行时间最小的第一任务;控制模块1504用于控制第一目标虚拟机执行第一任务。
可选地,获取模块1501具体用于,根据第一目标虚拟机中,第一调度器所存储的待执行任务队列,确定第一目标虚拟机待执行的多个任务的优先级。
可选地,获取模块1501具体用于,遍历第一调度器所存储的待执行任务队列上所有任务的优先级,从待执行任务的队列中确定优先级最高的至少一个任务。
可选地,获取模块1501具体用于,通过第一调度器中存储的优先级记录信息,确定多个任务中优先级最高的至少一个任务;其中,优先级记录信息用于记录第一调度器待的执行任务的队列上所有任务的优先级。
可选地,获取模块1501具体用于,根据第一调度器中存储的最高优先级对应的队列中的任务,确定优先级最高的至少一个任务;其中,第一调度器待执行任务通过多个队列存储待执行的任务,每个队列对应不同的优先级。
图16为本申请提供的任务调度装置一实施例的结构示意图,如图16所示的任务调度装置可用于执行如图10所示的任务调度方法,该装置包括:获取模块1601、虚拟运行时间调整模块1602和控制模块1603。其中,获取模块1601用于当第一目标虚拟机待执行的第二任务的优先级由第二优先级调整为第一优先级,获取第一目标虚拟 机待执行的与第一优先级相同的至少一个任务中,至少一个任务对应的最小的虚拟运行时间;虚拟运行时间调整模块1602用于根据最小的虚拟运行时间,将第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间;控制模块1603用于,当第一优先级高于第一目标虚拟机正在执行的第三任务的优先级,控制第一目标虚拟机执行第二任务。
可选地,第二虚拟运行时间大于第一目标虚拟机的第一调度器存储的待执行任务队列中,对应第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间。
可选地,所述任务调度装置还包括:接收模块1604,用于接收指示信息,并根据指示信息,确定第二任务的优先级由第二优先级调整为第一优先级。
可选地,虚拟时间调整模块1602具体用于,将第一虚拟运行时间加上最小的虚拟运行时间后,再减去待执行任务队列中对应第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间,得到第二虚拟运行时间。
图17为本申请提供的任务调度装置一实施例的结构示意图,如图17所示的任务调度装置可用于执行如图13所示的任务调度方法,该装置包括:获取模块1701和控制模块1702。其中,获取模块1701用于获取第一目标虚拟机的第一调度器存储的时间记录信息;其中,时间记录信息用于记录第四任务执行的时间,第四任务对应第三优先级,或者,时间记录信息用于记录第五任务在第一调度器存储的待执行任务队列中的等待时间,第五任务对应的优先级低于第三优先级;控制模块1702用于当时间记录信息满足预设条件,控制第一目标虚拟机的第一调度器将第五任务发送到第二目标虚拟机的第二调度器,使第二目标虚拟机执行第五任务。
可选地,当时间记录信息用于记录第四任务执行的时间,预设条件包括:第四任务执行的时间大于第一阈值。
可选地,当时间记录信息记录第五任务在第一调度器的待执行任务队列中的等待时间,预设条件包括:等待时间大于第二阈值。
可选地,第二目标虚拟机为第一目标虚拟机所在主机部署的多个虚拟机中处于空闲态的虚拟机;或者,第二目标虚拟机为主机部署的多个虚拟机中负载小于第三阈值的虚拟机;或者,第二目标虚拟机为主机部署的多个虚拟机中用于执行第四优先级的任务的调度器,其中,第四优先级低于第三优先级。
可选地,第二目标虚拟机是专用于当时间记录信息满足预设条件时执行第五任务的调度器。
需要说明的是,应理解以上装置的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些模块可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分模块通过处理元件调用软件的形式实现,部分模块通过硬件的形式实现。例如,确定模块可以为单独设立的处理元件,也可以集成在上述装置的某一个芯片中实现,此外,也可以以程序代码的形式存储于上述装置的存储器中,由上述装置的某一个处理元件调用并执行以上确定模块的功能。其它模块的实现与之类似。此外这些模块全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件可以是一种集成电路,具有信号的处理能力。在实现过程中,上述方法的各步骤或以上各个模块可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。
例如,以上这些模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(application specific integrated circuit,ASIC),或,一个或多个微处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序代码的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘solid state disk(SSD))等。
图18为本申请提供的电子设备一实施例的结构示意图,该电子设备可作为本申请前述实施例中任一所述的调度器,并执行调度器所执行的任务调度方法。如图18所示,该通信装置1100可以包括:处理器111(例如CPU)、收发器113;其中,收发器113耦合至处理器111,处理器111控制收发器113的收发动作。可选的,所述通信装置1100还包括存储器112,存储器112中可以存储各种指令,以用于完成各种处理功能以及实现本申请实施例中调度器执行的方法步骤。
可选的,本申请实施例涉及的电子设备还可以包括:电源114、系统总线115以及通信接口116。收发器113可以集成在电子设备的收发信机中,也可以为电子设备上独立的收发天线。系统总线115用于实现元件之间的通信连接。上述通信接口116用于实现电子设备与其他外设之间进行连接通信。
在本申请实施例中,上述处理器111用于与存储器112耦合,读取并执行存储器112中的指令,以实现上述方法实施例中调度器执行的方法步骤。收发器113与处理器111耦合,由处理器111控制收发器113进行消息收发,其实现原理和技术效果类似,在此不再赘述。
该图18中提到的系统总线可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。所述系统总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。通信接口用于实现数据库访问装置与其他设备(例如客户端、读写库和只读库)之间的通信。存储器可能包含RAM,也可能还包括非易失性存储器(non-volatile memory),例如 至少一个磁盘存储器。
该图18中提到的处理器可以是通用处理器,包括中央处理器CPU、网络处理器(network processor,NP)等;还可以是数字信号处理器DSP、专用集成电路ASIC、现场可编程门阵列FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
可选的,本申请实施例还提供一种可读存储介质,所述存储介质中存储有指令,当其在计算机上运行时,使得计算机执行如本申请前述任一实施例中由调度器所执行的方法。
可选的,本申请实施例还提供一种运行指令的芯片,所述芯片用于执行如本申请前述任一实施例中由调度器所执行的方法。
本申请实施例还提供一种程序产品,所述程序产品包括计算机程序,所述计算机程序存储在存储介质中,至少一个处理器可以从所述存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序时可实现如本申请前述任一实施例中由调度器所执行的方法。
在本申请实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系;在公式中,字符“/”,表示前后关联对象是一种“相除”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中,a,b,c可以是单个,也可以是多个。同时,在本申请实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请实施例的范围。并且,在本发明的实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。
Claims (30)
- 一种任务调度方法,其特征在于,包括:获取第一目标虚拟机待执行的多个任务的优先级;确定所述多个任务中优先级最高的至少一个任务;从所述至少一个任务中,确定虚拟运行时间最小的第一任务;控制所述第一目标虚拟机执行所述第一任务。
- 根据权利要求1所述的方法,其特征在于,所述获取第一目标虚拟机待执行的多个任务的优先级,包括:根据所述第一目标虚拟机中,第一调度器所存储的待执行任务队列,确定所述第一目标虚拟机待执行的多个任务的优先级。
- 根据权利要求2所述的方法,其特征在于,所述确定所述多个任务中优先级最高的至少一个任务,包括:遍历所述第一调度器所存储的待执行任务队列上所有任务的优先级,从所述待执行任务的队列中确定所述优先级最高的至少一个任务。
- 根据权利要求2所述的方法,其特征在于,所述确定所述多个任务中优先级最高的至少一个任务,包括:通过所述第一调度器中存储的优先级记录信息,确定所述多个任务中优先级最高的至少一个任务;其中,所述优先级记录信息用于记录所述第一调度器待的执行任务的队列上所有任务的优先级。
- 根据权利要求2所述的方法,其特征在于,所述确定所述多个任务中优先级最高的至少一个任务,包括:根据所述第一调度器中存储的最高优先级对应的队列中的任务,确定所述优先级最高的至少一个任务;其中,所述第一调度器待执行任务通过多个队列存储待执行的任务,每个队列对应不同的优先级。
- 一种任务优先级调整方法,其特征在于,包括:当第一目标虚拟机待执行的第二任务的优先级由第二优先级调整为第一优先级,获取所述第一目标虚拟机待执行的与所述第一优先级相同的至少一个任务中,所述至少一个任务对应的最小的虚拟运行时间;根据所述最小的虚拟运行时间,将所述第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间;当所述第一优先级高于所述第一目标虚拟机正在执行的第三任务的优先级,控制所述第一目标虚拟机执行所述第二任务。
- 根据权利要求6所述的方法,其特征在于,所述第二虚拟运行时间大于所述第一目标虚拟机的第一调度器存储的待执行任务队列中,对应所述第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间。
- 根据权利要求6所述的方法,其特征在于,所述获取所述第一目标虚拟机待执行的与所述第一优先级相同的至少一个任务中,所述至少一个任务对应的最小的虚拟运行时间之前,还包括:接收指示信息,并根据所述指示信息,确定所述第二任务的优先级由第二优先级 调整为第一优先级。
- 根据权利要求6-8任一项所述的方法,其特征在于,所述根据所述最小的虚拟运行时间,将所述第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间,包括:将所述第一虚拟运行时间加上所述最小的虚拟运行时间后,再减去所述待执行任务队列中对应所述第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间,得到所述第二虚拟运行时间。
- 一种任务调度方法,其特征在于,包括:获取第一目标虚拟机的第一调度器存储的时间记录信息;其中,所述时间记录信息用于记录第四任务执行的时间,所述第四任务对应第三优先级,或者,所述时间记录信息用于记录第五任务在所述第一调度器存储的待执行任务队列中的等待时间,所述第五任务对应的优先级低于所述第三优先级;当所述时间记录信息满足预设条件,控制所述第一目标虚拟机的第一调度器将所述第五任务发送到第二目标虚拟机的第二调度器,使所述第二目标虚拟机执行所述第五任务。
- 根据权利要求10所述的方法,其特征在于,当所述时间记录信息用于记录所述第四任务执行的时间,所述预设条件包括:所述第四任务执行的时间大于第一阈值。
- 根据权利要求10所述的方法,其特征在于,当所述时间记录信息记录第五任务在所述第一调度器的待执行任务队列中的等待时间,所述预设条件包括:所述等待时间大于第二阈值。
- 根据权利要求10-12任一项所述的方法,其特征在于,所述第二目标虚拟机为所述第一目标虚拟机所在主机部署的多个虚拟机中处于空闲态的虚拟机;或者,所述第二目标虚拟机为所述主机部署的多个虚拟机中负载小于第三阈值的虚拟机;或者,所述第二目标虚拟机为所述主机部署的多个虚拟机中用于执行第四优先级的任务的调度器,其中,所述第四优先级低于所述第三优先级。
- 根据权利要求10-12任一项所述的方法,其特征在于,所述第二目标虚拟机是专用于当所述时间记录信息满足预设条件时执行所述第五任务的调度器。
- 一种任务调度装置,其特征在于,包括:获取模块,用于获取第一目标虚拟机待执行的多个任务的优先级;优先级确定模块,用于确定所述多个任务中优先级最高的至少一个任务;虚拟运行时间确定模块,用于从所述至少一个任务中,确定虚拟运行时间最小的第一任务;控制模块,用于控制所述第一目标虚拟机执行所述第一任务。
- 根据权利要求15所述的装置,其特征在于,所述获取模块具体用于,根据所述第一目标虚拟机中,第一调度器所存储的待执行任务队列,确定所述第一目标虚拟机待执行的多个任务的优先级。
- 根据权利要求16所述的装置,其特征在于,所述获取模块具体用于,遍历所述第一调度器所存储的待执行任务队列上所有任务的优先级,从所述待执行任务的队列中确定所述优先级最高的至少一个任务。
- 根据权利要求16所述的装置,其特征在于,所述获取模块具体用于,通过所述第一调度器中存储的优先级记录信息,确定所述多个任务中优先级最高的至少一个任务;其中,所述优先级记录信息用于记录所述第一调度器待的执行任务的队列上所有任务的优先级。
- 根据权利要求16所述的装置,其特征在于,所述获取模块具体用于,根据所述第一调度器中存储的最高优先级对应的队列中的任务,确定所述优先级最高的至少一个任务;其中,所述第一调度器待执行任务通过多个队列存储待执行的任务,每个队列对应不同的优先级。
- 一种任务优先级调整装置,其特征在于,包括:获取模块,用于当第一目标虚拟机待执行的第二任务的优先级由第二优先级调整为第一优先级,获取所述第一目标虚拟机待执行的与所述第一优先级相同的至少一个任务中,所述至少一个任务对应的最小的虚拟运行时间;虚拟运行时间调整模块,用于根据所述最小的虚拟运行时间,将所述第二任务对应的第一虚拟运行时间调整为第二虚拟运行时间;控制模块,用于当所述第一优先级高于所述第一目标虚拟机正在执行的第三任务的优先级,控制所述第一目标虚拟机执行所述第二任务。
- 根据权利要求20所述的装置,其特征在于,所述第二虚拟运行时间大于所述第一目标虚拟机的第一调度器存储的待执行任务队列中,对应所述第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间。
- 根据权利要求20所述的装置,其特征在于,还包括:接收模块,用于接收指示信息,并根据所述指示信息,确定所述第二任务的优先级由第二优先级调整为第一优先级。
- 根据权利要求20-22任一项所述的装置,其特征在于,所述虚拟时间调整模块具体用于,将所述第一虚拟运行时间加上所述最小的虚拟运行时间后,再减去所述待执行任务队列中对应所述第一优先级的至少一个任务的虚拟运行时间中最小的虚拟运行时间,得到所述第二虚拟运行时间。
- 一种任务调度装置,其特征在于,包括:获取模块,用于获取第一目标虚拟机的第一调度器存储的时间记录信息;其中,所述时间记录信息用于记录第四任务执行的时间,所述第四任务对应第三优先级,或者,所述时间记录信息用于记录第五任务在所述第一调度器存储的待执行任务队列中的等待时间,所述第五任务对应的优先级低于所述第三优先级;控制模块,用于当所述时间记录信息满足预设条件,控制所述第一目标虚拟机的第一调度器将所述第五任务发送到第二目标虚拟机的第二调度器,使所述第二目标虚拟机执行所述第五任务。
- 根据权利要求24所述的装置,其特征在于,当所述时间记录信息用于记录所述第四任务执行的时间,所述预设条件包括:所述第四任务执行的时间大于第一阈值。
- 根据权利要求24所述的装置,其特征在于,当所述时间记录信息记录第五任务在所述第一调度器的待执行任务队列中的等待时间,所述预设条件包括:所述等待时间大于第二阈值。
- 根据权利要求24-26任一项所述的装置,其特征在于,所述第二目标虚拟机为所述第一目标虚拟机所在主机部署的多个虚拟机中处于空闲态的虚拟机;或者,所述第二目标虚拟机为所述主机部署的多个虚拟机中负载小于第三阈值的虚拟机;或者,所述第二目标虚拟机为所述主机部署的多个虚拟机中用于执行第四优先级的任务的调度器,其中,所述第四优先级低于所述第三优先级。
- 根据权利要求24-26任一项所述的装置,其特征在于,所述第二目标虚拟机是专用于当所述时间记录信息满足预设条件时执行所述第五任务的调度器。
- 一种电子设备,其特征在于,包括:处理器和通信接口;所述通信接口用于实现所述电子设备与其他装置进行通信;所述处理器用于实现如权利要求1-5任一项、6-9任一项或者10-14任一项所述的方法。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,当所述计算机程序被运行时,用于实现如权利要求1-5任一项、6-9任一项或者10-14任一项所述的方法。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP21874357.3A EP4209903A4 (en) | 2020-09-29 | 2021-09-24 | TASK SCHEDULING METHOD AND APPARATUS |
| US18/191,151 US20230229495A1 (en) | 2020-09-29 | 2023-03-28 | Task scheduling method and apparatus |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011053405.3 | 2020-09-29 | ||
| CN202011053405.3A CN114327843B (zh) | 2020-09-29 | 2020-09-29 | 任务调度方法及装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US18/191,151 Continuation US20230229495A1 (en) | 2020-09-29 | 2023-03-28 | Task scheduling method and apparatus |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2022068697A1 true WO2022068697A1 (zh) | 2022-04-07 |
Family
ID=80951145
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2021/120360 Ceased WO2022068697A1 (zh) | 2020-09-29 | 2021-09-24 | 任务调度方法及装置 |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US20230229495A1 (zh) |
| EP (1) | EP4209903A4 (zh) |
| CN (1) | CN114327843B (zh) |
| WO (1) | WO2022068697A1 (zh) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114968565A (zh) * | 2022-05-17 | 2022-08-30 | 北京百度网讯科技有限公司 | 资源管理方法、装置、电子设备、存储介质及服务器 |
| CN115827230A (zh) * | 2022-12-06 | 2023-03-21 | 中国联合网络通信集团有限公司 | 任务执行方法、装置、电子设备及存储介质 |
| CN116258352A (zh) * | 2023-05-15 | 2023-06-13 | 民航成都信息技术有限公司 | 一种航班保障任务的调度方法、装置及电子设备 |
| CN117472530A (zh) * | 2023-10-25 | 2024-01-30 | 上海宽睿信息科技有限责任公司 | 一种基于集中管理的数据智能调度方法及系统 |
Families Citing this family (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119256300A (zh) * | 2022-05-31 | 2025-01-03 | 深圳引望智能技术有限公司 | 调度方法及相关装置 |
| CN117252242B (zh) * | 2022-06-08 | 2025-12-02 | Oppo广东移动通信有限公司 | 计算设备和任务处理方法 |
| CN117407128A (zh) * | 2022-07-06 | 2024-01-16 | 华为技术有限公司 | 任务迁移方法、装置、设备、存储介质及产品 |
| US20240092220A1 (en) * | 2022-09-15 | 2024-03-21 | GM Global Technology Operations LLC | Key-off electrical load management for a vehicle |
| CN115658277B (zh) * | 2022-12-06 | 2023-03-17 | 苏州浪潮智能科技有限公司 | 一种任务调度方法、装置及电子设备和存储介质 |
| CN116069471B (zh) * | 2023-01-12 | 2024-03-19 | 苏州畅行智驾汽车科技有限公司 | 一种任务的确定性调度方法、装置及电子设备 |
| CN116302485B (zh) * | 2023-01-31 | 2026-01-02 | 维沃移动通信有限公司 | Cpu调度方法、装置、电子设备及可读存储介质 |
| CN116527605A (zh) * | 2023-04-04 | 2023-08-01 | 深圳清华大学研究院 | 资源的编排方法、相关装置和存储介质 |
| CN116521376B (zh) * | 2023-06-29 | 2023-11-21 | 南京砺算科技有限公司 | 物理显卡的资源调度方法及装置、存储介质、终端 |
| CN119493643A (zh) * | 2023-08-21 | 2025-02-21 | 阿里云计算有限公司 | 调度方法、系统、计算设备及计算机可读存储介质 |
| CN117539642B (zh) * | 2024-01-09 | 2024-04-02 | 上海晨钦信息科技服务有限公司 | 一种信用卡分布式调度平台及调度方法 |
| CN118963972B (zh) * | 2024-10-16 | 2025-02-07 | 上海芯力基半导体有限公司 | 一种任务处理方法、处理器及存储介质 |
| CN119645589B (zh) * | 2024-11-20 | 2026-04-28 | 北京百度网讯科技有限公司 | 任务调度方法、装置、设备以及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7293136B1 (en) * | 2005-08-19 | 2007-11-06 | Emc Corporation | Management of two-queue request structure for quality of service in disk storage systems |
| CN103605567A (zh) * | 2013-10-29 | 2014-02-26 | 河海大学 | 面向实时性需求变化的云计算任务调度方法 |
| CN108268310A (zh) * | 2016-12-30 | 2018-07-10 | 大唐移动通信设备有限公司 | 一种确定最小调度粒度的方法及装置 |
| CN108595249A (zh) * | 2018-05-02 | 2018-09-28 | 联想(北京)有限公司 | 一种虚拟机任务调度方法及电子设备 |
| CN109684060A (zh) * | 2018-12-21 | 2019-04-26 | 中国航空工业集团公司西安航空计算技术研究所 | 一种多类型时间关键任务的混合调度方法 |
| CN111400087A (zh) * | 2020-02-26 | 2020-07-10 | 深圳震有科技股份有限公司 | 一种操作系统的控制方法、终端以及存储介质 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9639396B2 (en) * | 2014-09-16 | 2017-05-02 | Nxp Usa, Inc. | Starvation control in a data processing system |
| US10990441B2 (en) * | 2018-07-31 | 2021-04-27 | Nutanix, Inc. | Multi-level job processing queues |
| US11941451B2 (en) * | 2018-10-02 | 2024-03-26 | Siemens Aktiengesellschaft | Orchestration of containerized applications |
| CN111400022A (zh) * | 2019-01-02 | 2020-07-10 | 中国移动通信有限公司研究院 | 一种资源调度方法、装置及电子设备 |
| CN111143045B (zh) * | 2019-12-11 | 2024-03-22 | 青岛海尔科技有限公司 | 智能家居操作系统的任务调度方法及装置、存储介质 |
| CN111488210B (zh) * | 2020-04-02 | 2023-04-07 | 腾讯科技(深圳)有限公司 | 基于云计算的任务调度方法、装置和计算机设备 |
-
2020
- 2020-09-29 CN CN202011053405.3A patent/CN114327843B/zh active Active
-
2021
- 2021-09-24 WO PCT/CN2021/120360 patent/WO2022068697A1/zh not_active Ceased
- 2021-09-24 EP EP21874357.3A patent/EP4209903A4/en active Pending
-
2023
- 2023-03-28 US US18/191,151 patent/US20230229495A1/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7293136B1 (en) * | 2005-08-19 | 2007-11-06 | Emc Corporation | Management of two-queue request structure for quality of service in disk storage systems |
| CN103605567A (zh) * | 2013-10-29 | 2014-02-26 | 河海大学 | 面向实时性需求变化的云计算任务调度方法 |
| CN108268310A (zh) * | 2016-12-30 | 2018-07-10 | 大唐移动通信设备有限公司 | 一种确定最小调度粒度的方法及装置 |
| CN108595249A (zh) * | 2018-05-02 | 2018-09-28 | 联想(北京)有限公司 | 一种虚拟机任务调度方法及电子设备 |
| CN109684060A (zh) * | 2018-12-21 | 2019-04-26 | 中国航空工业集团公司西安航空计算技术研究所 | 一种多类型时间关键任务的混合调度方法 |
| CN111400087A (zh) * | 2020-02-26 | 2020-07-10 | 深圳震有科技股份有限公司 | 一种操作系统的控制方法、终端以及存储介质 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP4209903A4 |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114968565A (zh) * | 2022-05-17 | 2022-08-30 | 北京百度网讯科技有限公司 | 资源管理方法、装置、电子设备、存储介质及服务器 |
| CN115827230A (zh) * | 2022-12-06 | 2023-03-21 | 中国联合网络通信集团有限公司 | 任务执行方法、装置、电子设备及存储介质 |
| CN116258352A (zh) * | 2023-05-15 | 2023-06-13 | 民航成都信息技术有限公司 | 一种航班保障任务的调度方法、装置及电子设备 |
| CN116258352B (zh) * | 2023-05-15 | 2023-08-18 | 中国民用航空总局第二研究所 | 一种航班保障任务的调度方法、装置及电子设备 |
| CN117472530A (zh) * | 2023-10-25 | 2024-01-30 | 上海宽睿信息科技有限责任公司 | 一种基于集中管理的数据智能调度方法及系统 |
| CN117472530B (zh) * | 2023-10-25 | 2024-04-05 | 上海宽睿信息科技有限责任公司 | 一种基于集中管理的数据智能调度方法及系统 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114327843B (zh) | 2025-05-16 |
| US20230229495A1 (en) | 2023-07-20 |
| CN114327843A (zh) | 2022-04-12 |
| EP4209903A4 (en) | 2024-06-05 |
| EP4209903A1 (en) | 2023-07-12 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2022068697A1 (zh) | 任务调度方法及装置 | |
| CN104580396B (zh) | 一种任务调度方法、节点及系统 | |
| US8424007B1 (en) | Prioritizing tasks from virtual machines | |
| EP0617361B1 (en) | Scheduling method and apparatus for a communication network | |
| US9019826B2 (en) | Hierarchical allocation of network bandwidth for quality of service | |
| US9973512B2 (en) | Determining variable wait time in an asynchronous call-back system based on calculated average sub-queue wait time | |
| Madden | Challenges using Linux as a real-time operating system | |
| WO2016078178A1 (zh) | 一种虚拟cpu调度方法 | |
| CN108123980B (zh) | 一种资源调度方法及系统 | |
| CN112860387A (zh) | 分布式任务调度方法、装置、计算机设备及存储介质 | |
| US20250390341A1 (en) | Scheduling method and computer system | |
| CN112214299A (zh) | 多核处理器及其任务调度方法和装置 | |
| CN117667324A (zh) | 用于处理任务的方法、装置、设备和存储介质 | |
| CN112671832A (zh) | 虚拟交换机中保障层次化时延的转发任务调度方法及系统 | |
| CN118885307A (zh) | 共享资源的访问控制方法及装置、存储介质及电子设备 | |
| CN115048206B (zh) | 资源调度方法及服务器 | |
| CN119336510B (zh) | 一种计算内核动态调度系统及方法 | |
| CN119376881A (zh) | 一种基于分阶段事件驱动架构的事件处理方法、装置、设备及介质 | |
| CN109062706B (zh) | 电子装置及其限制进程间通信的方法、存储介质 | |
| CN116149804A (zh) | 任务调度方法、装置和服务器 | |
| CN110955500B (zh) | 大规模并发任务的调度方法与装置 | |
| CN119645589B (zh) | 任务调度方法、装置、设备以及存储介质 | |
| Kim et al. | Dynamic transaction management for system level quality-of-service in mobile APs | |
| CN118760639B (zh) | 一种中断处理模块、方法、桥片及多核处理器系统 | |
| CN104809078A (zh) | 基于退出退让机制的共享高速缓存硬件资源访问方法 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21874357 Country of ref document: EP Kind code of ref document: A1 |
|
| ENP | Entry into the national phase |
Ref document number: 2021874357 Country of ref document: EP Effective date: 20230405 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |